Skip to content

Commit e063ce9

Browse files
SaadnajmiCopilot
andcommitted
feat(rctuikit): Add RCTUITableView for RedboxV1 and RedboxV2 (#3056)
## Summary Adds two narrow RCTUIKit compatibility primitives and adopts them in RedBox, which collapses most of RedBox's platform forking. - `RCTUITableView` / `RCTUITableViewCell` — `@compatibility_alias` to `UITableView`/`UITableViewCell` on iOS and visionOS; on macOS an `NSScrollView` subclass wrapping a private `NSTableView`, with narrow data-source/delegate protocols and an exact `NSIndexPath` row/section bridge, plus a one-case `RCTUITableViewStyle` and a forwarding `-initWithFrame:style:` so the iOS initializer shape is shared. - `RCTUILabel` — implements the `text` getter and the `numberOfLines`/`textAlignment` pairs that were already declared in the header but never backed. RedBox goes from 1124 to 1007 lines. `TARGET_OS_OSX` conditional blocks fall from 30 to 25. Platform-forked lines fall from 431 to 244 (macOS-only 243 → 133, iOS-only 188 → 111); this revision deliberately gives a few of those back to restore upstream's exact iOS bytes in the table setup and the two `reuseCell:` methods. The upstream iOS button code is left untouched. `RCTRedBox.mm`'s `UIButton (RCTRedBox)` category and its `redBoxButton:` factory are byte-identical to upstream `a034841`; the macOS variants are added only inside `TARGET_OS_OSX` guards. Against upstream, the button region has zero removed lines. ## macOS design notes - The macOS table flattens sections and headers into a single backing row list, and uses `NSTableViewStyleInset` explicitly. - Row heights use AppKit's native `usesAutomaticRowHeights`. Fixed heights come from an explicit height constraint on the cell; `tableView:heightOfRow:` supplies the estimate. Automatic heights come from AutoLayout, with `preferredMaxLayoutWidth` maintained as the cell resizes so text reflows on window resize. - Header views are created lazily, cached per reload generation, and pointer-stable within a generation. Sections with zero header height get no slot at all. - Cells go through real `makeViewWithIdentifier:` reuse, so `prepareForReuse` is driven by AppKit rather than called manually. ## RedBox behavior changes Visuals are intended to be unchanged. The macOS RedBox keeps its 16pt inset and 8pt continuous-radius message card, and the buttons keep their existing borderless momentary-push appearance, attributed titles, and key equivalents (⎋ / ⌘R / ⌥⌘C). Bugs fixed along the way, all of which were coupled to the migration: - Stack rows are now recycled instead of a new cell being built for every row. - Reused rows have their line limits and identifiers reset unconditionally, instead of leaking a 3-line limit onto later rows. - The message cell's accessibility identifier was `"red box-error"` and is now `redbox-error`, matching iOS. - A nil error message is now mapped through the section count rather than shifting every stack row by one. - `redBoxButton:` set its accessibility identifier to the literal string `@"accessibilityIdentifier"` instead of the parameter. - The macOS message text is selectable again. ## Validation status — draft; a reported visual regression has been addressed but not re-verified A macOS capture of the previous revision showed the RedBox message card losing its rounded corners and its text insets, and stack frame rows clipped at the top. This revision addresses all three: - The red background and the 8pt continuous corner radius are applied to the cell's own layer again, matching the code this PR replaces. No competing background is drawn over the corners. - Subtitle-style cells now carry a 5pt top inset and a 5pt bottom inset, which the previous revision had dropped to zero. - `RCTUITableViewCell` sets `rowSizeStyle = NSTableViewRowSizeStyleCustom`, so NSTableCellView does not apply its own standard metrics to the `textField` outlet. - Header views now reuse a single identified height constraint instead of gaining a new one on every reload. These fixes have NOT been visually re-verified. Do not merge until all of the following pass: - [ ] RNTester macOS native project build (`pod install` + `xcodebuild`) - [ ] RNTester iOS native project build - [ ] visionOS build - [ ] Capture the RedBox sheet on `main` and on this branch at an identical window size and compare corner radius, text insets, glyph tops, 16pt row inset, and the footer Known risk: `NSTableView` assigns its `effectiveRowSizeStyle` onto each cell view, so the cell-side `rowSizeStyle` may need to be set on the table as well. This must be validated in the macOS build and GUI pass. ## Known follow-ups - The RedBox message-height estimate measures against the scroll view's content width minus 30, which does not account for the inset style's row padding. Worth confirming during the GUI pass that long messages are not clipped. - `RCTUITableViewAutomaticDimension` and the header APIs have no consumer in this PR. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit efb2eb5)
1 parent 4f3275e commit e063ce9

5 files changed

Lines changed: 677 additions & 193 deletions

File tree

0 commit comments

Comments
 (0)