@umituz/react-native-design-system 2.9.1 → 2.9.2
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": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.2",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, and onboarding utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -26,8 +26,10 @@ export function StackNavigator<T extends ParamListBase>({ config }: StackNavigat
|
|
|
26
26
|
try {
|
|
27
27
|
NavigationValidator.validateScreens(config.screens, "stack");
|
|
28
28
|
NavigationValidator.validateInitialRoute(config.initialRouteName, config.screens);
|
|
29
|
-
} catch {
|
|
30
|
-
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (__DEV__) {
|
|
31
|
+
console.error('[StackNavigator] Validation failed:', error);
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const { screens } = config;
|
|
@@ -32,8 +32,10 @@ export function TabsNavigator<T extends ParamListBase>({
|
|
|
32
32
|
config.initialRouteName,
|
|
33
33
|
config.screens
|
|
34
34
|
);
|
|
35
|
-
} catch {
|
|
36
|
-
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (__DEV__) {
|
|
37
|
+
console.error('[TabsNavigator] Validation failed:', error);
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
// Memoize filtered screens
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { useNavigation } from "@react-navigation/native";
|
|
2
2
|
import type { NavigationProp, ParamListBase } from "@react-navigation/native";
|
|
3
|
+
import { AppNavigation } from "../utils/AppNavigation";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* useAppNavigation Hook
|
|
6
7
|
*
|
|
7
|
-
* A wrapper around React Navigation's useNavigation hook.
|
|
8
|
-
* Standardizes navigation usage across all packages and apps
|
|
8
|
+
* A unified wrapper around React Navigation's useNavigation hook.
|
|
9
|
+
* Standardizes navigation usage across all packages and apps by
|
|
10
|
+
* providing a consistent interface that bridges static and hook-based navigation.
|
|
9
11
|
*/
|
|
10
|
-
export function useAppNavigation<T extends ParamListBase>()
|
|
11
|
-
|
|
12
|
+
export function useAppNavigation<T extends ParamListBase>() {
|
|
13
|
+
const navigation = useNavigation<NavigationProp<T>>();
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
...navigation,
|
|
17
|
+
// Standardized actions using the global AppNavigation utility for consistency
|
|
18
|
+
goBack: () => AppNavigation.goBack(),
|
|
19
|
+
navigate: (name: any, params?: any) => AppNavigation.navigate(name, params),
|
|
20
|
+
push: (name: any, params?: any) => AppNavigation.push(name, params),
|
|
21
|
+
replace: (name: any, params?: any) => AppNavigation.replace(name, params),
|
|
22
|
+
reset: (name: any, params?: any) => AppNavigation.reset(name, params),
|
|
23
|
+
pop: (count?: number) => AppNavigation.pop(count),
|
|
24
|
+
popToTop: () => AppNavigation.popToTop(),
|
|
25
|
+
} as NavigationProp<T> & {
|
|
26
|
+
push: (name: string, params?: object) => void;
|
|
27
|
+
replace: (name: string, params?: object) => void;
|
|
28
|
+
reset: (name: string, params?: object) => void;
|
|
29
|
+
pop: (count?: number) => void;
|
|
30
|
+
popToTop: () => void;
|
|
31
|
+
};
|
|
12
32
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { NavigationContainerRef, CommonActions, StackActions } from '@react-navigation/native';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* AppNavigation - Global Navigation Utility
|
|
5
|
+
*
|
|
6
|
+
* Provides static access to navigation methods from anywhere in the app.
|
|
7
|
+
* Must be initialized with setRef in the root NavigationContainer.
|
|
8
|
+
*/
|
|
3
9
|
export class AppNavigation {
|
|
4
10
|
private static navigationRef: NavigationContainerRef<any> | null = null;
|
|
5
11
|
|
|
6
12
|
static setRef(ref: NavigationContainerRef<any> | null): void {
|
|
13
|
+
if (__DEV__) {
|
|
14
|
+
console.log('[AppNavigation] Setting navigation ref', !!ref);
|
|
15
|
+
}
|
|
7
16
|
this.navigationRef = ref;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use setRef instead
|
|
12
|
-
*/
|
|
13
|
-
static setNavigationRef(ref: NavigationContainerRef<any> | null): void {
|
|
14
|
-
this.setRef(ref);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
19
|
static getRef(): NavigationContainerRef<any> | null {
|
|
18
20
|
return this.navigationRef;
|
|
19
21
|
}
|
|
@@ -27,24 +29,36 @@ export class AppNavigation {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
static navigate(name: string, params?: object): void {
|
|
32
|
+
if (__DEV__) {
|
|
33
|
+
console.log('[AppNavigation] Navigating to:', name, params);
|
|
34
|
+
}
|
|
30
35
|
if (this.navigationRef?.isReady()) {
|
|
31
36
|
this.navigationRef.navigate(name, params);
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
static push(name: string, params?: object): void {
|
|
41
|
+
if (__DEV__) {
|
|
42
|
+
console.log('[AppNavigation] Pushing:', name, params);
|
|
43
|
+
}
|
|
36
44
|
if (this.navigationRef?.isReady()) {
|
|
37
45
|
this.navigationRef.dispatch(StackActions.push(name, params));
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
static goBack(): void {
|
|
50
|
+
if (__DEV__) {
|
|
51
|
+
console.log('[AppNavigation] Going back');
|
|
52
|
+
}
|
|
42
53
|
if (this.navigationRef?.isReady() && this.navigationRef.canGoBack()) {
|
|
43
54
|
this.navigationRef.goBack();
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
static reset(name: string, params?: object): void {
|
|
59
|
+
if (__DEV__) {
|
|
60
|
+
console.log('[AppNavigation] Resetting to:', name, params);
|
|
61
|
+
}
|
|
48
62
|
if (this.navigationRef?.isReady()) {
|
|
49
63
|
this.navigationRef.dispatch(
|
|
50
64
|
CommonActions.reset({
|
|
@@ -56,18 +70,27 @@ export class AppNavigation {
|
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
static replace(name: string, params?: object): void {
|
|
73
|
+
if (__DEV__) {
|
|
74
|
+
console.log('[AppNavigation] Replacing with:', name, params);
|
|
75
|
+
}
|
|
59
76
|
if (this.navigationRef?.isReady()) {
|
|
60
77
|
this.navigationRef.dispatch(StackActions.replace(name, params));
|
|
61
78
|
}
|
|
62
79
|
}
|
|
63
80
|
|
|
64
81
|
static navigateToNested(parentParams: { screen: string; params?: any }): void {
|
|
82
|
+
if (__DEV__) {
|
|
83
|
+
console.log('[AppNavigation] Navigating to nested:', parentParams);
|
|
84
|
+
}
|
|
65
85
|
if (this.navigationRef?.isReady()) {
|
|
66
86
|
this.navigationRef.navigate(parentParams.screen, parentParams.params);
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
|
|
70
90
|
static navigateToParent(name: string, params?: object): void {
|
|
91
|
+
if (__DEV__) {
|
|
92
|
+
console.log('[AppNavigation] Navigating to parent:', name, params);
|
|
93
|
+
}
|
|
71
94
|
if (this.navigationRef?.isReady()) {
|
|
72
95
|
const parent = this.navigationRef.getParent();
|
|
73
96
|
if (parent) {
|
|
@@ -77,12 +100,18 @@ export class AppNavigation {
|
|
|
77
100
|
}
|
|
78
101
|
|
|
79
102
|
static popToTop(): void {
|
|
103
|
+
if (__DEV__) {
|
|
104
|
+
console.log('[AppNavigation] Popping to top');
|
|
105
|
+
}
|
|
80
106
|
if (this.navigationRef?.isReady()) {
|
|
81
107
|
this.navigationRef.dispatch(StackActions.popToTop());
|
|
82
108
|
}
|
|
83
109
|
}
|
|
84
110
|
|
|
85
111
|
static pop(count: number = 1): void {
|
|
112
|
+
if (__DEV__) {
|
|
113
|
+
console.log('[AppNavigation] Popping:', count);
|
|
114
|
+
}
|
|
86
115
|
if (this.navigationRef?.isReady()) {
|
|
87
116
|
this.navigationRef.dispatch(StackActions.pop(count));
|
|
88
117
|
}
|
|
@@ -113,6 +142,9 @@ export class AppNavigation {
|
|
|
113
142
|
}
|
|
114
143
|
|
|
115
144
|
static closeModal(): void {
|
|
145
|
+
if (__DEV__) {
|
|
146
|
+
console.log('[AppNavigation] Closing modal');
|
|
147
|
+
}
|
|
116
148
|
if (this.navigationRef?.isReady()) {
|
|
117
149
|
const parent = this.navigationRef.getParent();
|
|
118
150
|
if (parent?.canGoBack()) {
|