@highbeek/create-rnstarterkit 1.0.2-beta.2 → 1.0.2-beta.3
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/dist/bin/create-rnstarterkit.js +6 -0
- package/dist/src/generators/appGenerator.js +3 -1
- package/dist/templates/cli-base/.bundle/config +2 -0
- package/dist/templates/cli-base/.eslintrc.js +4 -0
- package/dist/templates/cli-base/.prettierrc.js +5 -0
- package/dist/templates/cli-base/.watchmanconfig +1 -0
- package/dist/templates/cli-base/App.tsx +45 -0
- package/dist/templates/cli-base/Gemfile +16 -0
- package/dist/templates/cli-base/Gemfile.lock +169 -0
- package/dist/templates/cli-base/README.md +97 -0
- package/dist/templates/cli-base/__tests__/App.test.tsx +13 -0
- package/dist/templates/cli-base/android/app/build.gradle +119 -0
- package/dist/templates/cli-base/android/app/debug.keystore +0 -0
- package/dist/templates/cli-base/android/app/proguard-rules.pro +10 -0
- package/dist/templates/cli-base/android/app/src/main/AndroidManifest.xml +27 -0
- package/dist/templates/cli-base/android/app/src/main/java/com/baseapp/MainActivity.kt +22 -0
- package/dist/templates/cli-base/android/app/src/main/java/com/baseapp/MainApplication.kt +27 -0
- package/dist/templates/cli-base/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/dist/templates/cli-base/android/app/src/main/res/values/strings.xml +3 -0
- package/dist/templates/cli-base/android/app/src/main/res/values/styles.xml +9 -0
- package/dist/templates/cli-base/android/build.gradle +21 -0
- package/dist/templates/cli-base/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/dist/templates/cli-base/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/dist/templates/cli-base/android/gradle.properties +44 -0
- package/dist/templates/cli-base/android/gradlew +251 -0
- package/dist/templates/cli-base/android/gradlew.bat +99 -0
- package/dist/templates/cli-base/android/settings.gradle +6 -0
- package/dist/templates/cli-base/app.json +4 -0
- package/dist/templates/cli-base/babel.config.js +3 -0
- package/dist/templates/cli-base/index.js +9 -0
- package/dist/templates/cli-base/ios/.xcode.env +11 -0
- package/dist/templates/cli-base/ios/BaseApp/AppDelegate.swift +48 -0
- package/dist/templates/cli-base/ios/BaseApp/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/dist/templates/cli-base/ios/BaseApp/Images.xcassets/Contents.json +6 -0
- package/dist/templates/cli-base/ios/BaseApp/Info.plist +60 -0
- package/dist/templates/cli-base/ios/BaseApp/LaunchScreen.storyboard +47 -0
- package/dist/templates/cli-base/ios/BaseApp/PrivacyInfo.xcprivacy +37 -0
- package/dist/templates/cli-base/ios/BaseApp.xcodeproj/project.pbxproj +494 -0
- package/dist/templates/cli-base/ios/BaseApp.xcodeproj/xcshareddata/xcschemes/BaseApp.xcscheme +88 -0
- package/dist/templates/cli-base/ios/BaseApp.xcworkspace/contents.xcworkspacedata +10 -0
- package/dist/templates/cli-base/ios/Podfile +34 -0
- package/dist/templates/cli-base/ios/Podfile.lock +2165 -0
- package/dist/templates/cli-base/jest.config.js +3 -0
- package/dist/templates/cli-base/metro.config.js +11 -0
- package/dist/templates/cli-base/package-lock.json +11859 -0
- package/dist/templates/cli-base/package.json +41 -0
- package/dist/templates/cli-base/tsconfig.json +8 -0
- package/dist/templates/expo-base/.vscode/extensions.json +1 -0
- package/dist/templates/expo-base/.vscode/settings.json +7 -0
- package/dist/templates/expo-base/README.md +50 -0
- package/dist/templates/expo-base/app/(tabs)/_layout.tsx +35 -0
- package/dist/templates/expo-base/app/(tabs)/explore.tsx +112 -0
- package/dist/templates/expo-base/app/(tabs)/index.tsx +98 -0
- package/dist/templates/expo-base/app/_layout.tsx +24 -0
- package/dist/templates/expo-base/app/modal.tsx +29 -0
- package/dist/templates/expo-base/app.json +48 -0
- package/dist/templates/expo-base/assets/images/android-icon-background.png +0 -0
- package/dist/templates/expo-base/assets/images/android-icon-foreground.png +0 -0
- package/dist/templates/expo-base/assets/images/android-icon-monochrome.png +0 -0
- package/dist/templates/expo-base/assets/images/favicon.png +0 -0
- package/dist/templates/expo-base/assets/images/icon.png +0 -0
- package/dist/templates/expo-base/assets/images/partial-react-logo.png +0 -0
- package/dist/templates/expo-base/assets/images/react-logo.png +0 -0
- package/dist/templates/expo-base/assets/images/react-logo@2x.png +0 -0
- package/dist/templates/expo-base/assets/images/react-logo@3x.png +0 -0
- package/dist/templates/expo-base/assets/images/splash-icon.png +0 -0
- package/dist/templates/expo-base/components/external-link.tsx +25 -0
- package/dist/templates/expo-base/components/haptic-tab.tsx +18 -0
- package/dist/templates/expo-base/components/hello-wave.tsx +19 -0
- package/dist/templates/expo-base/components/parallax-scroll-view.tsx +79 -0
- package/dist/templates/expo-base/components/themed-text.tsx +60 -0
- package/dist/templates/expo-base/components/themed-view.tsx +14 -0
- package/dist/templates/expo-base/components/ui/collapsible.tsx +45 -0
- package/dist/templates/expo-base/components/ui/icon-symbol.ios.tsx +32 -0
- package/dist/templates/expo-base/components/ui/icon-symbol.tsx +41 -0
- package/dist/templates/expo-base/constants/theme.ts +53 -0
- package/dist/templates/expo-base/eslint.config.js +10 -0
- package/dist/templates/expo-base/hooks/use-color-scheme.ts +1 -0
- package/dist/templates/expo-base/hooks/use-color-scheme.web.ts +21 -0
- package/dist/templates/expo-base/hooks/use-theme-color.ts +21 -0
- package/dist/templates/expo-base/package-lock.json +12916 -0
- package/dist/templates/expo-base/package.json +47 -0
- package/dist/templates/expo-base/scripts/reset-project.js +112 -0
- package/dist/templates/expo-base/tsconfig.json +17 -0
- package/dist/templates/optional/apiClient/api/client.ts +86 -0
- package/dist/templates/optional/apiClient/api/index.ts +1 -0
- package/dist/templates/optional/apiClient/config/env.cli.ts +5 -0
- package/dist/templates/optional/apiClient/config/env.expo.ts +4 -0
- package/dist/templates/optional/apiClient/config/env.ts +1 -0
- package/dist/templates/optional/apiClient/env.d.ts +3 -0
- package/dist/templates/optional/auth-context/api/authApi.ts +14 -0
- package/dist/templates/optional/auth-context/context/AuthContext.tsx +47 -0
- package/dist/templates/optional/auth-context/navigation/ProtectedStack.tsx +38 -0
- package/dist/templates/optional/auth-context/navigation/cli/BottomTabs.tsx +17 -0
- package/dist/templates/optional/auth-context/navigation/expo/BottomTabs.tsx +29 -0
- package/dist/templates/optional/auth-context/screens/HomeScreen.tsx +14 -0
- package/dist/templates/optional/auth-context/screens/LoginScreen.tsx +28 -0
- package/dist/templates/optional/auth-context/screens/ProfileScreen.tsx +10 -0
- package/dist/templates/optional/auth-context/screens/RegisterScreen.tsx +28 -0
- package/dist/templates/optional/auth-context/screens/SettingsScreen.tsx +10 -0
- package/dist/templates/optional/auth-context/utils/storage.ts +13 -0
- package/dist/templates/optional/auth-redux/api/authApi.ts +14 -0
- package/dist/templates/optional/auth-redux/navigation/ProtectedStack.tsx +30 -0
- package/dist/templates/optional/auth-redux/navigation/cli/BottomTabs.tsx +17 -0
- package/dist/templates/optional/auth-redux/navigation/expo/BottomTabs.tsx +31 -0
- package/dist/templates/optional/auth-redux/screens/HomeScreen.tsx +15 -0
- package/dist/templates/optional/auth-redux/screens/LoginScreen.tsx +29 -0
- package/dist/templates/optional/auth-redux/screens/ProfileScreen.tsx +14 -0
- package/dist/templates/optional/auth-redux/screens/RegisterScreen.tsx +14 -0
- package/dist/templates/optional/auth-redux/screens/SettingsScreen.tsx +14 -0
- package/dist/templates/optional/auth-redux/store/authSlice.ts +25 -0
- package/dist/templates/optional/auth-redux/store/store.ts +11 -0
- package/dist/templates/optional/auth-zustand/api/authApi.ts +14 -0
- package/dist/templates/optional/auth-zustand/navigation/BottomTabs.tsx +1 -0
- package/dist/templates/optional/auth-zustand/navigation/ProtectedStack.tsx +44 -0
- package/dist/templates/optional/auth-zustand/navigation/cli/BottomTabs.tsx +17 -0
- package/dist/templates/optional/auth-zustand/navigation/expo/BottomTabs.tsx +31 -0
- package/dist/templates/optional/auth-zustand/screens/HomeScreen.tsx +14 -0
- package/dist/templates/optional/auth-zustand/screens/LoginScreen.tsx +28 -0
- package/dist/templates/optional/auth-zustand/screens/ProfileScreen.tsx +10 -0
- package/dist/templates/optional/auth-zustand/screens/RegisterScreen.tsx +28 -0
- package/dist/templates/optional/auth-zustand/screens/SettingsScreen.tsx +10 -0
- package/dist/templates/optional/auth-zustand/store/authStore.ts +30 -0
- package/dist/templates/optional/auth-zustand/utils/storage.ts +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StyleSheet, Text, type TextProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { useThemeColor } from '@/hooks/use-theme-color';
|
|
4
|
+
|
|
5
|
+
export type ThemedTextProps = TextProps & {
|
|
6
|
+
lightColor?: string;
|
|
7
|
+
darkColor?: string;
|
|
8
|
+
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function ThemedText({
|
|
12
|
+
style,
|
|
13
|
+
lightColor,
|
|
14
|
+
darkColor,
|
|
15
|
+
type = 'default',
|
|
16
|
+
...rest
|
|
17
|
+
}: ThemedTextProps) {
|
|
18
|
+
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Text
|
|
22
|
+
style={[
|
|
23
|
+
{ color },
|
|
24
|
+
type === 'default' ? styles.default : undefined,
|
|
25
|
+
type === 'title' ? styles.title : undefined,
|
|
26
|
+
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
|
27
|
+
type === 'subtitle' ? styles.subtitle : undefined,
|
|
28
|
+
type === 'link' ? styles.link : undefined,
|
|
29
|
+
style,
|
|
30
|
+
]}
|
|
31
|
+
{...rest}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
default: {
|
|
38
|
+
fontSize: 16,
|
|
39
|
+
lineHeight: 24,
|
|
40
|
+
},
|
|
41
|
+
defaultSemiBold: {
|
|
42
|
+
fontSize: 16,
|
|
43
|
+
lineHeight: 24,
|
|
44
|
+
fontWeight: '600',
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
fontSize: 32,
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
lineHeight: 32,
|
|
50
|
+
},
|
|
51
|
+
subtitle: {
|
|
52
|
+
fontSize: 20,
|
|
53
|
+
fontWeight: 'bold',
|
|
54
|
+
},
|
|
55
|
+
link: {
|
|
56
|
+
lineHeight: 30,
|
|
57
|
+
fontSize: 16,
|
|
58
|
+
color: '#0a7ea4',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { View, type ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { useThemeColor } from '@/hooks/use-theme-color';
|
|
4
|
+
|
|
5
|
+
export type ThemedViewProps = ViewProps & {
|
|
6
|
+
lightColor?: string;
|
|
7
|
+
darkColor?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
|
|
11
|
+
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
|
|
12
|
+
|
|
13
|
+
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PropsWithChildren, useState } from 'react';
|
|
2
|
+
import { StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { ThemedText } from '@/components/themed-text';
|
|
5
|
+
import { ThemedView } from '@/components/themed-view';
|
|
6
|
+
import { IconSymbol } from '@/components/ui/icon-symbol';
|
|
7
|
+
import { Colors } from '@/constants/theme';
|
|
8
|
+
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
9
|
+
|
|
10
|
+
export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const theme = useColorScheme() ?? 'light';
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ThemedView>
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={styles.heading}
|
|
18
|
+
onPress={() => setIsOpen((value) => !value)}
|
|
19
|
+
activeOpacity={0.8}>
|
|
20
|
+
<IconSymbol
|
|
21
|
+
name="chevron.right"
|
|
22
|
+
size={18}
|
|
23
|
+
weight="medium"
|
|
24
|
+
color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
|
|
25
|
+
style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<ThemedText type="defaultSemiBold">{title}</ThemedText>
|
|
29
|
+
</TouchableOpacity>
|
|
30
|
+
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
|
|
31
|
+
</ThemedView>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
heading: {
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
gap: 6,
|
|
40
|
+
},
|
|
41
|
+
content: {
|
|
42
|
+
marginTop: 6,
|
|
43
|
+
marginLeft: 24,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export function IconSymbol({
|
|
5
|
+
name,
|
|
6
|
+
size = 24,
|
|
7
|
+
color,
|
|
8
|
+
style,
|
|
9
|
+
weight = 'regular',
|
|
10
|
+
}: {
|
|
11
|
+
name: SymbolViewProps['name'];
|
|
12
|
+
size?: number;
|
|
13
|
+
color: string;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
weight?: SymbolWeight;
|
|
16
|
+
}) {
|
|
17
|
+
return (
|
|
18
|
+
<SymbolView
|
|
19
|
+
weight={weight}
|
|
20
|
+
tintColor={color}
|
|
21
|
+
resizeMode="scaleAspectFit"
|
|
22
|
+
name={name}
|
|
23
|
+
style={[
|
|
24
|
+
{
|
|
25
|
+
width: size,
|
|
26
|
+
height: size,
|
|
27
|
+
},
|
|
28
|
+
style,
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Fallback for using MaterialIcons on Android and web.
|
|
2
|
+
|
|
3
|
+
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
4
|
+
import { SymbolWeight, SymbolViewProps } from 'expo-symbols';
|
|
5
|
+
import { ComponentProps } from 'react';
|
|
6
|
+
import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
|
|
7
|
+
|
|
8
|
+
type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof MaterialIcons>['name']>;
|
|
9
|
+
type IconSymbolName = keyof typeof MAPPING;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Add your SF Symbols to Material Icons mappings here.
|
|
13
|
+
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
|
|
14
|
+
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
|
|
15
|
+
*/
|
|
16
|
+
const MAPPING = {
|
|
17
|
+
'house.fill': 'home',
|
|
18
|
+
'paperplane.fill': 'send',
|
|
19
|
+
'chevron.left.forwardslash.chevron.right': 'code',
|
|
20
|
+
'chevron.right': 'chevron-right',
|
|
21
|
+
} as IconMapping;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
|
|
25
|
+
* This ensures a consistent look across platforms, and optimal resource usage.
|
|
26
|
+
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
|
|
27
|
+
*/
|
|
28
|
+
export function IconSymbol({
|
|
29
|
+
name,
|
|
30
|
+
size = 24,
|
|
31
|
+
color,
|
|
32
|
+
style,
|
|
33
|
+
}: {
|
|
34
|
+
name: IconSymbolName;
|
|
35
|
+
size?: number;
|
|
36
|
+
color: string | OpaqueColorValue;
|
|
37
|
+
style?: StyleProp<TextStyle>;
|
|
38
|
+
weight?: SymbolWeight;
|
|
39
|
+
}) {
|
|
40
|
+
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
|
|
41
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Below are the colors that are used in the app. The colors are defined in the light and dark mode.
|
|
3
|
+
* There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Platform } from 'react-native';
|
|
7
|
+
|
|
8
|
+
const tintColorLight = '#0a7ea4';
|
|
9
|
+
const tintColorDark = '#fff';
|
|
10
|
+
|
|
11
|
+
export const Colors = {
|
|
12
|
+
light: {
|
|
13
|
+
text: '#11181C',
|
|
14
|
+
background: '#fff',
|
|
15
|
+
tint: tintColorLight,
|
|
16
|
+
icon: '#687076',
|
|
17
|
+
tabIconDefault: '#687076',
|
|
18
|
+
tabIconSelected: tintColorLight,
|
|
19
|
+
},
|
|
20
|
+
dark: {
|
|
21
|
+
text: '#ECEDEE',
|
|
22
|
+
background: '#151718',
|
|
23
|
+
tint: tintColorDark,
|
|
24
|
+
icon: '#9BA1A6',
|
|
25
|
+
tabIconDefault: '#9BA1A6',
|
|
26
|
+
tabIconSelected: tintColorDark,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Fonts = Platform.select({
|
|
31
|
+
ios: {
|
|
32
|
+
/** iOS `UIFontDescriptorSystemDesignDefault` */
|
|
33
|
+
sans: 'system-ui',
|
|
34
|
+
/** iOS `UIFontDescriptorSystemDesignSerif` */
|
|
35
|
+
serif: 'ui-serif',
|
|
36
|
+
/** iOS `UIFontDescriptorSystemDesignRounded` */
|
|
37
|
+
rounded: 'ui-rounded',
|
|
38
|
+
/** iOS `UIFontDescriptorSystemDesignMonospaced` */
|
|
39
|
+
mono: 'ui-monospace',
|
|
40
|
+
},
|
|
41
|
+
default: {
|
|
42
|
+
sans: 'normal',
|
|
43
|
+
serif: 'serif',
|
|
44
|
+
rounded: 'normal',
|
|
45
|
+
mono: 'monospace',
|
|
46
|
+
},
|
|
47
|
+
web: {
|
|
48
|
+
sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
49
|
+
serif: "Georgia, 'Times New Roman', serif",
|
|
50
|
+
rounded: "'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Meiryo, 'MS PGothic', sans-serif",
|
|
51
|
+
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useColorScheme } from 'react-native';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useColorScheme as useRNColorScheme } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* To support static rendering, this value needs to be re-calculated on the client side for web
|
|
6
|
+
*/
|
|
7
|
+
export function useColorScheme() {
|
|
8
|
+
const [hasHydrated, setHasHydrated] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setHasHydrated(true);
|
|
12
|
+
}, []);
|
|
13
|
+
|
|
14
|
+
const colorScheme = useRNColorScheme();
|
|
15
|
+
|
|
16
|
+
if (hasHydrated) {
|
|
17
|
+
return colorScheme;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return 'light';
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learn more about light and dark modes:
|
|
3
|
+
* https://docs.expo.dev/guides/color-schemes/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Colors } from '@/constants/theme';
|
|
7
|
+
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
8
|
+
|
|
9
|
+
export function useThemeColor(
|
|
10
|
+
props: { light?: string; dark?: string },
|
|
11
|
+
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
|
|
12
|
+
) {
|
|
13
|
+
const theme = useColorScheme() ?? 'light';
|
|
14
|
+
const colorFromProps = props[theme];
|
|
15
|
+
|
|
16
|
+
if (colorFromProps) {
|
|
17
|
+
return colorFromProps;
|
|
18
|
+
} else {
|
|
19
|
+
return Colors[theme][colorName];
|
|
20
|
+
}
|
|
21
|
+
}
|