@@ -24,9 +24,14 @@ import {
2424 Switch ,
2525 Touchable ,
2626} from 'react-native-gesture-handler' ;
27- import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
27+ import {
28+ initialWindowMetrics ,
29+ SafeAreaProvider ,
30+ useSafeAreaInsets ,
31+ } from 'react-native-safe-area-context' ;
2832
2933import { COLORS } from './src/common' ;
34+ import { ConsoleHeaderButton , ConsoleModalProvider } from './src/console' ;
3035import { OLD_EXAMPLES } from './src/legacy' ;
3136import { TouchableExample } from './src/legacy/release_tests/touchables' ;
3237import { ListWithHeader } from './src/ListWithHeader' ;
@@ -45,41 +50,57 @@ type RootStackParamList = {
4550
4651const Stack = createStackNavigator < RootStackParamList > ( ) ;
4752export default function App ( ) {
53+ return (
54+ < SafeAreaProvider initialMetrics = { initialWindowMetrics } >
55+ < AppContent />
56+ </ SafeAreaProvider >
57+ ) ;
58+ }
59+
60+ function AppContent ( ) {
4861 const [ showLegacyVersion , setShowLegacyVersion ] = useState ( false ) ;
4962 return (
50- < GestureHandlerRootView >
51- < NavigationContainer >
52- < Stack . Navigator
53- screenOptions = { {
54- cardStyle : {
55- // It's important to set height for the screen, without it scroll doesn't work on web platform.
56- height : Dimensions . get ( 'window' ) . height ,
57- backgroundColor : COLORS . offWhite ,
58- } ,
59- headerStyle : {
60- backgroundColor : COLORS . offWhite ,
61- borderBottomColor : COLORS . headerSeparator ,
62- borderBottomWidth : 1 ,
63- } ,
64- } } >
65- < Stack . Screen
66- name = "Home"
67- options = { { headerShown : false } }
68- component = { MainScreen }
69- />
70- { ( showLegacyVersion ? OLD_EXAMPLES : NEW_EXAMPLES )
71- . flatMap ( ( { data } ) => data )
72- . flatMap ( ( { name, component } ) => (
63+ < GestureHandlerRootView style = { styles . root } >
64+ < ConsoleModalProvider >
65+ < View style = { styles . root } >
66+ < NavigationContainer >
67+ < Stack . Navigator
68+ screenOptions = { {
69+ cardStyle : {
70+ // It's important to set height for the screen, without it scroll doesn't work on web platform.
71+ height : Dimensions . get ( 'window' ) . height ,
72+ backgroundColor : COLORS . offWhite ,
73+ } ,
74+ headerRight : ( ) => < ConsoleHeaderButton /> ,
75+ headerStyle : {
76+ backgroundColor : COLORS . offWhite ,
77+ borderBottomColor : COLORS . headerSeparator ,
78+ borderBottomWidth : 1 ,
79+ } ,
80+ } } >
7381 < Stack . Screen
74- key = { name }
75- name = { name }
76- getComponent = { ( ) => component }
77- options = { { title : name } }
82+ name = "Home"
83+ options = { { headerShown : false } }
84+ component = { MainScreen }
7885 />
79- ) ) }
80- < Stack . Screen name = "TouchableExample" component = { TouchableExample } />
81- </ Stack . Navigator >
82- </ NavigationContainer >
86+ { ( showLegacyVersion ? OLD_EXAMPLES : NEW_EXAMPLES )
87+ . flatMap ( ( { data } ) => data )
88+ . flatMap ( ( { name, component } ) => (
89+ < Stack . Screen
90+ key = { name }
91+ name = { name }
92+ getComponent = { ( ) => component }
93+ options = { { title : name } }
94+ />
95+ ) ) }
96+ < Stack . Screen
97+ name = "TouchableExample"
98+ component = { TouchableExample }
99+ />
100+ </ Stack . Navigator >
101+ </ NavigationContainer >
102+ </ View >
103+ </ ConsoleModalProvider >
83104 </ GestureHandlerRootView >
84105 ) ;
85106
@@ -298,6 +319,9 @@ export default function App() {
298319}
299320
300321const styles = StyleSheet . create ( {
322+ root : {
323+ flex : 1 ,
324+ } ,
301325 container : {
302326 flex : 1 ,
303327 backgroundColor : COLORS . offWhite ,
0 commit comments