@umituz/react-native-design-system 1.0.6 → 1.1.1

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": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "Universal design system for React Native apps - Domain-Driven Design architecture with Material Design 3 components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -31,7 +31,8 @@
31
31
  "react-native-reanimated": "~3.10.1",
32
32
  "@react-native-community/datetimepicker": "8.0.1",
33
33
  "@expo/vector-icons": "^14.0.0",
34
- "lucide-react-native": "^0.468.0"
34
+ "lucide-react-native": "^0.468.0",
35
+ "zustand": "^5.0.2"
35
36
  },
36
37
  "peerDependenciesMeta": {
37
38
  "@react-native-community/datetimepicker": {
package/src/index.ts CHANGED
@@ -343,3 +343,12 @@ export {
343
343
  getOnboardingDescriptionMarginTop,
344
344
  DeviceType,
345
345
  } from './presentation/utils/responsive';
346
+
347
+ // =============================================================================
348
+ // THEME MANAGEMENT - Global Theme Store
349
+ // =============================================================================
350
+
351
+ export {
352
+ useDesignSystemTheme,
353
+ type ThemeMode,
354
+ } from './infrastructure/theme/globalThemeStore';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Global Theme Store for Design System
3
+ *
4
+ * Minimal Zustand store for theme state management.
5
+ * Apps can sync their theme state with this global store.
6
+ *
7
+ * WHY THIS EXISTS:
8
+ * - ScreenLayout needs to know current theme mode
9
+ * - Without prop drilling or Context API
10
+ * - Single source of truth for design system components
11
+ * - Apps control theme, design system reacts
12
+ *
13
+ * USAGE IN APP:
14
+ * ```typescript
15
+ * import { useDesignSystemTheme } from '@umituz/react-native-design-system';
16
+ * import { useTheme } from '@domains/theme';
17
+ *
18
+ * // Sync app theme with design system
19
+ * const { themeMode } = useTheme();
20
+ * const { setThemeMode } = useDesignSystemTheme();
21
+ *
22
+ * useEffect(() => {
23
+ * setThemeMode(themeMode);
24
+ * }, [themeMode]);
25
+ * ```
26
+ */
27
+
28
+ import { create } from 'zustand';
29
+
30
+ export type ThemeMode = 'light' | 'dark';
31
+
32
+ interface GlobalThemeStore {
33
+ /** Current theme mode */
34
+ themeMode: ThemeMode;
35
+
36
+ /** Update theme mode (called by app when theme changes) */
37
+ setThemeMode: (mode: ThemeMode) => void;
38
+ }
39
+
40
+ /**
41
+ * Global theme store for design system components
42
+ *
43
+ * This is a MINIMAL store - app has the real theme logic.
44
+ * Design system just mirrors the current theme for its components.
45
+ */
46
+ export const useDesignSystemTheme = create<GlobalThemeStore>((set) => ({
47
+ themeMode: 'light',
48
+ setThemeMode: (mode: ThemeMode) => set({ themeMode: mode }),
49
+ }));
@@ -1,19 +1,17 @@
1
1
  /**
2
2
  * useAppDesignTokens Hook - Theme-Aware Design Tokens
3
3
  *
4
- * ✅ Accepts optional themeMode parameter
5
- * ✅ Returns tokens for specified theme (light/dark)
6
- * ✅ Apps control theme, package provides tokens
4
+ * ✅ Automatically reads theme from global store
5
+ * ✅ No parameters needed - fully automatic!
6
+ * ✅ Returns tokens for current theme (light/dark)
7
7
  * ✅ Single source of truth
8
8
  *
9
- * @param themeMode - Optional theme mode ('light' | 'dark'), defaults to 'light'
10
- *
11
- * @example Basic usage (light theme)
9
+ * @example Usage (fully automatic theme-aware)
12
10
  * ```typescript
13
11
  * import { useAppDesignTokens } from '@umituz/react-native-design-system';
14
12
  *
15
13
  * const MyComponent = () => {
16
- * const tokens = useAppDesignTokens(); // Uses light theme by default
14
+ * const tokens = useAppDesignTokens(); // Automatically uses current theme!
17
15
  * return (
18
16
  * <View style={{
19
17
  * backgroundColor: tokens.colors.primary,
@@ -25,29 +23,18 @@
25
23
  * };
26
24
  * ```
27
25
  *
28
- * @example Theme-aware usage
29
- * ```typescript
30
- * import { useAppDesignTokens } from '@umituz/react-native-design-system';
31
- * import { useTheme } from '@domains/theme';
32
- *
33
- * const MyComponent = () => {
34
- * const { themeMode } = useTheme(); // Get theme from app's theme system
35
- * const tokens = useAppDesignTokens(themeMode); // Pass theme to hook
36
- *
37
- * return (
38
- * <View style={{ backgroundColor: tokens.colors.background }}>
39
- * <Text style={{ color: tokens.colors.textPrimary }}>
40
- * This text color changes with theme!
41
- * </Text>
42
- * </View>
43
- * );
44
- * };
45
- * ```
26
+ * How it works:
27
+ * - Reads themeMode from global store (useDesignSystemTheme)
28
+ * - App's theme store syncs to global store automatically
29
+ * - All components get correct tokens without prop drilling
30
+ * - Change theme once, everything updates!
46
31
  */
47
32
 
48
33
  import { useMemo } from 'react';
49
- import { createDesignTokens, type DesignTokens, type ThemeMode } from '../tokens/core/TokenFactory';
34
+ import { createDesignTokens, type DesignTokens } from '../tokens/core/TokenFactory';
35
+ import { useDesignSystemTheme } from '../../infrastructure/theme/globalThemeStore';
50
36
 
51
- export const useAppDesignTokens = (themeMode: ThemeMode = 'light'): DesignTokens => {
37
+ export const useAppDesignTokens = (): DesignTokens => {
38
+ const { themeMode } = useDesignSystemTheme();
52
39
  return useMemo(() => createDesignTokens(themeMode), [themeMode]);
53
40
  };
@@ -30,7 +30,6 @@ import { View, ScrollView, StyleSheet, ViewStyle } from 'react-native';
30
30
  import { SafeAreaView, Edge } from 'react-native-safe-area-context';
31
31
  import { useAppDesignTokens } from '../hooks/useAppDesignTokens';
32
32
  import { LoadingState } from '../loading/presentation/components/LoadingState';
33
- import type { ThemeMode } from '../tokens/core/TokenFactory';
34
33
 
35
34
  export interface ScreenLayoutProps {
36
35
  /**
@@ -113,11 +112,6 @@ export interface ScreenLayoutProps {
113
112
  */
114
113
  keyboardAvoiding?: boolean;
115
114
 
116
- /**
117
- * Theme mode for design tokens (default: 'light')
118
- * Pass 'dark' for dark mode styling
119
- */
120
- themeMode?: ThemeMode;
121
115
  }
122
116
 
123
117
  export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
@@ -135,9 +129,9 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
135
129
  testID,
136
130
  hideScrollIndicator = false,
137
131
  keyboardAvoiding = false,
138
- themeMode = 'light',
139
132
  }) => {
140
- const tokens = useAppDesignTokens(themeMode);
133
+ // Automatically uses current theme from global store
134
+ const tokens = useAppDesignTokens();
141
135
  const styles = useMemo(() => getStyles(tokens), [tokens]);
142
136
 
143
137
  const bgColor = backgroundColor || tokens.colors.backgroundPrimary;