@umituz/react-native-design-system 2.5.26 → 2.5.28

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.26",
3
+ "version": "2.5.28",
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,103 @@
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 } from "../types";
8
+
9
+ export interface UseTabConfigProps<T extends ParamListBase> {
10
+ config: TabNavigatorConfig<T>;
11
+ }
12
+
13
+ export const useTabConfig = <T extends ParamListBase>({
14
+ config,
15
+ }: UseTabConfigProps<T>) => {
16
+ const tokens = useAppDesignTokens();
17
+ const insets = useSafeAreaInsets();
18
+
19
+ const finalConfig: TabNavigatorConfig<T> = useMemo(() => {
20
+ return {
21
+ ...config,
22
+ renderIcon: (
23
+ iconName: string,
24
+ focused: boolean,
25
+ routeName: string,
26
+ isFab: boolean,
27
+ ) => {
28
+ // If user provided a custom renderer, use it
29
+ if (config.renderIcon) {
30
+ return config.renderIcon(iconName, focused, routeName, isFab);
31
+ }
32
+
33
+ const screen = config.screens.find((s) => s.name === routeName);
34
+ const fabConfig = config.fabConfig;
35
+
36
+ if (isFab) {
37
+ const size = fabConfig?.size ?? 84;
38
+ return (
39
+ <View
40
+ style={{
41
+ width: size,
42
+ height: size,
43
+ borderRadius: size / 2,
44
+ backgroundColor: tokens.colors.primary,
45
+ justifyContent: "center",
46
+ alignItems: "center",
47
+ marginTop: fabConfig?.offsetY ?? -32,
48
+ }}
49
+ >
50
+ <AtomicIcon
51
+ name={iconName}
52
+ svgPath={screen?.svgPath}
53
+ customSize={size * 0.57} // Approx 48/84 ratio
54
+ customColor="#FFFFFF"
55
+ />
56
+ </View>
57
+ );
58
+ }
59
+
60
+ return (
61
+ <AtomicIcon
62
+ name={iconName}
63
+ customColor={
64
+ focused ? tokens.colors.primary : tokens.colors.textSecondary
65
+ }
66
+ size="lg"
67
+ />
68
+ );
69
+ },
70
+ screenOptions: {
71
+ tabBarActiveTintColor: tokens.colors.primary,
72
+ tabBarInactiveTintColor: tokens.colors.textSecondary,
73
+ tabBarShowLabel: false,
74
+ tabBarIconStyle: {
75
+ marginBottom: 0,
76
+ },
77
+ tabBarStyle: {
78
+ backgroundColor: tokens.colors.surface,
79
+ borderTopColor: tokens.colors.borderLight,
80
+ borderTopWidth: 0,
81
+ paddingBottom: insets.bottom || 0,
82
+ height: tokens.spacing.tabBarHeight + (insets.bottom || 16),
83
+ },
84
+ headerStyle: {
85
+ backgroundColor: tokens.colors.surface,
86
+ borderBottomColor: tokens.colors.borderLight,
87
+ borderBottomWidth: 1,
88
+ },
89
+ headerTitleStyle: {
90
+ fontSize: 18,
91
+ fontWeight: "600",
92
+ color: tokens.colors.textPrimary,
93
+ },
94
+ headerTintColor: tokens.colors.textPrimary,
95
+ ...(typeof config.screenOptions === "object"
96
+ ? config.screenOptions
97
+ : {}),
98
+ },
99
+ };
100
+ }, [tokens, config, insets]);
101
+
102
+ return finalConfig;
103
+ };
@@ -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
  }