@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,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
4
|
+
import { BasicLayout, Settings } from '../../components';
|
|
5
|
+
import { useHistory } from 'react-router-native';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
7
|
+
import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';
|
|
8
|
+
|
|
9
|
+
export interface ReduxState {
|
|
10
|
+
settings: Settings;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Layout: React.FC<any & ReduxState & { routeParams: any }> = (props) => {
|
|
14
|
+
const user = useSelector((state: any) => state?.user);
|
|
15
|
+
const { settings } = props;
|
|
16
|
+
const history = useHistory();
|
|
17
|
+
|
|
18
|
+
const logout = () => {
|
|
19
|
+
history.push('/logout');
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
<BasicLayout
|
|
23
|
+
{...props}
|
|
24
|
+
{...settings}
|
|
25
|
+
showSettings={true}
|
|
26
|
+
currentRoute={props.route.routes.find((route) => {
|
|
27
|
+
if (route.path.split('/').pop() === props.location.pathname.split('/').pop()) {
|
|
28
|
+
return route;
|
|
29
|
+
} else if (
|
|
30
|
+
route.path.split('/')[route.path.split('/').length - 2] ===
|
|
31
|
+
props.location.pathname.split('/')[props.location.pathname.split('/').length - 2]
|
|
32
|
+
) {
|
|
33
|
+
return route;
|
|
34
|
+
}
|
|
35
|
+
})}
|
|
36
|
+
rightContentRender={(rightProps) => {
|
|
37
|
+
return (
|
|
38
|
+
<Ionicons
|
|
39
|
+
color={rightProps.navTheme === 'dark' ? 'white' : 'black'}
|
|
40
|
+
name="exit-outline"
|
|
41
|
+
onPress={() => logout()}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default connect(
|
|
50
|
+
({ settings, router }: any) => ({
|
|
51
|
+
settings,
|
|
52
|
+
location: router.location,
|
|
53
|
+
}),
|
|
54
|
+
(dispatch) => ({
|
|
55
|
+
onSettingChange: (data: any) =>
|
|
56
|
+
dispatch({
|
|
57
|
+
type: CHANGE_SETTINGS_ACTION,
|
|
58
|
+
payload: data,
|
|
59
|
+
}),
|
|
60
|
+
}),
|
|
61
|
+
)(Layout);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Feature } from '@common-stack/client-react';
|
|
3
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
4
|
+
import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
5
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
6
|
+
import { Drawer, Header,BottomTabBar, Sample } from '../../components';
|
|
7
|
+
import { Ionicons,MaterialIcons,FontAwesome,FontAwesome5 ,AntDesign} from '@expo/vector-icons';
|
|
8
|
+
import { ProLayout } from './ProLayout';
|
|
9
|
+
|
|
10
|
+
export const appDrawerBottomNavigationConfig = {
|
|
11
|
+
['/']: {
|
|
12
|
+
exact: false,
|
|
13
|
+
container: createStackNavigator(),
|
|
14
|
+
name: 'MainStack',
|
|
15
|
+
props: {
|
|
16
|
+
initialRouteName: 'MainStack.MainDrawer',
|
|
17
|
+
screenOptions: {
|
|
18
|
+
headerShown: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
['//main_drawer']: {
|
|
23
|
+
exact: false,
|
|
24
|
+
container: createDrawerNavigator(),
|
|
25
|
+
name: 'MainDrawer',
|
|
26
|
+
props: {
|
|
27
|
+
initialRouteName: 'MainStack.MainDrawer.MainBottomTab',
|
|
28
|
+
drawerContent: (props: any) => (
|
|
29
|
+
<Drawer
|
|
30
|
+
{...props}
|
|
31
|
+
title={'ClockBook'}
|
|
32
|
+
titleColor={'black'}
|
|
33
|
+
logout={true}
|
|
34
|
+
redirect={'MainStack.Login'}
|
|
35
|
+
/>
|
|
36
|
+
),
|
|
37
|
+
screenOptions:(options:any) =>{
|
|
38
|
+
|
|
39
|
+
return{
|
|
40
|
+
headerShown:false,
|
|
41
|
+
drawerIcon: 'grid',
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
['//main_drawer/mainbottomtab']: {
|
|
47
|
+
container: createBottomTabNavigator(),
|
|
48
|
+
exact: false,
|
|
49
|
+
name: 'MainBottomTab',
|
|
50
|
+
props: {
|
|
51
|
+
initialRouteName: 'MainStack.MainDrawer.MainBottomTab.Home',
|
|
52
|
+
tabBar: (props: any) => <BottomTabBar {...props} />,
|
|
53
|
+
screenOptions: ({ route }: any) => {
|
|
54
|
+
return {
|
|
55
|
+
headerShown: false,
|
|
56
|
+
title:'Home',
|
|
57
|
+
headerTitle:'Home',
|
|
58
|
+
tabBarActiveTintColor: '#ff5a60',
|
|
59
|
+
tabBarInactiveTintColor: 'black',
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
// ['//o']: {
|
|
65
|
+
// exact: false,
|
|
66
|
+
// name: 'Home',
|
|
67
|
+
// props: {
|
|
68
|
+
// initialParams: { orgName: null,title:'Home',priority:1 },
|
|
69
|
+
// component: ProLayout,
|
|
70
|
+
// priority:1,
|
|
71
|
+
// options: {
|
|
72
|
+
// headerShown: true,
|
|
73
|
+
// header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
74
|
+
// title: 'Home',
|
|
75
|
+
// headerTitle: 'Home',
|
|
76
|
+
// priority: 1,
|
|
77
|
+
// tabBarActiveTintColor: '#ff5a60',
|
|
78
|
+
// tabBarInactiveTintColor: 'black',
|
|
79
|
+
// tabBarIcon: ({ color }: { color: any }) => <MaterialIcons name="home" size={24} color={color} />,
|
|
80
|
+
// tabBarLabel: 'Home',
|
|
81
|
+
// },
|
|
82
|
+
// },
|
|
83
|
+
// },
|
|
84
|
+
};
|
|
85
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Feature } from '@common-stack/client-react';
|
|
3
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
4
|
+
import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
5
|
+
import { Drawer, Header, Sample } from '../../components';
|
|
6
|
+
import { ProLayout } from './ProLayout';
|
|
7
|
+
|
|
8
|
+
export const appDrawerConfig = {
|
|
9
|
+
['/']: {
|
|
10
|
+
exact: false,
|
|
11
|
+
container: createStackNavigator(),
|
|
12
|
+
name: 'MainStack',
|
|
13
|
+
props: {
|
|
14
|
+
initialRouteName: 'MainStack.MainDrawer',
|
|
15
|
+
screenOptions: {
|
|
16
|
+
headerShown: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
['//main_drawer']: {
|
|
21
|
+
exact: false,
|
|
22
|
+
container: createDrawerNavigator(),
|
|
23
|
+
name: 'MainDrawer',
|
|
24
|
+
props: {
|
|
25
|
+
initialRouteName: 'MainStack.MainDrawer.Home',
|
|
26
|
+
drawerContent: (props: any) => (
|
|
27
|
+
<Drawer
|
|
28
|
+
{...props}
|
|
29
|
+
title={'ClockBook'}
|
|
30
|
+
titleColor={'black'}
|
|
31
|
+
logout={true}
|
|
32
|
+
redirect={'MainStack.Login'}
|
|
33
|
+
/>
|
|
34
|
+
),
|
|
35
|
+
screenOptions:(options:any) =>{
|
|
36
|
+
|
|
37
|
+
return{
|
|
38
|
+
headerShown:false,
|
|
39
|
+
drawerIcon: 'grid',
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
// ['//main_drawer/home']: {
|
|
45
|
+
// exact: false,
|
|
46
|
+
// name: 'Home',
|
|
47
|
+
// auth: true,
|
|
48
|
+
// props: {
|
|
49
|
+
// initialParams: { orgName: null },
|
|
50
|
+
// component: ProLayout,
|
|
51
|
+
// options: {
|
|
52
|
+
// headerShown: true,
|
|
53
|
+
// title: 'Home',
|
|
54
|
+
// header: (props: any) => <Header showToggle={true} right={true} {...props} />,
|
|
55
|
+
// drawerIcon: 'grid',
|
|
56
|
+
// },
|
|
57
|
+
// },
|
|
58
|
+
// },
|
|
59
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LifecyclePhase,
|
|
4
|
+
} from '@workbench-stack/core';
|
|
5
|
+
import { LifecycleCommonComponent } from '@adminide-stack/platform-client';
|
|
6
|
+
|
|
7
|
+
export type WithFalse<T> = T | false;
|
|
8
|
+
|
|
9
|
+
export interface LifecycleProps {
|
|
10
|
+
setPhaseReady?: boolean;
|
|
11
|
+
setPhase?: LifecyclePhase;
|
|
12
|
+
renderWhenPhase?: LifecyclePhase;
|
|
13
|
+
loadingRenderer: ({ loading }: {
|
|
14
|
+
loading: boolean;
|
|
15
|
+
}) => ReactElement;
|
|
16
|
+
children?: ReactElement
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Lifecycle = ({ children, ...rest }: LifecycleProps) => {
|
|
20
|
+
return <LifecycleCommonComponent {...rest} >
|
|
21
|
+
{children}
|
|
22
|
+
</LifecycleCommonComponent>
|
|
23
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Box, Spinner } from '@gluestack-ui/themed';
|
|
3
|
+
import { NavigationContainerComponent, ApplicationErrorHandler, ErrorBoundary } from '../../components';
|
|
4
|
+
import { PluginArea } from '@common-stack/client-react';
|
|
5
|
+
import routeConfigKeyReplace from '../../utils/routeConfigKeyReplace';
|
|
6
|
+
import { useLayoutSetting } from '../../hooks/useLayoutSetting';
|
|
7
|
+
let AppFeatures: any;
|
|
8
|
+
let AppLayout: any;
|
|
9
|
+
|
|
10
|
+
const ProLayout: React.FC<any> = (props) => {
|
|
11
|
+
const [appRoutes, setAppRoutes] = React.useState<any>([]);
|
|
12
|
+
const { pathKey, appLayout } = useLayoutSetting(props);
|
|
13
|
+
AppLayout = appLayout;
|
|
14
|
+
const {appFeatures} = routeConfigKeyReplace(pathKey, props?.features,appLayout);
|
|
15
|
+
AppFeatures = appFeatures;
|
|
16
|
+
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (appLayout) {
|
|
19
|
+
let routes = AppFeatures ? AppFeatures?.getRoutes2('/', 'MainStack') || [] : null;
|
|
20
|
+
setAppRoutes(routes);
|
|
21
|
+
}
|
|
22
|
+
}, [appLayout]);
|
|
23
|
+
|
|
24
|
+
//const appRoutes = AppFeatures ? AppFeatures?.getRoutes2('/', 'MainStack') || [] : null;
|
|
25
|
+
|
|
26
|
+
const loadingComponent = () => <Box flex={1}>{<Spinner />}</Box>;
|
|
27
|
+
|
|
28
|
+
let plugins = AppFeatures?.getComponentFillPlugins() ?? props.features;
|
|
29
|
+
let configuredRoutes = AppFeatures?.getConfiguredRoutes2('/') ?? props?.features?.getConfiguredRoutes2('/');
|
|
30
|
+
if (!appRoutes) return loadingComponent();
|
|
31
|
+
return (
|
|
32
|
+
<ErrorBoundary>
|
|
33
|
+
<NavigationContainerComponent configurableRoutes={configuredRoutes} independent={true}>
|
|
34
|
+
{appRoutes}
|
|
35
|
+
<PluginArea />
|
|
36
|
+
<ApplicationErrorHandler plugins={plugins} />
|
|
37
|
+
</NavigationContainerComponent>
|
|
38
|
+
</ErrorBoundary>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { ProLayout, AppFeatures, AppLayout };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import { Feature } from '@common-stack/client-react';
|
|
3
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
4
|
+
import { ProLayout, AppFeatures, AppLayout } from './ProLayout';
|
|
5
|
+
|
|
6
|
+
export { ProLayout, AppFeatures, AppLayout };
|
|
7
|
+
|
|
8
|
+
const layoutConfig = {
|
|
9
|
+
['/']: {
|
|
10
|
+
exact: false,
|
|
11
|
+
container: createStackNavigator(),
|
|
12
|
+
name: 'MainStack',
|
|
13
|
+
props: {
|
|
14
|
+
initialRouteName: 'MainStack.MainBottomTab',
|
|
15
|
+
screenOptions: {
|
|
16
|
+
headerShown: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default new Feature({
|
|
23
|
+
routeConfig: layoutConfig,
|
|
24
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { InteractionManager } from 'react-native';
|
|
3
|
+
import { TransitioningView } from 'react-native-reanimated';
|
|
4
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
5
|
+
|
|
6
|
+
export const useAfterInteractions = () => {
|
|
7
|
+
const [interactionsComplete, setInteractionsComplete] = useState(false);
|
|
8
|
+
|
|
9
|
+
const subscriptionRef = useRef(null);
|
|
10
|
+
|
|
11
|
+
const transitionRef = useRef<TransitioningView>(null);
|
|
12
|
+
|
|
13
|
+
useFocusEffect(
|
|
14
|
+
React.useCallback(() => {
|
|
15
|
+
// Do something when the screen is focused
|
|
16
|
+
subscriptionRef.current = InteractionManager.runAfterInteractions(() => {
|
|
17
|
+
transitionRef.current?.animateNextTransition();
|
|
18
|
+
setInteractionsComplete(true);
|
|
19
|
+
subscriptionRef.current = null;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
// Do something when the screen is unfocused
|
|
24
|
+
// Useful for cleanup functions
|
|
25
|
+
setInteractionsComplete(false);
|
|
26
|
+
subscriptionRef.current?.cancel();
|
|
27
|
+
};
|
|
28
|
+
}, []),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
interactionsComplete,
|
|
33
|
+
transitionRef,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const useIsReady = (stack: boolean = true) => {
|
|
5
|
+
const [isReady, setIsReady] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
useFocusEffect(
|
|
8
|
+
React.useCallback(() => {
|
|
9
|
+
// Do something when the screen is focused
|
|
10
|
+
|
|
11
|
+
let timer: any;
|
|
12
|
+
if (!isReady) {
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
setIsReady(true);
|
|
15
|
+
}, 200);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return () => {
|
|
19
|
+
// Do something when the screen is unfocused
|
|
20
|
+
// Useful for cleanup functions
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
// unsubscribeFocus();
|
|
23
|
+
// unsubscribeTransitionEnd && unsubscribeTransitionEnd();
|
|
24
|
+
};
|
|
25
|
+
}, []),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return isReady;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default useIsReady;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
3
|
+
import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';
|
|
4
|
+
import {
|
|
5
|
+
appDrawerFeature,
|
|
6
|
+
appBottomTabFeature,
|
|
7
|
+
appDrawerBottomTabFeature,
|
|
8
|
+
appBottomTabDrawerFeature,
|
|
9
|
+
appHostBottomTabFeature,
|
|
10
|
+
} from '../../components/Layout/compute';
|
|
11
|
+
import routeConfigKeyReplace from '../../utils/routeConfigKeyReplace';
|
|
12
|
+
|
|
13
|
+
const layoutSettings: any =
|
|
14
|
+
process.APP_ENV && process.APP_ENV.LAYOUT_SETTINGS ? JSON.parse(process.APP_ENV.LAYOUT_SETTINGS) : null;
|
|
15
|
+
|
|
16
|
+
export interface LayoutSettingProps {
|
|
17
|
+
drawerConfig?: any;
|
|
18
|
+
appFeatures?: any;
|
|
19
|
+
tabBarConfig?:any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useLayoutSetting(props = null as LayoutSettingProps) {
|
|
23
|
+
const dispatch = useDispatch();
|
|
24
|
+
const [settings, setAppSettings] = React.useState<any>();
|
|
25
|
+
const defaultSettings = useSelector<any>((state) => state.settings) as any;
|
|
26
|
+
const [appLayout, setAppLayout] = React.useState(appDrawerFeature(props?.drawerConfig ?? null));
|
|
27
|
+
const [pathKey, setPathKey] = React.useState('//main_drawer/');
|
|
28
|
+
const [intialRouteName, setInitialRouteName] = React.useState('MainStack.Layout');
|
|
29
|
+
const [appLayoutFeatures, setAppLayoutFeatures] = React.useState<any>(null);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (layoutSettings) {
|
|
33
|
+
const config: any = {
|
|
34
|
+
...settings,
|
|
35
|
+
...layoutSettings,
|
|
36
|
+
};
|
|
37
|
+
setDefalutSettings(config);
|
|
38
|
+
setAppSettings(config);
|
|
39
|
+
} else setAppSettings(defaultSettings);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (defaultSettings) {
|
|
44
|
+
setAppSettings(defaultSettings);
|
|
45
|
+
}
|
|
46
|
+
}, [defaultSettings]);
|
|
47
|
+
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (settings) {
|
|
50
|
+
let AppLayout =
|
|
51
|
+
settings?.layout == 'side'
|
|
52
|
+
? appDrawerFeature(props)
|
|
53
|
+
: settings?.layout == 'bottom'
|
|
54
|
+
? appBottomTabFeature(props)
|
|
55
|
+
: settings?.layout == 'host-bottom'
|
|
56
|
+
? appHostBottomTabFeature(props)
|
|
57
|
+
: appDrawerBottomTabFeature(props);
|
|
58
|
+
setAppLayout(AppLayout);
|
|
59
|
+
|
|
60
|
+
let layoutTypeKey =
|
|
61
|
+
settings?.layout == 'side'
|
|
62
|
+
? '//main_drawer/'
|
|
63
|
+
: settings?.layout == 'bottom'
|
|
64
|
+
? '//bottom_tab/'
|
|
65
|
+
: settings?.layout == 'host-bottom'
|
|
66
|
+
? '//host_tab/'
|
|
67
|
+
: '//main_drawer/bottom_tab/';
|
|
68
|
+
|
|
69
|
+
setPathKey(layoutTypeKey);
|
|
70
|
+
|
|
71
|
+
let initialRouteName =
|
|
72
|
+
settings?.layout == 'bottom'
|
|
73
|
+
? 'MainStack.Layout'
|
|
74
|
+
: settings?.layout == 'host-bottom'
|
|
75
|
+
? 'MainStack.Layout'
|
|
76
|
+
: 'MainStack.Layout';
|
|
77
|
+
|
|
78
|
+
setInitialRouteName(initialRouteName);
|
|
79
|
+
if (props?.appFeatures) {
|
|
80
|
+
const { appFeatures } = routeConfigKeyReplace(
|
|
81
|
+
layoutTypeKey,
|
|
82
|
+
props?.appFeatures,
|
|
83
|
+
AppLayout,
|
|
84
|
+
initialRouteName,
|
|
85
|
+
);
|
|
86
|
+
setAppLayoutFeatures(appFeatures);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [settings, props?.appFeatures]);
|
|
90
|
+
|
|
91
|
+
const setDefalutSettings = (config: any) => {
|
|
92
|
+
dispatch({
|
|
93
|
+
type: CHANGE_SETTINGS_ACTION,
|
|
94
|
+
payload: config,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return { appLayout, pathKey, intialRouteName, appLayoutFeatures };
|
|
99
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import { Feature } from '@common-stack/client-react';
|
|
3
|
+
import { applicationErrors, errorReduxLink } from '@admin-layout/client';
|
|
4
|
+
import { settingsReducer } from './redux/settings';
|
|
5
|
+
import { useAfterInteractions } from './hooks/use-after-interactions';
|
|
6
|
+
import useIsReady from './hooks/useIsReady';
|
|
7
|
+
import routeConfigKeyReplace from './utils/routeConfigKeyReplace';
|
|
8
|
+
//changed
|
|
9
|
+
import LayoutFeature, { ProLayout, AppFeatures, AppLayout } from './containers/layout/module';
|
|
10
|
+
import { useLayoutSetting, LayoutSettingProps } from './hooks/useLayoutSetting';
|
|
11
|
+
|
|
12
|
+
//...........................No change....///
|
|
13
|
+
export * from '@gluestack-ui/themed';
|
|
14
|
+
export * from '@gluestack-ui/config';
|
|
15
|
+
export * from '@gluestack-style/react';
|
|
16
|
+
export * from './containers/layout/Lifecycle';
|
|
17
|
+
//............................No change....///
|
|
18
|
+
|
|
19
|
+
//changed
|
|
20
|
+
export * from './components';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
useLayoutSetting,
|
|
26
|
+
LayoutSettingProps,
|
|
27
|
+
routeConfigKeyReplace,
|
|
28
|
+
LayoutFeature,
|
|
29
|
+
ProLayout,
|
|
30
|
+
AppFeatures,
|
|
31
|
+
AppLayout,
|
|
32
|
+
useAfterInteractions,
|
|
33
|
+
useIsReady,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default new Feature({
|
|
37
|
+
reducer: { settings: settingsReducer, applicationErrors },
|
|
38
|
+
clientStateParams: {
|
|
39
|
+
preLinkFuncs: [errorReduxLink],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './settings';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
+
/* eslint-disable no-case-declarations */
|
|
3
|
+
import { CHANGE_LANGUAGE, CHANGE_SETTINGS_ACTION } from "@admin-layout/client";
|
|
4
|
+
import { config } from "../config";
|
|
5
|
+
import { DefaultSettings } from "../interfaces";
|
|
6
|
+
|
|
7
|
+
const settingsReducer = (
|
|
8
|
+
state = config.LAYOUT_SETTINGS,
|
|
9
|
+
{ type, payload = {} }: { type: string; payload: DefaultSettings }
|
|
10
|
+
) => {
|
|
11
|
+
switch (type) {
|
|
12
|
+
case CHANGE_SETTINGS_ACTION:
|
|
13
|
+
return {
|
|
14
|
+
...state,
|
|
15
|
+
...payload
|
|
16
|
+
};
|
|
17
|
+
case CHANGE_LANGUAGE:
|
|
18
|
+
return {
|
|
19
|
+
...state,
|
|
20
|
+
language: payload,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
default:
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { settingsReducer };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`route config key replace getSortedNavigations with routeConfigKeyReplace 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"_pathPrefix": "",
|
|
7
|
+
"children": [
|
|
8
|
+
{
|
|
9
|
+
"_pathPrefix": "/",
|
|
10
|
+
"children": [
|
|
11
|
+
{
|
|
12
|
+
"_pathPrefix": "/",
|
|
13
|
+
"exact": true,
|
|
14
|
+
"name": "Account",
|
|
15
|
+
"path": "/:orgName/bottom_tab/account",
|
|
16
|
+
"position": "MIDDLE",
|
|
17
|
+
"props": {
|
|
18
|
+
"component": [Function],
|
|
19
|
+
"initialParams": {
|
|
20
|
+
"menu_position": "bottom",
|
|
21
|
+
"options": "{"headerShown":true,"tabBarLabel":"Account","headerTitle":"Account"}",
|
|
22
|
+
"priority": 0,
|
|
23
|
+
},
|
|
24
|
+
"options": {
|
|
25
|
+
"headerShown": true,
|
|
26
|
+
"headerTitle": "Account",
|
|
27
|
+
"tabBarLabel": "Account",
|
|
28
|
+
},
|
|
29
|
+
"priority": 3,
|
|
30
|
+
},
|
|
31
|
+
"routeParams": [
|
|
32
|
+
"orgName",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"_pathPrefix": "/",
|
|
37
|
+
"exact": true,
|
|
38
|
+
"name": "Home",
|
|
39
|
+
"path": "/:orgName/bottom_tab/home",
|
|
40
|
+
"position": "MIDDLE",
|
|
41
|
+
"props": {
|
|
42
|
+
"component": [Function],
|
|
43
|
+
"initialParams": {
|
|
44
|
+
"menu_position": "bottom",
|
|
45
|
+
"options": "{"headerShown":true,"tabBarLabel":"Home","headerTitle":"Home"}",
|
|
46
|
+
"orgName": "test",
|
|
47
|
+
"priority": 0,
|
|
48
|
+
},
|
|
49
|
+
"options": {
|
|
50
|
+
"headerShown": true,
|
|
51
|
+
"headerTitle": "Home",
|
|
52
|
+
"tabBarLabel": "Home",
|
|
53
|
+
},
|
|
54
|
+
"priority": 1,
|
|
55
|
+
},
|
|
56
|
+
"routeParams": [
|
|
57
|
+
"orgName",
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"_pathPrefix": "/",
|
|
62
|
+
"exact": false,
|
|
63
|
+
"name": "About",
|
|
64
|
+
"path": "/:orgName/bottom_tab/home/:about",
|
|
65
|
+
"position": "MIDDLE",
|
|
66
|
+
"props": {
|
|
67
|
+
"component": [Function],
|
|
68
|
+
"initialParams": {
|
|
69
|
+
"menu_position": "bottom",
|
|
70
|
+
"options": "{"headerShown":true,"tabBarLabel":"About","headerTitle":"About"}",
|
|
71
|
+
"priority": 0,
|
|
72
|
+
},
|
|
73
|
+
"options": {
|
|
74
|
+
"headerShown": true,
|
|
75
|
+
"headerTitle": "About",
|
|
76
|
+
"tabBarLabel": "About",
|
|
77
|
+
},
|
|
78
|
+
"priority": 2,
|
|
79
|
+
},
|
|
80
|
+
"routeParams": [
|
|
81
|
+
"orgName",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
"container": {
|
|
86
|
+
"Group": [Function],
|
|
87
|
+
"Navigator": [Function],
|
|
88
|
+
"Screen": [Function],
|
|
89
|
+
},
|
|
90
|
+
"exact": false,
|
|
91
|
+
"name": "MainBottomTab",
|
|
92
|
+
"path": "/:orgName/bottom_tab",
|
|
93
|
+
"position": "MIDDLE",
|
|
94
|
+
"props": {
|
|
95
|
+
"initialRouteName": "MainStack.MainBottomTab.Home",
|
|
96
|
+
"screenOptions": [Function],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
"container": {
|
|
101
|
+
"Group": [Function],
|
|
102
|
+
"Navigator": [Function],
|
|
103
|
+
"Screen": [Function],
|
|
104
|
+
},
|
|
105
|
+
"exact": false,
|
|
106
|
+
"name": "MainStack",
|
|
107
|
+
"path": "/",
|
|
108
|
+
"position": "MIDDLE",
|
|
109
|
+
"props": {
|
|
110
|
+
"initialRouteName": "MainStack.MainBottomTab",
|
|
111
|
+
"screenOptions": {
|
|
112
|
+
"headerShown": false,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
]
|
|
117
|
+
`;
|