@umituz/react-native-design-system 2.5.26 → 2.5.27
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.5.
|
|
3
|
+
"version": "2.5.27",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import type { ParamListBase } from "@react-navigation/native";
|
|
4
|
+
import { AtomicIcon } from "../../../atoms/AtomicIcon";
|
|
5
|
+
import { useAppDesignTokens } from "../../../theme";
|
|
6
|
+
import { useSafeAreaInsets } from "../../../safe-area";
|
|
7
|
+
import type { TabNavigatorConfig, TabScreen } from "../types";
|
|
8
|
+
|
|
9
|
+
export interface UseTabConfigProps<T extends ParamListBase> {
|
|
10
|
+
config: TabNavigatorConfig<T>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useTabConfig = <T extends ParamListBase>({ config }: UseTabConfigProps<T>) => {
|
|
14
|
+
const tokens = useAppDesignTokens();
|
|
15
|
+
const insets = useSafeAreaInsets();
|
|
16
|
+
|
|
17
|
+
const finalConfig: TabNavigatorConfig<T> = useMemo(
|
|
18
|
+
() => ({
|
|
19
|
+
...config,
|
|
20
|
+
renderIcon: (
|
|
21
|
+
iconName: string,
|
|
22
|
+
focused: boolean,
|
|
23
|
+
routeName: string,
|
|
24
|
+
isFab: boolean,
|
|
25
|
+
) => {
|
|
26
|
+
// If user provided a custom renderer, use it
|
|
27
|
+
if (config.renderIcon) {
|
|
28
|
+
return config.renderIcon(iconName, focused, routeName, isFab);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const screen = config.screens.find(s => s.name === routeName);
|
|
32
|
+
const fabConfig = config.fabConfig;
|
|
33
|
+
|
|
34
|
+
if (isFab) {
|
|
35
|
+
const size = fabConfig?.size ?? 84;
|
|
36
|
+
return (
|
|
37
|
+
<View
|
|
38
|
+
style={{
|
|
39
|
+
width: size,
|
|
40
|
+
height: size,
|
|
41
|
+
borderRadius: size / 2,
|
|
42
|
+
backgroundColor: tokens.colors.primary,
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
alignItems: "center",
|
|
45
|
+
marginTop: fabConfig?.offsetY ?? -32,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<AtomicIcon
|
|
49
|
+
name={iconName}
|
|
50
|
+
svgPath={screen?.svgPath}
|
|
51
|
+
customSize={size * 0.57} // Approx 48/84 ratio
|
|
52
|
+
customColor="#FFFFFF"
|
|
53
|
+
/>
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<AtomicIcon
|
|
60
|
+
name={iconName}
|
|
61
|
+
customColor={
|
|
62
|
+
focused ? tokens.colors.primary : tokens.colors.textSecondary
|
|
63
|
+
}
|
|
64
|
+
size="lg"
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
screenOptions: {
|
|
69
|
+
tabBarActiveTintColor: tokens.colors.primary,
|
|
70
|
+
tabBarInactiveTintColor: tokens.colors.textSecondary,
|
|
71
|
+
tabBarShowLabel: false,
|
|
72
|
+
tabBarIconStyle: {
|
|
73
|
+
marginBottom: 0,
|
|
74
|
+
},
|
|
75
|
+
tabBarStyle: {
|
|
76
|
+
backgroundColor: tokens.colors.surface,
|
|
77
|
+
borderTopColor: tokens.colors.borderLight,
|
|
78
|
+
borderTopWidth: 0,
|
|
79
|
+
paddingBottom: insets.bottom || 0,
|
|
80
|
+
height: tokens.spacing.tabBarHeight + (insets.bottom || 16),
|
|
81
|
+
},
|
|
82
|
+
headerStyle: {
|
|
83
|
+
backgroundColor: tokens.colors.surface,
|
|
84
|
+
borderBottomColor: tokens.colors.borderLight,
|
|
85
|
+
borderBottomWidth: 1,
|
|
86
|
+
},
|
|
87
|
+
headerTitleStyle: {
|
|
88
|
+
fontSize: 18,
|
|
89
|
+
fontWeight: "600",
|
|
90
|
+
color: tokens.colors.textPrimary,
|
|
91
|
+
},
|
|
92
|
+
headerTintColor: tokens.colors.textPrimary,
|
|
93
|
+
...(typeof config.screenOptions === 'object' ? config.screenOptions : {}),
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
[tokens, config, insets],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return finalConfig;
|
|
100
|
+
};
|
|
@@ -32,6 +32,7 @@ export type { StackNavigationOptions } from "@react-navigation/stack";
|
|
|
32
32
|
export { AppNavigation } from "./utils/AppNavigation";
|
|
33
33
|
export { TabLabel, type TabLabelProps } from "./components/TabLabel";
|
|
34
34
|
export { useTabBarStyles, type TabBarConfig } from "./hooks/useTabBarStyles";
|
|
35
|
+
export { useTabConfig, type UseTabConfigProps } from "./hooks/useTabConfig";
|
|
35
36
|
|
|
36
37
|
// Navigation Theme
|
|
37
38
|
export { createNavigationTheme } from "./utils/NavigationTheme";
|
|
@@ -49,6 +49,8 @@ export interface TabScreen<T extends ParamListBase = ParamListBase>
|
|
|
49
49
|
options?:
|
|
50
50
|
| BottomTabNavigationOptions
|
|
51
51
|
| ((props: BottomTabScreenProps<T>) => BottomTabNavigationOptions);
|
|
52
|
+
/** Custom SVG path for the icon */
|
|
53
|
+
svgPath?: string;
|
|
52
54
|
/** Whether the tab should be visible */
|
|
53
55
|
visible?: boolean;
|
|
54
56
|
}
|