mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* feat(mobile): light and dark themes with desktop's palettes Settings → Appearance offers System, Light and Dark. The shell passes the resolved scheme to over-the-air pages in its init frame. Fixes #22184 * fix(mobile): draw your chat messages in desktop's user bubble Desktop uses a faint surface with a hairline border in both themes; the inverted fill went black in light. * test(mobile): re-measure the page script sweep after the shared theme hooks Every route now imports the theme hooks while the entry does not, so they emit one shared script (96 for the tree). Re-swept every route prefix; the worst route step is now 15. * test(mobile): read themed stylesheets in the text-input font-size census The census only unwrapped StyleSheet.create({...}); inputs styled through themedStyleSheet(() => ({...})) came back unread.
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { useMemo, useSyncExternalStore } from 'react'
|
||
import { useWindowDimensions, View } from 'react-native'
|
||
import { Slot, usePathname } from 'expo-router'
|
||
import { SafeAreaFrameContext, SafeAreaInsetsContext } from 'react-native-safe-area-context'
|
||
import { ZERO_SAFE_AREA_INSETS } from '../src/mobile-web-shell/bridge/bridge-safe-area-insets'
|
||
import { SideSafeArea } from '../src/layout/side-safe-area'
|
||
import { usePageBridgeClient } from '../src/transport/client-context.web'
|
||
import { colors } from '../src/theme/mobile-theme'
|
||
import { themedStyleSheet } from '../src/theme/themed-styles'
|
||
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
|
||
import { isOverlayPageRoute } from '../src/new-workspace/overlay-page-route'
|
||
|
||
// Provide shell insets below ExpoRoot (WebView CSS env insets are zero); pad only sides to avoid DefaultNavigator’s duplicate all-edge SafeAreaView.
|
||
export default function PageRootLayout() {
|
||
useMobileColorScheme()
|
||
const client = usePageBridgeClient()
|
||
const insets = useSyncExternalStore(
|
||
client.onSafeAreaInsetsUpdate,
|
||
() => client.getShellSession()?.safeAreaInsets ?? ZERO_SAFE_AREA_INSETS
|
||
)
|
||
const { width, height } = useWindowDimensions()
|
||
const transparent = isOverlayPageRoute(usePathname())
|
||
const frame = useMemo(() => ({ x: 0, y: 0, width, height }), [width, height])
|
||
return (
|
||
<SafeAreaFrameContext.Provider value={frame}>
|
||
<SafeAreaInsetsContext.Provider value={insets}>
|
||
<View style={[styles.root, transparent && styles.transparent]}>
|
||
<SideSafeArea>
|
||
<Slot />
|
||
</SideSafeArea>
|
||
</View>
|
||
</SafeAreaInsetsContext.Provider>
|
||
</SafeAreaFrameContext.Provider>
|
||
)
|
||
}
|
||
|
||
const styles = themedStyleSheet(() => ({
|
||
root: {
|
||
flex: 1,
|
||
backgroundColor: colors.bgBase
|
||
},
|
||
transparent: {
|
||
backgroundColor: 'transparent'
|
||
}
|
||
}))
|