@gv-tech/ui-native 2.25.0 → 2.25.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": "@gv-tech/ui-native",
3
- "version": "2.25.0",
3
+ "version": "2.25.2",
4
4
  "description": "React Native implementations of the GV Tech design system components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,8 +1,8 @@
1
1
  import { theme as designTokens } from '@gv-tech/design-tokens';
2
- import { useColorScheme } from 'nativewind';
2
+ import { useColorScheme } from 'react-native';
3
3
 
4
4
  export function useTheme() {
5
- const { colorScheme, setColorScheme } = useColorScheme();
5
+ const colorScheme = useColorScheme();
6
6
 
7
7
  const resolvedTheme = colorScheme as 'light' | 'dark';
8
8
 
@@ -11,7 +11,6 @@ export function useTheme() {
11
11
 
12
12
  return {
13
13
  theme: colorScheme,
14
- setTheme: setColorScheme,
15
14
  resolvedTheme,
16
15
  tokens: activeTokens,
17
16
  };
@@ -1,9 +1,24 @@
1
- import { useColorScheme } from 'nativewind';
2
1
  import * as React from 'react';
3
- import { View } from 'react-native';
2
+ import { View, ViewProps } from 'react-native';
3
+ import { useTheme } from './hooks/use-theme';
4
4
  import { cn } from './lib/utils';
5
5
 
6
- export function ThemeProvider({ children, className }: { children: React.ReactNode; className?: string }) {
7
- const { colorScheme } = useColorScheme();
8
- return <View className={cn('flex-1', colorScheme === 'dark' ? 'dark' : '', className)}>{children}</View>;
6
+ export interface ThemeProviderProps extends ViewProps {
7
+ children: React.ReactNode;
8
+ [key: string]: unknown;
9
+ }
10
+
11
+ export function ThemeProvider({ children, className, style, ...props }: ThemeProviderProps) {
12
+ const { theme, tokens } = useTheme();
13
+ const isDark = theme === 'dark';
14
+
15
+ return (
16
+ <View
17
+ className={cn('flex-1', isDark ? 'dark' : '', className)}
18
+ style={[{ backgroundColor: tokens.background }, style]}
19
+ {...props}
20
+ >
21
+ {children}
22
+ </View>
23
+ );
9
24
  }
@@ -1,6 +1,6 @@
1
1
  import { ThemeToggleBaseProps } from '@gv-tech/ui-core';
2
2
  import { Moon, Sun, SunMoon } from 'lucide-react-native';
3
- import { View } from 'react-native';
3
+ import { Appearance, View } from 'react-native';
4
4
  import { Button } from './button';
5
5
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './dropdown-menu';
6
6
  import { useTheme } from './hooks/use-theme';
@@ -15,12 +15,12 @@ iconWithClassName(SunMoon);
15
15
  export type ThemeToggleProps = ThemeToggleBaseProps;
16
16
 
17
17
  export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, className }: ThemeToggleProps) {
18
- const { theme, setTheme, resolvedTheme } = useTheme();
18
+ const { theme, resolvedTheme } = useTheme();
19
19
 
20
20
  const currentTheme = (customTheme ?? theme) as 'light' | 'dark' | 'system';
21
21
 
22
22
  // Determine the effective theme for icon rendering
23
- const effectiveTheme = customTheme ? customTheme : resolvedTheme;
23
+ const effectiveTheme = customTheme === 'system' || !customTheme ? resolvedTheme : customTheme;
24
24
  const isDark = effectiveTheme === 'dark';
25
25
  const isSystem = currentTheme === 'system';
26
26
 
@@ -28,7 +28,12 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
28
28
  if (onThemeChange) {
29
29
  onThemeChange(newTheme);
30
30
  } else {
31
- setTheme(newTheme as 'light' | 'dark');
31
+ if (newTheme === 'system') {
32
+ // @ts-expect-error React Native Appearance.setColorScheme accepts null to reset to system theme
33
+ Appearance.setColorScheme(null);
34
+ } else {
35
+ Appearance.setColorScheme(newTheme);
36
+ }
32
37
  }
33
38
  };
34
39
 
@@ -37,7 +42,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
37
42
  <View
38
43
  className={cn(
39
44
  'items-center justify-center transition-all',
40
- !isSystem && !isDark ? 'scale-100 rotate-0 opacity-100' : 'absolute scale-0 -rotate-90 opacity-0',
45
+ !isSystem && !isDark ? 'rotate-0 opacity-100' : 'absolute -rotate-90 opacity-0',
41
46
  )}
42
47
  >
43
48
  <Sun size={18} className="text-foreground" />
@@ -45,7 +50,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
45
50
  <View
46
51
  className={cn(
47
52
  'items-center justify-center transition-all',
48
- !isSystem && isDark ? 'scale-100 rotate-0 opacity-100' : 'absolute scale-0 rotate-90 opacity-0',
53
+ !isSystem && isDark ? 'rotate-0 opacity-100' : 'absolute rotate-90 opacity-0',
49
54
  )}
50
55
  >
51
56
  <Moon size={18} className="text-foreground" />
@@ -53,7 +58,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
53
58
  <View
54
59
  className={cn(
55
60
  'items-center justify-center transition-all',
56
- isSystem ? 'scale-100 rotate-0 opacity-100' : 'absolute scale-0 rotate-90 opacity-0',
61
+ isSystem ? 'rotate-0 opacity-100' : 'absolute rotate-90 opacity-0',
57
62
  )}
58
63
  >
59
64
  <SunMoon size={18} className="text-foreground" />