@idealyst/navigation 1.0.76 → 1.0.78
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/navigation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.78",
|
|
4
4
|
"description": "Cross-platform navigation library for React and React Native",
|
|
5
5
|
"readme": "README.md",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"publish:npm": "npm publish"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@idealyst/components": "^1.0.
|
|
42
|
-
"@idealyst/theme": "^1.0.
|
|
41
|
+
"@idealyst/components": "^1.0.78",
|
|
42
|
+
"@idealyst/theme": "^1.0.78",
|
|
43
43
|
"@react-navigation/bottom-tabs": "^7.0.0",
|
|
44
44
|
"@react-navigation/drawer": "^7.0.0",
|
|
45
45
|
"@react-navigation/native": "^7.0.0",
|
package/src/context/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const buildNavigator = (params: NavigatorParam, parentPath = '') => {
|
|
|
16
16
|
<NavigatorType.Navigator screenOptions={{
|
|
17
17
|
headerShown: params.options?.headerShown
|
|
18
18
|
}}>
|
|
19
|
-
{params.routes.map((child) => buildScreen(child, NavigatorType))}
|
|
19
|
+
{params.routes.map((child, index) => buildScreen(child, NavigatorType, parentPath, index))}
|
|
20
20
|
</NavigatorType.Navigator>
|
|
21
21
|
)
|
|
22
22
|
}
|
|
@@ -43,11 +43,33 @@ const getNavigatorType = (params: NavigatorParam) => {
|
|
|
43
43
|
* @param parentPath
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
|
-
const buildScreen = (params: RouteParam, Navigator: TypedNavigator, parentPath = '') => {
|
|
46
|
+
const buildScreen = (params: RouteParam, Navigator: TypedNavigator, parentPath = '', index: number) => {
|
|
47
|
+
// Build the full path by combining parent path with current route path
|
|
48
|
+
// Handle root paths properly to avoid double slashes
|
|
49
|
+
let fullPath: string;
|
|
50
|
+
if (!parentPath || parentPath === '/') {
|
|
51
|
+
// If no parent path or parent is root, use the route path directly
|
|
52
|
+
fullPath = params.path;
|
|
53
|
+
} else {
|
|
54
|
+
// For nested routes, combine parent path with route path
|
|
55
|
+
// Remove leading slash from route path to avoid double slashes
|
|
56
|
+
const routePath = params.path.startsWith('/') ? params.path.slice(1) : params.path;
|
|
57
|
+
fullPath = `${parentPath}/${routePath}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('📱 Registering screen:', {
|
|
61
|
+
originalPath: params.path,
|
|
62
|
+
parentPath,
|
|
63
|
+
fullPath,
|
|
64
|
+
type: params.type,
|
|
65
|
+
screenName: fullPath
|
|
66
|
+
});
|
|
67
|
+
|
|
47
68
|
return (
|
|
48
69
|
<Navigator.Screen
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
key={`${fullPath}-${index}`}
|
|
71
|
+
name={fullPath}
|
|
72
|
+
component={params.type === 'screen' ? params.component : buildNavigator(params, fullPath)}
|
|
51
73
|
options={params.options}
|
|
52
74
|
/>
|
|
53
75
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { NavigatorParam, RouteParam, TabNavigatorParam, StackNavigatorParam } from './types'
|
|
3
|
-
import { DefaultTabLayout } from '../layouts/DefaultTabLayout'
|
|
4
2
|
import { DefaultStackLayout } from '../layouts/DefaultStackLayout'
|
|
3
|
+
import { DefaultTabLayout } from '../layouts/DefaultTabLayout'
|
|
4
|
+
import { NavigatorParam, StackNavigatorParam, TabNavigatorParam } from './types'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Build the Web navigator using custom layout components
|
|
@@ -44,7 +44,7 @@ const buildFullPath = (parentPath: string, childPath: string): string => {
|
|
|
44
44
|
|
|
45
45
|
const normalizedParent = parentPath === '/' ? '' : parentPath
|
|
46
46
|
const normalizedChild = normalizePath(childPath)
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
return `${normalizedParent}${normalizedChild}`
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -164,7 +164,7 @@ const StackNavigator: React.FC<{ params: StackNavigatorParam; parentPath: string
|
|
|
164
164
|
const navigatorRoute = params.routes.find(route => {
|
|
165
165
|
if (route.type === 'navigator') {
|
|
166
166
|
const fullRoutePath = buildFullPath(parentPath, route.path)
|
|
167
|
-
return currentPath.startsWith(fullRoutePath)
|
|
167
|
+
return currentPath.startsWith(fullRoutePath + '/') || currentPath === fullRoutePath
|
|
168
168
|
}
|
|
169
169
|
return false
|
|
170
170
|
})
|