@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.
- package/CHANGELOG.md +117 -0
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/assets/logo.png +0 -0
- package/babel.config.js +26 -0
- package/jest-react-navigation-setup.js +14 -0
- package/jest.config.js +39 -0
- package/jest.env.js +2 -0
- package/lib/__tests__/prolayout-layout-feature.test.d.ts +1 -0
- package/lib/__tests__/prolayout-layout-feature.test.js +202 -0
- package/lib/__tests__/prolayout-layout-feature.test.js.map +1 -0
- package/lib/components/ApplicationErrorFillWrapper.d.ts +2 -0
- package/lib/components/ApplicationErrorFillWrapper.js +7 -0
- package/lib/components/ApplicationErrorFillWrapper.js.map +1 -0
- package/lib/components/ApplicationErrorHandler.d.ts +2 -0
- package/lib/components/ApplicationErrorHandler.js +24 -0
- package/lib/components/ApplicationErrorHandler.js.map +1 -0
- package/lib/components/ErrorBounday.d.ts +18 -0
- package/lib/components/ErrorBounday.js +22 -0
- package/lib/components/ErrorBounday.js.map +1 -0
- package/lib/components/Fallback.d.ts +6 -0
- package/lib/components/Fallback.js +53 -0
- package/lib/components/Fallback.js.map +1 -0
- package/lib/components/Layout/components/BasicLayout.d.ts +5 -0
- package/lib/components/Layout/components/BasicLayout.js +28 -0
- package/lib/components/Layout/components/BasicLayout.js.map +1 -0
- package/lib/components/Layout/components/BottomTabBar.d.ts +2 -0
- package/lib/components/Layout/components/BottomTabBar.js +90 -0
- package/lib/components/Layout/components/BottomTabBar.js.map +1 -0
- package/lib/components/Layout/components/Drawer.d.ts +2 -0
- package/lib/components/Layout/components/Drawer.js +253 -0
- package/lib/components/Layout/components/Drawer.js.map +1 -0
- package/lib/components/Layout/components/Header.d.ts +2 -0
- package/lib/components/Layout/components/Header.js +130 -0
- package/lib/components/Layout/components/Header.js.map +1 -0
- package/lib/components/Layout/components/Sample.d.ts +2 -0
- package/lib/components/Layout/components/Sample.js +7 -0
- package/lib/components/Layout/components/Sample.js.map +1 -0
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.d.ts +3 -0
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js +66 -0
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js.map +1 -0
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.d.ts +2 -0
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js +23 -0
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js.map +1 -0
- package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.d.ts +3 -0
- package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js +24 -0
- package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js.map +1 -0
- package/lib/components/Layout/components/SettingDrawer/index.d.ts +1 -0
- package/lib/components/Layout/components/SettingDrawer/index.js +2 -0
- package/lib/components/Layout/components/SettingDrawer/index.js.map +1 -0
- package/lib/components/Layout/components/SideBar.d.ts +10 -0
- package/lib/components/Layout/components/SideBar.js +59 -0
- package/lib/components/Layout/components/SideBar.js.map +1 -0
- package/lib/components/Layout/components/defaultSettings.d.ts +4 -0
- package/lib/components/Layout/components/defaultSettings.js +16 -0
- package/lib/components/Layout/components/defaultSettings.js.map +1 -0
- package/lib/components/Layout/components/index.d.ts +4 -0
- package/lib/components/Layout/components/index.js +5 -0
- package/lib/components/Layout/components/index.js.map +1 -0
- package/lib/components/Layout/components/util.d.ts +1 -0
- package/lib/components/Layout/components/util.js +15 -0
- package/lib/components/Layout/components/util.js.map +1 -0
- package/lib/components/Layout/compute.d.ts +6 -0
- package/lib/components/Layout/compute.js +316 -0
- package/lib/components/Layout/compute.js.map +1 -0
- package/lib/components/Layout/compute.test.d.ts +6 -0
- package/lib/components/Layout/compute.test.js +120 -0
- package/lib/components/Layout/compute.test.js.map +1 -0
- package/lib/components/Layout/index.d.ts +4 -0
- package/lib/components/Layout/index.js +4 -0
- package/lib/components/Layout/index.js.map +1 -0
- package/lib/components/Layout/typings.d.ts +1 -0
- package/lib/components/Layout/typings.js +2 -0
- package/lib/components/Layout/typings.js.map +1 -0
- package/lib/components/NavigationComponent.d.ts +15 -0
- package/lib/components/NavigationComponent.js +120 -0
- package/lib/components/NavigationComponent.js.map +1 -0
- package/lib/components/PluginArea.d.ts +2 -0
- package/lib/components/PluginArea.js +8 -0
- package/lib/components/PluginArea.js.map +1 -0
- package/lib/components/ToastAlert.d.ts +12 -0
- package/lib/components/ToastAlert.js +17 -0
- package/lib/components/ToastAlert.js.map +1 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +10 -0
- package/lib/components/index.js.map +1 -0
- package/lib/components/with-interactions-managed.d.ts +2 -0
- package/lib/components/with-interactions-managed.js +18 -0
- package/lib/components/with-interactions-managed.js.map +1 -0
- package/lib/config/config.d.ts +17 -0
- package/lib/config/config.js +18 -0
- package/lib/config/config.js.map +1 -0
- package/lib/config/index.d.ts +1 -0
- package/lib/config/index.js +2 -0
- package/lib/config/index.js.map +1 -0
- package/lib/constants/routes.d.ts +3 -0
- package/lib/constants/routes.js +5 -0
- package/lib/constants/routes.js.map +1 -0
- package/lib/containers/layout/BasicLayout.d.ts +7 -0
- package/lib/containers/layout/BasicLayout.js +36 -0
- package/lib/containers/layout/BasicLayout.js.map +1 -0
- package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +128 -0
- package/lib/containers/layout/DrawerBottomNavigationConfig.js +72 -0
- package/lib/containers/layout/DrawerBottomNavigationConfig.js.map +1 -0
- package/lib/containers/layout/DrawerConfig.d.ts +85 -0
- package/lib/containers/layout/DrawerConfig.js +48 -0
- package/lib/containers/layout/DrawerConfig.js.map +1 -0
- package/lib/containers/layout/Lifecycle.d.ts +13 -0
- package/lib/containers/layout/Lifecycle.js +18 -0
- package/lib/containers/layout/Lifecycle.js.map +1 -0
- package/lib/containers/layout/ProLayout.d.ts +5 -0
- package/lib/containers/layout/ProLayout.js +35 -0
- package/lib/containers/layout/ProLayout.js.map +1 -0
- package/lib/containers/layout/module.d.ts +5 -0
- package/lib/containers/layout/module.js +22 -0
- package/lib/containers/layout/module.js.map +1 -0
- package/lib/hooks/use-after-interactions.d.ts +6 -0
- package/lib/hooks/use-after-interactions.js +29 -0
- package/lib/hooks/use-after-interactions.js.map +1 -0
- package/lib/hooks/useIsReady.d.ts +2 -0
- package/lib/hooks/useIsReady.js +24 -0
- package/lib/hooks/useIsReady.js.map +1 -0
- package/lib/hooks/useLayoutSetting/index.d.ts +11 -0
- package/lib/hooks/useLayoutSetting/index.js +68 -0
- package/lib/hooks/useLayoutSetting/index.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +1 -0
- package/lib/interfaces/index.js +2 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/settings.d.ts +4 -0
- package/lib/interfaces/settings.js +2 -0
- package/lib/interfaces/settings.js.map +1 -0
- package/lib/redux/settings.d.ts +80 -0
- package/lib/redux/settings.js +16 -0
- package/lib/redux/settings.js.map +1 -0
- package/lib/utils/ThemeColor.d.ts +8 -0
- package/lib/utils/ThemeColor.js +9 -0
- package/lib/utils/ThemeColor.js.map +1 -0
- package/lib/utils/routeConfigKeyReplace.d.ts +7 -0
- package/lib/utils/routeConfigKeyReplace.js +77 -0
- package/lib/utils/routeConfigKeyReplace.js.map +1 -0
- package/lib/utils/routeConfigKeyReplace.test.d.ts +1 -0
- package/lib/utils/routeConfigKeyReplace.test.js +102 -0
- package/lib/utils/routeConfigKeyReplace.test.js.map +1 -0
- package/package.json +40 -0
- package/src/__tests__/prolayout-layout-feature.test.tsx +207 -0
- package/src/components/ApplicationErrorFillWrapper.tsx +7 -0
- package/src/components/ApplicationErrorHandler.tsx +30 -0
- package/src/components/ErrorBounday.tsx +31 -0
- package/src/components/Fallback.tsx +65 -0
- package/src/components/Layout/README.md +11 -0
- package/src/components/Layout/components/BasicLayout.tsx +70 -0
- package/src/components/Layout/components/BottomTabBar.tsx +135 -0
- package/src/components/Layout/components/Drawer.tsx +412 -0
- package/src/components/Layout/components/Header.tsx +195 -0
- package/src/components/Layout/components/Sample.tsx +10 -0
- package/src/components/Layout/components/SettingDrawer/LayoutButton.tsx +102 -0
- package/src/components/Layout/components/SettingDrawer/SettingDrawer.tsx +60 -0
- package/src/components/Layout/components/SettingDrawer/ThemeColorButton.tsx +26 -0
- package/src/components/Layout/components/SettingDrawer/index.ts +1 -0
- package/src/components/Layout/components/SideBar.tsx +109 -0
- package/src/components/Layout/components/defaultSettings.ts +19 -0
- package/src/components/Layout/components/index.ts +4 -0
- package/src/components/Layout/components/util.ts +14 -0
- package/src/components/Layout/compute.test.tsx +129 -0
- package/src/components/Layout/compute.tsx +384 -0
- package/src/components/Layout/eslint.json +1 -0
- package/src/components/Layout/index.ts +5 -0
- package/src/components/Layout/typings.ts +1 -0
- package/src/components/NavigationComponent.tsx +154 -0
- package/src/components/PluginArea.tsx +11 -0
- package/src/components/ToastAlert.tsx +44 -0
- package/src/components/index.ts +9 -0
- package/src/components/with-interactions-managed.tsx +33 -0
- package/src/config/config.ts +17 -0
- package/src/config/index.ts +1 -0
- package/src/constants/routes.ts +3 -0
- package/src/containers/layout/BasicLayout.tsx +61 -0
- package/src/containers/layout/DrawerBottomNavigationConfig.tsx +85 -0
- package/src/containers/layout/DrawerConfig.tsx +59 -0
- package/src/containers/layout/Lifecycle.tsx +23 -0
- package/src/containers/layout/ProLayout.tsx +42 -0
- package/src/containers/layout/module.ts +24 -0
- package/src/hooks/use-after-interactions.ts +35 -0
- package/src/hooks/useIsReady.ts +31 -0
- package/src/hooks/useLayoutSetting/index.ts +99 -0
- package/src/index.ts +41 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/settings.ts +5 -0
- package/src/redux/settings.ts +28 -0
- package/src/utils/ThemeColor.ts +9 -0
- package/src/utils/__snapshots__/routeConfigKeyReplace.test.ts.snap +117 -0
- package/src/utils/routeConfigKeyReplace.test.ts +114 -0
- package/src/utils/routeConfigKeyReplace.ts +74 -0
- package/tsconfig.json +37 -0
- package/types.d.ts +11 -0
- package/webpack.config.js +104 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Feature } from '@common-stack/client-react';
|
|
3
|
+
import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
4
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
5
|
+
import { Drawer, BottomTabBar, Header } from './components';
|
|
6
|
+
import { AntDesign } from '@expo/vector-icons';
|
|
7
|
+
import { navigationRef } from '@common-stack/client-react';
|
|
8
|
+
|
|
9
|
+
const layoutSettingConfig =
|
|
10
|
+
process.APP_ENV && process.APP_ENV.LAYOUT_SETTINGS ? JSON.parse(process.APP_ENV.LAYOUT_SETTINGS) : null;
|
|
11
|
+
|
|
12
|
+
const headerSettings: any = layoutSettingConfig
|
|
13
|
+
? {
|
|
14
|
+
showToggle: layoutSettingConfig.hasOwnProperty('topLeftToggle')
|
|
15
|
+
? layoutSettingConfig.topLeftToggle
|
|
16
|
+
? true
|
|
17
|
+
: false
|
|
18
|
+
: true,
|
|
19
|
+
rightSettingToggle: layoutSettingConfig.hasOwnProperty('topRightSettingToggle')
|
|
20
|
+
? layoutSettingConfig.topRightSettingToggle
|
|
21
|
+
? true
|
|
22
|
+
: false
|
|
23
|
+
: true,
|
|
24
|
+
}
|
|
25
|
+
: { showToggle: true, rightSettingToggle: true };
|
|
26
|
+
|
|
27
|
+
const drawerConfig = (props: any) => {
|
|
28
|
+
let drawerProps = props?.drawerConfig??null;
|
|
29
|
+
return {
|
|
30
|
+
['//main_drawer']: {
|
|
31
|
+
exact: false,
|
|
32
|
+
container: createDrawerNavigator(),
|
|
33
|
+
name: 'Layout',
|
|
34
|
+
props: {
|
|
35
|
+
initialRouteName: 'MainStack.Layout.Home',
|
|
36
|
+
drawerContent: (props: any) => {
|
|
37
|
+
let currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
38
|
+
let currentOptions = currentRoute?.params?.options
|
|
39
|
+
? JSON.parse(currentRoute?.params?.options)
|
|
40
|
+
: null;
|
|
41
|
+
let drawerOptions = { ...currentOptions?.drawerOption, ...drawerProps?.drawerOption };
|
|
42
|
+
return React.createElement(
|
|
43
|
+
drawerProps?.drawerContent ?? Drawer,
|
|
44
|
+
Object.assign({}, props, {
|
|
45
|
+
title: 'ClockBook',
|
|
46
|
+
titleColor: 'black',
|
|
47
|
+
logout: true,
|
|
48
|
+
redirect: 'MainStack.Login',
|
|
49
|
+
...drawerOptions,
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
screenOptions: (options: any) => {
|
|
54
|
+
let currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
55
|
+
let currentOptions = currentRoute?.params?.options
|
|
56
|
+
? JSON.parse(currentRoute?.params?.options)
|
|
57
|
+
: null;
|
|
58
|
+
return {
|
|
59
|
+
headerShown: true,
|
|
60
|
+
header: (props: any) => (
|
|
61
|
+
<Header
|
|
62
|
+
showToggle={
|
|
63
|
+
headerSettings && headerSettings.showToggle ? headerSettings.showToggle : false
|
|
64
|
+
}
|
|
65
|
+
right={
|
|
66
|
+
headerSettings && headerSettings.rightSettingToggle
|
|
67
|
+
? headerSettings.rightSettingToggle
|
|
68
|
+
: false
|
|
69
|
+
}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
),
|
|
73
|
+
drawerIcon: 'grid',
|
|
74
|
+
drawerStyle: currentOptions?.drawerStyle ?? drawerProps?.drawerStyle ?? {},
|
|
75
|
+
gestureEnabled: currentOptions?.gestureEnabled ?? true,
|
|
76
|
+
swipeEnabled: currentOptions?.swipeEnabled ?? true,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const bottomTabConfig = (props: any) => {
|
|
85
|
+
let tabBarProps = props?.tabBarConfig??null;
|
|
86
|
+
return {
|
|
87
|
+
['//bottom_tab']: {
|
|
88
|
+
exact: false,
|
|
89
|
+
container: createBottomTabNavigator(),
|
|
90
|
+
name: 'Layout',
|
|
91
|
+
props: {
|
|
92
|
+
initialRouteName: 'MainStack.Layout.Home',
|
|
93
|
+
//tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
94
|
+
tabBar: (props: any) => {
|
|
95
|
+
return React.createElement(
|
|
96
|
+
tabBarProps?.bottomTabBar ?? BottomTabBar,
|
|
97
|
+
Object.assign({}, props),
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
screenOptions: ({ route }: any) => {
|
|
101
|
+
return {
|
|
102
|
+
headerShown: false,
|
|
103
|
+
title: 'Home',
|
|
104
|
+
headerTitle: 'Home',
|
|
105
|
+
tabBarActiveTintColor: '#4c87f9',
|
|
106
|
+
tabBarInactiveTintColor: 'black',
|
|
107
|
+
tabBarIcon: ({ color }: { color: any }) => <AntDesign name={'search1'} color={color} size={24} />,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}};
|
|
113
|
+
|
|
114
|
+
const hostBottomTabConfig = (props: any) => {
|
|
115
|
+
let tabBarProps = props?.tabBarConfig??null;
|
|
116
|
+
return {
|
|
117
|
+
['//host_tab']: {
|
|
118
|
+
container: createBottomTabNavigator(),
|
|
119
|
+
exact: false,
|
|
120
|
+
name: 'Layout',
|
|
121
|
+
props: {
|
|
122
|
+
initialRouteName: 'MainStack.Layout.Home',
|
|
123
|
+
//tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
124
|
+
tabBar: (props: any) => {
|
|
125
|
+
return React.createElement(
|
|
126
|
+
tabBarProps?.bottomTabBar ?? BottomTabBar,
|
|
127
|
+
Object.assign({}, props),
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
screenOptions: (props: any) => {
|
|
131
|
+
return {
|
|
132
|
+
headerShown: false,
|
|
133
|
+
title: 'Home',
|
|
134
|
+
headerTitle: 'Home',
|
|
135
|
+
tabBarActiveTintColor: '#4c87f9',
|
|
136
|
+
tabBarInactiveTintColor: 'black',
|
|
137
|
+
tabBarIcon: ({ color }: { color: any }) => <AntDesign name={'search1'} color={color} size={24} />,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}};
|
|
143
|
+
|
|
144
|
+
const drawerBottomTabConfig = (props: any) => {
|
|
145
|
+
let drawerProps = props?.drawerConfig??null;
|
|
146
|
+
let tabBarProps = props?.tabBarConfig??null;
|
|
147
|
+
return {
|
|
148
|
+
['//main_drawer']: {
|
|
149
|
+
exact: false,
|
|
150
|
+
container: createDrawerNavigator(),
|
|
151
|
+
name: 'Layout',
|
|
152
|
+
props: {
|
|
153
|
+
initialRouteName: 'MainStack.Layout.MainBottomTab',
|
|
154
|
+
drawerContent: (props: any) => {
|
|
155
|
+
let currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
156
|
+
let currentOptions = currentRoute?.params?.options
|
|
157
|
+
? JSON.parse(currentRoute?.params?.options)
|
|
158
|
+
: null;
|
|
159
|
+
let drawerOptions = { ...currentOptions?.drawerOption, ...drawerProps?.drawerOption };
|
|
160
|
+
return React.createElement(
|
|
161
|
+
drawerProps?.drawerContent ?? Drawer,
|
|
162
|
+
Object.assign({}, props, {
|
|
163
|
+
title: 'ClockBook',
|
|
164
|
+
titleColor: 'black',
|
|
165
|
+
logout: true,
|
|
166
|
+
redirect: 'MainStack.Login',
|
|
167
|
+
...drawerOptions,
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
},
|
|
171
|
+
screenOptions: (options: any) => {
|
|
172
|
+
let currentRoute = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
173
|
+
let currentOptions = currentRoute?.params?.options
|
|
174
|
+
? JSON.parse(currentRoute?.params?.options)
|
|
175
|
+
: null;
|
|
176
|
+
return {
|
|
177
|
+
headerShown: false,
|
|
178
|
+
drawerIcon: 'grid',
|
|
179
|
+
drawerStyle: currentOptions?.drawerStyle ?? drawerProps?.drawerStyle ?? {},
|
|
180
|
+
gestureEnabled: currentOptions?.gestureEnabled ?? true,
|
|
181
|
+
swipeEnabled: currentOptions?.swipeEnabled ?? true,
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
['//main_drawer/bottom_tab']: {
|
|
187
|
+
container: createBottomTabNavigator(),
|
|
188
|
+
exact: false,
|
|
189
|
+
name: 'MainBottomTab',
|
|
190
|
+
props: {
|
|
191
|
+
initialRouteName: 'MainStack.MainDrawer.MainBottomTab.Home',
|
|
192
|
+
//tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
193
|
+
tabBar: (props: any) => {
|
|
194
|
+
return React.createElement(
|
|
195
|
+
tabBarProps?.bottomTabBar ?? BottomTabBar,
|
|
196
|
+
Object.assign({}, props),
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
screenOptions: ({ route }: any) => {
|
|
200
|
+
return {
|
|
201
|
+
headerShown: true,
|
|
202
|
+
header: (props: any) => (
|
|
203
|
+
<Header
|
|
204
|
+
showToggle={
|
|
205
|
+
headerSettings && headerSettings.showToggle ? headerSettings.showToggle : false
|
|
206
|
+
}
|
|
207
|
+
right={
|
|
208
|
+
headerSettings && headerSettings.rightSettingToggle
|
|
209
|
+
? headerSettings.rightSettingToggle
|
|
210
|
+
: false
|
|
211
|
+
}
|
|
212
|
+
{...props}
|
|
213
|
+
/>
|
|
214
|
+
),
|
|
215
|
+
title: 'Home',
|
|
216
|
+
headerTitle: 'Home',
|
|
217
|
+
tabBarActiveTintColor: '#ff5a60',
|
|
218
|
+
tabBarInactiveTintColor: 'black',
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const bottomTabDrawerConfig = (props: any) => {
|
|
227
|
+
let drawerProps = props?.drawerConfig??null;
|
|
228
|
+
let tabBarProps = props?.tabBarConfig??null;
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
['//bottom_tab']: {
|
|
232
|
+
container: createBottomTabNavigator(),
|
|
233
|
+
exact: false,
|
|
234
|
+
name: 'Layout',
|
|
235
|
+
props: {
|
|
236
|
+
initialRouteName: 'MainStack.Layout.Home',
|
|
237
|
+
// tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
238
|
+
tabBar: (props: any) => {
|
|
239
|
+
return React.createElement(
|
|
240
|
+
tabBarProps?.bottomTabBar ?? BottomTabBar,
|
|
241
|
+
Object.assign({}, props),
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
screenOptions: ({ route }: any) => {
|
|
245
|
+
return {
|
|
246
|
+
headerShown: true,
|
|
247
|
+
header: (props: any) => (
|
|
248
|
+
<Header
|
|
249
|
+
showToggle={
|
|
250
|
+
headerSettings && headerSettings.showToggle ? headerSettings.showToggle : false
|
|
251
|
+
}
|
|
252
|
+
right={
|
|
253
|
+
headerSettings && headerSettings.rightSettingToggle
|
|
254
|
+
? headerSettings.rightSettingToggle
|
|
255
|
+
: false
|
|
256
|
+
}
|
|
257
|
+
{...props}
|
|
258
|
+
/>
|
|
259
|
+
),
|
|
260
|
+
title: 'Home',
|
|
261
|
+
headerTitle: 'Home',
|
|
262
|
+
tabBarActiveTintColor: '#ff5a60',
|
|
263
|
+
tabBarInactiveTintColor: 'black',
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
// screenOptions: ({ route }: any) => {
|
|
267
|
+
// return {
|
|
268
|
+
// headerShown: false,
|
|
269
|
+
// //header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
270
|
+
// title: 'Home',
|
|
271
|
+
// headerTitle: 'Home',
|
|
272
|
+
// tabBarActiveTintColor: '#ff5a60',
|
|
273
|
+
// tabBarInactiveTintColor: 'black',
|
|
274
|
+
// };
|
|
275
|
+
// },
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
// ['//bottom_tab/main_drawer']: {
|
|
279
|
+
// exact: false,
|
|
280
|
+
// container: createDrawerNavigator(),
|
|
281
|
+
// name: 'MainDrawer',
|
|
282
|
+
// props: {
|
|
283
|
+
// initialRouteName: 'MainStack.MainBottomTab.MainDrawer.Home',
|
|
284
|
+
// drawerContent: (props: any) => (
|
|
285
|
+
// <Drawer
|
|
286
|
+
// {...props}
|
|
287
|
+
// title={'ClockBook'}
|
|
288
|
+
// titleColor={'black'}
|
|
289
|
+
// logout={true}
|
|
290
|
+
// redirect={'MainStack.Login'}
|
|
291
|
+
// />
|
|
292
|
+
// ),
|
|
293
|
+
// screenOptions:(options:any) =>{
|
|
294
|
+
|
|
295
|
+
// return{
|
|
296
|
+
// headerShown: true,
|
|
297
|
+
// header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
298
|
+
// drawerIcon: 'grid',
|
|
299
|
+
// }
|
|
300
|
+
// }
|
|
301
|
+
// },
|
|
302
|
+
// },
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// const bottomTabDrawerConfig = {
|
|
308
|
+
// ['//bottom_tab']: {
|
|
309
|
+
// container: createBottomTabNavigator(),
|
|
310
|
+
// exact: false,
|
|
311
|
+
// name: 'Layout',
|
|
312
|
+
// props: {
|
|
313
|
+
// initialRouteName: 'MainStack.Layout.Home',
|
|
314
|
+
// tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
315
|
+
// screenOptions: ({ route }: any) => {
|
|
316
|
+
// return {
|
|
317
|
+
// headerShown: false,
|
|
318
|
+
// //header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
319
|
+
// title: 'Home',
|
|
320
|
+
// headerTitle: 'Home',
|
|
321
|
+
// tabBarActiveTintColor: '#ff5a60',
|
|
322
|
+
// tabBarInactiveTintColor: 'black',
|
|
323
|
+
// };
|
|
324
|
+
// },
|
|
325
|
+
// },
|
|
326
|
+
// },
|
|
327
|
+
// // ['//bottom_tab/main_drawer']: {
|
|
328
|
+
// // exact: false,
|
|
329
|
+
// // container: createDrawerNavigator(),
|
|
330
|
+
// // name: 'MainDrawer',
|
|
331
|
+
// // props: {
|
|
332
|
+
// // initialRouteName: 'MainStack.MainBottomTab.MainDrawer.Home',
|
|
333
|
+
// // drawerContent: (props: any) => (
|
|
334
|
+
// // <Drawer
|
|
335
|
+
// // {...props}
|
|
336
|
+
// // title={'ClockBook'}
|
|
337
|
+
// // titleColor={'black'}
|
|
338
|
+
// // logout={true}
|
|
339
|
+
// // redirect={'MainStack.Login'}
|
|
340
|
+
// // />
|
|
341
|
+
// // ),
|
|
342
|
+
// // screenOptions:(options:any) =>{
|
|
343
|
+
|
|
344
|
+
// // return{
|
|
345
|
+
// // headerShown: true,
|
|
346
|
+
// // header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
347
|
+
// // drawerIcon: 'grid',
|
|
348
|
+
// // }
|
|
349
|
+
// // }
|
|
350
|
+
// // },
|
|
351
|
+
// // },
|
|
352
|
+
// };
|
|
353
|
+
|
|
354
|
+
// export const appDrawerFeature = new Feature({
|
|
355
|
+
// routeConfig: drawerConfig as any,
|
|
356
|
+
// });
|
|
357
|
+
|
|
358
|
+
// export const appDrawerBottomTabFeature = new Feature({
|
|
359
|
+
// routeConfig: drawerBottomTabConfig as any,
|
|
360
|
+
// });
|
|
361
|
+
|
|
362
|
+
export const appDrawerFeature = (props: any) =>
|
|
363
|
+
new Feature({
|
|
364
|
+
routeConfig: drawerConfig(props) as any,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
export const appDrawerBottomTabFeature = (props: any) =>
|
|
368
|
+
new Feature({
|
|
369
|
+
routeConfig: drawerBottomTabConfig(props) as any,
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
export const appBottomTabFeature = (props: any) =>
|
|
373
|
+
new Feature({
|
|
374
|
+
routeConfig: bottomTabConfig(props) as any,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
export const appHostBottomTabFeature = (props: any) =>
|
|
378
|
+
new Feature({
|
|
379
|
+
routeConfig: hostBottomTabConfig(props) as any,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
export const appBottomTabDrawerFeature = new Feature({
|
|
383
|
+
routeConfig: bottomTabDrawerConfig as any,
|
|
384
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@admin-layout/client/lib/interfaces/typings';
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { LOCATION_CHANGE as LOCATION_CHANGE_SUCCESS } from '@common-stack/remix-router-redux';
|
|
2
|
+
import { NavigationContainer, LinkingOptions } from '@react-navigation/native';
|
|
3
|
+
import { cloneDeep, merge } from 'lodash-es';
|
|
4
|
+
import React, { MutableRefObject, ReactElement, useRef } from 'react';
|
|
5
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
6
|
+
import { navigationRef } from '@common-stack/client-react';
|
|
7
|
+
|
|
8
|
+
interface INavigationContainerComponentProps {
|
|
9
|
+
children: ReactElement[];
|
|
10
|
+
configurableRoutes: Record<string, any>[];
|
|
11
|
+
independent?: boolean;
|
|
12
|
+
linking?: LinkingOptions<any>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface INavigationContainerRef {
|
|
16
|
+
name: string;
|
|
17
|
+
key: string;
|
|
18
|
+
params?: Readonly<object | undefined>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const getPath = (routeName: string, configurableRoutes: Record<string, any>[]) => {
|
|
22
|
+
let resultantPath = '';
|
|
23
|
+
configurableRoutes.forEach((item) => {
|
|
24
|
+
if (item.children?.length) {
|
|
25
|
+
const value = getPath(routeName, item.children);
|
|
26
|
+
if (value) {
|
|
27
|
+
resultantPath = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (item.navigationRouteName === routeName) {
|
|
31
|
+
resultantPath = item.path;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return resultantPath;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const configurableRoutesWithNavigationRouteName = (
|
|
38
|
+
configurableRoutes: Record<string, any>[],
|
|
39
|
+
parentName: string = '',
|
|
40
|
+
) => {
|
|
41
|
+
return configurableRoutes.map((item) => {
|
|
42
|
+
const resultantName = parentName;
|
|
43
|
+
const navigationRouteName = resultantName.length ? `${resultantName}.${item.name}` : item.name;
|
|
44
|
+
item.navigationRouteName = navigationRouteName;
|
|
45
|
+
if (item.children) {
|
|
46
|
+
item.children = configurableRoutesWithNavigationRouteName(item.children, navigationRouteName);
|
|
47
|
+
}
|
|
48
|
+
return item;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const useLocationChange = () => {
|
|
53
|
+
const dispatch = useDispatch();
|
|
54
|
+
const [locationChange, setLocationChange] = React.useState<any>(null);
|
|
55
|
+
const platformState = useSelector((state) => (state as any).platform);
|
|
56
|
+
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (locationChange) setLocation(locationChange);
|
|
59
|
+
}, [locationChange]);
|
|
60
|
+
|
|
61
|
+
const setLocation = ({ configurableRoutes, previousRoute = null, orgName = null }: any) => {
|
|
62
|
+
const currentRoute: any = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
63
|
+
const currentRouteName = currentRoute ? currentRoute!?.name : null;
|
|
64
|
+
const configuredRoutes = configurableRoutesWithNavigationRouteName(configurableRoutes);
|
|
65
|
+
const currentPath = currentRouteName ? getPath(currentRouteName as string, configuredRoutes) : null;
|
|
66
|
+
const previousPath = previousRoute ? getPath(previousRoute?.current!.name, configuredRoutes) : null;
|
|
67
|
+
const currParams = {
|
|
68
|
+
...(currentRoute!.params || {}),
|
|
69
|
+
orgName: orgName ? orgName : currentRoute!.params?.orgName ?? platformState?.orgName,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
navigationRef?.setParams(currParams);
|
|
73
|
+
|
|
74
|
+
dispatch({
|
|
75
|
+
type: LOCATION_CHANGE_SUCCESS,
|
|
76
|
+
payload: {
|
|
77
|
+
currentRoute: {
|
|
78
|
+
path: currentPath,
|
|
79
|
+
params: currParams,
|
|
80
|
+
},
|
|
81
|
+
previousRoute: {
|
|
82
|
+
path: previousPath,
|
|
83
|
+
params: previousRoute?.current?.params ?? { orgName: '' },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return { setLocationChange };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const NavigationContainerComponent = ({
|
|
93
|
+
children,
|
|
94
|
+
configurableRoutes,
|
|
95
|
+
independent,
|
|
96
|
+
linking,
|
|
97
|
+
}: INavigationContainerComponentProps): ReactElement => {
|
|
98
|
+
const routeNameRef = useRef() as MutableRefObject<INavigationContainerRef | undefined>;
|
|
99
|
+
const dispatch = useDispatch();
|
|
100
|
+
const platformState = useSelector((state) => (state as any).platform);
|
|
101
|
+
const { setLocationChange } = useLocationChange();
|
|
102
|
+
//const user = useSelector((state: any) => state.user);
|
|
103
|
+
return (
|
|
104
|
+
<NavigationContainer
|
|
105
|
+
ref={navigationRef}
|
|
106
|
+
linking={linking}
|
|
107
|
+
independent={independent}
|
|
108
|
+
onReady={() => {
|
|
109
|
+
routeNameRef.current = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
110
|
+
const currentRoute: any = routeNameRef?.current;
|
|
111
|
+
setLocationChange({
|
|
112
|
+
configurableRoutes,
|
|
113
|
+
orgName: platformState?.orgName ?? currentRoute?.params?.orgName ?? '',
|
|
114
|
+
});
|
|
115
|
+
}}
|
|
116
|
+
onStateChange={async () => {
|
|
117
|
+
const previousRoute: any = routeNameRef?.current ? cloneDeep(routeNameRef) : null;
|
|
118
|
+
const currentRoute: any = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
119
|
+
const previousRouteName = previousRoute ? previousRoute?.current!.name : null;
|
|
120
|
+
const currentRouteName = currentRoute ? currentRoute!?.name : null;
|
|
121
|
+
|
|
122
|
+
const configuredRoutes = configurableRoutesWithNavigationRouteName(configurableRoutes);
|
|
123
|
+
const currentPath = currentRouteName ? getPath(currentRouteName as string, configuredRoutes) : null;
|
|
124
|
+
const previousPath = previousRoute ? getPath(previousRoute?.current!.name, configuredRoutes) : null;
|
|
125
|
+
const currParams = {
|
|
126
|
+
...(currentRoute!.params || {}),
|
|
127
|
+
orgName: currentRoute!.params?.orgName || platformState?.orgName,
|
|
128
|
+
};
|
|
129
|
+
//if (previousRouteName && currentRouteName && previousRouteName !== currentRouteName) {
|
|
130
|
+
if (previousPath !== currentPath) {
|
|
131
|
+
routeNameRef.current = currentRoute;
|
|
132
|
+
|
|
133
|
+
setLocationChange({ configurableRoutes, previousRoute });
|
|
134
|
+
|
|
135
|
+
// dispatch({
|
|
136
|
+
// type: LOCATION_CHANGE_SUCCESS,
|
|
137
|
+
// payload: {
|
|
138
|
+
// currentRoute: {
|
|
139
|
+
// path: currentPath,
|
|
140
|
+
// params: currParams,
|
|
141
|
+
// },
|
|
142
|
+
// previousRoute: {
|
|
143
|
+
// path: previousPath,
|
|
144
|
+
// params: previousRoute?.current?.params ?? { orgName: '' },
|
|
145
|
+
// },
|
|
146
|
+
// },
|
|
147
|
+
// });
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{children}
|
|
152
|
+
</NavigationContainer>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Toast,
|
|
5
|
+
VStack,
|
|
6
|
+
ToastTitle,
|
|
7
|
+
ToastDescription,
|
|
8
|
+
Pressable,
|
|
9
|
+
Icon,
|
|
10
|
+
CloseIcon,
|
|
11
|
+
} from '@gluestack-ui/themed';
|
|
12
|
+
|
|
13
|
+
interface IToast {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
status?: any;
|
|
17
|
+
description?: string;
|
|
18
|
+
isClosable?: boolean;
|
|
19
|
+
toast?: any;
|
|
20
|
+
variant?:any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// variants:
|
|
24
|
+
// accent,
|
|
25
|
+
// solid,
|
|
26
|
+
// outline
|
|
27
|
+
|
|
28
|
+
export const ToastAlert = ({ id, status = 'info', title='', description = '',variant='solid', isClosable, toast=null }: IToast) => {
|
|
29
|
+
const toastId = 'toast-' + id;
|
|
30
|
+
const actionType = status || 'info';
|
|
31
|
+
return (
|
|
32
|
+
<Toast nativeID={toastId} variant={variant} action={actionType}>
|
|
33
|
+
<VStack space="xs">
|
|
34
|
+
<ToastTitle>{title}</ToastTitle>
|
|
35
|
+
{description && <ToastDescription>{description}</ToastDescription>}
|
|
36
|
+
</VStack>
|
|
37
|
+
{isClosable && toast ? (
|
|
38
|
+
<Pressable mt="$1" onPress={() => toast?.close(id)}>
|
|
39
|
+
<Icon as={CloseIcon} color="$coolGray50" />
|
|
40
|
+
</Pressable>
|
|
41
|
+
) : null}
|
|
42
|
+
</Toast>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './Layout';
|
|
2
|
+
export * from './PluginArea';
|
|
3
|
+
export * from './ApplicationErrorHandler';
|
|
4
|
+
export * from './ApplicationErrorFillWrapper';
|
|
5
|
+
export * from './Fallback';
|
|
6
|
+
export * from './ErrorBounday';
|
|
7
|
+
export * from './NavigationComponent';
|
|
8
|
+
export * from './ToastAlert';
|
|
9
|
+
export * from './with-interactions-managed';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { Transition, Transitioning } from 'react-native-reanimated';
|
|
3
|
+
import { useAfterInteractions } from '../hooks/use-after-interactions';
|
|
4
|
+
import { Box, Spinner, Text } from '@gluestack-ui/themed';
|
|
5
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
6
|
+
|
|
7
|
+
export function withInteractionsManaged<Props>(
|
|
8
|
+
Component: ComponentType<Props>,
|
|
9
|
+
Placeholder: ComponentType | null = null,
|
|
10
|
+
) {
|
|
11
|
+
const Wrapped = (props: Props) => {
|
|
12
|
+
const { transitionRef, interactionsComplete } = useAfterInteractions();
|
|
13
|
+
const LoadingComponent = () => <Box flex={1}>{<Spinner color={'blue.500'} />}</Box>;
|
|
14
|
+
console.log('interactionsComplete', interactionsComplete);
|
|
15
|
+
return (
|
|
16
|
+
<Transitioning.View
|
|
17
|
+
transition={
|
|
18
|
+
<Transition.Together>
|
|
19
|
+
<Transition.Change interpolation="easeInOut" />
|
|
20
|
+
<Transition.In type="fade" />
|
|
21
|
+
</Transition.Together>
|
|
22
|
+
}
|
|
23
|
+
style={{ flex: 1 }}
|
|
24
|
+
ref={transitionRef}
|
|
25
|
+
>
|
|
26
|
+
{interactionsComplete ? <Component {...props} /> : Placeholder ? <Placeholder /> : <LoadingComponent />}
|
|
27
|
+
</Transitioning.View>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
hoistNonReactStatics(Wrapped, Component);
|
|
32
|
+
return Wrapped;
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const config = {
|
|
2
|
+
LAYOUT_SETTINGS: {
|
|
3
|
+
logo: 'https://cdmbase.s3.ca-central-1.amazonaws.com/favicon-new-128.svg',
|
|
4
|
+
navTheme: 'light', // 'dark'
|
|
5
|
+
primaryColor: '#3FA541C', // '#1890ff'
|
|
6
|
+
layout: 'side',
|
|
7
|
+
contentWidth: 'Fluid',
|
|
8
|
+
fixedHeader: false,
|
|
9
|
+
fixSiderbar: true,
|
|
10
|
+
colorWeak: false,
|
|
11
|
+
title: 'CDMBase LLC',
|
|
12
|
+
iconfontUrl: '',
|
|
13
|
+
language: 'en-US',
|
|
14
|
+
topLeftToggle: true,
|
|
15
|
+
topRightSettingToggle: true,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config';
|