@admin-layout/gluestack-ui-mobile 6.5.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/LICENSE +21 -0
  3. package/README.md +4 -0
  4. package/assets/logo.png +0 -0
  5. package/babel.config.js +26 -0
  6. package/jest-react-navigation-setup.js +14 -0
  7. package/jest.config.js +39 -0
  8. package/jest.env.js +2 -0
  9. package/lib/__tests__/prolayout-layout-feature.test.d.ts +1 -0
  10. package/lib/__tests__/prolayout-layout-feature.test.js +202 -0
  11. package/lib/__tests__/prolayout-layout-feature.test.js.map +1 -0
  12. package/lib/components/ApplicationErrorFillWrapper.d.ts +2 -0
  13. package/lib/components/ApplicationErrorFillWrapper.js +7 -0
  14. package/lib/components/ApplicationErrorFillWrapper.js.map +1 -0
  15. package/lib/components/ApplicationErrorHandler.d.ts +2 -0
  16. package/lib/components/ApplicationErrorHandler.js +24 -0
  17. package/lib/components/ApplicationErrorHandler.js.map +1 -0
  18. package/lib/components/ErrorBounday.d.ts +18 -0
  19. package/lib/components/ErrorBounday.js +22 -0
  20. package/lib/components/ErrorBounday.js.map +1 -0
  21. package/lib/components/Fallback.d.ts +6 -0
  22. package/lib/components/Fallback.js +53 -0
  23. package/lib/components/Fallback.js.map +1 -0
  24. package/lib/components/Layout/components/BasicLayout.d.ts +5 -0
  25. package/lib/components/Layout/components/BasicLayout.js +28 -0
  26. package/lib/components/Layout/components/BasicLayout.js.map +1 -0
  27. package/lib/components/Layout/components/BottomTabBar.d.ts +2 -0
  28. package/lib/components/Layout/components/BottomTabBar.js +90 -0
  29. package/lib/components/Layout/components/BottomTabBar.js.map +1 -0
  30. package/lib/components/Layout/components/Drawer.d.ts +2 -0
  31. package/lib/components/Layout/components/Drawer.js +253 -0
  32. package/lib/components/Layout/components/Drawer.js.map +1 -0
  33. package/lib/components/Layout/components/Header.d.ts +2 -0
  34. package/lib/components/Layout/components/Header.js +130 -0
  35. package/lib/components/Layout/components/Header.js.map +1 -0
  36. package/lib/components/Layout/components/Sample.d.ts +2 -0
  37. package/lib/components/Layout/components/Sample.js +7 -0
  38. package/lib/components/Layout/components/Sample.js.map +1 -0
  39. package/lib/components/Layout/components/SettingDrawer/LayoutButton.d.ts +3 -0
  40. package/lib/components/Layout/components/SettingDrawer/LayoutButton.js +66 -0
  41. package/lib/components/Layout/components/SettingDrawer/LayoutButton.js.map +1 -0
  42. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.d.ts +2 -0
  43. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js +23 -0
  44. package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js.map +1 -0
  45. package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.d.ts +3 -0
  46. package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js +24 -0
  47. package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js.map +1 -0
  48. package/lib/components/Layout/components/SettingDrawer/index.d.ts +1 -0
  49. package/lib/components/Layout/components/SettingDrawer/index.js +2 -0
  50. package/lib/components/Layout/components/SettingDrawer/index.js.map +1 -0
  51. package/lib/components/Layout/components/SideBar.d.ts +10 -0
  52. package/lib/components/Layout/components/SideBar.js +59 -0
  53. package/lib/components/Layout/components/SideBar.js.map +1 -0
  54. package/lib/components/Layout/components/defaultSettings.d.ts +4 -0
  55. package/lib/components/Layout/components/defaultSettings.js +16 -0
  56. package/lib/components/Layout/components/defaultSettings.js.map +1 -0
  57. package/lib/components/Layout/components/index.d.ts +4 -0
  58. package/lib/components/Layout/components/index.js +5 -0
  59. package/lib/components/Layout/components/index.js.map +1 -0
  60. package/lib/components/Layout/components/util.d.ts +1 -0
  61. package/lib/components/Layout/components/util.js +15 -0
  62. package/lib/components/Layout/components/util.js.map +1 -0
  63. package/lib/components/Layout/compute.d.ts +6 -0
  64. package/lib/components/Layout/compute.js +316 -0
  65. package/lib/components/Layout/compute.js.map +1 -0
  66. package/lib/components/Layout/compute.test.d.ts +6 -0
  67. package/lib/components/Layout/compute.test.js +120 -0
  68. package/lib/components/Layout/compute.test.js.map +1 -0
  69. package/lib/components/Layout/index.d.ts +4 -0
  70. package/lib/components/Layout/index.js +4 -0
  71. package/lib/components/Layout/index.js.map +1 -0
  72. package/lib/components/Layout/typings.d.ts +1 -0
  73. package/lib/components/Layout/typings.js +2 -0
  74. package/lib/components/Layout/typings.js.map +1 -0
  75. package/lib/components/NavigationComponent.d.ts +15 -0
  76. package/lib/components/NavigationComponent.js +120 -0
  77. package/lib/components/NavigationComponent.js.map +1 -0
  78. package/lib/components/PluginArea.d.ts +2 -0
  79. package/lib/components/PluginArea.js +8 -0
  80. package/lib/components/PluginArea.js.map +1 -0
  81. package/lib/components/ToastAlert.d.ts +12 -0
  82. package/lib/components/ToastAlert.js +17 -0
  83. package/lib/components/ToastAlert.js.map +1 -0
  84. package/lib/components/index.d.ts +9 -0
  85. package/lib/components/index.js +10 -0
  86. package/lib/components/index.js.map +1 -0
  87. package/lib/components/with-interactions-managed.d.ts +2 -0
  88. package/lib/components/with-interactions-managed.js +18 -0
  89. package/lib/components/with-interactions-managed.js.map +1 -0
  90. package/lib/config/config.d.ts +17 -0
  91. package/lib/config/config.js +18 -0
  92. package/lib/config/config.js.map +1 -0
  93. package/lib/config/index.d.ts +1 -0
  94. package/lib/config/index.js +2 -0
  95. package/lib/config/index.js.map +1 -0
  96. package/lib/constants/routes.d.ts +3 -0
  97. package/lib/constants/routes.js +5 -0
  98. package/lib/constants/routes.js.map +1 -0
  99. package/lib/containers/layout/BasicLayout.d.ts +7 -0
  100. package/lib/containers/layout/BasicLayout.js +36 -0
  101. package/lib/containers/layout/BasicLayout.js.map +1 -0
  102. package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +128 -0
  103. package/lib/containers/layout/DrawerBottomNavigationConfig.js +72 -0
  104. package/lib/containers/layout/DrawerBottomNavigationConfig.js.map +1 -0
  105. package/lib/containers/layout/DrawerConfig.d.ts +85 -0
  106. package/lib/containers/layout/DrawerConfig.js +48 -0
  107. package/lib/containers/layout/DrawerConfig.js.map +1 -0
  108. package/lib/containers/layout/Lifecycle.d.ts +13 -0
  109. package/lib/containers/layout/Lifecycle.js +18 -0
  110. package/lib/containers/layout/Lifecycle.js.map +1 -0
  111. package/lib/containers/layout/ProLayout.d.ts +5 -0
  112. package/lib/containers/layout/ProLayout.js +35 -0
  113. package/lib/containers/layout/ProLayout.js.map +1 -0
  114. package/lib/containers/layout/module.d.ts +5 -0
  115. package/lib/containers/layout/module.js +22 -0
  116. package/lib/containers/layout/module.js.map +1 -0
  117. package/lib/hooks/use-after-interactions.d.ts +6 -0
  118. package/lib/hooks/use-after-interactions.js +29 -0
  119. package/lib/hooks/use-after-interactions.js.map +1 -0
  120. package/lib/hooks/useIsReady.d.ts +2 -0
  121. package/lib/hooks/useIsReady.js +24 -0
  122. package/lib/hooks/useIsReady.js.map +1 -0
  123. package/lib/hooks/useLayoutSetting/index.d.ts +11 -0
  124. package/lib/hooks/useLayoutSetting/index.js +68 -0
  125. package/lib/hooks/useLayoutSetting/index.js.map +1 -0
  126. package/lib/index.d.ts +14 -0
  127. package/lib/index.js +26 -0
  128. package/lib/index.js.map +1 -0
  129. package/lib/interfaces/index.d.ts +1 -0
  130. package/lib/interfaces/index.js +2 -0
  131. package/lib/interfaces/index.js.map +1 -0
  132. package/lib/interfaces/settings.d.ts +4 -0
  133. package/lib/interfaces/settings.js +2 -0
  134. package/lib/interfaces/settings.js.map +1 -0
  135. package/lib/redux/settings.d.ts +80 -0
  136. package/lib/redux/settings.js +16 -0
  137. package/lib/redux/settings.js.map +1 -0
  138. package/lib/utils/ThemeColor.d.ts +8 -0
  139. package/lib/utils/ThemeColor.js +9 -0
  140. package/lib/utils/ThemeColor.js.map +1 -0
  141. package/lib/utils/routeConfigKeyReplace.d.ts +7 -0
  142. package/lib/utils/routeConfigKeyReplace.js +77 -0
  143. package/lib/utils/routeConfigKeyReplace.js.map +1 -0
  144. package/lib/utils/routeConfigKeyReplace.test.d.ts +1 -0
  145. package/lib/utils/routeConfigKeyReplace.test.js +102 -0
  146. package/lib/utils/routeConfigKeyReplace.test.js.map +1 -0
  147. package/package.json +40 -0
  148. package/src/__tests__/prolayout-layout-feature.test.tsx +207 -0
  149. package/src/components/ApplicationErrorFillWrapper.tsx +7 -0
  150. package/src/components/ApplicationErrorHandler.tsx +30 -0
  151. package/src/components/ErrorBounday.tsx +31 -0
  152. package/src/components/Fallback.tsx +65 -0
  153. package/src/components/Layout/README.md +11 -0
  154. package/src/components/Layout/components/BasicLayout.tsx +70 -0
  155. package/src/components/Layout/components/BottomTabBar.tsx +135 -0
  156. package/src/components/Layout/components/Drawer.tsx +412 -0
  157. package/src/components/Layout/components/Header.tsx +195 -0
  158. package/src/components/Layout/components/Sample.tsx +10 -0
  159. package/src/components/Layout/components/SettingDrawer/LayoutButton.tsx +102 -0
  160. package/src/components/Layout/components/SettingDrawer/SettingDrawer.tsx +60 -0
  161. package/src/components/Layout/components/SettingDrawer/ThemeColorButton.tsx +26 -0
  162. package/src/components/Layout/components/SettingDrawer/index.ts +1 -0
  163. package/src/components/Layout/components/SideBar.tsx +109 -0
  164. package/src/components/Layout/components/defaultSettings.ts +19 -0
  165. package/src/components/Layout/components/index.ts +4 -0
  166. package/src/components/Layout/components/util.ts +14 -0
  167. package/src/components/Layout/compute.test.tsx +129 -0
  168. package/src/components/Layout/compute.tsx +384 -0
  169. package/src/components/Layout/eslint.json +1 -0
  170. package/src/components/Layout/index.ts +5 -0
  171. package/src/components/Layout/typings.ts +1 -0
  172. package/src/components/NavigationComponent.tsx +154 -0
  173. package/src/components/PluginArea.tsx +11 -0
  174. package/src/components/ToastAlert.tsx +44 -0
  175. package/src/components/index.ts +9 -0
  176. package/src/components/with-interactions-managed.tsx +33 -0
  177. package/src/config/config.ts +17 -0
  178. package/src/config/index.ts +1 -0
  179. package/src/constants/routes.ts +3 -0
  180. package/src/containers/layout/BasicLayout.tsx +61 -0
  181. package/src/containers/layout/DrawerBottomNavigationConfig.tsx +85 -0
  182. package/src/containers/layout/DrawerConfig.tsx +59 -0
  183. package/src/containers/layout/Lifecycle.tsx +23 -0
  184. package/src/containers/layout/ProLayout.tsx +42 -0
  185. package/src/containers/layout/module.ts +24 -0
  186. package/src/hooks/use-after-interactions.ts +35 -0
  187. package/src/hooks/useIsReady.ts +31 -0
  188. package/src/hooks/useLayoutSetting/index.ts +99 -0
  189. package/src/index.ts +41 -0
  190. package/src/interfaces/index.ts +1 -0
  191. package/src/interfaces/settings.ts +5 -0
  192. package/src/redux/settings.ts +28 -0
  193. package/src/utils/ThemeColor.ts +9 -0
  194. package/src/utils/__snapshots__/routeConfigKeyReplace.test.ts.snap +117 -0
  195. package/src/utils/routeConfigKeyReplace.test.ts +114 -0
  196. package/src/utils/routeConfigKeyReplace.ts +74 -0
  197. package/tsconfig.json +37 -0
  198. package/types.d.ts +11 -0
  199. package/webpack.config.js +104 -0
@@ -0,0 +1,412 @@
1
+ import React from 'react';
2
+ import { Ionicons } from '@expo/vector-icons';
3
+ import { DrawerContentScrollView, DrawerItemList, DrawerItem } from '@react-navigation/drawer';
4
+ import {
5
+ SafeAreaView,
6
+ Box,
7
+ Text,
8
+ Heading,
9
+ Divider,
10
+ StatusBar,
11
+ Avatar,
12
+ AvatarFallbackText,
13
+ AvatarImage,
14
+ HStack,
15
+ VStack,
16
+ useToast,
17
+ Toast,
18
+ ToastTitle,
19
+ ToastDescription,
20
+ } from '@gluestack-ui/themed';
21
+ import { useNavigation, useRoute } from '@react-navigation/native';
22
+ import { navigationRef } from '@common-stack/client-react';
23
+ import { useSelector, useDispatch } from 'react-redux';
24
+ import { logoutAndRedirect, resetReduxState } from '@adminide-stack/user-auth0-client';
25
+
26
+ export const Drawer = (props: any) => {
27
+ const settings = useSelector<any>((state) => state.settings) as any;
28
+ const platform = useSelector<any>((state) => state.platform) as any;
29
+ const user = useSelector<any>((state) => state.user) as any;
30
+ const dispatch = useDispatch();
31
+ const navigation = useNavigation<any>();
32
+ const route = useRoute<any>();
33
+ const toast = useToast();
34
+ const currentRoute: any = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
35
+ let getRootState: any = null;
36
+ let allRoutes: any = null;
37
+ let tabRoutes: any = null;
38
+ if (settings && settings.layout == 'mixSide') {
39
+ getRootState = navigationRef.isReady() ? navigationRef?.getRootState() : null;
40
+ if (getRootState) {
41
+ allRoutes = getRootState?.routes[0]?.state?.routes ?? null;
42
+ tabRoutes =
43
+ allRoutes
44
+ ?.map((tr: any) => tr?.state?.routes?.filter((r: any) => r?.params?.menu_position == 'side'))
45
+ ?.flat(1) ?? [];
46
+ }
47
+ }
48
+
49
+ const drawerRoutes = props?.state?.routes;
50
+
51
+ const routes = settings && settings.layout == 'mixSide' ? tabRoutes : drawerRoutes;
52
+
53
+ const sideRoutes =
54
+ routes
55
+ ?.filter((r: any) => r?.params?.menu_position == 'side')
56
+ ?.sort(
57
+ (a: any, b: any) =>
58
+ (a?.params?.priority ? a?.params?.priority : a?.name) -
59
+ (b?.params?.priority ? b?.params?.priority : b?.name),
60
+ ) ?? [];
61
+ const bottomRoutes =
62
+ routes
63
+ ?.filter((r: any) => r?.params?.menu_position == 'bottom')
64
+ ?.sort(
65
+ (a: any, b: any) =>
66
+ (a?.params?.priority ? a?.params?.priority : a?.name) -
67
+ (b?.params?.priority ? b?.params?.priority : b?.name),
68
+ ) ?? [];
69
+
70
+ const logoUrl = settings?.logo?.split('.') ?? null;
71
+ const logoType = logoUrl ? logoUrl[logoUrl.length - 1] : null;
72
+
73
+ return (
74
+ <Box flex={1}>
75
+ <StatusBar barStyle={settings?.navTheme == 'dark' ? 'light-content':'dark-content'} />
76
+ <DrawerContentScrollView
77
+ {...props}
78
+ style={{
79
+ backgroundColor: props?.backgroundColor
80
+ ? props?.backgroundColor
81
+ : settings?.navTheme == 'dark'
82
+ ? '#000'
83
+ : '#fff',
84
+ }}
85
+ >
86
+ {settings?.logo && logoType && logoType != 'svg' ? (
87
+ <HStack px={"$3"} alignItems={'center'}>
88
+ <Avatar size={'sm'} bg='transparent'>
89
+ <AvatarFallbackText>Logo</AvatarFallbackText>
90
+ <AvatarImage
91
+ source={{
92
+ uri: settings?.logo,
93
+ }}
94
+ alt='logo'
95
+ />
96
+ </Avatar>
97
+
98
+ {props.title ? (
99
+ <Heading
100
+ p={"$5"}
101
+ size={'lg'}
102
+ color={
103
+ props?.titleColor
104
+ ? props?.titleColor
105
+ : settings?.navTheme == 'dark'
106
+ ? '$white'
107
+ : '$black'
108
+ }
109
+ >
110
+ {props?.headingTitle ?? settings?.title ?? props.title}
111
+ </Heading>
112
+ ) : null}
113
+ </HStack>
114
+ ) : (
115
+ <>
116
+ {props.title ? (
117
+ <Heading
118
+ p={"$5"}
119
+ size={'lg'}
120
+ color={
121
+ props?.titleColor
122
+ ? props?.titleColor
123
+ : settings?.navTheme == 'dark'
124
+ ? '$white'
125
+ : '$black'
126
+ }
127
+ >
128
+ {props?.headingTitle ?? settings?.title ?? props.title}
129
+ </Heading>
130
+ ) : null}
131
+ </>
132
+ )}
133
+
134
+ {[...sideRoutes]?.map((data: any) => {
135
+ return (
136
+ <DrawerItem
137
+ key={data.key}
138
+ icon={({ focused }) => {
139
+ if (settings && settings.layout == 'mixSide') {
140
+ const option = data.params.options ? JSON.parse(data.params.options) : null;
141
+ if (option) {
142
+ const drawerIcon = option?.drawerIcon??'home';
143
+ if (typeof drawerIcon === 'function')
144
+ return drawerIcon({
145
+ color: focused
146
+ ? props?.activeTintColor ?? '#ff5a00'
147
+ : props?.inactiveTintColor
148
+ ? props?.inactiveTintColor
149
+ : settings?.navTheme == 'dark'
150
+ ? 'white'
151
+ : 'black',
152
+ size: 'md',
153
+ });
154
+ return (
155
+ <Ionicons
156
+ name={drawerIcon}
157
+ color={
158
+ focused
159
+ ? props?.activeTintColor ?? '#ff5a00'
160
+ : props?.inactiveTintColor
161
+ ? props?.inactiveTintColor
162
+ : settings?.navTheme == 'dark'
163
+ ? 'white'
164
+ : 'black'
165
+ }
166
+ size={20}
167
+ />
168
+ );
169
+ } else {
170
+ <Ionicons
171
+ name={`grid`}
172
+ color={
173
+ focused
174
+ ? props?.activeTintColor ?? '#ff5a00'
175
+ : props?.inactiveTintColor
176
+ ? props?.inactiveTintColor
177
+ : settings?.navTheme == 'dark'
178
+ ? 'white'
179
+ : 'black'
180
+ }
181
+ size={20}
182
+ />;
183
+ }
184
+ } else {
185
+ if (typeof props.descriptors[data.key].options.drawerIcon === 'function')
186
+ return props.descriptors[data.key].options.drawerIcon({
187
+ color: focused
188
+ ? props?.activeTintColor ?? '#ff5a00'
189
+ : props?.inactiveTintColor
190
+ ? props?.inactiveTintColor
191
+ : settings?.navTheme == 'dark'
192
+ ? 'white'
193
+ : 'black',
194
+ size: 'md',
195
+ });
196
+ const drawerIcon = props?.descriptors?.[data?.key]?.options?.drawerIcon??'home';
197
+ return (
198
+ <Ionicons
199
+ name={drawerIcon}
200
+ color={
201
+ focused
202
+ ? props?.activeTintColor ?? '#ff5a00'
203
+ : props?.inactiveTintColor
204
+ ? props?.inactiveTintColor
205
+ : settings?.navTheme == 'dark'
206
+ ? 'white'
207
+ : 'black'
208
+ }
209
+ size={20}
210
+ />
211
+ );
212
+ }
213
+ }}
214
+ label={({ color }) => (
215
+ <Text style={{ color,fontSize:15 }} fontWeight={'$semibold'}>
216
+ {data.name.split('.').pop() === 'Home' ? 'Home' : data.name.split('.').pop()}
217
+ </Text>
218
+ )}
219
+ focused={
220
+ // props.state.routes.findIndex((e: any) => e.name === data.name) === props.state.index
221
+ settings?.layout == 'side'
222
+ ? props.state.routes.findIndex((e: any) => e.name === data.name) ===
223
+ props.state.index
224
+ : data.name === currentRoute?.name
225
+ }
226
+ onPress={() => navigation.navigate(data.name, { orgName: platform.orgName })}
227
+ activeTintColor={props?.activeTintColor ?? '#ff5a00'}
228
+ inactiveTintColor={
229
+ props?.inactiveTintColor
230
+ ? props?.inactiveTintColor
231
+ : settings?.navTheme == 'dark'
232
+ ? 'white'
233
+ : 'black'
234
+ }
235
+ />
236
+ );
237
+ })}
238
+ </DrawerContentScrollView>
239
+
240
+ <Box
241
+ mb={settings?.layout == 'bottomDrawer' ? "$0" : "$4"}
242
+ bg={props?.backgroundColor ? props?.backgroundColor : settings?.navTheme == 'dark' ? '#000' : '#fff'}
243
+ >
244
+ <Divider />
245
+ <>
246
+ {[...bottomRoutes]?.map((data: any) => {
247
+ return (
248
+ <DrawerItem
249
+ key={data.key}
250
+ icon={({ focused }) => {
251
+ if (settings && settings.layout == 'mixSide') {
252
+ const option = data.params.options ? JSON.parse(data.params.options) : null;
253
+ if (option) {
254
+ const drawerIcon = option?.drawerIcon??'home';
255
+ if (typeof drawerIcon === 'function')
256
+ return drawerIcon({
257
+ color: focused
258
+ ? props?.activeTintColor ?? '#ff5a00'
259
+ : props?.inactiveTintColor
260
+ ? props?.inactiveTintColor
261
+ : settings?.navTheme == 'dark'
262
+ ? 'white'
263
+ : 'black',
264
+ size: 'md',
265
+ });
266
+ return (
267
+ <Ionicons
268
+ name={drawerIcon}
269
+ color={
270
+ focused
271
+ ? props?.activeTintColor ?? '#ff5a00'
272
+ : props?.inactiveTintColor
273
+ ? props?.inactiveTintColor
274
+ : settings?.navTheme == 'dark'
275
+ ? 'white'
276
+ : 'black'
277
+ }
278
+ size={20}
279
+ />
280
+ );
281
+ } else {
282
+ <Ionicons
283
+ name={`grid`}
284
+ color={
285
+ focused
286
+ ? props?.activeTintColor ?? '#ff5a00'
287
+ : props?.inactiveTintColor
288
+ ? props?.inactiveTintColor
289
+ : settings?.navTheme == 'dark'
290
+ ? 'white'
291
+ : 'black'
292
+ }
293
+ size={20}
294
+ />;
295
+ }
296
+ } else {
297
+ if (typeof props.descriptors[data.key].options.drawerIcon === 'function')
298
+ return props.descriptors[data.key].options.drawerIcon({
299
+ color: focused
300
+ ? props?.activeTintColor ?? '#ff5a00'
301
+ : props?.inactiveTintColor
302
+ ? props?.inactiveTintColor
303
+ : settings?.navTheme == 'dark'
304
+ ? 'white'
305
+ : 'black',
306
+ size: 'md',
307
+ });
308
+ const drawerIcon = props?.descriptors?.[data?.key]?.options?.drawerIcon??'home';
309
+ return (
310
+ <Ionicons
311
+ name={drawerIcon}
312
+ color={
313
+ focused
314
+ ? props?.activeTintColor ?? '#ff5a00'
315
+ : props?.inactiveTintColor
316
+ ? props?.inactiveTintColor
317
+ : settings?.navTheme == 'dark'
318
+ ? 'white'
319
+ : 'black'
320
+ }
321
+ size={20}
322
+ />
323
+ );
324
+ }
325
+ }}
326
+ label={({ color }) => (
327
+ <Text style={{ color, fontSize: 15 }} fontWeight={'$semibold'}>
328
+ {data.name.split('.').pop() === 'Home' ? 'Home' : data.name.split('.').pop()}
329
+ </Text>
330
+ )}
331
+ focused={
332
+ // props.state.routes.findIndex((e: any) => e.name === data.name) === props.state.index
333
+ settings?.layout == 'side'
334
+ ? props.state.routes.findIndex((e: any) => e.name === data.name) ===
335
+ props.state.index
336
+ : data.name === currentRoute?.name
337
+ }
338
+ activeTintColor={props?.activeTintColor ?? '#ff5a00'}
339
+ inactiveTintColor={
340
+ props?.inactiveTintColor
341
+ ? props?.inactiveTintColor
342
+ : settings?.navTheme == 'dark'
343
+ ? 'white'
344
+ : 'black'
345
+ }
346
+ onPress={() =>
347
+ navigation.navigate(data.name, { orgName: platform.orgName })
348
+ }
349
+ />
350
+ );
351
+ })}
352
+ </>
353
+ {props.logout && user && user.accessToken && (
354
+ <DrawerItem
355
+ label={({ color }) => (
356
+ <Text style={{ color, fontSize: 18 }} fontWeight={'$semibold'}>
357
+ Logout
358
+ </Text>
359
+ )}
360
+ icon={({ focused }) => (
361
+ <Ionicons
362
+ name={'log-out'}
363
+ size={20}
364
+ color={
365
+ focused
366
+ ? props?.activeTintColor ?? '#ff5a00'
367
+ : props?.inactiveTintColor
368
+ ? props?.inactiveTintColor
369
+ : settings?.navTheme == 'dark'
370
+ ? 'white'
371
+ : 'black'
372
+ }
373
+ />
374
+ )}
375
+ activeTintColor={props?.activeTintColor ?? '#ff5a00'}
376
+ inactiveTintColor={
377
+ props?.inactiveTintColor
378
+ ? props?.inactiveTintColor
379
+ : settings?.navTheme == 'dark'
380
+ ? 'white'
381
+ : 'black'
382
+ }
383
+ //onPress={() => navigation.navigate('MainStack.Logout', { redirect: props.redirect })}
384
+ onPress={async () => {
385
+ try {
386
+ dispatch(logoutAndRedirect());
387
+ dispatch(resetReduxState());
388
+ toast.show({
389
+ placement: 'top',
390
+ render: ({ id }) => {
391
+ const toastId = 'toast-' + id;
392
+ return (
393
+ <Toast nativeID={toastId} action="attention" variant="solid">
394
+ <VStack space="xs">
395
+ <ToastTitle>Logging out</ToastTitle>
396
+ {/* <ToastDescription></ToastDescription> */}
397
+ </VStack>
398
+ </Toast>
399
+ );
400
+ },
401
+ });
402
+ props?.navigation?.closeDrawer();
403
+ } catch (error) {
404
+ console.error('Error signing out', error);
405
+ }
406
+ }}
407
+ />
408
+ )}
409
+ </Box>
410
+ </Box>
411
+ );
412
+ };
@@ -0,0 +1,195 @@
1
+ import React, { useState, useCallback } from 'react';
2
+ import { HStack, Icon, Text, Box, StatusBar, Divider, Button, ButtonIcon, SafeAreaView } from '@gluestack-ui/themed';
3
+ import { getHeaderTitle } from '@react-navigation/elements';
4
+ import { Ionicons } from '@expo/vector-icons';
5
+ import { SettingDrawer } from './SettingDrawer';
6
+ import { useDispatch } from 'react-redux';
7
+ import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';
8
+ import { useSelector } from 'react-redux';
9
+
10
+
11
+ export const Header = React.memo(({
12
+ navigation,
13
+ route,
14
+ options,
15
+ back,
16
+ showToggle = null,
17
+ theme = 'light',
18
+ right = null,
19
+ rightComponent,
20
+ }: any)=>{
21
+ const title = getHeaderTitle(options, route.name);
22
+
23
+ const matches: any = title.match(/\b(\w)/g);
24
+ const acronym: any = matches.join('').substring(0, 2); // JSON
25
+ const [settingToggle, setSettingToggle] = useState(false);
26
+ const settings = useSelector<any>((state) => state.settings) as any;
27
+ const dispatch = useDispatch();
28
+
29
+ const onSettingChange = useCallback(
30
+ (config: any) =>
31
+ dispatch({
32
+ type: CHANGE_SETTINGS_ACTION,
33
+ payload: config,
34
+ }),
35
+ [dispatch],
36
+ );
37
+
38
+ return (
39
+ <SafeAreaView>
40
+ <StatusBar barStyle={theme === 'light' ? 'dark-content':'light-content'} />
41
+ <Box bg={theme === 'light' ? '$white' : '$black'}>
42
+ <HStack
43
+ bg={theme === 'light' ? '$white' : '$black'}
44
+ px="$1"
45
+ py="$3"
46
+ // justifyContent={
47
+ // settings?.layout === 'bottom' || settings?.layout === 'host-bottom' ? 'center' : 'space-between'
48
+ // }
49
+ justifyContent={
50
+ (settings?.layout === 'bottom' || settings?.layout === 'host-bottom') && !right
51
+ ? 'center'
52
+ : 'space-between'
53
+ }
54
+ alignItems="center"
55
+ borderBottomWidth={'$1'}
56
+ borderBottomColor={'#d3d3d3'}
57
+ w="100%"
58
+
59
+ >
60
+ {back ? (
61
+ <Button size="xs" bg={'transparent'} onPress={() => navigation.goBack()}>
62
+ <Ionicons name={'arrow-back'} color={theme === 'light' ? 'black' : 'white'} size={20} />
63
+ </Button>
64
+ ) : showToggle && settings?.layout !== 'bottom' ? (
65
+ <Button size="xs" bg={'transparent'} onPress={() => navigation.toggleDrawer()}>
66
+ <Ionicons name={'menu'} color={theme === 'light' ? 'black' : 'white'} size={20} />
67
+ </Button>
68
+ ) : (
69
+ <></>
70
+ )}
71
+ <Text
72
+ px={'$2'}
73
+ color={theme === 'light' ? '$black' : '$white'}
74
+ style={{ fontSize: 20 }}
75
+ fontWeight="$bold"
76
+ >
77
+ {title}
78
+ </Text>
79
+ {!!settingToggle ? (
80
+ <SettingDrawer
81
+ onSettingChange={(settings: any) => {
82
+ onSettingChange(settings);
83
+ setSettingToggle(false);
84
+ }}
85
+ />
86
+ ) : null}
87
+ {right ? (
88
+ <HStack alignItems={'center'}>
89
+ <Button size="xs" bg={'transparent'} onPress={() => setSettingToggle(!settingToggle)}>
90
+ <Ionicons name={'cog'} color={theme === 'light' ? 'black' : 'white'} size={20} />
91
+ </Button>
92
+ {rightComponent ? <Box>{rightComponent}</Box> : null}
93
+ </HStack>
94
+ ) : (
95
+ <Button bg={'transparent'} mr={'$2'}></Button>
96
+ )}
97
+ </HStack>
98
+
99
+ </Box>
100
+ </SafeAreaView>
101
+ );
102
+ });
103
+
104
+ // export const Header = ({
105
+ // navigation,
106
+ // route,
107
+ // options,
108
+ // back,
109
+ // showToggle = null,
110
+ // theme = 'light',
111
+ // right = null,
112
+ // rightComponent,
113
+ // }: any) => {
114
+ // const title = getHeaderTitle(options, route.name);
115
+
116
+ // const matches: any = title.match(/\b(\w)/g);
117
+ // const acronym: any = matches.join('').substring(0, 2); // JSON
118
+ // const [settingToggle, setSettingToggle] = useState(false);
119
+ // const settings = useSelector<any>((state) => state.settings) as any;
120
+ // const dispatch = useDispatch();
121
+
122
+ // const onSettingChange = useCallback(
123
+ // (config: any) =>
124
+ // dispatch({
125
+ // type: CHANGE_SETTINGS_ACTION,
126
+ // payload: config,
127
+ // }),
128
+ // [dispatch],
129
+ // );
130
+
131
+ // return (
132
+ // <SafeAreaView>
133
+ // <StatusBar barStyle={theme === 'light' ? 'dark-content':'light-content'} />
134
+ // <Box bg={theme === 'light' ? '$white' : '$black'}>
135
+ // <HStack
136
+ // bg={theme === 'light' ? '$white' : '$black'}
137
+ // px="$1"
138
+ // py="$3"
139
+ // // justifyContent={
140
+ // // settings?.layout === 'bottom' || settings?.layout === 'host-bottom' ? 'center' : 'space-between'
141
+ // // }
142
+ // justifyContent={
143
+ // (settings?.layout === 'bottom' || settings?.layout === 'host-bottom') && !right
144
+ // ? 'center'
145
+ // : 'space-between'
146
+ // }
147
+ // alignItems="center"
148
+ // borderBottomWidth={'$1'}
149
+ // borderBottomColor={'#d3d3d3'}
150
+ // w="100%"
151
+
152
+ // >
153
+ // {back ? (
154
+ // <Button size="xs" bg={'transparent'} onPress={() => navigation.goBack()}>
155
+ // <Ionicons name={'arrow-back'} color={theme === 'light' ? 'black' : 'white'} size={20} />
156
+ // </Button>
157
+ // ) : showToggle && settings?.layout !== 'bottom' ? (
158
+ // <Button size="xs" bg={'transparent'} onPress={() => navigation.toggleDrawer()}>
159
+ // <Ionicons name={'menu'} color={theme === 'light' ? 'black' : 'white'} size={20} />
160
+ // </Button>
161
+ // ) : (
162
+ // <></>
163
+ // )}
164
+ // <Text
165
+ // px={'$2'}
166
+ // color={theme === 'light' ? '$black' : '$white'}
167
+ // style={{ fontSize: 20 }}
168
+ // fontWeight="$bold"
169
+ // >
170
+ // {title}
171
+ // </Text>
172
+ // {!!settingToggle ? (
173
+ // <SettingDrawer
174
+ // onSettingChange={(settings: any) => {
175
+ // onSettingChange(settings);
176
+ // setSettingToggle(false);
177
+ // }}
178
+ // />
179
+ // ) : null}
180
+ // {right ? (
181
+ // <HStack alignItems={'center'}>
182
+ // <Button size="xs" bg={'transparent'} onPress={() => setSettingToggle(!settingToggle)}>
183
+ // <Ionicons name={'cog'} color={theme === 'light' ? 'black' : 'white'} size={20} />
184
+ // </Button>
185
+ // {rightComponent ? <Box>{rightComponent}</Box> : null}
186
+ // </HStack>
187
+ // ) : (
188
+ // <Button bg={'transparent'} mr={'$2'}></Button>
189
+ // )}
190
+ // </HStack>
191
+
192
+ // </Box>
193
+ // </SafeAreaView>
194
+ // );
195
+ // };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Box, Text } from '@gluestack-ui/themed';
3
+
4
+ export const Sample = () => {
5
+ return (
6
+ <Box>
7
+ <Text>Sample</Text>
8
+ </Box>
9
+ );
10
+ };