@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,207 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import { ProLayout } from '../containers/layout/ProLayout';
4
+ import { Feature, IRouteData, getNavigation, getSortedNavigations } from '@common-stack/client-react';
5
+ import { createStackNavigator } from '@react-navigation/stack';
6
+ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
7
+ import { createDrawerNavigator } from '@react-navigation/drawer';
8
+ const MyComponent = () => {
9
+ const routerConfig = {
10
+ ['/']: {
11
+ exact: false,
12
+ container: createStackNavigator(),
13
+ name: 'MainStack',
14
+ props: {
15
+ initialRouteName: 'MainStack.MainDrawer',
16
+ screenOptions: {
17
+ headerShown: false,
18
+ },
19
+ },
20
+ },
21
+ ['//maindrawer']: {
22
+ container: createDrawerNavigator(),
23
+ exact: false,
24
+ name: 'MainDrawer',
25
+ props: {
26
+ initialRouteName: 'MainStack.MainDrawer.MainBottomTab',
27
+ screenOptions: {
28
+ headerShown: false,
29
+ tabBarLabel: 'About',
30
+ // tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
31
+ },
32
+ },
33
+ },
34
+ ['//maindrawer/bottom_tab']: {
35
+ container: createBottomTabNavigator(),
36
+ exact: false,
37
+ name: 'MainBottomTab',
38
+ props: {
39
+ initialRouteName: 'MainStack.MainDrawer.MainBottomTab.Home',
40
+ screenOptions: {
41
+ headerShown: false,
42
+ tabBarLabel: 'About',
43
+ // tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
44
+ },
45
+ },
46
+ },
47
+ ['//maindrawer/bottom_tab/home']: {
48
+ name: 'Home',
49
+ props: {
50
+ priority: 1,
51
+ initialParams: { orgName: 'test' },
52
+ component: MyComponent,
53
+ options: {
54
+ headerShown: true,
55
+ tabBarLabel: 'Home',
56
+ headerTitle: 'Home',
57
+ // tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
58
+ },
59
+ },
60
+ },
61
+ ['//maindrawer/bottom_tab/home/:about']: {
62
+ exact: false,
63
+ container: createStackNavigator(),
64
+ name: 'About',
65
+ props: {
66
+ initialRouteName: 'Hello',
67
+ },
68
+ },
69
+ ['//maindrawer/bottom_tab/home/:about/info']: {
70
+ name: 'Info',
71
+ props: {
72
+ priority: 2,
73
+ initialParams: {},
74
+ component: MyComponent,
75
+ options: {
76
+ headerTitle: 'Info',
77
+ },
78
+ },
79
+ },
80
+ ['//maindrawer/bottom_tab/account']: {
81
+ name: 'Account',
82
+ props: {
83
+ priority: 3,
84
+ initialParams: {},
85
+ component: MyComponent,
86
+ options: {
87
+ headerShown: true,
88
+ tabBarLabel: 'Account',
89
+ headerTitle: 'Account',
90
+ // tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
91
+ },
92
+ },
93
+ },
94
+ };
95
+
96
+ const feature = new Feature({ routeConfig: routerConfig });
97
+ return <ProLayout features={feature} />;
98
+ };
99
+
100
+ test('renders correctly', () => {
101
+ const tree = renderer.create(<MyComponent />).toJSON();
102
+ expect(tree).toMatchSnapshot();
103
+ });
104
+
105
+ // import { Feature, IRouteData, getNavigation, getSortedNavigations } from '@common-stack/client-react';
106
+ // import { createStackNavigator } from '@react-navigation/stack';
107
+ // import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
108
+ // import { createDrawerNavigator } from '@react-navigation/drawer';
109
+
110
+ // const MyComponent = () => {};
111
+
112
+ // describe('prolayout feature testing with basic routes', () => {
113
+ // const routerConfig: IRouteData = {
114
+ // ['/']: {
115
+ // exact: false,
116
+ // container: createStackNavigator(),
117
+ // name: 'MainStack',
118
+ // props: {
119
+ // initialRouteName: 'MainStack.MainDrawer',
120
+ // screenOptions: {
121
+ // headerShown: false,
122
+ // },
123
+ // },
124
+ // },
125
+ // ['//maindrawer']: {
126
+ // container: createDrawerNavigator(),
127
+ // exact: false,
128
+ // name: 'MainDrawer',
129
+ // props: {
130
+ // initialRouteName: 'MainStack.MainDrawer.MainBottomTab',
131
+ // screenOptions: {
132
+ // headerShown: false,
133
+ // tabBarLabel: 'About',
134
+ // // tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
135
+ // },
136
+ // },
137
+ // },
138
+ // ['//maindrawer/bottom_tab']: {
139
+ // container: createBottomTabNavigator(),
140
+ // exact: false,
141
+ // name: 'MainBottomTab',
142
+ // props: {
143
+ // initialRouteName: 'MainStack.MainDrawer.MainBottomTab.Home',
144
+ // screenOptions: {
145
+ // headerShown: false,
146
+ // tabBarLabel: 'About',
147
+ // // tabBarIcon: ({ color }) => <Ionicons name="person" size={24} color={color} />,
148
+ // },
149
+ // },
150
+ // },
151
+ // ['//maindrawer/bottom_tab/home']: {
152
+ // name: 'Home',
153
+ // props: {
154
+ // priority: 1,
155
+ // initialParams: { orgName: 'test' },
156
+ // component: MyComponent,
157
+ // options: {
158
+ // headerShown: true,
159
+ // tabBarLabel: 'Home',
160
+ // headerTitle: 'Home',
161
+ // // tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
162
+ // },
163
+ // },
164
+ // },
165
+ // ['//maindrawer/bottom_tab/home/:about']: {
166
+ // exact: false,
167
+ // container: createStackNavigator(),
168
+ // name: 'About',
169
+ // props: {
170
+ // initialRouteName: 'Hello',
171
+ // },
172
+ // },
173
+ // ['//maindrawer/bottom_tab/home/:about/info']: {
174
+ // name: 'Info',
175
+ // props: {
176
+ // priority: 2,
177
+ // initialParams: {},
178
+ // component: MyComponent,
179
+ // options: {
180
+ // headerTitle: 'Info',
181
+ // },
182
+ // },
183
+ // },
184
+ // ['//maindrawer/bottom_tab/account']: {
185
+ // name: 'Account',
186
+ // props: {
187
+ // priority: 3,
188
+ // initialParams: {},
189
+ // component: MyComponent,
190
+ // options: {
191
+ // headerShown: true,
192
+ // tabBarLabel: 'Account',
193
+ // headerTitle: 'Account',
194
+ // // tabBarIcon: ({ color }) => <Ionicons name="home" size={24} color={color} />,
195
+ // },
196
+ // },
197
+ // },
198
+ // };
199
+
200
+ // it('get prolayout getSortedNavigations', () => {
201
+ // const feature = new Feature({ routeConfig: routerConfig });
202
+ // const Render = feature.getRoutes2('/', 'MainStack');
203
+ // const Nav = getSortedNavigations('/', routerConfig);
204
+ // console.log('Nav1', JSON.stringify(Nav));
205
+ // expect(Render).toMatchSnapshot();
206
+ // });
207
+ // });
@@ -0,0 +1,7 @@
1
+ import { Fill } from '@common-stack/components-pro';
2
+ import { APPLICATION_ERROR_SLOT_FILL } from '@admin-layout/client';
3
+ import * as React from 'react';
4
+
5
+ export const ApplicationErrorFillWrapper = (props) => {
6
+ return <Fill {...props} name={APPLICATION_ERROR_SLOT_FILL} />
7
+ }
@@ -0,0 +1,30 @@
1
+ import { ApplicationErrorHandlerCommon, APPLICATION_ERROR_SLOT_FILL } from '@admin-layout/client'
2
+ import { Slot } from '@common-stack/components-pro'
3
+ import Toast from 'react-native-toast-message';
4
+ import * as React from 'react';
5
+
6
+ const FallbackComponent = () => {
7
+ React.useLayoutEffect(() => {
8
+ Toast.show({
9
+ type: 'error',
10
+ text1: 'Something went wrong...'
11
+ });
12
+ }, [])
13
+
14
+ return null;
15
+ }
16
+
17
+ const RendererComponent = (props) => {
18
+ const { applicationErrors, backendError } = props;
19
+ return (
20
+ <>
21
+ {!!backendError && <FallbackComponent />}
22
+ {!!applicationErrors?.length && <Slot name={APPLICATION_ERROR_SLOT_FILL} fillProps={{ active: true, applicationErrors: applicationErrors }} />}
23
+ </>
24
+ )
25
+ }
26
+
27
+ export const ApplicationErrorHandler = (props) => {
28
+ const CommonHandler = ApplicationErrorHandlerCommon(FallbackComponent, Slot, RendererComponent);
29
+ return <CommonHandler {...props} />
30
+ }
@@ -0,0 +1,31 @@
1
+ import React, { ReactElement } from 'react';
2
+ import { FallbackComponent } from './Fallback';
3
+ import { logger } from '@cdm-logger/client';
4
+ import { useDispatch } from 'react-redux'
5
+
6
+ type IErrorBoundryState = { hasError: boolean, error: Error | null };
7
+ type IErrorBoundryProps = {
8
+ children: ReactElement,
9
+ };
10
+
11
+ export class ErrorBoundary extends React.Component<IErrorBoundryProps, IErrorBoundryState> {
12
+ constructor(props: IErrorBoundryProps) {
13
+ super(props);
14
+ this.state = { hasError: false, error: null };
15
+ }
16
+
17
+ static getDerivedStateFromError(error: Error) {
18
+ return { hasError: true, error };
19
+ }
20
+
21
+ componentDidCatch(error: Error) {
22
+ logger.debug(error)
23
+ }
24
+
25
+ render() {
26
+ if (this.state.hasError) {
27
+ return <FallbackComponent error={this.state.error as Error} />;
28
+ }
29
+ return this.props.children;
30
+ }
31
+ }
@@ -0,0 +1,65 @@
1
+ import { navigationRef } from '@common-stack/client-react';
2
+ import { Button,ButtonText } from '@gluestack-ui/themed'
3
+ import * as React from 'react'
4
+ import { StyleSheet } from 'react-native'
5
+
6
+ import {
7
+ SafeAreaView,
8
+ Text,
9
+ View,
10
+ } from 'react-native'
11
+ import { useDispatch } from 'react-redux'
12
+
13
+ type Props = { error: Error }
14
+
15
+ export const FallbackComponent = (props: Props) => {
16
+ const dispatch = useDispatch()
17
+ return (
18
+ <SafeAreaView style={styles.container}>
19
+ <View style={styles.content}>
20
+ <Text style={styles.title}>Oops!</Text>
21
+ <Text style={styles.subtitle}>{'There\'s an error'}</Text>
22
+ <Text style={styles.error}>{props?.error?.message}</Text>
23
+ <Button style={styles.button} onPress={() => navigationRef.navigate("MainStack.Layout.Home")}>
24
+ <ButtonText style={styles.buttonText}>Go to homepage</ButtonText>
25
+ </Button>
26
+ </View>
27
+ </SafeAreaView>
28
+ )
29
+ }
30
+
31
+ const styles: any = StyleSheet.create({
32
+ container: {
33
+ backgroundColor: '#fafafa',
34
+ flex: 1,
35
+ justifyContent: 'center'
36
+ },
37
+ content: {
38
+ marginHorizontal: 16
39
+ },
40
+ title: {
41
+ fontSize: 48,
42
+ fontWeight: '300',
43
+ paddingBottom: 16,
44
+ color: '#000'
45
+ },
46
+ subtitle: {
47
+ fontSize: 32,
48
+ fontWeight: '800',
49
+ color: '#000'
50
+ },
51
+ error: {
52
+ paddingVertical: 16
53
+ },
54
+ button: {
55
+ backgroundColor: '#2196f3',
56
+ borderRadius: 50,
57
+ padding: 25,
58
+ height: 40
59
+ },
60
+ buttonText: {
61
+ color: '#fff',
62
+ fontWeight: '600',
63
+ textAlign: 'center'
64
+ }
65
+ })
@@ -0,0 +1,11 @@
1
+
2
+
3
+
4
+ To Convert `less` to `css`, use the following
5
+
6
+ https://jsonformatter.org/less-to-css
7
+
8
+ Add prefix
9
+ ---
10
+
11
+ @ant-prefix: ant;
@@ -0,0 +1,70 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { Route } from 'react-router-native';
3
+ import { Box, StatusBar, Divider, SafeAreaView } from '@gluestack-ui/themed';
4
+ import { Header } from './Header';
5
+ import { Drawer } from './Drawer';
6
+ import { RouterTypes } from '../typings';
7
+ import defaultSettings from './defaultSettings';
8
+ import { SettingDrawer } from './SettingDrawer';
9
+ import { BottomTabBar } from './BottomTabBar';
10
+ import { ProSettings } from './defaultSettings';
11
+
12
+ type MergerSettingsType<T> = Partial<T> & {
13
+ primaryColor?: string;
14
+ colorWeak?: boolean;
15
+ };
16
+
17
+ const BasicLayout: React.FC<any & { routeParams: any }> = (props) => {
18
+ const { route, rightContentRender, onSettingChange, settings, routeParams, showSettings, currentRoute } = props;
19
+ const drawerRef = useRef();
20
+ const [settingToggle, setSettingToggle] = useState(false);
21
+
22
+ return (
23
+ <Box flex={1}>
24
+ <Header
25
+ layout={settings.layout}
26
+ setSettingToggle={setSettingToggle}
27
+ title={currentRoute.name}
28
+ drawerRef={drawerRef}
29
+ rightContentRender={rightContentRender}
30
+ settingToggle={settingToggle}
31
+ navTheme={settings.navTheme}
32
+ showSettings={showSettings}
33
+ route={currentRoute.key}
34
+ nextButton={currentRoute.nextButton}
35
+ />
36
+ <Divider />
37
+ {!!settings && settings.layout !== 'bottom' ? (
38
+ <Drawer
39
+ navTheme={settings.navTheme}
40
+ match={props.match}
41
+ routeParams={routeParams}
42
+ routes={route.routes}
43
+ drawerRef={drawerRef}
44
+ />
45
+ ) : null}
46
+ {settings && settings.layout === 'bottom'
47
+ ? route.routes.map((route: any) => (
48
+ <Route key={route.path} path={route.path} Component={route.component} />
49
+ ))
50
+ : null}
51
+ {!!settingToggle ? (
52
+ <SettingDrawer
53
+ onSettingChange={(settings) => {
54
+ onSettingChange(settings);
55
+ setSettingToggle(false);
56
+ }}
57
+ />
58
+ ) : null}
59
+ {settings && (settings.layout === 'mixSide' || settings.layout === 'bottom') && (
60
+ <BottomTabBar navTheme={settings.navTheme} routes={route.routes} />
61
+ )}
62
+ </Box>
63
+ );
64
+ };
65
+
66
+ BasicLayout.defaultProps = {
67
+ ...defaultSettings,
68
+ };
69
+
70
+ export default BasicLayout;
@@ -0,0 +1,135 @@
1
+ import React from 'react';
2
+ import {Box,Pressable,Center,Text, SafeAreaView} from '@gluestack-ui/themed';
3
+ import { useSelector } from 'react-redux';
4
+ import { useRoute } from '@react-navigation/native';
5
+ import { navigationRef } from '@common-stack/client-react';
6
+
7
+ export const BottomTabBar = ({ state, descriptors, navigation }: any) => {
8
+ const settings = useSelector<any>((state) => state.settings) as any;
9
+ //const currentRoute: any = useRoute();
10
+ const currentRoute: any = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
11
+ const platformState = useSelector((state) => (state as any).platform);
12
+ let appRoutes: any = Object.keys(descriptors)
13
+ .map((k: any) => {
14
+ let route = { ...descriptors[k] };
15
+ route.index = state.routes.findIndex((x: any) => x.key === k);
16
+ return route;
17
+ })
18
+ .filter((r: any) => (settings?.layout == 'bottom' ? r : r?.route?.params?.menu_position == 'bottom'))
19
+ .sort(
20
+ (a: any, b: any) =>
21
+ (a.options.priority ? a.options.priority : a.options.title) -
22
+ (b.options.priority ? b.options.priority : b.options.title),
23
+ );
24
+
25
+ const onPress = React.useCallback((route, navigation, isFocused) => {
26
+ if (route?.route) {
27
+ const event = navigation.emit({
28
+ type: 'tabPress',
29
+ target: route.route.key,
30
+ canPreventDefault: true,
31
+ });
32
+
33
+ if (!isFocused && !event.defaultPrevented) {
34
+ // The `merge: true` option makes sure that the params inside the tab screen are preserved
35
+ navigation.navigate({
36
+ name: route.route.name,
37
+ merge: true,
38
+ orgName: currentRoute?.params?.orgName || platformState?.orgName,
39
+ });
40
+ }
41
+ }
42
+ }, []);
43
+
44
+ const onLongPress = React.useCallback((route, navigation, isFocused) => {
45
+ if (route?.route) {
46
+ navigation.emit({
47
+ type: 'tabLongPress',
48
+ target: route.route.key,
49
+ });
50
+ }
51
+ }, []);
52
+
53
+
54
+ return (
55
+ <SafeAreaView>
56
+ <Box
57
+ flexDirection="row"
58
+ width="100%"
59
+ alignSelf="center"
60
+ bg={'white'}
61
+ borderTopWidth={"$1"}
62
+ borderTopColor={'#d3d3d3'}
63
+ >
64
+ {appRoutes.map((route: any, index: any) => {
65
+ const options = route.options;
66
+ const label =
67
+ options.tabBarLabel !== undefined
68
+ ? options.tabBarLabel
69
+ : options.title !== undefined
70
+ ? options.title
71
+ : route.route.name;
72
+
73
+ const isFocused = state.index === route.index;
74
+
75
+ // const onPress = () => {
76
+ // const event = navigation.emit({
77
+ // type: 'tabPress',
78
+ // target: route.route.key,
79
+ // canPreventDefault: true,
80
+ // });
81
+
82
+ // if (!isFocused && !event.defaultPrevented) {
83
+ // // The `merge: true` option makes sure that the params inside the tab screen are preserved
84
+ // navigation.navigate({
85
+ // name: route.route.name,
86
+ // merge: true,
87
+ // orgName: currentRoute?.params?.orgName || platformState?.orgName,
88
+ // });
89
+ // }
90
+ // };
91
+
92
+ // const onLongPress = () => {
93
+ // navigation.emit({
94
+ // type: 'tabLongPress',
95
+ // target: route.route.key,
96
+ // });
97
+ // };
98
+
99
+ return (
100
+ <Pressable
101
+ key={index}
102
+ opacity={isFocused ? "$100" : "$50"}
103
+ // pb="$8"
104
+ pt={"$3"}
105
+ flex={1}
106
+ onPress={()=>onPress(route,navigation,isFocused)}
107
+ onLongPress={()=>onLongPress(route,navigation,isFocused)}
108
+ testID={options.tabBarTestID}
109
+ accessibilityState={isFocused ? { selected: true } : {}}
110
+ accessibilityLabel={options.tabBarAccessibilityLabel}
111
+ >
112
+ <Center>
113
+ {options?.tabBarIcon
114
+ ? options.tabBarIcon({
115
+ color: isFocused
116
+ ? options.tabBarActiveTintColor
117
+ : options.tabBarInactiveTintColor,
118
+ size: 24,
119
+ })
120
+ : null}
121
+
122
+ <Text
123
+ color={isFocused ? options.tabBarActiveTintColor : options.tabBarInactiveTintColor}
124
+ style={{fontSize:12}}
125
+ >
126
+ {label}
127
+ </Text>
128
+ </Center>
129
+ </Pressable>
130
+ );
131
+ })}
132
+ </Box>
133
+ </SafeAreaView>
134
+ );
135
+ };