@admin-layout/gluestack-ui-mobile 9.0.2-alpha.4 → 9.0.4-alpha.11
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 +20 -0
- package/lib/components/AuthWrapper.d.ts +2 -1
- package/lib/components/AuthWrapper.js +3 -2
- package/lib/components/AuthWrapper.js.map +1 -1
- package/lib/containers/layout/BasicLayout.d.ts +1 -1
- package/lib/utils/generateMobileNavigations.d.ts +2 -1
- package/lib/utils/generateMobileNavigations.js +262 -50
- package/lib/utils/generateMobileNavigations.js.map +1 -1
- package/package.json +3 -3
- package/src/components/AuthWrapper.tsx +28 -17
- package/src/utils/generateMobileNavigations.ts +274 -48
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.0.4-alpha.11](https://github.com/CDEBase/admin-layout/compare/v9.0.4-alpha.10...v9.0.4-alpha.11) (2024-09-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
9
|
+
|
|
10
|
+
## [9.0.4-alpha.0](https://github.com/CDEBase/admin-layout/compare/v9.0.1-alpha.3...v9.0.4-alpha.0) (2024-09-13)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
13
|
+
|
|
14
|
+
## [9.0.1-alpha.2](https://github.com/CDEBase/admin-layout/compare/v9.0.1-alpha.1...v9.0.1-alpha.2) (2024-09-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
17
|
+
|
|
18
|
+
## [9.0.1-alpha.1](https://github.com/CDEBase/admin-layout/compare/v9.0.1-alpha.0...v9.0.1-alpha.1) (2024-09-12)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
21
|
+
|
|
22
|
+
## [9.0.1-alpha.0](https://github.com/CDEBase/admin-layout/compare/v9.0.2-alpha.13...v9.0.1-alpha.0) (2024-09-11)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
25
|
+
|
|
6
26
|
## [9.0.2-alpha.4](https://github.com/cdmbase/admin-layout/compare/v9.0.2-alpha.3...v9.0.2-alpha.4) (2024-09-08)
|
|
7
27
|
|
|
8
28
|
**Note:** Version bump only for package @admin-layout/gluestack-ui-mobile
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const AuthWrapper: ({ auth, component, unauthenticatedComponent, withLifeCycle, withInteraction, withLifeCycleInteraction }: any) => any;
|
|
1
|
+
export declare const AuthWrapper: ({ auth, component, unauthenticatedComponent, withLifeCycle, withInteraction, withLifeCycleInteraction, }: any) => any;
|
|
2
|
+
export default AuthWrapper;
|
|
@@ -3,8 +3,8 @@ import { isUserAuthenticated } from '@adminide-stack/user-auth0-client';
|
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { useSelector } from 'react-redux';
|
|
5
5
|
import DefaultAuthComponent from './UnAuthenticatedComponent';
|
|
6
|
-
import { withLifeCycleManaged, withInteractionsManaged, withLifeCycleInteractionsManaged } from './with-interactions-lifecycle-managed';
|
|
7
|
-
export const AuthWrapper = ({ auth = false, component, unauthenticatedComponent = null, withLifeCycle = null, withInteraction = null, withLifeCycleInteraction = null }) => {
|
|
6
|
+
import { withLifeCycleManaged, withInteractionsManaged, withLifeCycleInteractionsManaged, } from './with-interactions-lifecycle-managed';
|
|
7
|
+
export const AuthWrapper = ({ auth = false, component, unauthenticatedComponent = null, withLifeCycle = null, withInteraction = null, withLifeCycleInteraction = null, }) => {
|
|
8
8
|
const user = useSelector((state) => state.user);
|
|
9
9
|
const { authenticated } = isUserAuthenticated();
|
|
10
10
|
const navigation = useNavigation();
|
|
@@ -24,4 +24,5 @@ export const AuthWrapper = ({ auth = false, component, unauthenticatedComponent
|
|
|
24
24
|
else
|
|
25
25
|
return wrapperComponent;
|
|
26
26
|
};
|
|
27
|
+
export default AuthWrapper;
|
|
27
28
|
//# sourceMappingURL=AuthWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthWrapper.js","sourceRoot":"","sources":["../../src/components/AuthWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"AuthWrapper.js","sourceRoot":"","sources":["../../src/components/AuthWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,gCAAgC,GACnC,MAAM,uCAAuC,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EACxB,IAAI,GAAG,KAAK,EACZ,SAAS,EACT,wBAAwB,GAAG,IAAI,EAC/B,aAAa,GAAG,IAAI,EACpB,eAAe,GAAG,IAAI,EACtB,wBAAwB,GAAG,IAAI,GAC7B,EAAE,EAAE;IACN,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAChD,MAAM,UAAU,GAAG,aAAa,EAAO,CAAC;IAExC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO;YAAE,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACvE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEjB,MAAM,gBAAgB,GAAG,aAAa;QAClC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC;QACjC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,uBAAuB,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ,IAAI,IAAI,CAAC;YACvE,CAAC,CAAC,wBAAwB;gBAC1B,CAAC,CAAC,gCAAgC,CAAC,SAAS,EAAE,wBAAwB,EAAE,QAAQ,IAAI,IAAI,CAAC;gBACzF,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO;QAAE,OAAO,wBAAwB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,oBAAC,oBAAoB,OAAG,CAAC;;QAC7G,OAAO,gBAAgB,CAAC;AACjC,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -7,7 +7,7 @@ declare const _default: import("react-redux").ConnectedComponent<React.FC<any>,
|
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
[x: number]: any;
|
|
9
9
|
[x: symbol]: any;
|
|
10
|
-
context?: React.Context<import("react-redux").ReactReduxContextValue<any, UnknownAction>>;
|
|
10
|
+
context?: React.Context<import("react-redux").ReactReduxContextValue<any, import("redux").UnknownAction>>;
|
|
11
11
|
store?: import("redux").Store;
|
|
12
12
|
} | {
|
|
13
13
|
[x: string]: any;
|
|
@@ -6,13 +6,14 @@ type IGenerateMobileNavigationsProps = {
|
|
|
6
6
|
customTabBarPath?: string;
|
|
7
7
|
customDrawerPath?: string;
|
|
8
8
|
customHeaderPath?: string;
|
|
9
|
+
i18Options: any;
|
|
9
10
|
};
|
|
10
11
|
export declare const readJsonFile: (filePath: any) => Promise<unknown>;
|
|
11
12
|
export declare const readFile: (filePath: any) => Promise<unknown>;
|
|
12
13
|
export declare const getLayoutConfig: () => Promise<unknown>;
|
|
13
14
|
export declare class GenerateMobileNavigations {
|
|
14
15
|
#private;
|
|
15
|
-
constructor({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath, customTabBarPath, customDrawerPath, customHeaderPath, }: IGenerateMobileNavigationsProps);
|
|
16
|
+
constructor({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath, customTabBarPath, customDrawerPath, customHeaderPath, i18Options, }: IGenerateMobileNavigationsProps);
|
|
16
17
|
generateAppNavigations(): Promise<boolean>;
|
|
17
18
|
}
|
|
18
19
|
export {};
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _GenerateMobileNavigations_instances, _GenerateMobileNavigations_layoutSettings, _GenerateMobileNavigations_appDirPath, _GenerateMobileNavigations_modules, _GenerateMobileNavigations_initialRouteName, _GenerateMobileNavigations_unauthenticatedComponentPath, _GenerateMobileNavigations_customTabBarPath, _GenerateMobileNavigations_customDrawerPath, _GenerateMobileNavigations_customHeaderPath, _GenerateMobileNavigations_readJsonFile, _GenerateMobileNavigations_getLayoutConfig, _GenerateMobileNavigations_execPromise, _GenerateMobileNavigations_renameFile, _GenerateMobileNavigations_writeFile, _GenerateMobileNavigations_makeDir, _GenerateMobileNavigations_getModulesRouteConfig, _GenerateMobileNavigations_resolveImportPath, _GenerateMobileNavigations_generateAppRoutesJson, _GenerateMobileNavigations_generateImportStatements, _GenerateMobileNavigations_generateModulesTsFile, _GenerateMobileNavigations_generateStackNavigations, _GenerateMobileNavigations_generateDrawerNavigationsFile, _GenerateMobileNavigations_generateDrawerNavigations, _GenerateMobileNavigations_generateBottomTabNavigationsFile, _GenerateMobileNavigations_generateBottomTabNavigations, _GenerateMobileNavigations_generateBottomTabDrawerNavigations, _GenerateMobileNavigations_generateAppNavigationFile, _GenerateMobileNavigations_setLayoutAndGenerateNavigation;
|
|
12
|
+
var _GenerateMobileNavigations_instances, _GenerateMobileNavigations_layoutSettings, _GenerateMobileNavigations_appDirPath, _GenerateMobileNavigations_modules, _GenerateMobileNavigations_initialRouteName, _GenerateMobileNavigations_unauthenticatedComponentPath, _GenerateMobileNavigations_customTabBarPath, _GenerateMobileNavigations_customDrawerPath, _GenerateMobileNavigations_customHeaderPath, _GenerateMobileNavigations_i18Options, _GenerateMobileNavigations_readJsonFile, _GenerateMobileNavigations_getLayoutConfig, _GenerateMobileNavigations_execPromise, _GenerateMobileNavigations_renameFile, _GenerateMobileNavigations_writeFile, _GenerateMobileNavigations_makeDir, _GenerateMobileNavigations_getModulesRouteConfig, _GenerateMobileNavigations_resolveImportPath, _GenerateMobileNavigations_generateAppRoutesJson, _GenerateMobileNavigations_generateImportStatements, _GenerateMobileNavigations_generateModulesTsFile, _GenerateMobileNavigations_generateMainRoutesFile, _GenerateMobileNavigations_generateMainRoutes, _GenerateMobileNavigations_generateAppFile, _GenerateMobileNavigations_generateApp, _GenerateMobileNavigations_generateStackNavigations, _GenerateMobileNavigations_generateDrawerNavigationsFile, _GenerateMobileNavigations_generateDrawerNavigations, _GenerateMobileNavigations_generateBottomTabNavigationsFile, _GenerateMobileNavigations_generateBottomTabNavigations, _GenerateMobileNavigations_generateBottomTabDrawerNavigations, _GenerateMobileNavigations_generateAppNavigationFile, _GenerateMobileNavigations_setLayoutAndGenerateNavigation;
|
|
13
13
|
import * as fs from 'fs';
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import prettier from 'prettier';
|
|
@@ -22,14 +22,16 @@ const require = createRequire(import.meta.url);
|
|
|
22
22
|
const __filename = fileURLToPath(import.meta.url);
|
|
23
23
|
const __dirname = path.dirname(__filename);
|
|
24
24
|
const configFilePath = path.join(__dirname, '../layout.json');
|
|
25
|
-
const appNavigationFileName = 'navigation.
|
|
25
|
+
const appNavigationFileName = 'navigation.js';
|
|
26
26
|
const mainRoutesFileName = 'main_routes.json';
|
|
27
27
|
const modulesFileName = 'modules.ts';
|
|
28
|
-
const stacksDirPath = 'stack/index.
|
|
29
|
-
const drawerFilePath = 'drawer/index.
|
|
30
|
-
const hostDrawerFilePath = 'host_drawer/index.
|
|
31
|
-
const bottomFilePath = 'bottom/index.
|
|
32
|
-
const hostBottomFilePath = 'host_bottom/index.
|
|
28
|
+
const stacksDirPath = 'stack/index.js';
|
|
29
|
+
const drawerFilePath = 'drawer/index.js';
|
|
30
|
+
const hostDrawerFilePath = 'host_drawer/index.js';
|
|
31
|
+
const bottomFilePath = 'bottom/index.js';
|
|
32
|
+
const hostBottomFilePath = 'host_bottom/index.js';
|
|
33
|
+
const mainRoutesJsFileName = 'mainRoutes.js';
|
|
34
|
+
const mainAppFileName = 'index.js';
|
|
33
35
|
export const readJsonFile = (filePath) => {
|
|
34
36
|
return new Promise((resolve, reject) => {
|
|
35
37
|
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
@@ -66,7 +68,7 @@ export const getLayoutConfig = async () => {
|
|
|
66
68
|
return layoutConfigFileData;
|
|
67
69
|
};
|
|
68
70
|
export class GenerateMobileNavigations {
|
|
69
|
-
constructor({ appDirPath, modules, initialRouteName = '', unauthenticatedComponentPath = null, customTabBarPath = null, customDrawerPath = null, customHeaderPath = null, }) {
|
|
71
|
+
constructor({ appDirPath, modules, initialRouteName = '', unauthenticatedComponentPath = null, customTabBarPath = null, customDrawerPath = null, customHeaderPath = null, i18Options = {}, }) {
|
|
70
72
|
_GenerateMobileNavigations_instances.add(this);
|
|
71
73
|
_GenerateMobileNavigations_layoutSettings.set(this, process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null);
|
|
72
74
|
_GenerateMobileNavigations_appDirPath.set(this, void 0);
|
|
@@ -76,6 +78,7 @@ export class GenerateMobileNavigations {
|
|
|
76
78
|
_GenerateMobileNavigations_customTabBarPath.set(this, void 0);
|
|
77
79
|
_GenerateMobileNavigations_customDrawerPath.set(this, void 0);
|
|
78
80
|
_GenerateMobileNavigations_customHeaderPath.set(this, void 0);
|
|
81
|
+
_GenerateMobileNavigations_i18Options.set(this, void 0);
|
|
79
82
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_layoutSettings, process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null, "f");
|
|
80
83
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_appDirPath, appDirPath, "f");
|
|
81
84
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_modules, modules, "f");
|
|
@@ -84,12 +87,13 @@ export class GenerateMobileNavigations {
|
|
|
84
87
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_customTabBarPath, customTabBarPath, "f");
|
|
85
88
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_customDrawerPath, customDrawerPath, "f");
|
|
86
89
|
__classPrivateFieldSet(this, _GenerateMobileNavigations_customHeaderPath, customHeaderPath, "f");
|
|
90
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_i18Options, i18Options, "f");
|
|
87
91
|
}
|
|
88
92
|
async generateAppNavigations() {
|
|
89
93
|
return __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_setLayoutAndGenerateNavigation).call(this);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
|
-
_GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNavigations_appDirPath = new WeakMap(), _GenerateMobileNavigations_modules = new WeakMap(), _GenerateMobileNavigations_initialRouteName = new WeakMap(), _GenerateMobileNavigations_unauthenticatedComponentPath = new WeakMap(), _GenerateMobileNavigations_customTabBarPath = new WeakMap(), _GenerateMobileNavigations_customDrawerPath = new WeakMap(), _GenerateMobileNavigations_customHeaderPath = new WeakMap(), _GenerateMobileNavigations_instances = new WeakSet(), _GenerateMobileNavigations_readJsonFile = async function _GenerateMobileNavigations_readJsonFile(filePath) {
|
|
96
|
+
_GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNavigations_appDirPath = new WeakMap(), _GenerateMobileNavigations_modules = new WeakMap(), _GenerateMobileNavigations_initialRouteName = new WeakMap(), _GenerateMobileNavigations_unauthenticatedComponentPath = new WeakMap(), _GenerateMobileNavigations_customTabBarPath = new WeakMap(), _GenerateMobileNavigations_customDrawerPath = new WeakMap(), _GenerateMobileNavigations_customHeaderPath = new WeakMap(), _GenerateMobileNavigations_i18Options = new WeakMap(), _GenerateMobileNavigations_instances = new WeakSet(), _GenerateMobileNavigations_readJsonFile = async function _GenerateMobileNavigations_readJsonFile(filePath) {
|
|
93
97
|
return readJsonFile(filePath);
|
|
94
98
|
}, _GenerateMobileNavigations_getLayoutConfig = async function _GenerateMobileNavigations_getLayoutConfig() {
|
|
95
99
|
return getLayoutConfig();
|
|
@@ -378,6 +382,201 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
378
382
|
return false;
|
|
379
383
|
}
|
|
380
384
|
return false;
|
|
385
|
+
}, _GenerateMobileNavigations_generateMainRoutesFile = async function _GenerateMobileNavigations_generateMainRoutesFile({ initialRouteName, i18Options }) {
|
|
386
|
+
try {
|
|
387
|
+
const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
|
|
388
|
+
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
389
|
+
const hostRouteConfig = layoutConfigFileData['host-bottom'];
|
|
390
|
+
const hostRouteKey = Object.keys(hostRouteConfig)[1];
|
|
391
|
+
const hostLayout = hostRouteConfig[hostRouteKey];
|
|
392
|
+
let importStatements = '';
|
|
393
|
+
importStatements += `import React from 'react';\n`;
|
|
394
|
+
importStatements += `import { InversifyProvider, PluginArea } from '@common-stack/client-react';\n`;
|
|
395
|
+
importStatements += `import { useSelector, useDispatch } from 'react-redux';\n`;
|
|
396
|
+
importStatements += `import { CHANGE_SETTINGS_ACTION } from '@admin-layout/client';\n`;
|
|
397
|
+
importStatements += `import {layoutRouteConfig,getReplacedRouteConfig,ErrorBoundary,NavigationContainerComponent,ApplicationErrorHandler,Box,Spinner,} from '@admin-layout/gluestack-ui-mobile';\n`;
|
|
398
|
+
importStatements += `import mainRouteConfig from './main_routes.json';\n`;
|
|
399
|
+
importStatements += `import features from './mobile-stack-react/modules.js';\n`;
|
|
400
|
+
importStatements += `import AppNavigations from './navigation';\n`;
|
|
401
|
+
importStatements += `import {loadContext} from './mobile-stack-react/load-context.mobile.js';\n`;
|
|
402
|
+
let classStructure = `
|
|
403
|
+
|
|
404
|
+
const mainAppRoutes = mainRouteConfig || [];
|
|
405
|
+
|
|
406
|
+
const appRoutes = [...[mainAppRoutes],features?.routeConfig];
|
|
407
|
+
|
|
408
|
+
const featureRouteConfig = appRoutes?.flat(1)??features?.routeConfig;
|
|
409
|
+
features.routeConfig = featureRouteConfig;
|
|
410
|
+
let appConfiguredRoutes = features?.getConfiguredRoutes2("/");
|
|
411
|
+
|
|
412
|
+
const DefaultProvider = ({children}) => <>{children}</>
|
|
413
|
+
|
|
414
|
+
export function MainRoute({ container,externalProvider: ExternalProvider = DefaultProvider,externalProviderProps={},linking = {} }){
|
|
415
|
+
const dispatch = useDispatch();
|
|
416
|
+
const defaultSettings = useSelector((state) => state.settings);
|
|
417
|
+
const initialRouteName = '${initialRouteName}';
|
|
418
|
+
const layoutSettings = ${JSON.stringify({ ...layoutSettings, hostLayout: hostLayout.key })}
|
|
419
|
+
const [mainFeatures, setMainFeatures] = React.useState(null);
|
|
420
|
+
|
|
421
|
+
React.useEffect(() => {
|
|
422
|
+
setDefalutSettings();
|
|
423
|
+
}, []);
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
const setDefalutSettings = React.useCallback(()=>{
|
|
427
|
+
const config = {
|
|
428
|
+
...defaultSettings,
|
|
429
|
+
...layoutSettings,
|
|
430
|
+
};
|
|
431
|
+
dispatch({
|
|
432
|
+
type: CHANGE_SETTINGS_ACTION,
|
|
433
|
+
payload: config,
|
|
434
|
+
});
|
|
435
|
+
},[]);
|
|
436
|
+
|
|
437
|
+
React.useEffect(() => {
|
|
438
|
+
if (defaultSettings) {
|
|
439
|
+
const settingObj = { ...defaultSettings };
|
|
440
|
+
const layoutType = settingObj.layout;
|
|
441
|
+
const {replacedConfiguredRouteConfig} = getReplacedRouteConfig({
|
|
442
|
+
layoutType: layoutType,
|
|
443
|
+
routeConfig: appRoutes,
|
|
444
|
+
layoutConfigData: layoutRouteConfig,
|
|
445
|
+
initialRouteName,
|
|
446
|
+
});
|
|
447
|
+
if(replacedConfiguredRouteConfig){
|
|
448
|
+
const moduleRouteConfigObject = Object.assign({}, ...replacedConfiguredRouteConfig?.flat(1)??[]);
|
|
449
|
+
const replacedRouteConfig = Object.fromEntries(Object.entries(moduleRouteConfigObject));
|
|
450
|
+
const appReplacedRouteConfig = replacedRouteConfig ? Object.keys(replacedRouteConfig)?.map((k)=>({[k]:replacedRouteConfig[k]})) : [];
|
|
451
|
+
|
|
452
|
+
if (appReplacedRouteConfig) {
|
|
453
|
+
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)??[];
|
|
454
|
+
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)??[];
|
|
455
|
+
const featureRouteConfig = defaultSettings?.layout == 'host-bottom' ? hostRouteConfig:layoutRouteConfig;
|
|
456
|
+
features.routeConfig = featureRouteConfig;
|
|
457
|
+
setMainFeatures(features);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}, [defaultSettings]);
|
|
462
|
+
|
|
463
|
+
const loadingComponent = () => <Box flex={1}>{<Spinner />}</Box>;
|
|
464
|
+
|
|
465
|
+
if (!mainFeatures || mainFeatures?.routeConfig?.length == 0) return loadingComponent();
|
|
466
|
+
|
|
467
|
+
const plugins = mainFeatures?.getComponentFillPlugins();
|
|
468
|
+
const configuredRoutes = mainFeatures?.getConfiguredRoutes2('/');
|
|
469
|
+
appConfiguredRoutes = configuredRoutes;
|
|
470
|
+
|
|
471
|
+
return (
|
|
472
|
+
<InversifyProvider container={container} modules={mainFeatures}>
|
|
473
|
+
{mainFeatures?.getWrappedRoot(
|
|
474
|
+
<ErrorBoundary>
|
|
475
|
+
<NavigationContainerComponent configurableRoutes={configuredRoutes} independent={true} linking={linking}>
|
|
476
|
+
<ExternalProvider {...externalProviderProps}>
|
|
477
|
+
<AppNavigations />
|
|
478
|
+
</ExternalProvider>
|
|
479
|
+
<PluginArea />
|
|
480
|
+
<ApplicationErrorHandler plugins={plugins} />
|
|
481
|
+
</NavigationContainerComponent>
|
|
482
|
+
</ErrorBoundary>,
|
|
483
|
+
)}
|
|
484
|
+
</InversifyProvider>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export { loadContext,appConfiguredRoutes };
|
|
489
|
+
|
|
490
|
+
export default features;
|
|
491
|
+
`.replace(/,(\s*)$/, ''); // Removes trailing comma
|
|
492
|
+
// Use Prettier to format the code
|
|
493
|
+
classStructure = prettier.format(classStructure, { parser: 'babel' });
|
|
494
|
+
const appFeatures = importStatements + '\n' + classStructure;
|
|
495
|
+
return { appFeatures };
|
|
496
|
+
}
|
|
497
|
+
catch (err) {
|
|
498
|
+
console.error('Error:', err);
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
}, _GenerateMobileNavigations_generateMainRoutes = async function _GenerateMobileNavigations_generateMainRoutes({ appDirPath, i18Options, initialRouteName }) {
|
|
502
|
+
const mainRoutesFile = path.join(appDirPath, `/${mainRoutesJsFileName}`);
|
|
503
|
+
const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutesFile).call(this, { initialRouteName, i18Options });
|
|
504
|
+
const { appFeatures } = imports;
|
|
505
|
+
if (appFeatures) {
|
|
506
|
+
const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
|
|
507
|
+
if (writeFileResponse)
|
|
508
|
+
return true;
|
|
509
|
+
else
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
return false;
|
|
513
|
+
}, _GenerateMobileNavigations_generateAppFile = async function _GenerateMobileNavigations_generateAppFile({ initialRouteName, i18Options }) {
|
|
514
|
+
try {
|
|
515
|
+
let importStatements = '';
|
|
516
|
+
importStatements += `import 'reflect-metadata';\n`;
|
|
517
|
+
importStatements += `import React from 'react';\n`;
|
|
518
|
+
importStatements += `import { SlotFillProvider } from '@common-stack/components-pro';\n`;
|
|
519
|
+
importStatements += `import { ApolloProvider } from '@apollo/client';\n`;
|
|
520
|
+
importStatements += `import { Provider } from 'react-redux';\n`;
|
|
521
|
+
importStatements += `import { PersistGate } from 'redux-persist/integration/react';\n`;
|
|
522
|
+
importStatements += `import { SafeAreaProvider } from 'react-native-safe-area-context';\n`;
|
|
523
|
+
importStatements += `import {GluestackUIProvider,config,i18next,reactI18Next} from '@admin-layout/gluestack-ui-mobile';\n`;
|
|
524
|
+
importStatements += `import { enableScreens } from 'react-native-screens';\n`;
|
|
525
|
+
importStatements += `import {MainRoute,loadContext,appConfiguredRoutes} from './mainRoutes.js'\n`;
|
|
526
|
+
let classStructure = `
|
|
527
|
+
enableScreens(true);
|
|
528
|
+
const { I18nextProvider } = reactI18Next;
|
|
529
|
+
i18next.options ={...i18next?.options??{},...${JSON.stringify(i18Options)}};
|
|
530
|
+
|
|
531
|
+
const DefaultProvider = ({children}) => <>{children}</>
|
|
532
|
+
|
|
533
|
+
function App({externalProvider = DefaultProvider,externalProviderProps={},linking = {}}){
|
|
534
|
+
const {store,persistor,container,apolloClient: client} = loadContext();
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
return (
|
|
538
|
+
<SlotFillProvider>
|
|
539
|
+
<ApolloProvider client={client}>
|
|
540
|
+
<Provider store={store}>
|
|
541
|
+
<PersistGate persistor={persistor}>
|
|
542
|
+
<I18nextProvider i18n={i18next}>
|
|
543
|
+
<SafeAreaProvider>
|
|
544
|
+
<GluestackUIProvider config={config}>
|
|
545
|
+
<MainRoute container={container} externalProvider={externalProvider} linking={linking} externalProviderProps={externalProviderProps} />
|
|
546
|
+
</GluestackUIProvider>
|
|
547
|
+
</SafeAreaProvider>
|
|
548
|
+
</I18nextProvider>
|
|
549
|
+
</PersistGate>
|
|
550
|
+
</Provider>
|
|
551
|
+
</ApolloProvider>
|
|
552
|
+
</SlotFillProvider>
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
export const configuredRoutes = appConfiguredRoutes;
|
|
557
|
+
export default App;
|
|
558
|
+
`.replace(/,(\s*)$/, ''); // Removes trailing comma
|
|
559
|
+
// Use Prettier to format the code
|
|
560
|
+
classStructure = prettier.format(classStructure, { parser: 'babel' });
|
|
561
|
+
const appFeatures = importStatements + '\n' + classStructure;
|
|
562
|
+
return { appFeatures };
|
|
563
|
+
}
|
|
564
|
+
catch (err) {
|
|
565
|
+
console.error('Error:', err);
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
}, _GenerateMobileNavigations_generateApp = async function _GenerateMobileNavigations_generateApp({ appDirPath, i18Options, initialRouteName }) {
|
|
569
|
+
const mainRoutesFile = path.join(appDirPath, `/${mainAppFileName}`);
|
|
570
|
+
const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppFile).call(this, { initialRouteName, i18Options });
|
|
571
|
+
const { appFeatures } = imports;
|
|
572
|
+
if (appFeatures) {
|
|
573
|
+
const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
|
|
574
|
+
if (writeFileResponse)
|
|
575
|
+
return true;
|
|
576
|
+
else
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
381
580
|
}, _GenerateMobileNavigations_generateStackNavigations = async function _GenerateMobileNavigations_generateStackNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
|
|
382
581
|
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
383
582
|
const stackDirPath = path.join(appDirPath, `/${stacksDirPath}`);
|
|
@@ -422,7 +621,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
422
621
|
let customUnauthenticatedComponentNames = '';
|
|
423
622
|
const regex = /\.(tsx|ts|jsx|js)$/i;
|
|
424
623
|
importStatements += `import * as React from 'react';\n`;
|
|
425
|
-
importStatements += `import
|
|
624
|
+
importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
|
|
426
625
|
if (unauthenticatedComponentPath)
|
|
427
626
|
importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
|
|
428
627
|
for (const pkg of stackRouteConfig) {
|
|
@@ -456,9 +655,9 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
456
655
|
options={{...${options},...{${pkgRouteConfig?.customHeader &&
|
|
457
656
|
Object.keys(pkgRouteConfig.customHeader)?.length &&
|
|
458
657
|
customHeaderComponentPath
|
|
459
|
-
? `header: (props
|
|
658
|
+
? `header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
|
|
460
659
|
: ''}}}}
|
|
461
|
-
>{(props
|
|
660
|
+
>{(props) => <AuthWrapper
|
|
462
661
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
463
662
|
component={<Component${moduleNumber} {...props} />}
|
|
464
663
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
@@ -498,7 +697,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
498
697
|
});
|
|
499
698
|
}
|
|
500
699
|
moduleContent += `</Stack.Group>`;
|
|
501
|
-
moduleRender = `export default ({Stack,...rest}
|
|
700
|
+
moduleRender = `export default ({Stack,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
502
701
|
}
|
|
503
702
|
stackNavigator = importStatements + '\n' + moduleRender;
|
|
504
703
|
if (stackNavigator) {
|
|
@@ -531,7 +730,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
531
730
|
let customUnauthenticatedComponentNames = '';
|
|
532
731
|
const regex = /\.(tsx|ts|jsx|js)$/i;
|
|
533
732
|
importStatements += `import * as React from 'react';\n`;
|
|
534
|
-
importStatements += `import
|
|
733
|
+
importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
|
|
535
734
|
if (unauthenticatedComponentPath)
|
|
536
735
|
importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
|
|
537
736
|
for (const pkgRouteConfig of drawerConfig) {
|
|
@@ -565,14 +764,14 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
565
764
|
//component={Component${moduleNumber}}
|
|
566
765
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
567
766
|
options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
568
|
-
? `drawerIcon: ({ color, size }
|
|
767
|
+
? `drawerIcon: ({ color, size }) => <${pkgRouteConfig?.icon?.name} name="${pkgRouteConfig?.icon?.props?.name ?? 'home'}" size={${pkgRouteConfig?.icon?.props?.size ?? `size`}} color={${pkgRouteConfig?.icon?.props?.color ?? 'color'}} />,`
|
|
569
768
|
: ''}
|
|
570
769
|
${pkgRouteConfig?.customHeader &&
|
|
571
770
|
Object.keys(pkgRouteConfig.customHeader)?.length &&
|
|
572
771
|
customHeaderComponentPath
|
|
573
|
-
? `header: (props
|
|
772
|
+
? `header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
|
|
574
773
|
: ''}}}}
|
|
575
|
-
>{(props
|
|
774
|
+
>{(props) => <AuthWrapper
|
|
576
775
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
577
776
|
component={<Component${moduleNumber} {...props} />}
|
|
578
777
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
@@ -615,7 +814,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
615
814
|
importStatements += `import ${impUnauthenticatedName} from '${unCompPath}';\n`;
|
|
616
815
|
});
|
|
617
816
|
}
|
|
618
|
-
moduleRender = `export default ({Drawer,...rest}
|
|
817
|
+
moduleRender = `export default ({Drawer,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
619
818
|
moduleNavigation = importStatements + '\n' + moduleRender;
|
|
620
819
|
const drawerNavigator = moduleNavigation;
|
|
621
820
|
if (drawerNavigator) {
|
|
@@ -719,7 +918,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
719
918
|
let customUnauthenticatedComponentNames = '';
|
|
720
919
|
const regex = /\.(tsx|ts|jsx|js)$/i;
|
|
721
920
|
importStatements += `import * as React from 'react';\n`;
|
|
722
|
-
importStatements += `import
|
|
921
|
+
importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
|
|
723
922
|
if (unauthenticatedComponentPath)
|
|
724
923
|
importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
|
|
725
924
|
for (const pkgRouteConfig of bottomTabConfig) {
|
|
@@ -745,10 +944,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
745
944
|
customUnauthenticatedComponentName = `UnauthenticatedComponent${moduleNumber}`;
|
|
746
945
|
customUnauthenticatedComponentNames += `${customUnauthenticatedComponentName},`;
|
|
747
946
|
}
|
|
748
|
-
const options = JSON.stringify(
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
947
|
+
const options = JSON.stringify(pkgRouteConfig?.props?.options
|
|
948
|
+
? {
|
|
949
|
+
...pkgRouteConfig.props.options,
|
|
950
|
+
headerShown: mixLayout ? false : pkgRouteConfig.props.options.headerShown,
|
|
951
|
+
}
|
|
952
|
+
: { headerShown: mixLayout ? false : true });
|
|
752
953
|
importStatements += `import Component${moduleNumber} from '${pkgRouteConfig.componentPath}';\n`;
|
|
753
954
|
moduleContent += `<Tab.Screen
|
|
754
955
|
key="${pkgRouteConfig.key}"
|
|
@@ -756,15 +957,15 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
756
957
|
//component={Component${moduleNumber}}
|
|
757
958
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
758
959
|
options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
759
|
-
? `tabBarIcon: ({ color }
|
|
960
|
+
? `tabBarIcon: ({ color }) => <${pkgRouteConfig?.icon?.name} name="${pkgRouteConfig?.icon?.props?.name ?? 'home'}" size={${pkgRouteConfig?.icon?.props?.size ?? 24}} color={${pkgRouteConfig?.icon?.props?.color ?? 'color'}} />`
|
|
760
961
|
: ''}
|
|
761
962
|
${pkgRouteConfig?.customHeader &&
|
|
762
963
|
Object.keys(pkgRouteConfig.customHeader)?.length &&
|
|
763
964
|
customHeaderComponentPath
|
|
764
|
-
? `,header: (props
|
|
965
|
+
? `,header: (props) => <${customHeaderName} {...props} {...${JSON.stringify(pkgRouteConfig?.customHeader?.props ?? '')}} />`
|
|
765
966
|
: ''}
|
|
766
967
|
}}}
|
|
767
|
-
>{(props
|
|
968
|
+
>{(props) => <AuthWrapper
|
|
768
969
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
769
970
|
component={<Component${moduleNumber} {...props} />}
|
|
770
971
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
@@ -808,7 +1009,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
808
1009
|
importStatements += `import ${impUnauthenticatedName} from '${unCompPath}';\n`;
|
|
809
1010
|
});
|
|
810
1011
|
}
|
|
811
|
-
moduleRender = `export default ({Tab,...rest}
|
|
1012
|
+
moduleRender = `export default ({Tab,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
812
1013
|
moduleNavigation = importStatements + '\n' + moduleRender;
|
|
813
1014
|
const bottomTabNavigator = moduleNavigation;
|
|
814
1015
|
if (bottomTabNavigator) {
|
|
@@ -1052,8 +1253,8 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1052
1253
|
const Drawer = createDrawerNavigator();
|
|
1053
1254
|
`;
|
|
1054
1255
|
rootComponent += `
|
|
1055
|
-
const RootComponent = (props
|
|
1056
|
-
const settings = useSelector((state
|
|
1256
|
+
const RootComponent = (props) => {
|
|
1257
|
+
const settings = useSelector((state) => state.settings);
|
|
1057
1258
|
const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
|
|
1058
1259
|
return (
|
|
1059
1260
|
<Drawer.Navigator
|
|
@@ -1061,13 +1262,13 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1061
1262
|
//screenOptions={${JSON.stringify(screenOptions)}}
|
|
1062
1263
|
screenOptions={({ route }) => ({ ...${JSON.stringify(screenOptions)} ,...{
|
|
1063
1264
|
${customHeaderPath
|
|
1064
|
-
? `header: (props
|
|
1265
|
+
? `header: (props) => {
|
|
1065
1266
|
const title = getHeaderTitle(props.options, props.route.name);
|
|
1066
1267
|
return <CustomHeader {...defaultHeaderProps} {...props} title={title} style={props.options.headerStyle} />;
|
|
1067
1268
|
}`
|
|
1068
1269
|
: ''}
|
|
1069
1270
|
}})}
|
|
1070
|
-
${customDrawerPath ? 'drawerContent={(props
|
|
1271
|
+
${customDrawerPath ? 'drawerContent={(props) => <CustomDrawerContent {...props} />}' : ''}
|
|
1071
1272
|
>
|
|
1072
1273
|
{settings?.layout == 'host-bottom' ? hostDrawerNavigations({ Drawer }) : drawerNavigations({ Drawer })}
|
|
1073
1274
|
</Drawer.Navigator>
|
|
@@ -1091,23 +1292,23 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1091
1292
|
const Tab = createBottomTabNavigator();
|
|
1092
1293
|
`;
|
|
1093
1294
|
rootComponent += `
|
|
1094
|
-
const RootComponent = (props
|
|
1095
|
-
const settings = useSelector((state
|
|
1295
|
+
const RootComponent = (props) => {
|
|
1296
|
+
const settings = useSelector((state) => state.settings);
|
|
1096
1297
|
const initialRouteName = ${JSON.stringify(initialRouteName)};
|
|
1097
1298
|
let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
|
|
1098
1299
|
const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
|
|
1099
|
-
const defaultHeader = {${isShowDefalutHeader ? `header:(props
|
|
1300
|
+
const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
|
|
1100
1301
|
return (
|
|
1101
1302
|
<Tab.Navigator
|
|
1102
1303
|
initialRouteName={initialRouteName}
|
|
1103
|
-
screenOptions={(props
|
|
1104
|
-
? `header: (props
|
|
1304
|
+
screenOptions={(props)=>({...props,...defaultScreenOptions,...{${customHeaderPath
|
|
1305
|
+
? `header: (props) => {
|
|
1105
1306
|
const title = getHeaderTitle(props.options, props.route.name);
|
|
1106
1307
|
return <CustomHeader {...defaultHeaderProps} {...props} title={title} style={props.options.headerStyle} />;
|
|
1107
1308
|
}`
|
|
1108
1309
|
: ''}}})}
|
|
1109
1310
|
${customTabBarPath
|
|
1110
|
-
? 'tabBar={(props
|
|
1311
|
+
? 'tabBar={(props) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
|
|
1111
1312
|
: ''}
|
|
1112
1313
|
>
|
|
1113
1314
|
{settings?.layout == 'host-bottom' ? hostBottomNavigations({ Tab }) : bottomNavigations({Tab})}
|
|
@@ -1140,30 +1341,30 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1140
1341
|
`;
|
|
1141
1342
|
rootComponent += `
|
|
1142
1343
|
const TabNavigator = () => {
|
|
1143
|
-
const settings = useSelector((state
|
|
1344
|
+
const settings = useSelector((state) => state.settings);
|
|
1144
1345
|
const initialRouteName = ${JSON.stringify(initialRouteName)};
|
|
1145
1346
|
let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
|
|
1146
1347
|
const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
|
|
1147
|
-
const defaultHeader = {${isShowDefalutHeader ? `header:(props
|
|
1348
|
+
const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
|
|
1148
1349
|
|
|
1149
1350
|
return (
|
|
1150
1351
|
<Tab.Navigator
|
|
1151
1352
|
initialRouteName={initialRouteName}
|
|
1152
|
-
screenOptions={(props
|
|
1353
|
+
screenOptions={(props)=>({...props,...defaultScreenOptions,...{headerShown: false,header:()=>null},})}
|
|
1153
1354
|
${customTabBarPath
|
|
1154
|
-
? 'tabBar={(props
|
|
1355
|
+
? 'tabBar={(props) => <CustomTabBar key={props?.key??"customTabBarKey"} {...props} />}'
|
|
1155
1356
|
: ''}
|
|
1156
1357
|
>
|
|
1157
1358
|
{settings?.layout == 'host-bottom' ? hostBottomNavigations({ Tab }) : bottomNavigations({Tab})}
|
|
1158
1359
|
</Tab.Navigator>
|
|
1159
1360
|
)
|
|
1160
1361
|
}
|
|
1161
|
-
const RootComponent = (props
|
|
1362
|
+
const RootComponent = (props) => {
|
|
1162
1363
|
const initialRouteName = ${JSON.stringify(initialRouteName)};
|
|
1163
|
-
const settings = useSelector((state
|
|
1364
|
+
const settings = useSelector((state) => state.settings);
|
|
1164
1365
|
let defaultScreenOptions = ${JSON.stringify(screenOptionsTab)};
|
|
1165
1366
|
const defaultHeaderProps = ${JSON.stringify(defaultHeaderProps || {})};
|
|
1166
|
-
const defaultHeader = {${isShowDefalutHeader ? `header:(props
|
|
1367
|
+
const defaultHeader = {${isShowDefalutHeader ? `header:(props)=><Header {...defaultHeaderProps} {...props} />` : ''}};
|
|
1167
1368
|
return (
|
|
1168
1369
|
<Drawer.Navigator
|
|
1169
1370
|
initialRouteName={${JSON.stringify(initialRouteName)}}
|
|
@@ -1174,7 +1375,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1174
1375
|
: navigationRef?.getCurrentRoute()?.route?.name
|
|
1175
1376
|
: "Home",
|
|
1176
1377
|
${customHeaderPath
|
|
1177
|
-
? `header: (props
|
|
1378
|
+
? `header: (props) => {
|
|
1178
1379
|
const title = getHeaderTitle(props.options, props.route.name);
|
|
1179
1380
|
return <CustomHeader {...defaultHeaderProps} {...props} title={title} isMixedLayout={true} style={props.options.headerStyle} />;
|
|
1180
1381
|
}`
|
|
@@ -1182,10 +1383,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1182
1383
|
|
|
1183
1384
|
}})}
|
|
1184
1385
|
${customDrawerPath
|
|
1185
|
-
? 'drawerContent={((props
|
|
1386
|
+
? 'drawerContent={((props)) => <CustomDrawerContent {...props} showDefaultRoutes={true} />}'
|
|
1186
1387
|
: ''}
|
|
1187
1388
|
>
|
|
1188
|
-
<Drawer.Screen name="Layout" options={{title:"Home", drawerIcon: ({ color, size }
|
|
1389
|
+
<Drawer.Screen name="Layout" options={{title:"Home", drawerIcon: ({ color, size }) => (
|
|
1189
1390
|
<MaterialIcons name="home" size={24} color={color} />
|
|
1190
1391
|
),}}
|
|
1191
1392
|
component={TabNavigator} />
|
|
@@ -1226,17 +1427,28 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1226
1427
|
const customTabBarPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customTabBarPath, "f");
|
|
1227
1428
|
const customDrawerPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customDrawerPath, "f");
|
|
1228
1429
|
const customHeaderPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customHeaderPath, "f");
|
|
1430
|
+
const i18Options = __classPrivateFieldGet(this, _GenerateMobileNavigations_i18Options, "f");
|
|
1229
1431
|
const layoutSettings = __classPrivateFieldGet(this, _GenerateMobileNavigations_layoutSettings, "f");
|
|
1230
1432
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
1231
1433
|
const layoutType = layoutSettings?.layout || 'bottom';
|
|
1232
1434
|
const isAppRoutesGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppRoutesJson).call(this, { appDirPath });
|
|
1233
1435
|
if (isAppRoutesGenerated) {
|
|
1234
|
-
|
|
1436
|
+
// await this.#generateModulesTsFile({
|
|
1437
|
+
// appDirPath,
|
|
1438
|
+
// modules,
|
|
1439
|
+
// initialRouteName,
|
|
1440
|
+
// });
|
|
1441
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutes).call(this, {
|
|
1442
|
+
appDirPath,
|
|
1443
|
+
i18Options,
|
|
1444
|
+
initialRouteName,
|
|
1445
|
+
});
|
|
1446
|
+
const isAppFileGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateApp).call(this, {
|
|
1235
1447
|
appDirPath,
|
|
1236
|
-
|
|
1448
|
+
i18Options,
|
|
1237
1449
|
initialRouteName,
|
|
1238
1450
|
});
|
|
1239
|
-
if (
|
|
1451
|
+
if (isAppFileGenerated) {
|
|
1240
1452
|
const isStackCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateStackNavigations).call(this, {
|
|
1241
1453
|
appDirPath,
|
|
1242
1454
|
modules,
|