@admin-layout/gluestack-ui-mobile 9.1.1-alpha.0 → 9.1.1-alpha.47
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 +8 -0
- package/lib/components/Layout/components/Drawer.js +2 -2
- package/lib/components/Layout/components/Drawer.js.map +1 -1
- package/lib/components/Layout/components/Header.js +23 -13
- package/lib/components/Layout/components/Header.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js +14 -6
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.d.ts +1 -1
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js +55 -15
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js +1 -1
- package/lib/components/NavigationComponent.js +3 -1
- package/lib/components/NavigationComponent.js.map +1 -1
- package/lib/components/WithConfiguration.js +2 -1
- package/lib/components/WithConfiguration.js.map +1 -1
- package/lib/components/WithPermission.js +2 -1
- package/lib/components/WithPermission.js.map +1 -1
- package/lib/components/usePermissionAutoFetch.d.ts +17 -17
- package/lib/components/with-interactions-lifecycle-managed.js.map +1 -1
- package/lib/containers/layout/BasicLayout.d.ts +2 -2
- package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +393 -88
- package/lib/containers/layout/DrawerConfig.d.ts +266 -60
- package/lib/containers/layout/module.js +2 -2
- package/lib/containers/layout/module.js.map +1 -1
- package/lib/redux/settings.d.ts +8 -8
- package/lib/utils/ThemeColor.js +11 -1
- package/lib/utils/ThemeColor.js.map +1 -1
- package/lib/utils/generateMobileNavigations.d.ts +1 -1
- package/lib/utils/generateMobileNavigations.js +47 -13
- package/lib/utils/generateMobileNavigations.js.map +1 -1
- package/package.json +7 -7
- package/src/components/Layout/components/Drawer.tsx +2 -2
- package/src/components/Layout/components/Header.tsx +69 -10
- package/src/components/Layout/components/SettingDrawer/LayoutButton.tsx +27 -13
- package/src/components/Layout/components/SettingDrawer/SettingDrawer.tsx +151 -48
- package/src/components/Layout/components/SettingDrawer/ThemeColorButton.tsx +2 -2
- package/src/components/NavigationComponent.tsx +1 -1
- package/src/components/WithConfiguration.tsx +2 -1
- package/src/components/WithPermission.tsx +2 -2
- package/src/components/with-interactions-lifecycle-managed.tsx +3 -3
- package/src/containers/layout/module.ts +2 -2
- package/src/utils/ThemeColor.ts +11 -1
- package/src/utils/generateMobileNavigations.ts +49 -13
|
@@ -4,21 +4,29 @@ import { Box, Pressable, HStack, VStack, Text } from '@gluestack-ui/themed';
|
|
|
4
4
|
const LayoutButton = ({ color, onSettingChange, settings, bottom, mode, bottomOnly, bottomDrawer }: any) => {
|
|
5
5
|
return (
|
|
6
6
|
<Pressable
|
|
7
|
-
backgroundColor={'#f0f2f5'}
|
|
7
|
+
backgroundColor={color === 'light' || color === 'dark' ? '#f0f2f5' : '#263749'}
|
|
8
8
|
width={50}
|
|
9
9
|
height={50}
|
|
10
10
|
borderRadius={'$sm'}
|
|
11
|
+
softShadow={'4'}
|
|
11
12
|
mr={'$4'}
|
|
12
13
|
onPress={() => {
|
|
13
14
|
if (mode === 'style') {
|
|
14
15
|
let { navTheme, ...rest } = settings;
|
|
15
|
-
if (color === '
|
|
16
|
+
if (color === 'light') {
|
|
16
17
|
navTheme = 'light';
|
|
17
18
|
const newSettings = {
|
|
18
19
|
...rest,
|
|
19
20
|
navTheme,
|
|
20
21
|
};
|
|
21
22
|
onSettingChange(newSettings);
|
|
23
|
+
} else if (color === 'realDark') {
|
|
24
|
+
navTheme = 'realDark';
|
|
25
|
+
const newSettings = {
|
|
26
|
+
...rest,
|
|
27
|
+
navTheme,
|
|
28
|
+
};
|
|
29
|
+
onSettingChange(newSettings);
|
|
22
30
|
} else {
|
|
23
31
|
navTheme = 'dark';
|
|
24
32
|
const newSettings = {
|
|
@@ -63,33 +71,39 @@ const LayoutButton = ({ color, onSettingChange, settings, bottom, mode, bottomOn
|
|
|
63
71
|
>
|
|
64
72
|
<HStack>
|
|
65
73
|
<Box
|
|
66
|
-
backgroundColor={color}
|
|
74
|
+
backgroundColor={color === 'light' ? '$white' : '$black'}
|
|
67
75
|
height={bottomOnly ? '$0' : 50}
|
|
68
|
-
width={'28%'}
|
|
76
|
+
width={bottomOnly ? '$0' : '28%'}
|
|
69
77
|
borderTopLeftRadius={'$sm'}
|
|
70
78
|
borderBottomLeftRadius={'$sm'}
|
|
71
79
|
/>
|
|
72
80
|
<VStack justifyContent={'space-between'}>
|
|
73
|
-
<Box
|
|
81
|
+
<Box
|
|
82
|
+
height={15}
|
|
83
|
+
width={bottomOnly ? 49 : 36}
|
|
84
|
+
backgroundColor={color === 'light' || color === 'dark' ? '$white' : '$black'}
|
|
85
|
+
borderTopRightRadius={'$sm'}
|
|
86
|
+
/>
|
|
74
87
|
{bottom ? (
|
|
75
88
|
<Box height={15} width={36} backgroundColor={'$black'} borderBottomRightRadius={'$sm'} />
|
|
76
89
|
) : null}
|
|
77
90
|
|
|
78
91
|
{bottomOnly ? (
|
|
79
92
|
<>
|
|
80
|
-
<Box height={
|
|
81
|
-
<Box height={15} width={49} backgroundColor={'$black'} />
|
|
82
|
-
</>
|
|
83
|
-
) : null}
|
|
84
|
-
|
|
85
|
-
{bottomDrawer ? (
|
|
86
|
-
<>
|
|
93
|
+
<Box height={18} width={'$0'} backgroundColor={'$white'} borderTopRightRadius={'$sm'} />
|
|
87
94
|
<Box
|
|
88
95
|
height={15}
|
|
89
|
-
width={
|
|
96
|
+
width={49}
|
|
90
97
|
backgroundColor={'$black'}
|
|
98
|
+
borderBottomLeftRadius={'$sm'}
|
|
91
99
|
borderBottomRightRadius={'$sm'}
|
|
92
100
|
/>
|
|
101
|
+
</>
|
|
102
|
+
) : null}
|
|
103
|
+
|
|
104
|
+
{bottomDrawer ? (
|
|
105
|
+
<>
|
|
106
|
+
<Box height={15} width={36} backgroundColor={'$black'} borderBottomRightRadius={'$sm'} />
|
|
93
107
|
<Text></Text>
|
|
94
108
|
</>
|
|
95
109
|
) : null}
|
|
@@ -1,60 +1,163 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Text,
|
|
5
|
+
HStack,
|
|
6
|
+
Actionsheet,
|
|
7
|
+
ActionsheetBackdrop,
|
|
8
|
+
ActionsheetContent,
|
|
9
|
+
ActionsheetDragIndicatorWrapper,
|
|
10
|
+
ActionsheetDragIndicator,
|
|
11
|
+
Select,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
SelectInput,
|
|
14
|
+
Icon,
|
|
15
|
+
ChevronDownIcon,
|
|
16
|
+
SelectPortal,
|
|
17
|
+
SelectBackdrop,
|
|
18
|
+
SelectContent,
|
|
19
|
+
SelectDragIndicatorWrapper,
|
|
20
|
+
SelectDragIndicator,
|
|
21
|
+
SelectItem,
|
|
22
|
+
Divider,
|
|
23
|
+
Switch,
|
|
24
|
+
ScrollView,
|
|
25
|
+
} from '@gluestack-ui/themed';
|
|
3
26
|
import { useSelector } from 'react-redux';
|
|
4
27
|
|
|
5
28
|
import LayoutButton from './LayoutButton';
|
|
6
29
|
import ThemeColorButton from './ThemeColorButton';
|
|
7
30
|
import { THEMECOLOR } from '../../../../utils/ThemeColor';
|
|
8
31
|
|
|
9
|
-
export const SettingDrawer = ({ onSettingChange }: any) => {
|
|
32
|
+
export const SettingDrawer = ({ isOpen, onSettingChange, handleClose }: any) => {
|
|
10
33
|
const settings = useSelector<any>((state) => state.settings) as any;
|
|
11
34
|
return (
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
<Actionsheet isOpen={isOpen} onClose={handleClose} zIndex={999}>
|
|
36
|
+
<ActionsheetBackdrop />
|
|
37
|
+
<ActionsheetContent zIndex={999} w={'100%'}>
|
|
38
|
+
<ActionsheetDragIndicatorWrapper>
|
|
39
|
+
<ActionsheetDragIndicator />
|
|
40
|
+
</ActionsheetDragIndicatorWrapper>
|
|
41
|
+
<ScrollView>
|
|
42
|
+
<Box alignItems="flex-start" bg={'$white'} w={'100%'} p={'$3'}>
|
|
43
|
+
<Text color={'#00000'} fontWeight={'$semibold'}>
|
|
44
|
+
Page style setting
|
|
45
|
+
</Text>
|
|
46
|
+
<HStack space={'md'} mt={'$3'}>
|
|
47
|
+
<LayoutButton
|
|
48
|
+
mode="style"
|
|
49
|
+
settings={settings}
|
|
50
|
+
onSettingChange={onSettingChange}
|
|
51
|
+
color={'light'}
|
|
52
|
+
/>
|
|
53
|
+
<LayoutButton
|
|
54
|
+
mode="style"
|
|
55
|
+
settings={settings}
|
|
56
|
+
onSettingChange={onSettingChange}
|
|
57
|
+
color={'dark'}
|
|
58
|
+
/>
|
|
59
|
+
<LayoutButton
|
|
60
|
+
mode="style"
|
|
61
|
+
settings={settings}
|
|
62
|
+
onSettingChange={onSettingChange}
|
|
63
|
+
color={'realDark'}
|
|
64
|
+
/>
|
|
65
|
+
</HStack>
|
|
66
|
+
<Text color={'#000000'} fontWeight={'$semibold'} mt={'$2'}>
|
|
67
|
+
Select Theme
|
|
68
|
+
</Text>
|
|
69
|
+
<Select
|
|
70
|
+
mt={'$2'}
|
|
71
|
+
w={'100%'}
|
|
72
|
+
selectedValue={settings?.themeName}
|
|
73
|
+
onValueChange={(value) => {
|
|
74
|
+
const newSettings = {
|
|
75
|
+
...settings,
|
|
76
|
+
themeName: value,
|
|
77
|
+
};
|
|
78
|
+
onSettingChange(newSettings);
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<SelectTrigger variant="outline" size="md">
|
|
82
|
+
<SelectInput placeholder="Select option" />
|
|
83
|
+
<Icon as={ChevronDownIcon} mr={'$3'} />
|
|
84
|
+
</SelectTrigger>
|
|
85
|
+
<SelectPortal>
|
|
86
|
+
<SelectBackdrop />
|
|
87
|
+
<SelectContent>
|
|
88
|
+
<SelectDragIndicatorWrapper>
|
|
89
|
+
<SelectDragIndicator />
|
|
90
|
+
</SelectDragIndicatorWrapper>
|
|
91
|
+
<SelectItem label="Default" value="default" />
|
|
92
|
+
<SelectItem label="Github Theme" value="github" />
|
|
93
|
+
<SelectItem label="Slack Theme" value="slack" />
|
|
94
|
+
<SelectItem label="Airbnb Theme" value="airbnb" />
|
|
95
|
+
<SelectItem label="Spotify Theme" value="spotify" />
|
|
96
|
+
</SelectContent>
|
|
97
|
+
</SelectPortal>
|
|
98
|
+
</Select>
|
|
99
|
+
<Text color={'#000000'} fontWeight={'$semibold'} mt={'$2'}>
|
|
100
|
+
Theme Color
|
|
101
|
+
</Text>
|
|
102
|
+
<HStack space={'md'} mt={'$3'} flexWrap={'wrap'}>
|
|
103
|
+
{THEMECOLOR.map((color, index) => (
|
|
104
|
+
<ThemeColorButton
|
|
105
|
+
key={index}
|
|
106
|
+
color={color}
|
|
107
|
+
settings={settings}
|
|
108
|
+
onSettingChange={onSettingChange}
|
|
109
|
+
/>
|
|
110
|
+
))}
|
|
111
|
+
</HStack>
|
|
112
|
+
<Divider my={'$4'} />
|
|
113
|
+
<Text color={'#000000'} fontWeight={'$semibold'} mt={'$2'}>
|
|
114
|
+
Navigation Mode
|
|
115
|
+
</Text>
|
|
116
|
+
<HStack space={'md'} mt={'$3'}>
|
|
117
|
+
<LayoutButton
|
|
118
|
+
mode="layout"
|
|
119
|
+
settings={settings}
|
|
120
|
+
onSettingChange={onSettingChange}
|
|
121
|
+
color={'light'}
|
|
122
|
+
/>
|
|
123
|
+
<LayoutButton
|
|
124
|
+
mode="layout"
|
|
125
|
+
bottom={true}
|
|
126
|
+
settings={settings}
|
|
127
|
+
onSettingChange={onSettingChange}
|
|
128
|
+
color={'light'}
|
|
129
|
+
/>
|
|
40
130
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
131
|
+
<LayoutButton
|
|
132
|
+
mode="light"
|
|
133
|
+
bottomOnly={true}
|
|
134
|
+
settings={settings}
|
|
135
|
+
onSettingChange={onSettingChange}
|
|
136
|
+
color={'light'}
|
|
137
|
+
/>
|
|
138
|
+
</HStack>
|
|
139
|
+
<Divider my={'$4'} />
|
|
140
|
+
<Text color={'#000000'} fontWeight={'$semibold'} mt={'$2'}>
|
|
141
|
+
Regional Settings
|
|
142
|
+
</Text>
|
|
143
|
+
<HStack w={'100%'} mt={'$3'} justifyContent={'space-between'} alignItems="center">
|
|
144
|
+
<Text>Menu Header</Text>
|
|
145
|
+
<Switch
|
|
146
|
+
onValueChange={(value) => {
|
|
147
|
+
console.log(value);
|
|
148
|
+
const newSettings = {
|
|
149
|
+
...settings,
|
|
150
|
+
menuHeader: value,
|
|
151
|
+
};
|
|
152
|
+
onSettingChange(newSettings);
|
|
153
|
+
}}
|
|
154
|
+
isChecked={settings?.menuHeader}
|
|
155
|
+
value={settings?.menuHeader}
|
|
156
|
+
/>
|
|
157
|
+
</HStack>
|
|
158
|
+
</Box>
|
|
159
|
+
</ScrollView>
|
|
160
|
+
</ActionsheetContent>
|
|
161
|
+
</Actionsheet>
|
|
59
162
|
);
|
|
60
163
|
};
|
|
@@ -5,8 +5,8 @@ const ThemeColorButton = ({ color, onSettingChange, settings }: any) => {
|
|
|
5
5
|
return (
|
|
6
6
|
<Pressable
|
|
7
7
|
backgroundColor={color}
|
|
8
|
-
height={'$
|
|
9
|
-
width={'$
|
|
8
|
+
height={'$6'}
|
|
9
|
+
width={'$6'}
|
|
10
10
|
borderRadius={'$sm'}
|
|
11
11
|
onPress={() => {
|
|
12
12
|
let { primaryColor, ...rest } = settings;
|
|
@@ -111,7 +111,7 @@ export const NavigationContainerComponent = ({
|
|
|
111
111
|
<NavigationContainer
|
|
112
112
|
ref={navigationRef}
|
|
113
113
|
linking={linking}
|
|
114
|
-
independent={independent}
|
|
114
|
+
// independent={independent}
|
|
115
115
|
onReady={() => {
|
|
116
116
|
routeNameRef.current = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
117
117
|
const currentRoute: any = routeNameRef?.current;
|
|
@@ -25,7 +25,8 @@ export const WithConfiguration = (props: IWithConfigurationProps) => {
|
|
|
25
25
|
configKey,
|
|
26
26
|
overrides: { resource: props.settingsUri },
|
|
27
27
|
});
|
|
28
|
-
const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
28
|
+
// const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
29
|
+
const { permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
29
30
|
|
|
30
31
|
const isPrivate = React.useMemo(
|
|
31
32
|
() => IVisibility.Private === data?.resolveConfiguration,
|
|
@@ -29,8 +29,8 @@ export const WithPermission = ({
|
|
|
29
29
|
alternative,
|
|
30
30
|
render,
|
|
31
31
|
}: IWithPermissionProps) => {
|
|
32
|
-
const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
33
|
-
|
|
32
|
+
// const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
33
|
+
const { permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
34
34
|
const hasPermission = React.useMemo(() => {
|
|
35
35
|
return permissionKeys.some((key) => permissionTypes.includes(get(permissions?.resolveConfiguration, key)));
|
|
36
36
|
}, [permissions, permissionTypes, permissionKeys]);
|
|
@@ -14,7 +14,7 @@ const LoadingComponent = () => (
|
|
|
14
14
|
</Center>
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
-
const LifecycleComponent = ({ children }) => {
|
|
17
|
+
const LifecycleComponent = ({ children }: { children?: any }) => {
|
|
18
18
|
const { authenticated } = isUserAuthenticated();
|
|
19
19
|
if (authenticated) {
|
|
20
20
|
return (
|
|
@@ -27,7 +27,7 @@ const LifecycleComponent = ({ children }) => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const IntractionComponent = ({ children, interationTime }) => {
|
|
30
|
+
const IntractionComponent = ({ children, interationTime }: { children?: any; interationTime: number }) => {
|
|
31
31
|
const { interactionsComplete, opacity, setInteractionsTimeOut } = useAfterInteractions();
|
|
32
32
|
React.useEffect(() => {
|
|
33
33
|
if (interationTime) setInteractionsTimeOut(interationTime);
|
|
@@ -51,7 +51,7 @@ const IntractionComponent = ({ children, interationTime }) => {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const IntractionWithLifeCycleComponent = ({ children, interationTime }) => {
|
|
54
|
+
const IntractionWithLifeCycleComponent = ({ children, interationTime }: { children?: any; interationTime: number }) => {
|
|
55
55
|
const { interactionsComplete, opacity, setInteractionsTimeOut } = useAfterInteractions();
|
|
56
56
|
React.useEffect(() => {
|
|
57
57
|
if (interationTime) setInteractionsTimeOut(interationTime);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
2
|
import { Feature } from '@common-stack/client-react';
|
|
3
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
+
// import { createStackNavigator } from '@react-navigation/stack';
|
|
4
4
|
import { ProLayout, AppFeatures, AppLayout } from './ProLayout';
|
|
5
5
|
|
|
6
6
|
export { ProLayout, AppFeatures, AppLayout };
|
|
@@ -8,7 +8,7 @@ export { ProLayout, AppFeatures, AppLayout };
|
|
|
8
8
|
const layoutConfig = {
|
|
9
9
|
['/']: {
|
|
10
10
|
exact: false,
|
|
11
|
-
container: createStackNavigator(),
|
|
11
|
+
// container: createStackNavigator(),
|
|
12
12
|
name: 'MainStack',
|
|
13
13
|
props: {
|
|
14
14
|
initialRouteName: 'MainStack.MainBottomTab',
|
package/src/utils/ThemeColor.ts
CHANGED
|
@@ -6,4 +6,14 @@ export const COLOR = {
|
|
|
6
6
|
GREYISH_BLACK: '#1f1f1f',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const THEMECOLOR = [
|
|
9
|
+
export const THEMECOLOR = [
|
|
10
|
+
'#4a154b',
|
|
11
|
+
'#601e69',
|
|
12
|
+
'#1d1c1d',
|
|
13
|
+
'#36c5ef',
|
|
14
|
+
'#2db57c',
|
|
15
|
+
'#e01d5a',
|
|
16
|
+
'#ecb12f',
|
|
17
|
+
'#616061',
|
|
18
|
+
'#dcd9d4',
|
|
19
|
+
];
|
|
@@ -66,10 +66,12 @@ export class GenerateMobileNavigations {
|
|
|
66
66
|
#configFileData: any = {};
|
|
67
67
|
#configFilePath: any;
|
|
68
68
|
#appPath: string = 'app';
|
|
69
|
+
#isDefaultPackagePathMobileRoot: boolean;
|
|
69
70
|
#mobileStackPath: string = 'mobile-stack-react';
|
|
70
71
|
//#layoutSettings: any = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
71
72
|
#appDirPath: any;
|
|
72
73
|
#modules: any;
|
|
74
|
+
#initialRouteNameRootStack: string;
|
|
73
75
|
#initialRouteName: string;
|
|
74
76
|
#unauthenticatedComponentPath: string;
|
|
75
77
|
#customTabBarPath: string;
|
|
@@ -84,11 +86,13 @@ export class GenerateMobileNavigations {
|
|
|
84
86
|
this.#configFileData = config;
|
|
85
87
|
// this.#layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
86
88
|
this.#appPath = config?.commonPaths?.appPath ?? 'app';
|
|
89
|
+
this.#isDefaultPackagePathMobileRoot = config?.mobileConfig?.isDefaultPackagePathMobileRoot ?? false;
|
|
87
90
|
this.#iconsRepository = config?.iconsRepository ?? '';
|
|
88
91
|
this.#mobileStackPath = config?.mobileStackPath ?? 'mobile-stack-react';
|
|
89
92
|
this.#appDirPath = path.join(path.dirname(configFilePath), this.#appPath);
|
|
90
93
|
this.#modules = config?.modules ?? [];
|
|
91
94
|
this.#initialRouteName = config?.mobileConfig?.initialRouteName ?? '';
|
|
95
|
+
this.#initialRouteNameRootStack = config?.mobileConfig?.initialRouteNameRootStack ?? 'MainStack';
|
|
92
96
|
this.#unauthenticatedComponentPath = config?.mobileConfig?.unauthenticatedComponentPath ?? '';
|
|
93
97
|
this.#customTabBarPath = config?.mobileConfig?.customTabBarPath ?? '';
|
|
94
98
|
this.#customDrawerPath = config?.mobileConfig?.customDrawerPath ?? '';
|
|
@@ -155,10 +159,20 @@ export class GenerateMobileNavigations {
|
|
|
155
159
|
|
|
156
160
|
async #getModulesRouteConfig({ modules }) {
|
|
157
161
|
const allFilteredRoutes = [];
|
|
162
|
+
let pkgFile;
|
|
158
163
|
for (const pkg of modules) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
if (this.#isDefaultPackagePathMobileRoot) {
|
|
165
|
+
const pkgRootFilePath = path.join(
|
|
166
|
+
path.join(path.dirname(this.#configFilePath), 'node_modules/lib'),
|
|
167
|
+
pkg,
|
|
168
|
+
);
|
|
169
|
+
pkgFile = path.join(pkgRootFilePath, 'routes.json');
|
|
170
|
+
} else {
|
|
171
|
+
const pkgPath = require.resolve(pkg);
|
|
172
|
+
const pkgDirPath = path.dirname(pkgPath);
|
|
173
|
+
pkgFile = path.join(pkgDirPath, 'routes.json');
|
|
174
|
+
}
|
|
175
|
+
|
|
162
176
|
if (fs.existsSync(pkgFile)) {
|
|
163
177
|
const fileModuleJSON: any = await readJsonFile(pkgFile);
|
|
164
178
|
if (fileModuleJSON) {
|
|
@@ -470,8 +484,24 @@ export class GenerateMobileNavigations {
|
|
|
470
484
|
const appReplacedRouteConfig = replacedRouteConfig ? Object.keys(replacedRouteConfig)?.map((k)=>({[k]:replacedRouteConfig[k]})) : [];
|
|
471
485
|
|
|
472
486
|
if (appReplacedRouteConfig) {
|
|
473
|
-
|
|
474
|
-
|
|
487
|
+
const hostRouteConfig = appReplacedRouteConfig.filter(item => {
|
|
488
|
+
return Object.keys(item).some(key =>
|
|
489
|
+
key === "/" ||
|
|
490
|
+
(key.startsWith("//" + layoutSettings.hostLayout) || key.startsWith("//:orgName/" + layoutSettings.hostLayout))
|
|
491
|
+
);
|
|
492
|
+
})?.filter((value) => Object.keys(value).length !== 0) ?? [];
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
const layoutRouteConfig = appReplacedRouteConfig.filter(item => {
|
|
496
|
+
return Object.keys(item).some(key =>
|
|
497
|
+
key === "/" ||
|
|
498
|
+
(!key.startsWith("//" + layoutSettings.hostLayout) && !key.startsWith("//:orgName/" + layoutSettings.hostLayout))
|
|
499
|
+
);
|
|
500
|
+
})?.filter((value) => Object.keys(value).length !== 0) ?? [];
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
// const hostRouteConfig = appReplacedRouteConfig?.map((obj)=> Object.fromEntries(Object.entries(obj)?.filter(([key,val])=>key === '/' || key.startsWith('//'+layoutSettings.hostLayout))))?.filter(value => Object.keys(value).length !== 0)??[];
|
|
504
|
+
// const layoutRouteConfig = appReplacedRouteConfig?.map((obj)=> Object.fromEntries(Object.entries(obj)?.filter(([key,val])=>key === '/' || !key.startsWith('//'+layoutSettings.hostLayout))))?.filter(value => Object.keys(value).length !== 0)??[];
|
|
475
505
|
const featureRouteConfig = defaultSettings?.layout == 'host-bottom' ? hostRouteConfig:layoutRouteConfig;
|
|
476
506
|
features.routeConfig = featureRouteConfig;
|
|
477
507
|
setMainFeatures(features);
|
|
@@ -841,7 +871,8 @@ export class GenerateMobileNavigations {
|
|
|
841
871
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
842
872
|
options={{...${options},...{${
|
|
843
873
|
pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
844
|
-
? `drawerIcon: ({
|
|
874
|
+
? `drawerIcon: ({ color }) => {
|
|
875
|
+
const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
|
|
845
876
|
const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
|
|
846
877
|
return (<SelectedIcon
|
|
847
878
|
{...{
|
|
@@ -1106,7 +1137,8 @@ export class GenerateMobileNavigations {
|
|
|
1106
1137
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
1107
1138
|
options={{...${options},...{${
|
|
1108
1139
|
pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
1109
|
-
? `tabBarIcon: ({
|
|
1140
|
+
? `tabBarIcon: ({ color }) => {
|
|
1141
|
+
const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
|
|
1110
1142
|
const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
|
|
1111
1143
|
return (<SelectedIcon
|
|
1112
1144
|
{...{
|
|
@@ -1414,11 +1446,13 @@ export class GenerateMobileNavigations {
|
|
|
1414
1446
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
1415
1447
|
const layoutRouteKey = Object.keys(layoutRouteConfig)[1];
|
|
1416
1448
|
const appLayout = layoutRouteConfig[layoutRouteKey];
|
|
1417
|
-
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1449
|
+
const initialRouteNameRootStack = this.#initialRouteNameRootStack;
|
|
1450
|
+
const layoutInitialRouteName = this.#initialRouteName;
|
|
1451
|
+
const initialRouteName = layoutInitialRouteName
|
|
1452
|
+
? layoutInitialRouteName
|
|
1453
|
+
: layoutType === 'mixSide'
|
|
1454
|
+
? appLayout?.[appLayout?.key]?.props?.initialRouteName ?? 'MainStack.Layout.Home'
|
|
1455
|
+
: appLayout?.props?.initialRouteName || 'MainStack.Home';
|
|
1422
1456
|
const isShowTabs = layoutType === 'mixSide' || layoutType === 'bottom' ? true : false;
|
|
1423
1457
|
const isShowDefalutHeader = layoutType === 'mixSide' ? true : false;
|
|
1424
1458
|
const defaultHeaderProps = {
|
|
@@ -1627,7 +1661,7 @@ export class GenerateMobileNavigations {
|
|
|
1627
1661
|
appComponent += `
|
|
1628
1662
|
const AppNavigations = () => {
|
|
1629
1663
|
return (
|
|
1630
|
-
<Stack.Navigator initialRouteName="${
|
|
1664
|
+
<Stack.Navigator initialRouteName="${initialRouteNameRootStack}">
|
|
1631
1665
|
<Stack.Screen
|
|
1632
1666
|
name="MainStack"
|
|
1633
1667
|
options={{ headerShown: false }}
|
|
@@ -1906,3 +1940,5 @@ export class GenerateMobileNavigations {
|
|
|
1906
1940
|
return this.#createAppDirectory();
|
|
1907
1941
|
}
|
|
1908
1942
|
}
|
|
1943
|
+
|
|
1944
|
+
export default GenerateMobileNavigations;
|