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

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.0",
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
+ }));
@@ -30,6 +30,7 @@ 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 { useDesignSystemTheme } from '../../infrastructure/theme/globalThemeStore';
33
34
  import type { ThemeMode } from '../tokens/core/TokenFactory';
34
35
 
35
36
  export interface ScreenLayoutProps {
@@ -114,8 +115,9 @@ export interface ScreenLayoutProps {
114
115
  keyboardAvoiding?: boolean;
115
116
 
116
117
  /**
117
- * Theme mode for design tokens (default: 'light')
118
- * Pass 'dark' for dark mode styling
118
+ * Theme mode for design tokens
119
+ * If not provided, uses global theme from useDesignSystemTheme()
120
+ * Apps should sync their theme with the global store instead of passing this prop
119
121
  */
120
122
  themeMode?: ThemeMode;
121
123
  }
@@ -135,9 +137,13 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
135
137
  testID,
136
138
  hideScrollIndicator = false,
137
139
  keyboardAvoiding = false,
138
- themeMode = 'light',
140
+ themeMode,
139
141
  }) => {
140
- const tokens = useAppDesignTokens(themeMode);
142
+ // Use global theme if themeMode prop not provided
143
+ const { themeMode: globalTheme } = useDesignSystemTheme();
144
+ const effectiveTheme = themeMode ?? globalTheme;
145
+
146
+ const tokens = useAppDesignTokens(effectiveTheme);
141
147
  const styles = useMemo(() => getStyles(tokens), [tokens]);
142
148
 
143
149
  const bgColor = backgroundColor || tokens.colors.backgroundPrimary;