11import * as React from 'react' ;
2- import { Platform } from 'react-native' ;
2+ import { Platform , StyleSheet , View } from 'react-native' ;
33
44import type { DrawerNavigationProp } from '@react-navigation/drawer' ;
55import { getHeaderTitle } from '@react-navigation/elements' ;
@@ -19,55 +19,68 @@ export default function Root() {
1919 ? CardStyleInterpolators . forFadeFromBottomAndroid
2020 : CardStyleInterpolators . forHorizontalIOS ;
2121 return (
22- < Stack . Navigator
23- screenOptions = { ( { navigation } ) => {
24- return {
25- detachPreviousScreen : ! navigation . isFocused ( ) ,
26- cardStyleInterpolator,
27- header : ( { navigation, route, options, back } ) => {
28- const title = getHeaderTitle ( options , route . name ) ;
29- return (
30- < Appbar . Header elevated >
31- { back ? (
32- < Appbar . BackAction onPress = { ( ) => navigation . goBack ( ) } />
33- ) : ( navigation as any ) . openDrawer ? (
34- < Appbar . Action
35- icon = "menu"
36- isLeading
37- onPress = { ( ) =>
38- (
39- navigation as any as DrawerNavigationProp < { } >
40- ) . openDrawer ( )
41- }
42- />
43- ) : null }
44- < Appbar . Content title = { title } />
45- </ Appbar . Header >
46- ) ;
47- } ,
48- } ;
49- } }
50- >
51- < Stack . Screen
52- name = "ExampleList"
53- component = { ExampleList }
54- options = { {
55- title : 'Examples' ,
22+ < View style = { styles . stackWrapper } >
23+ < Stack . Navigator
24+ screenOptions = { ( { navigation } ) => {
25+ return {
26+ detachPreviousScreen : ! navigation . isFocused ( ) ,
27+ cardStyleInterpolator,
28+ header : ( { navigation, route, options, back } ) => {
29+ const title = getHeaderTitle ( options , route . name ) ;
30+ return (
31+ < Appbar . Header elevated >
32+ { back ? (
33+ < Appbar . BackAction onPress = { ( ) => navigation . goBack ( ) } />
34+ ) : ( navigation as any ) . openDrawer ? (
35+ < Appbar . Action
36+ icon = "menu"
37+ isLeading
38+ onPress = { ( ) =>
39+ (
40+ navigation as any as DrawerNavigationProp < { } >
41+ ) . openDrawer ( )
42+ }
43+ />
44+ ) : null }
45+ < Appbar . Content title = { title } />
46+ </ Appbar . Header >
47+ ) ;
48+ } ,
49+ } ;
5650 } }
57- />
58- { ( Object . keys ( examples ) as Array < keyof typeof examples > ) . map ( ( id ) => {
59- return (
60- < Stack . Screen
61- key = { id }
62- name = { id }
63- component = { examples [ id ] }
64- options = { {
65- title : examples [ id ] . title ,
66- headerShown : id !== 'themingWithReactNavigation' ,
67- } }
68- />
69- ) ;
70- } ) }
71- </ Stack . Navigator >
51+ >
52+ < Stack . Screen
53+ name = "ExampleList"
54+ component = { ExampleList }
55+ options = { {
56+ title : 'Examples' ,
57+ } }
58+ />
59+ { ( Object . keys ( examples ) as Array < keyof typeof examples > ) . map ( ( id ) => {
60+ return (
61+ < Stack . Screen
62+ key = { id }
63+ name = { id }
64+ component = { examples [ id ] }
65+ options = { {
66+ title : examples [ id ] . title ,
67+ headerShown : id !== 'themingWithReactNavigation' ,
68+ } }
69+ />
70+ ) ;
71+ } ) }
72+ </ Stack . Navigator >
73+ </ View >
7274 ) ;
7375}
76+
77+ const styles = StyleSheet . create ( {
78+ stackWrapper : {
79+ flex : 1 ,
80+ ...Platform . select ( {
81+ web : {
82+ overflow : 'scroll' ,
83+ } ,
84+ } ) ,
85+ } ,
86+ } ) ;
0 commit comments