ScreenContainer
ScreenContainer — Layer-2 page primitive. Wires the chrome every layout needs without imposing layout structure: - Safe-area edges (configurable via `safeAreaEdges`) - StatusBar style (light / dark / auto) - Scroll vs static body - Tokens-aware background (`bg-background`) - A loading state (`loading`): a centred `NativeLoadingState` in place of the body - Pull to refresh (`onRefresh` + `refreshing`): a theme-tinted `NativeRefreshControl` - The native header (`header`): a large title that collapses on scroll, native header items and native search, set from inside the screen through `GenesisModules.router.StackScreen` - Tab bar visibility (`tabBar="hidden"`): UIKit's `hidesBottomBarWhenPushed`, through `useHideTabBar` and the tabs layout's `TabBarVisibilityProvider` The rule (docs/FRAMEWORK.md, "Native screens follow iOS"): every screen uses the stack's native header, never one it draws. Top-level screens take a large title; a drill-down takes a standard one (`large: false`) and the stack's own back button. Header customization is delegated: pass `headerLeft`, `headerRight`, `large`, `scrollEdgeBehavior`, `safeAreaEdges`, plus any direct `headerOptions` passthrough to `<Stack.Screen options={...} />`. We **do not** render the navigation header ourselves — Expo Router / React Navigation render the platform-native header. Consumer either: (a) Wraps the screen in `<ScreenContainer>` and ALSO declares `<Stack.Screen options={headerOptionsFromProps(props)} />` at the top of the screen (we export a helper `composeHeaderOptions` for this), OR (b) Imports `<NavBarTitle>` / `<NavBarSearchBar>` / `<NavBarSaveButton>` sub-primitives and threads them through `headerLeft` / `headerRight` options manually. The Layer-3/4 layouts (SettingsPage, etc.) compose ScreenContainer + a helper that wires Stack.Screen so consumers get the 3-line ergonomics.
packages/ui-native/src/layouts/screen-container.tsx
@marktiderman/genesis-ui-nativeimport { ScreenContainer } from "@marktiderman/genesis-ui-native";react-docgen-typescript.composeHeaderOptions
Compose a `<Stack.Screen options={...}>` object from Layer-3 named props + a direct `headerOptions` passthrough. Layouts call this and pass the result to `<Stack.Screen>` so the host's expo-router stack renders a platform-native large title / scroll-edge appearance. Usage (in a layout primitive): const opts = composeHeaderOptions({ headerTitle: "Settings", large: true, scrollEdgeBehavior: "match", headerOptions: rest.headerOptions, }); return <><Stack.Screen options={opts} /><ScreenContainer>...</ScreenContainer></>;
| Prop | Type | Default | Description |
|---|---|---|---|
| headerLeft | (() => ReactNode) | — | Custom node rendered on the left of the nav bar. |
| headerLeftItems | (() => readonly unknown[]) | — | Native header items on the left (`unstable_headerLeftItems`). |
| headerOptions | Record<string, unknown> | — | Direct passthrough merged INTO the resolved options object. Wins over named props. |
| headerRight | (() => ReactNode) | — | Custom node rendered on the right of the nav bar. |
| headerRightItems | (() => readonly unknown[]) | — | Native header items on the right (react-native-screens' `unstable_headerRightItems`): bar buttons and menus drawn by UIKit, with iOS 26's glass grouping. Prefer them to `headerRight`. |
| headerTitle | string | — | Custom header title. Falls back to `<Stack.Screen name>` mapping. |
| large | boolean | — | When true, iOS uses large-title mode + scroll-edge appearance. |
| scrollEdgeBehavior | enum | — | iOS scroll-edge behavior. `"match"` collapses, `"transparent"` always transparent, `"opaque"` always opaque. |
| search | ScreenSearchOptions | — | Native search in the header (react-native-screens' `headerSearchBarOptions`): the system search field under the large title, which hides on scroll. On iOS 26 pass `placement: "integrated"` (or `"integratedButton"`) to put it in the toolbar; with a tab bar, search is usually its own tab (`role: "search"` on NativeTabs). Never draw your own. |
ScreenContainer
| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode | — | Screen body. Pass any node tree. |
| className | string | — | Override root container className. |
| contentClassName | string | — | Override inner content container className (the ScrollView's contentContainerClassName when scroll=true). Without `scroll`, a list under a large title should leave this to layout only: a background or border keeps the body a native view of its own, and iOS then can't collapse the title as the list scrolls (put the background on the list instead). |
| header | ScreenHeaderProps | — | The screen's native header, set from inside the screen: `composeHeaderOptions` of these, passed to `GenesisModules.router.StackScreen` (expo-router's `Stack.Screen`). `large` defaults to `true` here, a large title that collapses on scroll; pass `large: false` on a drill-down. Without the router module, set `<Stack.Screen options={composeHeaderOptions(…)}>` yourself. An option this screen set and later leaves out is reset (the large title, a search that goes); one it never set is left to the layout's screenOptions. Keep `search`, the callbacks and `headerOptions` stable (useMemo / useCallback): they're compared by reference. |
| keyboardShouldPersistTaps | enum | handled | `keyboardShouldPersistTaps` for the inner ScrollView. Default `"handled"`. Only used when `scroll` is true. |
| loading | boolean | false | When `true`, a centred `NativeLoadingState` (theme-tinted spinner, announced as loading) replaces the body, inside the same safe area and background. Use it for redirect and first-load screens: the body is unmounted while it's on, so a form underneath loses its state. Default `false`. |
| loadingLabel | string | — | Text under the spinner while `loading`, and what screen readers announce: pass translated text. |
| onRefresh | (() => void | Promise<void>) | — | Pull to refresh: a theme-tinted `NativeRefreshControl` on the body, as InboxPage and NotificationsPage have. Pulling needs a scroll view, so passing it makes the body scroll (as `scroll`). Off unless passed. Never with a list child (FlatList, SectionList, NativeResourceView, InboxPage): a list inside a ScrollView loses virtualization, and those lists have their own pull to refresh. |
| refreshing | boolean | false | The refresh spinner shows while `true`: pass your query's refetching state. Default `false`. |
| safeAreaEdges | SafeAreaEdge[] | ["left", "right"] | SafeAreaView edges. Defaults to `["left", "right"]` — top/bottom are normally handled by the navigation header / tab bar. |
| scroll | boolean | false | When `true`, the body is wrapped in a vertical ScrollView. Default `false`. |
| statusBar | enum | auto | StatusBar appearance. `"auto"` follows the resolved theme mode. |
| style | ViewStyle | — | Style on the root, e.g. a theme-role background color. |
| tabBar | enum | visible | The tab bar while this screen is focused. `"hidden"` hides it (a conversation, a full-screen viewer, a form pushed over a list), as UIKit's `hidesBottomBarWhenPushed`; the stack's back button and edge swipe stay. Needs `TabBarVisibilityProvider` around the tabs. Default `"visible"`. |
| testID | string | — | testID on the root container. |
| themeMode | enum | system | Force light or dark theme on this screen regardless of OS preference. Default `"system"` (follow OS). |