@@ -19,11 +19,9 @@ function CustomDrawerContent(props) {
19
19
} ;
20
20
21
21
const onItemParentPress = ( key ) => {
22
- console . log ( 'key' , key ) ;
23
22
const filteredMainDrawerRoutes = props . drawerItems . find ( ( e ) => {
24
23
return e . key === key ;
25
24
} ) ;
26
- console . log ( filteredMainDrawerRoutes ) ;
27
25
if ( filteredMainDrawerRoutes . routes . length === 1 ) {
28
26
const selectedRoute = filteredMainDrawerRoutes . routes [ 0 ] ;
29
27
props . navigation . toggleDrawer ( ) ;
@@ -60,6 +58,33 @@ function CustomDrawerContent(props) {
60
58
) ;
61
59
}
62
60
61
+ function renderFilteredItemsDrawer ( ) {
62
+ return (
63
+ < View >
64
+ < TouchableOpacity
65
+ onPress = { ( ) => toggleMainDrawer ( ) }
66
+ style = { styles . backButtonRow } >
67
+ < Text style = { [ styles . backButtonText , styles . title ] } > { 'BACK' } </ Text >
68
+ </ TouchableOpacity >
69
+ { filteredItems . routes . map ( ( route ) => {
70
+ return (
71
+ < TouchableOpacity
72
+ key = { route . routeName }
73
+ testID = { route . routeName }
74
+ onPress = { ( ) =>
75
+ props . navigation . navigate ( route . nav , {
76
+ screen : route . routeName ,
77
+ } )
78
+ }
79
+ style = { styles . item } >
80
+ < Text style = { styles . title } > { route . title } </ Text >
81
+ </ TouchableOpacity >
82
+ ) ;
83
+ } ) }
84
+ </ View >
85
+ ) ;
86
+ }
87
+
63
88
function renderLogoutBtn ( ) {
64
89
return (
65
90
< View >
@@ -83,34 +108,7 @@ function CustomDrawerContent(props) {
83
108
style = { styles . logo }
84
109
/>
85
110
</ View >
86
- { mainDrawer ? (
87
- renderMainDrawer ( )
88
- ) : (
89
- < View >
90
- < TouchableOpacity
91
- onPress = { ( ) => toggleMainDrawer ( ) }
92
- style = { styles . backButtonRow } >
93
- < Text style = { [ styles . backButtonText , styles . title ] } >
94
- { 'BACK' }
95
- </ Text >
96
- </ TouchableOpacity >
97
- { filteredItems . routes . map ( ( route ) => {
98
- return (
99
- < TouchableOpacity
100
- key = { route . routeName }
101
- testID = { route . routeName }
102
- onPress = { ( ) =>
103
- props . navigation . navigate ( route . nav , {
104
- screen : route . routeName ,
105
- } )
106
- }
107
- style = { styles . item } >
108
- < Text style = { styles . title } > { route . title } </ Text >
109
- </ TouchableOpacity >
110
- ) ;
111
- } ) }
112
- </ View >
113
- ) }
111
+ { mainDrawer ? renderMainDrawer ( ) : renderFilteredItemsDrawer ( ) }
114
112
</ SafeAreaView >
115
113
</ ScrollView >
116
114
) ;
0 commit comments