@admin-layout/gluestack-ui-mobile 9.0.4-alpha.0 → 9.0.4-alpha.103
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 +100 -0
- package/lib/components/AuthWrapper.d.ts +4 -2
- package/lib/components/AuthWrapper.js +5 -5
- package/lib/components/AuthWrapper.js.map +1 -1
- package/lib/components/Layout/components/Drawer.js +9 -9
- package/lib/components/Layout/components/Drawer.js.map +1 -1
- package/lib/components/Layout/components/Header.js +28 -15
- 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 +11 -2
- package/lib/components/NavigationComponent.js.map +1 -1
- package/lib/components/WithConfiguration.d.ts +18 -0
- package/lib/components/WithConfiguration.js +42 -0
- package/lib/components/WithConfiguration.js.map +1 -0
- package/lib/components/WithPermission.d.ts +31 -0
- package/lib/components/WithPermission.js +53 -0
- package/lib/components/WithPermission.js.map +1 -0
- package/lib/components/WithPolicy.d.ts +13 -0
- package/lib/components/WithPolicy.js +18 -0
- package/lib/components/WithPolicy.js.map +1 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/usePermissionAutoFetch.d.ts +75 -0
- package/lib/components/usePermissionAutoFetch.js +63 -0
- package/lib/components/usePermissionAutoFetch.js.map +1 -0
- package/lib/components/useSetting.d.ts +25 -0
- package/lib/components/useSetting.js +87 -0
- package/lib/components/useSetting.js.map +1 -0
- package/lib/components/with-interactions-lifecycle-managed.d.ts +3 -3
- package/lib/components/with-interactions-lifecycle-managed.js +23 -15
- 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 +4 -11
- package/lib/utils/generateMobileNavigations.js +498 -298
- package/lib/utils/generateMobileNavigations.js.map +1 -1
- package/package.json +7 -7
- package/src/components/AuthWrapper.tsx +6 -4
- package/src/components/Layout/components/Drawer.tsx +19 -20
- package/src/components/Layout/components/Header.tsx +154 -93
- 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 +9 -2
- package/src/components/WithConfiguration.tsx +74 -0
- package/src/components/WithPermission.tsx +81 -0
- package/src/components/WithPolicy.tsx +32 -0
- package/src/components/index.ts +6 -1
- package/src/components/usePermissionAutoFetch.tsx +78 -0
- package/src/components/useSetting.tsx +137 -0
- package/src/components/with-interactions-lifecycle-managed.tsx +62 -26
- package/src/containers/layout/module.ts +2 -2
- package/src/utils/ThemeColor.ts +11 -1
- package/src/utils/generateMobileNavigations.ts +543 -276
- package/lib/components/Layout/components/util.d.ts +0 -1
- package/lib/components/Layout/components/util.js +0 -15
- package/lib/components/Layout/components/util.js.map +0 -1
- package/src/components/Layout/components/util.ts +0 -14
|
@@ -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,
|
|
12
|
+
var _GenerateMobileNavigations_instances, _GenerateMobileNavigations_configFileData, _GenerateMobileNavigations_configFilePath, _GenerateMobileNavigations_appPath, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, _GenerateMobileNavigations_mobileStackPath, _GenerateMobileNavigations_appDirPath, _GenerateMobileNavigations_modules, _GenerateMobileNavigations_initialRouteNameRootStack, _GenerateMobileNavigations_initialRouteName, _GenerateMobileNavigations_unauthenticatedComponentPath, _GenerateMobileNavigations_customTabBarPath, _GenerateMobileNavigations_customDrawerPath, _GenerateMobileNavigations_customHeaderPath, _GenerateMobileNavigations_i18Options, _GenerateMobileNavigations_iconsRepository, _GenerateMobileNavigations_readConfigFile, _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_generateSelectiveIconsFile, _GenerateMobileNavigations_setLayoutAndGenerateNavigation, _GenerateMobileNavigations_performCopyOperations, _GenerateMobileNavigations_deleteDirectoryRecursive, _GenerateMobileNavigations_createAppDirectory;
|
|
13
13
|
import * as fs from 'fs';
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import prettier from 'prettier';
|
|
@@ -17,6 +17,7 @@ import { fileURLToPath } from 'url';
|
|
|
17
17
|
import { createRequire } from 'module';
|
|
18
18
|
import { exec as execCallback } from 'child_process';
|
|
19
19
|
import { getSortedNavigations } from '@common-stack/client-react/lib/route/react-navigation/get-navigation-utils.js';
|
|
20
|
+
import { performCopyOperations } from '@common-stack/rollup-vite-utils/lib/preStartup/configLoader/configLoader.js';
|
|
20
21
|
import { getReplacedRouteConfig } from './getReplacedRouteConfig.js';
|
|
21
22
|
const require = createRequire(import.meta.url);
|
|
22
23
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -68,32 +69,50 @@ export const getLayoutConfig = async () => {
|
|
|
68
69
|
return layoutConfigFileData;
|
|
69
70
|
};
|
|
70
71
|
export class GenerateMobileNavigations {
|
|
71
|
-
constructor({
|
|
72
|
+
constructor({ configFilePath }) {
|
|
72
73
|
_GenerateMobileNavigations_instances.add(this);
|
|
73
|
-
|
|
74
|
+
_GenerateMobileNavigations_configFileData.set(this, {});
|
|
75
|
+
_GenerateMobileNavigations_configFilePath.set(this, void 0);
|
|
76
|
+
_GenerateMobileNavigations_appPath.set(this, 'app');
|
|
77
|
+
_GenerateMobileNavigations_isDefaultPackagePathMobileRoot.set(this, void 0);
|
|
78
|
+
_GenerateMobileNavigations_mobileStackPath.set(this, 'mobile-stack-react');
|
|
79
|
+
//#layoutSettings: any = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
74
80
|
_GenerateMobileNavigations_appDirPath.set(this, void 0);
|
|
75
81
|
_GenerateMobileNavigations_modules.set(this, void 0);
|
|
82
|
+
_GenerateMobileNavigations_initialRouteNameRootStack.set(this, void 0);
|
|
76
83
|
_GenerateMobileNavigations_initialRouteName.set(this, void 0);
|
|
77
84
|
_GenerateMobileNavigations_unauthenticatedComponentPath.set(this, void 0);
|
|
78
85
|
_GenerateMobileNavigations_customTabBarPath.set(this, void 0);
|
|
79
86
|
_GenerateMobileNavigations_customDrawerPath.set(this, void 0);
|
|
80
87
|
_GenerateMobileNavigations_customHeaderPath.set(this, void 0);
|
|
81
88
|
_GenerateMobileNavigations_i18Options.set(this, void 0);
|
|
82
|
-
|
|
83
|
-
__classPrivateFieldSet(this,
|
|
84
|
-
|
|
85
|
-
__classPrivateFieldSet(this,
|
|
86
|
-
|
|
87
|
-
__classPrivateFieldSet(this,
|
|
88
|
-
__classPrivateFieldSet(this,
|
|
89
|
-
__classPrivateFieldSet(this,
|
|
90
|
-
__classPrivateFieldSet(this,
|
|
89
|
+
_GenerateMobileNavigations_iconsRepository.set(this, void 0);
|
|
90
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_configFilePath, configFilePath, "f");
|
|
91
|
+
const config = __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_readConfigFile).call(this, configFilePath);
|
|
92
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_configFileData, config, "f");
|
|
93
|
+
// this.#layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
94
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_appPath, config?.commonPaths?.appPath ?? 'app', "f");
|
|
95
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, config?.mobileConfig?.isDefaultPackagePathMobileRoot ?? false, "f");
|
|
96
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_iconsRepository, config?.iconsRepository ?? '', "f");
|
|
97
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_mobileStackPath, config?.mobileStackPath ?? 'mobile-stack-react', "f");
|
|
98
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_appDirPath, path.join(path.dirname(configFilePath), __classPrivateFieldGet(this, _GenerateMobileNavigations_appPath, "f")), "f");
|
|
99
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_modules, config?.modules ?? [], "f");
|
|
100
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_initialRouteName, config?.mobileConfig?.initialRouteName ?? '', "f");
|
|
101
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_initialRouteNameRootStack, config?.mobileConfig?.initialRouteNameRootStack ?? 'MainStack', "f");
|
|
102
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_unauthenticatedComponentPath, config?.mobileConfig?.unauthenticatedComponentPath ?? '', "f");
|
|
103
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_customTabBarPath, config?.mobileConfig?.customTabBarPath ?? '', "f");
|
|
104
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_customDrawerPath, config?.mobileConfig?.customDrawerPath ?? '', "f");
|
|
105
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_customHeaderPath, config?.mobileConfig?.customHeaderPath ?? '', "f");
|
|
106
|
+
__classPrivateFieldSet(this, _GenerateMobileNavigations_i18Options, config?.i18n ?? {}, "f");
|
|
91
107
|
}
|
|
92
108
|
async generateAppNavigations() {
|
|
93
|
-
return __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m",
|
|
109
|
+
return __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_createAppDirectory).call(this);
|
|
94
110
|
}
|
|
95
111
|
}
|
|
96
|
-
|
|
112
|
+
_GenerateMobileNavigations_configFileData = new WeakMap(), _GenerateMobileNavigations_configFilePath = new WeakMap(), _GenerateMobileNavigations_appPath = new WeakMap(), _GenerateMobileNavigations_isDefaultPackagePathMobileRoot = new WeakMap(), _GenerateMobileNavigations_mobileStackPath = new WeakMap(), _GenerateMobileNavigations_appDirPath = new WeakMap(), _GenerateMobileNavigations_modules = new WeakMap(), _GenerateMobileNavigations_initialRouteNameRootStack = 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_iconsRepository = new WeakMap(), _GenerateMobileNavigations_instances = new WeakSet(), _GenerateMobileNavigations_readConfigFile = function _GenerateMobileNavigations_readConfigFile(configFilePath) {
|
|
113
|
+
const jsonData = fs.readFileSync(configFilePath, 'utf-8');
|
|
114
|
+
return JSON.parse(jsonData);
|
|
115
|
+
}, _GenerateMobileNavigations_readJsonFile = async function _GenerateMobileNavigations_readJsonFile(filePath) {
|
|
97
116
|
return readJsonFile(filePath);
|
|
98
117
|
}, _GenerateMobileNavigations_getLayoutConfig = async function _GenerateMobileNavigations_getLayoutConfig() {
|
|
99
118
|
return getLayoutConfig();
|
|
@@ -137,10 +156,17 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
137
156
|
});
|
|
138
157
|
}, _GenerateMobileNavigations_getModulesRouteConfig = async function _GenerateMobileNavigations_getModulesRouteConfig({ modules }) {
|
|
139
158
|
const allFilteredRoutes = [];
|
|
159
|
+
let pkgFile;
|
|
140
160
|
for (const pkg of modules) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
161
|
+
if (__classPrivateFieldGet(this, _GenerateMobileNavigations_isDefaultPackagePathMobileRoot, "f")) {
|
|
162
|
+
const pkgRootFilePath = path.join(path.join(path.dirname(__classPrivateFieldGet(this, _GenerateMobileNavigations_configFilePath, "f")), 'node_modules/lib'), pkg);
|
|
163
|
+
pkgFile = path.join(pkgRootFilePath, 'routes.json');
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const pkgPath = require.resolve(pkg);
|
|
167
|
+
const pkgDirPath = path.dirname(pkgPath);
|
|
168
|
+
pkgFile = path.join(pkgDirPath, 'routes.json');
|
|
169
|
+
}
|
|
144
170
|
if (fs.existsSync(pkgFile)) {
|
|
145
171
|
const fileModuleJSON = await readJsonFile(pkgFile);
|
|
146
172
|
if (fileModuleJSON) {
|
|
@@ -170,14 +196,16 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
170
196
|
}
|
|
171
197
|
}
|
|
172
198
|
return value;
|
|
173
|
-
}, _GenerateMobileNavigations_generateAppRoutesJson = async function _GenerateMobileNavigations_generateAppRoutesJson(
|
|
174
|
-
const
|
|
199
|
+
}, _GenerateMobileNavigations_generateAppRoutesJson = async function _GenerateMobileNavigations_generateAppRoutesJson() {
|
|
200
|
+
const appDirPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
|
|
201
|
+
const parentDirPath = path.dirname(__classPrivateFieldGet(this, _GenerateMobileNavigations_configFileData, "f")?.mobileConfig?.computeFilePath ?? __classPrivateFieldGet(this, _GenerateMobileNavigations_configFilePath, "f"));
|
|
175
202
|
const parentDirName = path.basename(parentDirPath);
|
|
176
203
|
const appDirName = path.basename(appDirPath);
|
|
177
204
|
// const tsFile = 'src/compute.ts';
|
|
178
205
|
// const outputDir = 'src/app';
|
|
179
206
|
const tsFile = `${parentDirName}/compute.ts`;
|
|
180
|
-
const outputDir = `${parentDirName}/${appDirName}`;
|
|
207
|
+
// const outputDir = `${parentDirName}/${appDirName}`;
|
|
208
|
+
const outputDir = `${appDirName}`;
|
|
181
209
|
const tscCommand = `tsc ${tsFile} --outDir ${outputDir} --target es6 --module esnext --jsx react --allowSyntheticDefaultImports true --moduleResolution node --esModuleInterop true --forceConsistentCasingInFileNames true --skipLibCheck true`;
|
|
182
210
|
const mainRoutesJsFile = path.join(appDirPath, '/compute.js');
|
|
183
211
|
const mainRoutesMjsFile = path.join(appDirPath, '/compute.mjs');
|
|
@@ -193,17 +221,13 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
193
221
|
const noWhitespaceJsData = noCommentsData.replace(/\s+/g, '');
|
|
194
222
|
if (noWhitespaceJsData?.length == 0) {
|
|
195
223
|
const outPutDirName = path.dirname(outputFile);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
else
|
|
203
|
-
return false;
|
|
224
|
+
try {
|
|
225
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
|
|
226
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
console.log('Error directory/file create', error);
|
|
204
230
|
}
|
|
205
|
-
else
|
|
206
|
-
return false;
|
|
207
231
|
}
|
|
208
232
|
else {
|
|
209
233
|
const newFilePath = mainRoutesJsFile.replace('.js', '.mjs');
|
|
@@ -223,56 +247,45 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
223
247
|
return { [routConfig.path]: routConfig };
|
|
224
248
|
}) ?? [];
|
|
225
249
|
allFilteredRoutes.push(...newRoutes);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
250
|
+
try {
|
|
251
|
+
const writeFileResponse = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes, null, 2));
|
|
252
|
+
if (writeFileResponse)
|
|
253
|
+
fs.unlinkSync(mainRoutesMjsFile);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.log('Error creating main routes file', error);
|
|
230
257
|
}
|
|
231
|
-
else
|
|
232
|
-
return false;
|
|
233
258
|
}
|
|
234
259
|
}
|
|
235
|
-
else
|
|
236
|
-
return false;
|
|
237
260
|
}
|
|
238
|
-
else
|
|
239
|
-
return false;
|
|
240
261
|
}
|
|
241
262
|
}
|
|
242
263
|
else {
|
|
243
264
|
const outPutDirName = path.dirname(outputFile);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
else
|
|
251
|
-
return false;
|
|
265
|
+
try {
|
|
266
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
|
|
267
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
console.log('Error creating main routes file', error);
|
|
252
271
|
}
|
|
253
|
-
else
|
|
254
|
-
return false;
|
|
255
272
|
}
|
|
256
273
|
// return true;
|
|
257
274
|
}
|
|
258
275
|
catch (error) {
|
|
259
276
|
console.error(`exec error: ${error.message}`);
|
|
260
277
|
const outPutDirName = path.dirname(outputFile);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
else
|
|
268
|
-
return false;
|
|
278
|
+
try {
|
|
279
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, outPutDirName);
|
|
280
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, outputFile, JSON.stringify(allFilteredRoutes));
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
console.log('Error creating main routes file', error);
|
|
269
284
|
}
|
|
270
|
-
else
|
|
271
|
-
return false;
|
|
272
285
|
}
|
|
273
286
|
}, _GenerateMobileNavigations_generateImportStatements = async function _GenerateMobileNavigations_generateImportStatements({ modules, initialRouteName }) {
|
|
274
287
|
try {
|
|
275
|
-
const layoutSettings =
|
|
288
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
276
289
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
277
290
|
const hostRouteConfig = layoutConfigFileData['host-bottom'];
|
|
278
291
|
const hostRouteKey = Object.keys(hostRouteConfig)[1];
|
|
@@ -384,7 +397,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
384
397
|
return false;
|
|
385
398
|
}, _GenerateMobileNavigations_generateMainRoutesFile = async function _GenerateMobileNavigations_generateMainRoutesFile({ initialRouteName, i18Options }) {
|
|
386
399
|
try {
|
|
387
|
-
const layoutSettings =
|
|
400
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
388
401
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
389
402
|
const hostRouteConfig = layoutConfigFileData['host-bottom'];
|
|
390
403
|
const hostRouteKey = Object.keys(hostRouteConfig)[1];
|
|
@@ -450,8 +463,24 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
450
463
|
const appReplacedRouteConfig = replacedRouteConfig ? Object.keys(replacedRouteConfig)?.map((k)=>({[k]:replacedRouteConfig[k]})) : [];
|
|
451
464
|
|
|
452
465
|
if (appReplacedRouteConfig) {
|
|
453
|
-
|
|
454
|
-
|
|
466
|
+
const hostRouteConfig = appReplacedRouteConfig.filter(item => {
|
|
467
|
+
return Object.keys(item).some(key =>
|
|
468
|
+
key === "/" ||
|
|
469
|
+
(key.startsWith("//" + layoutSettings.hostLayout) || key.startsWith("//:orgName/" + layoutSettings.hostLayout))
|
|
470
|
+
);
|
|
471
|
+
})?.filter((value) => Object.keys(value).length !== 0) ?? [];
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
const layoutRouteConfig = appReplacedRouteConfig.filter(item => {
|
|
475
|
+
return Object.keys(item).some(key =>
|
|
476
|
+
key === "/" ||
|
|
477
|
+
(!key.startsWith("//" + layoutSettings.hostLayout) && !key.startsWith("//:orgName/" + layoutSettings.hostLayout))
|
|
478
|
+
);
|
|
479
|
+
})?.filter((value) => Object.keys(value).length !== 0) ?? [];
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
// 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)??[];
|
|
483
|
+
// 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
484
|
const featureRouteConfig = defaultSettings?.layout == 'host-bottom' ? hostRouteConfig:layoutRouteConfig;
|
|
456
485
|
features.routeConfig = featureRouteConfig;
|
|
457
486
|
setMainFeatures(features);
|
|
@@ -496,20 +525,17 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
496
525
|
}
|
|
497
526
|
catch (err) {
|
|
498
527
|
console.error('Error:', err);
|
|
499
|
-
return false;
|
|
500
528
|
}
|
|
501
529
|
}, _GenerateMobileNavigations_generateMainRoutes = async function _GenerateMobileNavigations_generateMainRoutes({ appDirPath, i18Options, initialRouteName }) {
|
|
502
530
|
const mainRoutesFile = path.join(appDirPath, `/${mainRoutesJsFileName}`);
|
|
503
531
|
const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutesFile).call(this, { initialRouteName, i18Options });
|
|
504
532
|
const { appFeatures } = imports;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return false;
|
|
533
|
+
try {
|
|
534
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
|
|
535
|
+
}
|
|
536
|
+
catch (err) {
|
|
537
|
+
console.error('Error generating main routes:', err);
|
|
511
538
|
}
|
|
512
|
-
return false;
|
|
513
539
|
}, _GenerateMobileNavigations_generateAppFile = async function _GenerateMobileNavigations_generateAppFile({ initialRouteName, i18Options }) {
|
|
514
540
|
try {
|
|
515
541
|
let importStatements = '';
|
|
@@ -563,24 +589,21 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
563
589
|
}
|
|
564
590
|
catch (err) {
|
|
565
591
|
console.error('Error:', err);
|
|
566
|
-
return false;
|
|
567
592
|
}
|
|
568
593
|
}, _GenerateMobileNavigations_generateApp = async function _GenerateMobileNavigations_generateApp({ appDirPath, i18Options, initialRouteName }) {
|
|
569
594
|
const mainRoutesFile = path.join(appDirPath, `/${mainAppFileName}`);
|
|
570
595
|
const imports = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppFile).call(this, { initialRouteName, i18Options });
|
|
571
596
|
const { appFeatures } = imports;
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return false;
|
|
597
|
+
try {
|
|
598
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, mainRoutesFile, appFeatures);
|
|
599
|
+
}
|
|
600
|
+
catch (err) {
|
|
601
|
+
console.error('Error generating app:', err);
|
|
578
602
|
}
|
|
579
|
-
return false;
|
|
580
603
|
}, _GenerateMobileNavigations_generateStackNavigations = async function _GenerateMobileNavigations_generateStackNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
|
|
581
604
|
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
582
605
|
const stackDirPath = path.join(appDirPath, `/${stacksDirPath}`);
|
|
583
|
-
const layoutSettings =
|
|
606
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
584
607
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
585
608
|
const layoutType = layoutSettings?.layout || 'bottom';
|
|
586
609
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
@@ -659,7 +682,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
659
682
|
: ''}}}}
|
|
660
683
|
>{(props) => <AuthWrapper
|
|
661
684
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
662
|
-
|
|
685
|
+
authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
686
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
687
|
+
component={<Component${moduleNumber} {...props}
|
|
688
|
+
permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
689
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
690
|
+
/>}
|
|
663
691
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
664
692
|
? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
|
|
665
693
|
: unauthenticatedComponentPath
|
|
@@ -700,23 +728,18 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
700
728
|
moduleRender = `export default ({Stack,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
701
729
|
}
|
|
702
730
|
stackNavigator = importStatements + '\n' + moduleRender;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
731
|
+
let stackNavigation = stackNavigator;
|
|
732
|
+
stackNavigation = prettier.format(stackNavigation, { parser: 'babel' });
|
|
733
|
+
const stackDirName = path.dirname(stackDirPath);
|
|
734
|
+
try {
|
|
707
735
|
const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, stackDirName);
|
|
708
736
|
if (isDirCreated) {
|
|
709
|
-
|
|
710
|
-
if (writeFileResponse)
|
|
711
|
-
return true;
|
|
712
|
-
else
|
|
713
|
-
return false;
|
|
737
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, stackDirPath, stackNavigation);
|
|
714
738
|
}
|
|
715
|
-
else
|
|
716
|
-
return false;
|
|
717
739
|
}
|
|
718
|
-
|
|
719
|
-
|
|
740
|
+
catch (error) {
|
|
741
|
+
console.log('Error generating stack navigation', error);
|
|
742
|
+
}
|
|
720
743
|
}, _GenerateMobileNavigations_generateDrawerNavigationsFile = async function _GenerateMobileNavigations_generateDrawerNavigationsFile({ drawerConfig, unauthenticatedComponentPath, drawerDirPath }) {
|
|
721
744
|
let moduleNumber = 0;
|
|
722
745
|
let importStatements = '';
|
|
@@ -731,6 +754,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
731
754
|
const regex = /\.(tsx|ts|jsx|js)$/i;
|
|
732
755
|
importStatements += `import * as React from 'react';\n`;
|
|
733
756
|
importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
|
|
757
|
+
importStatements += `import DynamicIcons from '@app/selectiveIcons';\n`;
|
|
734
758
|
if (unauthenticatedComponentPath)
|
|
735
759
|
importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
|
|
736
760
|
for (const pkgRouteConfig of drawerConfig) {
|
|
@@ -764,7 +788,24 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
764
788
|
//component={Component${moduleNumber}}
|
|
765
789
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
766
790
|
options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
767
|
-
? `drawerIcon: ({ color
|
|
791
|
+
? `drawerIcon: ({ color }) => {
|
|
792
|
+
const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
|
|
793
|
+
const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
|
|
794
|
+
return (<SelectedIcon
|
|
795
|
+
{...{
|
|
796
|
+
...${JSON.stringify({ ...(pkgRouteConfig?.icon?.props || {}) })},
|
|
797
|
+
...{
|
|
798
|
+
color:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
|
|
799
|
+
pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
|
|
800
|
+
:${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
|
|
801
|
+
'grey'},
|
|
802
|
+
stroke:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
|
|
803
|
+
pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
|
|
804
|
+
:${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
|
|
805
|
+
'grey'}
|
|
806
|
+
}
|
|
807
|
+
}}
|
|
808
|
+
/>)},`
|
|
768
809
|
: ''}
|
|
769
810
|
${pkgRouteConfig?.customHeader &&
|
|
770
811
|
Object.keys(pkgRouteConfig.customHeader)?.length &&
|
|
@@ -773,7 +814,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
773
814
|
: ''}}}}
|
|
774
815
|
>{(props) => <AuthWrapper
|
|
775
816
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
776
|
-
|
|
817
|
+
authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
818
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
819
|
+
component={<Component${moduleNumber} {...props}
|
|
820
|
+
permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
821
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
822
|
+
/>}
|
|
777
823
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
778
824
|
? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
|
|
779
825
|
: unauthenticatedComponentPath
|
|
@@ -790,10 +836,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
790
836
|
: ''}
|
|
791
837
|
/>}</Drawer.Screen>`;
|
|
792
838
|
}
|
|
793
|
-
if (icons && icons?.length) {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
}
|
|
839
|
+
// if (icons && icons?.length) {
|
|
840
|
+
// const uniqueIcons = [...new Set(icons.split(','))].join(',');
|
|
841
|
+
// importStatements += `import Icons from '@expo/vector-icons';\n`;
|
|
842
|
+
// }
|
|
797
843
|
if (customHeaderPaths && customHeaderPaths?.length) {
|
|
798
844
|
const uniqueHeaderNames = [...new Set(customHeaderNames.split(','))]?.filter((str) => str?.length);
|
|
799
845
|
const uniqueHeaderPaths = [...new Set(customHeaderPaths.split(','))]?.filter((str) => str?.length);
|
|
@@ -817,27 +863,23 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
817
863
|
moduleRender = `export default ({Drawer,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
818
864
|
moduleNavigation = importStatements + '\n' + moduleRender;
|
|
819
865
|
const drawerNavigator = moduleNavigation;
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
866
|
+
let drawerNavigation = drawerNavigator;
|
|
867
|
+
drawerNavigation = prettier.format(drawerNavigation, { parser: 'babel' });
|
|
868
|
+
const drawerDirName = path.dirname(drawerDirPath);
|
|
869
|
+
try {
|
|
824
870
|
const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, drawerDirName);
|
|
825
871
|
if (isDirCreated) {
|
|
826
|
-
|
|
827
|
-
if (writeFileResponse)
|
|
828
|
-
return true;
|
|
829
|
-
else
|
|
830
|
-
return false;
|
|
872
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, drawerDirPath, drawerNavigation);
|
|
831
873
|
}
|
|
832
|
-
else
|
|
833
|
-
return false;
|
|
834
874
|
}
|
|
835
|
-
|
|
875
|
+
catch (error) {
|
|
876
|
+
console.log('Error generating drawer navigation file', error);
|
|
877
|
+
}
|
|
836
878
|
}, _GenerateMobileNavigations_generateDrawerNavigations = async function _GenerateMobileNavigations_generateDrawerNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
|
|
837
879
|
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
838
880
|
const drawerDirPath = path.join(appDirPath, `/${drawerFilePath}`);
|
|
839
881
|
const hostDirPath = path.join(appDirPath, `/${hostDrawerFilePath}`);
|
|
840
|
-
const layoutSettings =
|
|
882
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
841
883
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
842
884
|
const layoutType = 'side';
|
|
843
885
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
@@ -875,36 +917,34 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
875
917
|
return -1;
|
|
876
918
|
return a?.props?.options?.priority - b?.props?.options?.priority;
|
|
877
919
|
}) ?? [];
|
|
878
|
-
|
|
879
|
-
if (
|
|
880
|
-
|
|
881
|
-
drawerConfig: drawerConfig,
|
|
882
|
-
unauthenticatedComponentPath,
|
|
883
|
-
drawerDirPath: drawerDirPath,
|
|
884
|
-
});
|
|
885
|
-
if (drawerNavigation)
|
|
920
|
+
try {
|
|
921
|
+
if (layoutSettings?.layout == 'side') {
|
|
922
|
+
if (drawerConfig) {
|
|
886
923
|
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
887
|
-
drawerConfig:
|
|
924
|
+
drawerConfig: drawerConfig,
|
|
888
925
|
unauthenticatedComponentPath,
|
|
889
|
-
drawerDirPath:
|
|
926
|
+
drawerDirPath: drawerDirPath,
|
|
890
927
|
});
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
else {
|
|
894
|
-
if (hostDrawerConfig) {
|
|
895
|
-
const isDrawerGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
928
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
896
929
|
drawerConfig: hostDrawerConfig,
|
|
897
930
|
unauthenticatedComponentPath,
|
|
898
931
|
drawerDirPath: hostDirPath,
|
|
899
932
|
});
|
|
900
|
-
return isDrawerGenerated;
|
|
901
933
|
}
|
|
902
|
-
else
|
|
903
|
-
|
|
934
|
+
else {
|
|
935
|
+
if (hostDrawerConfig) {
|
|
936
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
937
|
+
drawerConfig: hostDrawerConfig,
|
|
938
|
+
unauthenticatedComponentPath,
|
|
939
|
+
drawerDirPath: hostDirPath,
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
904
943
|
}
|
|
905
944
|
}
|
|
906
|
-
|
|
907
|
-
|
|
945
|
+
catch (error) {
|
|
946
|
+
console.log('Error generating drawer navigation', error);
|
|
947
|
+
}
|
|
908
948
|
}, _GenerateMobileNavigations_generateBottomTabNavigationsFile = async function _GenerateMobileNavigations_generateBottomTabNavigationsFile({ bottomTabConfig, unauthenticatedComponentPath, bottomDirPath, mixLayout = null, }) {
|
|
909
949
|
let moduleNumber = 0;
|
|
910
950
|
let importStatements = '';
|
|
@@ -919,6 +959,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
919
959
|
const regex = /\.(tsx|ts|jsx|js)$/i;
|
|
920
960
|
importStatements += `import * as React from 'react';\n`;
|
|
921
961
|
importStatements += `import AuthWrapper from '@admin-layout/gluestack-ui-mobile/lib/components/AuthWrapper.js';\n`;
|
|
962
|
+
importStatements += `import DynamicIcons from '@app/selectiveIcons';\n`;
|
|
922
963
|
if (unauthenticatedComponentPath)
|
|
923
964
|
importStatements += `import UnauthenticatedComponent from '${unauthenticatedComponentPath}';\n`;
|
|
924
965
|
for (const pkgRouteConfig of bottomTabConfig) {
|
|
@@ -944,10 +985,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
944
985
|
customUnauthenticatedComponentName = `UnauthenticatedComponent${moduleNumber}`;
|
|
945
986
|
customUnauthenticatedComponentNames += `${customUnauthenticatedComponentName},`;
|
|
946
987
|
}
|
|
947
|
-
const options = JSON.stringify(
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
988
|
+
const options = JSON.stringify(pkgRouteConfig?.props?.options
|
|
989
|
+
? {
|
|
990
|
+
...pkgRouteConfig.props.options,
|
|
991
|
+
headerShown: mixLayout ? false : pkgRouteConfig.props.options.headerShown,
|
|
992
|
+
}
|
|
993
|
+
: { headerShown: mixLayout ? false : true });
|
|
951
994
|
importStatements += `import Component${moduleNumber} from '${pkgRouteConfig.componentPath}';\n`;
|
|
952
995
|
moduleContent += `<Tab.Screen
|
|
953
996
|
key="${pkgRouteConfig.key}"
|
|
@@ -955,7 +998,25 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
955
998
|
//component={Component${moduleNumber}}
|
|
956
999
|
initialParams={${JSON.stringify(pkgRouteConfig?.props?.initialParams || {})}}
|
|
957
1000
|
options={{...${options},...{${pkgRouteConfig?.icon && Object.keys(pkgRouteConfig.icon)?.length && pkgRouteConfig?.icon?.name
|
|
958
|
-
? `tabBarIcon: ({ color }) =>
|
|
1001
|
+
? `tabBarIcon: ({ color }) => {
|
|
1002
|
+
const focused = color === '${pkgRouteConfig?.props?.options?.tabBarActiveTintColor}' ? true : false;
|
|
1003
|
+
const SelectedIcon = DynamicIcons('${pkgRouteConfig?.icon?.name}');
|
|
1004
|
+
return (<SelectedIcon
|
|
1005
|
+
{...{
|
|
1006
|
+
...${JSON.stringify({ ...(pkgRouteConfig?.icon?.props || {}) })},
|
|
1007
|
+
...{
|
|
1008
|
+
color:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
|
|
1009
|
+
pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
|
|
1010
|
+
:${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
|
|
1011
|
+
'grey'},
|
|
1012
|
+
stroke:focused ? ${JSON.stringify(pkgRouteConfig?.icon?.props?.color ??
|
|
1013
|
+
pkgRouteConfig?.props?.options?.tabBarActiveTintColor) ?? 'black'}
|
|
1014
|
+
:${JSON.stringify(pkgRouteConfig?.props?.options?.tabBarInactiveTintColor) ??
|
|
1015
|
+
'grey'}
|
|
1016
|
+
}
|
|
1017
|
+
}}
|
|
1018
|
+
|
|
1019
|
+
/>)}`
|
|
959
1020
|
: ''}
|
|
960
1021
|
${pkgRouteConfig?.customHeader &&
|
|
961
1022
|
Object.keys(pkgRouteConfig.customHeader)?.length &&
|
|
@@ -965,7 +1026,12 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
965
1026
|
}}}
|
|
966
1027
|
>{(props) => <AuthWrapper
|
|
967
1028
|
auth={${pkgRouteConfig?.props?.initialParams?.auth ?? false}}
|
|
968
|
-
|
|
1029
|
+
authority={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
1030
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
1031
|
+
component={<Component${moduleNumber} {...props}
|
|
1032
|
+
permissions={${JSON.stringify(pkgRouteConfig?.authority) ?? null}}
|
|
1033
|
+
extraPermissions={${JSON.stringify(pkgRouteConfig?.extraPermissions) ?? null}}
|
|
1034
|
+
/>}
|
|
969
1035
|
${pkgRouteConfig?.unauthenticatedComponent && customUnauthenticatedComponentPath
|
|
970
1036
|
? `unauthenticatedComponent={<${customUnauthenticatedComponentName}/>}`
|
|
971
1037
|
: unauthenticatedComponentPath
|
|
@@ -983,10 +1049,10 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
983
1049
|
/>}
|
|
984
1050
|
</Tab.Screen>`;
|
|
985
1051
|
}
|
|
986
|
-
if (icons && icons?.length) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
1052
|
+
// if (icons && icons?.length) {
|
|
1053
|
+
// const uniqueIcons = [...new Set(icons.split(','))].join(',');
|
|
1054
|
+
// importStatements += `import { ${uniqueIcons} } from '@expo/vector-icons';\n`;
|
|
1055
|
+
// }
|
|
990
1056
|
if (customHeaderPaths && customHeaderPaths?.length) {
|
|
991
1057
|
const uniqueHeaderNames = [...new Set(customHeaderNames.split(','))]?.filter((str) => str?.length);
|
|
992
1058
|
const uniqueHeaderPaths = [...new Set(customHeaderPaths.split(','))]?.filter((str) => str?.length);
|
|
@@ -1010,27 +1076,23 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1010
1076
|
moduleRender = `export default ({Tab,...rest}) => { return (<>${moduleContent}</>)}`;
|
|
1011
1077
|
moduleNavigation = importStatements + '\n' + moduleRender;
|
|
1012
1078
|
const bottomTabNavigator = moduleNavigation;
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1079
|
+
let bottomTabNavigation = bottomTabNavigator;
|
|
1080
|
+
bottomTabNavigation = prettier.format(bottomTabNavigation, { parser: 'babel' });
|
|
1081
|
+
const bottomDirName = path.dirname(bottomDirPath);
|
|
1082
|
+
try {
|
|
1017
1083
|
const isDirCreated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_makeDir).call(this, bottomDirName);
|
|
1018
1084
|
if (isDirCreated) {
|
|
1019
|
-
|
|
1020
|
-
if (writeFileResponse)
|
|
1021
|
-
return true;
|
|
1022
|
-
else
|
|
1023
|
-
return false;
|
|
1085
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, bottomDirPath, bottomTabNavigation);
|
|
1024
1086
|
}
|
|
1025
|
-
else
|
|
1026
|
-
return false;
|
|
1027
1087
|
}
|
|
1028
|
-
|
|
1088
|
+
catch (error) {
|
|
1089
|
+
console.log('Error generating bottom tab navigation file', error);
|
|
1090
|
+
}
|
|
1029
1091
|
}, _GenerateMobileNavigations_generateBottomTabNavigations = async function _GenerateMobileNavigations_generateBottomTabNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
|
|
1030
1092
|
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
1031
1093
|
const bottomDirPath = path.join(appDirPath, `/${bottomFilePath}`);
|
|
1032
1094
|
const hostBottomDirPath = path.join(appDirPath, `/${hostBottomFilePath}`);
|
|
1033
|
-
const layoutSettings =
|
|
1095
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
1034
1096
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
1035
1097
|
const layoutType = layoutSettings?.layout ?? 'bottom';
|
|
1036
1098
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
@@ -1070,46 +1132,44 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1070
1132
|
return -1;
|
|
1071
1133
|
return a?.props?.options?.priority - b?.props?.options?.priority;
|
|
1072
1134
|
}) ?? [];
|
|
1073
|
-
|
|
1074
|
-
if (
|
|
1075
|
-
|
|
1076
|
-
bottomTabConfig: bottomTabConfig,
|
|
1077
|
-
unauthenticatedComponentPath,
|
|
1078
|
-
bottomDirPath: bottomDirPath,
|
|
1079
|
-
mixLayout,
|
|
1080
|
-
});
|
|
1081
|
-
if (drawerNavigation)
|
|
1135
|
+
try {
|
|
1136
|
+
if (layoutType == 'bottom' || layoutType == 'mixSide') {
|
|
1137
|
+
if (bottomTabConfig) {
|
|
1082
1138
|
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1083
|
-
bottomTabConfig:
|
|
1139
|
+
bottomTabConfig: bottomTabConfig,
|
|
1084
1140
|
unauthenticatedComponentPath,
|
|
1085
|
-
bottomDirPath:
|
|
1141
|
+
bottomDirPath: bottomDirPath,
|
|
1086
1142
|
mixLayout,
|
|
1087
1143
|
});
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
else {
|
|
1091
|
-
if (hostBottomTabConfig) {
|
|
1092
|
-
const isHostGenerated = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1144
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1093
1145
|
bottomTabConfig: hostBottomTabConfig,
|
|
1094
1146
|
unauthenticatedComponentPath,
|
|
1095
1147
|
bottomDirPath: hostBottomDirPath,
|
|
1096
1148
|
mixLayout,
|
|
1097
1149
|
});
|
|
1098
|
-
return isHostGenerated;
|
|
1099
1150
|
}
|
|
1100
|
-
else
|
|
1101
|
-
|
|
1151
|
+
else {
|
|
1152
|
+
if (hostBottomTabConfig) {
|
|
1153
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1154
|
+
bottomTabConfig: hostBottomTabConfig,
|
|
1155
|
+
unauthenticatedComponentPath,
|
|
1156
|
+
bottomDirPath: hostBottomDirPath,
|
|
1157
|
+
mixLayout,
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1102
1161
|
}
|
|
1103
1162
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1163
|
+
catch (error) {
|
|
1164
|
+
console.log('Error generating bottom tab navigation', error);
|
|
1165
|
+
}
|
|
1106
1166
|
}, _GenerateMobileNavigations_generateBottomTabDrawerNavigations = async function _GenerateMobileNavigations_generateBottomTabDrawerNavigations({ appDirPath, modules, initialRouteName, unauthenticatedComponentPath }) {
|
|
1107
1167
|
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
1108
1168
|
const bottomDirPath = path.join(appDirPath, `/${bottomFilePath}`);
|
|
1109
1169
|
const hostBottomDirPath = path.join(appDirPath, `/${hostBottomFilePath}`);
|
|
1110
1170
|
const drawerDirPath = path.join(appDirPath, `/${drawerFilePath}`);
|
|
1111
1171
|
const hostDirPath = path.join(appDirPath, `/${hostDrawerFilePath}`);
|
|
1112
|
-
const layoutSettings =
|
|
1172
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
1113
1173
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
1114
1174
|
const layoutType = layoutSettings?.layout ?? 'bottom';
|
|
1115
1175
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
@@ -1172,52 +1232,55 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1172
1232
|
return a?.props?.options?.priority - b?.props?.options?.priority;
|
|
1173
1233
|
}) ?? [];
|
|
1174
1234
|
if (bottomTabConfig) {
|
|
1175
|
-
|
|
1176
|
-
bottomTabConfig: bottomTabConfig,
|
|
1177
|
-
unauthenticatedComponentPath,
|
|
1178
|
-
bottomDirPath: bottomDirPath,
|
|
1179
|
-
mixLayout,
|
|
1180
|
-
});
|
|
1181
|
-
if (drawerNavigation)
|
|
1235
|
+
try {
|
|
1182
1236
|
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1183
|
-
bottomTabConfig:
|
|
1237
|
+
bottomTabConfig: bottomTabConfig,
|
|
1184
1238
|
unauthenticatedComponentPath,
|
|
1185
|
-
bottomDirPath:
|
|
1239
|
+
bottomDirPath: bottomDirPath,
|
|
1186
1240
|
mixLayout,
|
|
1187
1241
|
});
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
drawerConfig: drawerConfig,
|
|
1242
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigationsFile).call(this, {
|
|
1243
|
+
bottomTabConfig: hostBottomTabConfig,
|
|
1191
1244
|
unauthenticatedComponentPath,
|
|
1192
|
-
|
|
1245
|
+
bottomDirPath: hostBottomDirPath,
|
|
1246
|
+
mixLayout,
|
|
1193
1247
|
});
|
|
1194
|
-
if (
|
|
1248
|
+
if (drawerConfig) {
|
|
1249
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
1250
|
+
drawerConfig: drawerConfig,
|
|
1251
|
+
unauthenticatedComponentPath,
|
|
1252
|
+
drawerDirPath: drawerDirPath,
|
|
1253
|
+
});
|
|
1195
1254
|
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigationsFile).call(this, {
|
|
1196
1255
|
drawerConfig: hostDrawerConfig,
|
|
1197
1256
|
unauthenticatedComponentPath,
|
|
1198
1257
|
drawerDirPath: hostDirPath,
|
|
1199
1258
|
});
|
|
1200
|
-
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
catch (error) {
|
|
1262
|
+
console.log('Error in generating drawer bottom tab navigation', error);
|
|
1201
1263
|
}
|
|
1202
|
-
else
|
|
1203
|
-
return true;
|
|
1204
1264
|
}
|
|
1205
|
-
else
|
|
1206
|
-
return false;
|
|
1207
1265
|
}, _GenerateMobileNavigations_generateAppNavigationFile = async function _GenerateMobileNavigations_generateAppNavigationFile({ appDirPath, customTabBarPath, customDrawerPath, customHeaderPath }) {
|
|
1208
1266
|
const navigationDirPath = path.join(appDirPath, `/${appNavigationFileName}`);
|
|
1209
|
-
const layoutSettings =
|
|
1267
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
1210
1268
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
1211
1269
|
const layoutType = layoutSettings?.layout || 'bottom';
|
|
1212
1270
|
const layoutRouteConfig = layoutConfigFileData[layoutType];
|
|
1213
1271
|
const layoutRouteKey = Object.keys(layoutRouteConfig)[1];
|
|
1214
1272
|
const appLayout = layoutRouteConfig[layoutRouteKey];
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
|
|
1273
|
+
const initialRouteNameRootStack = __classPrivateFieldGet(this, _GenerateMobileNavigations_initialRouteNameRootStack, "f");
|
|
1274
|
+
const layoutInitialRouteName = __classPrivateFieldGet(this, _GenerateMobileNavigations_initialRouteName, "f");
|
|
1275
|
+
const initialRouteName = layoutInitialRouteName
|
|
1276
|
+
? layoutInitialRouteName
|
|
1277
|
+
: layoutType === 'mixSide'
|
|
1278
|
+
? appLayout?.[appLayout?.key]?.props?.initialRouteName ?? 'MainStack.Layout.Home'
|
|
1279
|
+
: appLayout?.props?.initialRouteName || 'MainStack.Home';
|
|
1218
1280
|
const isShowTabs = layoutType === 'mixSide' || layoutType === 'bottom' ? true : false;
|
|
1219
1281
|
const isShowDefalutHeader = layoutType === 'mixSide' ? true : false;
|
|
1220
1282
|
const defaultHeaderProps = {
|
|
1283
|
+
...(layoutSettings || {}),
|
|
1221
1284
|
showToggle: layoutSettings?.topLeftToggle || false,
|
|
1222
1285
|
right: layoutSettings?.topRightSettingToggle || false,
|
|
1223
1286
|
};
|
|
@@ -1266,7 +1329,9 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1266
1329
|
}`
|
|
1267
1330
|
: ''}
|
|
1268
1331
|
}})}
|
|
1269
|
-
${customDrawerPath
|
|
1332
|
+
${customDrawerPath
|
|
1333
|
+
? 'drawerContent={(props) => <CustomDrawerContent {...props} {...defaultHeaderProps || {}} />}'
|
|
1334
|
+
: ''}
|
|
1270
1335
|
>
|
|
1271
1336
|
{settings?.layout == 'host-bottom' ? hostDrawerNavigations({ Drawer }) : drawerNavigations({ Drawer })}
|
|
1272
1337
|
</Drawer.Navigator>
|
|
@@ -1397,7 +1462,7 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1397
1462
|
appComponent += `
|
|
1398
1463
|
const AppNavigations = () => {
|
|
1399
1464
|
return (
|
|
1400
|
-
<Stack.Navigator initialRouteName="${
|
|
1465
|
+
<Stack.Navigator initialRouteName="${initialRouteNameRootStack}">
|
|
1401
1466
|
<Stack.Screen
|
|
1402
1467
|
name="MainStack"
|
|
1403
1468
|
options={{ headerShown: false }}
|
|
@@ -1412,11 +1477,108 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1412
1477
|
`;
|
|
1413
1478
|
appNavigation = importStatements + '\n' + rootComponent + '\n' + appComponent;
|
|
1414
1479
|
appNavigation = prettier.format(appNavigation, { parser: 'babel' });
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1480
|
+
try {
|
|
1481
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_writeFile).call(this, navigationDirPath, appNavigation);
|
|
1482
|
+
}
|
|
1483
|
+
catch (error) {
|
|
1484
|
+
console.log('Error in generating app navigationfile', error);
|
|
1485
|
+
}
|
|
1486
|
+
}, _GenerateMobileNavigations_generateSelectiveIconsFile = async function _GenerateMobileNavigations_generateSelectiveIconsFile({ appDirPath, modules }) {
|
|
1487
|
+
const mainRoutes = path.join(appDirPath, `/${mainRoutesFileName}`);
|
|
1488
|
+
const modulesRouteConfig = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getModulesRouteConfig).call(this, { modules: modules });
|
|
1489
|
+
const mainRouteConfig = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_readJsonFile).call(this, mainRoutes);
|
|
1490
|
+
const allRoutes = [...[mainRouteConfig ?? []], ...(modulesRouteConfig ?? [])];
|
|
1491
|
+
let iconNames = [];
|
|
1492
|
+
allRoutes?.flat(1)?.forEach((route) => {
|
|
1493
|
+
const key = Object.keys(route)[0];
|
|
1494
|
+
const value = route[key];
|
|
1495
|
+
if (value?.icon && typeof value.icon === 'object') {
|
|
1496
|
+
if (typeof value.icon.name === 'string') {
|
|
1497
|
+
if (!iconNames.includes(value.icon.name))
|
|
1498
|
+
iconNames.push(value.icon.name);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
else if (value?.icon && typeof value.icon === 'string') {
|
|
1502
|
+
if (!iconNames.includes(value.icon))
|
|
1503
|
+
iconNames.push(value.icon);
|
|
1504
|
+
}
|
|
1505
|
+
if (value?.extraIcons && Array.isArray(value.extraIcons) && value?.extraIcons?.length > 0) {
|
|
1506
|
+
value?.extraIcons?.map((icon) => {
|
|
1507
|
+
if (typeof icon === 'string') {
|
|
1508
|
+
if (!iconNames.includes(icon))
|
|
1509
|
+
iconNames.push(icon);
|
|
1510
|
+
}
|
|
1511
|
+
else {
|
|
1512
|
+
console.warn(`Invalid icon type: ${typeof icon}`);
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
else if (value?.extraIcons && typeof value.extraIcons === 'string') {
|
|
1517
|
+
if (!iconNames.includes(value.extraIcons))
|
|
1518
|
+
iconNames.push(value.extraIcons);
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
const iconsRepository = __classPrivateFieldGet(this, _GenerateMobileNavigations_iconsRepository, "f");
|
|
1522
|
+
const expoIcons = [
|
|
1523
|
+
'AntDesign',
|
|
1524
|
+
'Entypo',
|
|
1525
|
+
'EvilIcons',
|
|
1526
|
+
'Feather',
|
|
1527
|
+
'FontAwesome',
|
|
1528
|
+
'FontAwesome5',
|
|
1529
|
+
'Fontisto',
|
|
1530
|
+
'Foundation',
|
|
1531
|
+
'Ionicons',
|
|
1532
|
+
'MaterialCommunityIcons',
|
|
1533
|
+
'MaterialIcons',
|
|
1534
|
+
'Octicons',
|
|
1535
|
+
'SimpleLineIcons',
|
|
1536
|
+
'Zocial',
|
|
1537
|
+
];
|
|
1538
|
+
let content = `
|
|
1539
|
+
function __variableDynamicIcon(icon) {
|
|
1540
|
+
switch (icon) {
|
|
1541
|
+
`;
|
|
1542
|
+
iconNames.forEach((name) => {
|
|
1543
|
+
let prefix, iconName;
|
|
1544
|
+
if (name.includes('.')) {
|
|
1545
|
+
[prefix, iconName] = name.split('.');
|
|
1546
|
+
}
|
|
1547
|
+
if (prefix && iconsRepository[prefix]) {
|
|
1548
|
+
const importPath = iconsRepository[prefix].replace('{iconName}', prefix === 'expo' ? iconName : iconName + '.native');
|
|
1549
|
+
// prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
|
|
1550
|
+
content += `
|
|
1551
|
+
case '${prefix + '.' + iconName}':
|
|
1552
|
+
return require('${importPath}')?.default;
|
|
1553
|
+
`;
|
|
1554
|
+
}
|
|
1555
|
+
else {
|
|
1556
|
+
content += `
|
|
1557
|
+
case '${name}':
|
|
1558
|
+
return ${expoIcons.includes(name)
|
|
1559
|
+
? `require('@expo/vector-icons/${name}.js')?.default`
|
|
1560
|
+
: `require('@expo/vector-icons/FontAwesome.js')?.default;`};
|
|
1561
|
+
`;
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
content += `
|
|
1565
|
+
default:
|
|
1566
|
+
console.warn('Sorry, the icon named "', icon, '" could not be found in "@react-icon/all-files" and "@app/icons". Please check again.');
|
|
1567
|
+
return require('@expo/vector-icons/FontAwesome.js')?.default;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
export default function(icon) {
|
|
1571
|
+
return __variableDynamicIcon(icon);
|
|
1572
|
+
}
|
|
1573
|
+
`;
|
|
1574
|
+
const rootPath = process.cwd();
|
|
1575
|
+
const fileName = `selectiveIcons.js`;
|
|
1576
|
+
const newFilePath = path.join(rootPath, 'app', fileName);
|
|
1577
|
+
// Ensure the directory exists
|
|
1578
|
+
if (!fs.existsSync(path.dirname(newFilePath))) {
|
|
1579
|
+
fs.mkdirSync(path.dirname(newFilePath), { recursive: true });
|
|
1580
|
+
}
|
|
1581
|
+
fs.writeFileSync(newFilePath, content, 'utf8');
|
|
1420
1582
|
}, _GenerateMobileNavigations_setLayoutAndGenerateNavigation = async function _GenerateMobileNavigations_setLayoutAndGenerateNavigation() {
|
|
1421
1583
|
const appDirPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
|
|
1422
1584
|
const modules = __classPrivateFieldGet(this, _GenerateMobileNavigations_modules, "f");
|
|
@@ -1426,108 +1588,146 @@ _GenerateMobileNavigations_layoutSettings = new WeakMap(), _GenerateMobileNaviga
|
|
|
1426
1588
|
const customDrawerPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customDrawerPath, "f");
|
|
1427
1589
|
const customHeaderPath = __classPrivateFieldGet(this, _GenerateMobileNavigations_customHeaderPath, "f");
|
|
1428
1590
|
const i18Options = __classPrivateFieldGet(this, _GenerateMobileNavigations_i18Options, "f");
|
|
1429
|
-
const layoutSettings =
|
|
1591
|
+
const layoutSettings = process.env.LAYOUT_SETTINGS ? JSON.parse(process.env.LAYOUT_SETTINGS) : null;
|
|
1430
1592
|
const layoutConfigFileData = await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_getLayoutConfig).call(this);
|
|
1431
1593
|
const layoutType = layoutSettings?.layout || 'bottom';
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
// appDirPath,
|
|
1436
|
-
// modules,
|
|
1437
|
-
// initialRouteName,
|
|
1438
|
-
// });
|
|
1594
|
+
try {
|
|
1595
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppRoutesJson).call(this);
|
|
1596
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateSelectiveIconsFile).call(this, { appDirPath, modules });
|
|
1439
1597
|
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateMainRoutes).call(this, {
|
|
1440
1598
|
appDirPath,
|
|
1441
1599
|
i18Options,
|
|
1442
1600
|
initialRouteName,
|
|
1443
1601
|
});
|
|
1444
|
-
|
|
1602
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateApp).call(this, {
|
|
1445
1603
|
appDirPath,
|
|
1446
1604
|
i18Options,
|
|
1447
1605
|
initialRouteName,
|
|
1448
1606
|
});
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
appDirPath,
|
|
1511
|
-
customTabBarPath,
|
|
1512
|
-
customDrawerPath,
|
|
1513
|
-
customHeaderPath,
|
|
1514
|
-
});
|
|
1515
|
-
if (appNavigationGenerated)
|
|
1516
|
-
return appNavigationGenerated;
|
|
1517
|
-
else
|
|
1518
|
-
return true;
|
|
1519
|
-
}
|
|
1520
|
-
else
|
|
1521
|
-
return false;
|
|
1522
|
-
}
|
|
1607
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateStackNavigations).call(this, {
|
|
1608
|
+
appDirPath,
|
|
1609
|
+
modules,
|
|
1610
|
+
initialRouteName,
|
|
1611
|
+
unauthenticatedComponentPath,
|
|
1612
|
+
});
|
|
1613
|
+
if (layoutType == 'side') {
|
|
1614
|
+
try {
|
|
1615
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateDrawerNavigations).call(this, {
|
|
1616
|
+
appDirPath,
|
|
1617
|
+
modules,
|
|
1618
|
+
initialRouteName,
|
|
1619
|
+
unauthenticatedComponentPath,
|
|
1620
|
+
});
|
|
1621
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
|
|
1622
|
+
appDirPath,
|
|
1623
|
+
customTabBarPath,
|
|
1624
|
+
customDrawerPath,
|
|
1625
|
+
customHeaderPath,
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
catch (error) {
|
|
1629
|
+
console.log('Error in generating side navigation', error);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
else if (layoutType == 'bottom' || layoutType == 'host-bottom') {
|
|
1633
|
+
try {
|
|
1634
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabNavigations).call(this, {
|
|
1635
|
+
appDirPath,
|
|
1636
|
+
modules,
|
|
1637
|
+
initialRouteName,
|
|
1638
|
+
unauthenticatedComponentPath,
|
|
1639
|
+
});
|
|
1640
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
|
|
1641
|
+
appDirPath,
|
|
1642
|
+
customTabBarPath,
|
|
1643
|
+
customDrawerPath,
|
|
1644
|
+
customHeaderPath,
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
catch (error) {
|
|
1648
|
+
console.log('Error in generating bottom navigation', error);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
else {
|
|
1652
|
+
try {
|
|
1653
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateBottomTabDrawerNavigations).call(this, {
|
|
1654
|
+
appDirPath,
|
|
1655
|
+
modules,
|
|
1656
|
+
initialRouteName,
|
|
1657
|
+
unauthenticatedComponentPath,
|
|
1658
|
+
});
|
|
1659
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_generateAppNavigationFile).call(this, {
|
|
1660
|
+
appDirPath,
|
|
1661
|
+
customTabBarPath,
|
|
1662
|
+
customDrawerPath,
|
|
1663
|
+
customHeaderPath,
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
catch (error) {
|
|
1667
|
+
console.log('Error in generating drawer bottom navigation', error);
|
|
1523
1668
|
}
|
|
1524
|
-
else
|
|
1525
|
-
return false;
|
|
1526
1669
|
}
|
|
1527
|
-
else
|
|
1528
|
-
return false;
|
|
1529
1670
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1671
|
+
catch (error) {
|
|
1672
|
+
console.log('Error generating app navigations', error);
|
|
1673
|
+
}
|
|
1674
|
+
}, _GenerateMobileNavigations_performCopyOperations = async function _GenerateMobileNavigations_performCopyOperations() {
|
|
1675
|
+
const config = __classPrivateFieldGet(this, _GenerateMobileNavigations_configFileData, "f");
|
|
1676
|
+
try {
|
|
1677
|
+
await performCopyOperations(config);
|
|
1678
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_setLayoutAndGenerateNavigation).call(this);
|
|
1679
|
+
}
|
|
1680
|
+
catch (error) {
|
|
1681
|
+
console.error('PerformCopyOperations error:', error);
|
|
1682
|
+
}
|
|
1683
|
+
}, _GenerateMobileNavigations_deleteDirectoryRecursive = async function _GenerateMobileNavigations_deleteDirectoryRecursive(dirPath) {
|
|
1684
|
+
if (fs.existsSync(dirPath)) {
|
|
1685
|
+
const files = fs.readdirSync(dirPath);
|
|
1686
|
+
for (const file of files) {
|
|
1687
|
+
const curPath = path.join(dirPath, file);
|
|
1688
|
+
if (fs.lstatSync(curPath).isDirectory()) {
|
|
1689
|
+
// Recursively delete subdirectories
|
|
1690
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_deleteDirectoryRecursive).call(this, curPath);
|
|
1691
|
+
}
|
|
1692
|
+
else {
|
|
1693
|
+
// Delete files
|
|
1694
|
+
fs.unlinkSync(curPath);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
// Delete the directory itself
|
|
1698
|
+
fs.rmdirSync(dirPath);
|
|
1699
|
+
}
|
|
1700
|
+
}, _GenerateMobileNavigations_createAppDirectory = async function _GenerateMobileNavigations_createAppDirectory() {
|
|
1701
|
+
const appDir = __classPrivateFieldGet(this, _GenerateMobileNavigations_appDirPath, "f");
|
|
1702
|
+
try {
|
|
1703
|
+
// Check if the directory exists
|
|
1704
|
+
if (fs.existsSync(appDir)) {
|
|
1705
|
+
console.log('Directory exists. Recreating it...');
|
|
1706
|
+
// Delete the directory and its contents
|
|
1707
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_deleteDirectoryRecursive).call(this, appDir);
|
|
1708
|
+
}
|
|
1709
|
+
// Create the directory
|
|
1710
|
+
fs.mkdirSync(appDir);
|
|
1711
|
+
console.log('Directory created');
|
|
1712
|
+
// Add 'app' to .gitignore if not already present
|
|
1713
|
+
const gitignorePath = path.resolve(appDir, '.gitignore');
|
|
1714
|
+
let gitignoreContent = '';
|
|
1715
|
+
if (fs.existsSync(gitignorePath)) {
|
|
1716
|
+
gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
|
|
1717
|
+
}
|
|
1718
|
+
else {
|
|
1719
|
+
fs.writeFileSync(gitignorePath, '');
|
|
1720
|
+
console.log('Created .gitignore file');
|
|
1721
|
+
}
|
|
1722
|
+
if (!gitignoreContent.includes('*')) {
|
|
1723
|
+
fs.appendFileSync(gitignorePath, '*\n');
|
|
1724
|
+
console.log('Added "*" to .gitignore');
|
|
1725
|
+
}
|
|
1726
|
+
await __classPrivateFieldGet(this, _GenerateMobileNavigations_instances, "m", _GenerateMobileNavigations_performCopyOperations).call(this);
|
|
1727
|
+
}
|
|
1728
|
+
catch (error) {
|
|
1729
|
+
console.error('Error creating app directory:', error);
|
|
1730
|
+
}
|
|
1532
1731
|
};
|
|
1732
|
+
export default GenerateMobileNavigations;
|
|
1533
1733
|
//# sourceMappingURL=generateMobileNavigations.js.map
|