11import React from 'react' ;
22import { NavigationContainer } from '@react-navigation/native' ;
3- import { Pressable , Text , View , StyleSheet , Button } from 'react-native' ;
3+ import { Text , View , StyleSheet , Button } from 'react-native' ;
44import { createNativeStackNavigator } from '@react-navigation/native-stack' ;
5- import { GestureHandlerRootView } from 'react-native-gesture-handler' ;
65import PressableWithFeedback from '../shared/PressableWithFeedback' ;
76
87const styles = StyleSheet . create ( {
@@ -24,7 +23,7 @@ const styles = StyleSheet.create({
2423
2524const Stack = createNativeStackNavigator ( ) ;
2625
27- function MyStack ( ) {
26+ function RootStack ( ) {
2827 return (
2928 < Stack . Navigator
3029 screenOptions = { {
@@ -44,36 +43,21 @@ const HomeScreen = ({ navigation }: any) => {
4443
4544 const headerRight = React . useCallback ( ( ) => {
4645 return (
47- < >
46+ < View style = { [ styles . buttonsView , ! showAllButtons && { display : 'none' } ] } >
4847 < PressableWithFeedback style = { styles . button } onPress = { ( ) => console . log ( 1 ) } >
4948 < Text > 1</ Text >
5049 </ PressableWithFeedback >
51- { secondButtonShown && (
52- < PressableWithFeedback style = { styles . button } onPress = { ( ) => console . log ( 2 ) } >
53- < Text > 2</ Text >
54- </ PressableWithFeedback >
55- ) }
56- { thirdButtonShown && (
57- < PressableWithFeedback style = { styles . button } onPress = { ( ) => console . log ( 3 ) } >
58- < Text > 3</ Text >
59- </ PressableWithFeedback >
60- ) }
61- </ >
50+ < PressableWithFeedback style = { styles . button } onPress = { ( ) => console . log ( 'D' ) } >
51+ < Text > [D]</ Text >
52+ </ PressableWithFeedback >
53+ </ View >
6254 ) ;
63- } , [ secondButtonShown , thirdButtonShown ] ) ;
55+ } , [ secondButtonShown , thirdButtonShown , showAllButtons ] ) ;
6456
6557 React . useLayoutEffect ( ( ) => {
6658 navigation . setOptions ( {
6759 headerStyle : { backgroundColor : 'pink' } ,
68- headerRight : ( ) => (
69- < View
70- style = { [ styles . buttonsView , ! showAllButtons && { display : 'none' } ] } >
71- { headerRight ( ) }
72- < PressableWithFeedback style = { styles . button } onPress = { ( ) => console . log ( 'D' ) } >
73- < Text > [D]</ Text >
74- </ PressableWithFeedback >
75- </ View >
76- ) ,
60+ headerRight : headerRight ,
7761 } ) ;
7862 } , [ navigation , headerRight , showAllButtons ] ) ;
7963
@@ -98,11 +82,9 @@ const HomeScreen = ({ navigation }: any) => {
9882
9983function App ( ) {
10084 return (
101- < GestureHandlerRootView >
102- < NavigationContainer >
103- < MyStack />
104- </ NavigationContainer >
105- </ GestureHandlerRootView >
85+ < NavigationContainer >
86+ < RootStack />
87+ </ NavigationContainer >
10688 ) ;
10789}
10890
0 commit comments