create-expo-stack 2.19.0-next.2970d7d → 2.19.0-next.d6fc7f8
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/build/cli.js +3 -2
- package/build/commands/create-expo-stack.js +9 -9
- package/build/constants.js +3 -4
- package/build/templates/base/app.json.ejs +1 -19
- package/build/templates/base/babel.config.js.ejs +10 -10
- package/build/templates/base/package.json.ejs +58 -72
- package/build/templates/base/tsconfig.json.ejs +12 -7
- package/build/templates/packages/expo-router/stack/app/+not-found.tsx.ejs +4 -4
- package/build/templates/packages/expo-router/stack/app/details.tsx.ejs +2 -2
- package/build/templates/packages/expo-router/stack/app/index.tsx.ejs +3 -3
- package/build/templates/packages/nativewindui/components/EditScreenInfo.tsx.ejs +1 -1
- package/build/templates/packages/nativewindui/components/ScreenContent.tsx.ejs +1 -1
- package/build/templates/packages/nativewindui/components/nativewindui/Icon/Icon.ios.tsx.ejs +52 -0
- package/build/templates/packages/nativewindui/components/nativewindui/Icon/Icon.tsx.ejs +58 -0
- package/build/templates/packages/nativewindui/components/nativewindui/Icon/index.ts.ejs +16 -0
- package/build/templates/packages/nativewindui/components/nativewindui/Icon/types.ts.ejs +18 -0
- package/build/templates/packages/nativewindui/components/{ThemeToggle.tsx.ejs → nativewindui/ThemeToggle.tsx.ejs} +8 -10
- package/build/templates/packages/nativewindui/drawer/app/(drawer)/index.tsx.ejs +17 -19
- package/build/templates/packages/nativewindui/drawer/app/+not-found.tsx.ejs +4 -4
- package/build/templates/packages/nativewindui/drawer/app/_layout.tsx.ejs +2 -2
- package/build/templates/packages/nativewindui/drawer/app/modal.tsx.ejs +4 -4
- package/build/templates/packages/nativewindui/lib/useColorScheme.tsx.ejs +3 -37
- package/build/templates/packages/nativewindui/stack/app/+not-found.tsx.ejs +1 -1
- package/build/templates/packages/nativewindui/stack/app/_layout.tsx.ejs +12 -34
- package/build/templates/packages/nativewindui/stack/app/index.tsx.ejs +216 -275
- package/build/templates/packages/nativewindui/stack/app/modal.tsx.ejs +7 -7
- package/build/templates/packages/nativewindui/tabs/app/(tabs)/index.tsx.ejs +6 -7
- package/build/templates/packages/nativewindui/theme/colors.ts.ejs +52 -0
- package/build/templates/packages/nativewindui/theme/index.ts.ejs +2 -2
- package/build/templates/packages/nativewindui/theme/with-opacity.ts.ejs +155 -0
- package/build/types/constants.d.ts +1 -1
- package/build/types/types.d.ts +1 -1
- package/build/types/utilities/configAnalytics.d.ts +2 -2
- package/build/utilities/clearNavigationPackages.js +2 -2
- package/build/utilities/clearStylingPackages.js +2 -2
- package/build/utilities/configAnalytics.js +5 -4
- package/build/utilities/configureProjectFiles.js +27 -25
- package/build/utilities/copyBaseAssets.js +3 -2
- package/build/utilities/generateNWUI.js +8 -7
- package/build/utilities/generateProjectFiles.js +3 -2
- package/build/utilities/getPackageManager.js +6 -5
- package/build/utilities/printOutput.js +5 -16
- package/build/utilities/renderTitle.js +3 -2
- package/build/utilities/runCLI.js +14 -13
- package/build/utilities/runEasConfigure.js +3 -2
- package/build/utilities/runIgnite.js +3 -2
- package/build/utilities/showHelp.js +3 -2
- package/build/utilities/systemCommand.js +3 -3
- package/build/utilities/usePackage.js +3 -2
- package/build/utilities/validateProjectName.js +3 -2
- package/package.json +8 -6
- package/build/templates/packages/nativewindui/components/BackButton.tsx.ejs +0 -23
- package/build/templates/packages/nativewindui/components/Button.tsx.ejs +0 -41
- package/build/templates/packages/nativewindui/lib/useHeaderSearchBar.tsx.ejs +0 -31
- /package/build/templates/packages/nativewind/{app-env.d.ts → nativewind-env.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SymbolView } from 'expo-symbols';
|
|
2
|
+
|
|
3
|
+
import type { IconProps } from './types';
|
|
4
|
+
|
|
5
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
6
|
+
|
|
7
|
+
function Icon({
|
|
8
|
+
materialCommunityIcon: _materialCommunityIcon,
|
|
9
|
+
materialIcon: _materialIcon,
|
|
10
|
+
sfSymbol,
|
|
11
|
+
name,
|
|
12
|
+
color,
|
|
13
|
+
size = 24,
|
|
14
|
+
...props
|
|
15
|
+
}: IconProps) {
|
|
16
|
+
const { colors } = useColorScheme();
|
|
17
|
+
return (
|
|
18
|
+
<SymbolView
|
|
19
|
+
name={name ?? 'questionmark'}
|
|
20
|
+
tintColor={rgbaToHex(color ?? colors.foreground)}
|
|
21
|
+
size={size}
|
|
22
|
+
resizeMode="scaleAspectFit"
|
|
23
|
+
{...props}
|
|
24
|
+
{...sfSymbol}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Icon };
|
|
30
|
+
|
|
31
|
+
// TODO: seems like the need to convert rgba to hex color is a bug in expo-symbols, accordion to the docs, it should accept a hex color, but it doesn't.
|
|
32
|
+
|
|
33
|
+
function rgbaToHex(color: string): string {
|
|
34
|
+
if (!color) return 'black';
|
|
35
|
+
const rgbaRegex =
|
|
36
|
+
/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d*\.?\d+))?\s*\)$/i;
|
|
37
|
+
const match = color.match(rgbaRegex);
|
|
38
|
+
|
|
39
|
+
if (!match) {
|
|
40
|
+
return color;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [, rStr, gStr, bStr, aStr] = match;
|
|
44
|
+
const r = Math.min(255, parseInt(rStr));
|
|
45
|
+
const g = Math.min(255, parseInt(gStr));
|
|
46
|
+
const b = Math.min(255, parseInt(bStr));
|
|
47
|
+
const a = aStr !== undefined ? Math.round(parseFloat(aStr) * 255) : 255;
|
|
48
|
+
|
|
49
|
+
const toHex = (n: number) => n.toString(16).padStart(2, '0');
|
|
50
|
+
|
|
51
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}${a < 255 ? toHex(a) : ''}`;
|
|
52
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
|
|
2
|
+
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
3
|
+
import {
|
|
4
|
+
SF_SYMBOLS_TO_MATERIAL_COMMUNITY_ICONS,
|
|
5
|
+
SF_SYMBOLS_TO_MATERIAL_ICONS,
|
|
6
|
+
} from 'rn-icon-mapper';
|
|
7
|
+
|
|
8
|
+
import type { IconProps } from './types';
|
|
9
|
+
|
|
10
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
11
|
+
|
|
12
|
+
function Icon({
|
|
13
|
+
name,
|
|
14
|
+
materialCommunityIcon,
|
|
15
|
+
materialIcon,
|
|
16
|
+
sfSymbol: _sfSymbol,
|
|
17
|
+
size = 24,
|
|
18
|
+
...props
|
|
19
|
+
}: IconProps) {
|
|
20
|
+
const { colors } = useColorScheme();
|
|
21
|
+
const defaultColor = colors.foreground;
|
|
22
|
+
|
|
23
|
+
if (materialCommunityIcon) {
|
|
24
|
+
return (
|
|
25
|
+
<MaterialCommunityIcons
|
|
26
|
+
size={size}
|
|
27
|
+
color={defaultColor}
|
|
28
|
+
{...props}
|
|
29
|
+
{...materialCommunityIcon}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (materialIcon) {
|
|
34
|
+
return <MaterialIcons size={size} color={defaultColor} {...props} {...materialIcon} />;
|
|
35
|
+
}
|
|
36
|
+
const materialCommunityIconName =
|
|
37
|
+
SF_SYMBOLS_TO_MATERIAL_COMMUNITY_ICONS[
|
|
38
|
+
name as keyof typeof SF_SYMBOLS_TO_MATERIAL_COMMUNITY_ICONS
|
|
39
|
+
];
|
|
40
|
+
if (materialCommunityIconName) {
|
|
41
|
+
return (
|
|
42
|
+
<MaterialCommunityIcons
|
|
43
|
+
name={materialCommunityIconName}
|
|
44
|
+
size={size}
|
|
45
|
+
color={defaultColor}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const materialIconName =
|
|
51
|
+
SF_SYMBOLS_TO_MATERIAL_ICONS[name as keyof typeof SF_SYMBOLS_TO_MATERIAL_ICONS];
|
|
52
|
+
if (materialIconName) {
|
|
53
|
+
return <MaterialIcons name={materialIconName} size={size} color={defaultColor} {...props} />;
|
|
54
|
+
}
|
|
55
|
+
return <MaterialCommunityIcons name="help" size={size} color={defaultColor} {...props} />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { Icon };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cssInterop } from 'nativewind';
|
|
2
|
+
|
|
3
|
+
import { Icon } from './Icon';
|
|
4
|
+
|
|
5
|
+
cssInterop(Icon, {
|
|
6
|
+
className: {
|
|
7
|
+
target: 'style',
|
|
8
|
+
nativeStyleToProp: {
|
|
9
|
+
color: 'color',
|
|
10
|
+
height: 'size',
|
|
11
|
+
width: 'size',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { Icon };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
|
|
2
|
+
import type MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
|
3
|
+
import type { SymbolViewProps } from 'expo-symbols';
|
|
4
|
+
import type { IconMapper } from 'rn-icon-mapper';
|
|
5
|
+
|
|
6
|
+
type MaterialCommunityIconsProps = React.ComponentProps<typeof MaterialCommunityIcons>;
|
|
7
|
+
type MaterialIconsProps = React.ComponentProps<typeof MaterialIcons>;
|
|
8
|
+
|
|
9
|
+
type Style = SymbolViewProps['style'] &
|
|
10
|
+
MaterialIconsProps['style'] &
|
|
11
|
+
MaterialCommunityIconsProps['style'];
|
|
12
|
+
|
|
13
|
+
type IconProps = IconMapper<SymbolViewProps, MaterialIconsProps, MaterialCommunityIconsProps> & {
|
|
14
|
+
style?: Style;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type { IconProps };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Icon } from '@roninoss/icons';
|
|
2
1
|
import { Pressable, View } from 'react-native';
|
|
3
2
|
import Animated, { LayoutAnimationConfig, ZoomInRotate } from 'react-native-reanimated';
|
|
4
3
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Icon } from '@/components/nativewindui/Icon';
|
|
5
|
+
import { cn } from '@/lib/cn';
|
|
6
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
7
|
+
import { COLORS } from '@/theme/colors';
|
|
8
8
|
|
|
9
9
|
export function ThemeToggle() {
|
|
10
10
|
const { colorScheme, toggleColorScheme } = useColorScheme();
|
|
@@ -14,22 +14,20 @@ export function ThemeToggle() {
|
|
|
14
14
|
className="items-center justify-center"
|
|
15
15
|
key={`toggle-${colorScheme}`}
|
|
16
16
|
entering={ZoomInRotate}>
|
|
17
|
-
<Pressable
|
|
18
|
-
onPress={toggleColorScheme}
|
|
19
|
-
className="opacity-80">
|
|
17
|
+
<Pressable onPress={toggleColorScheme} className="opacity-80">
|
|
20
18
|
{colorScheme === 'dark'
|
|
21
19
|
? ({ pressed }) => (
|
|
22
20
|
<View className={cn('px-0.5', pressed && 'opacity-50')}>
|
|
23
|
-
<Icon
|
|
21
|
+
<Icon name="moon.stars" color={COLORS.white} />
|
|
24
22
|
</View>
|
|
25
23
|
)
|
|
26
24
|
: ({ pressed }) => (
|
|
27
25
|
<View className={cn('px-0.5', pressed && 'opacity-50')}>
|
|
28
|
-
<Icon
|
|
26
|
+
<Icon name="sun.min" color={COLORS.black} />
|
|
29
27
|
</View>
|
|
30
28
|
)}
|
|
31
29
|
</Pressable>
|
|
32
30
|
</Animated.View>
|
|
33
31
|
</LayoutAnimationConfig>
|
|
34
32
|
);
|
|
35
|
-
}
|
|
33
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stack } from 'expo-router';
|
|
2
2
|
import { useHeaderHeight } from '@react-navigation/elements';
|
|
3
|
-
import {
|
|
3
|
+
import { FlashList } from '@shopify/flash-list';
|
|
4
4
|
import { cssInterop } from 'nativewind';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import {
|
|
@@ -32,34 +32,33 @@ import { Icon } from '@roninoss/icons';
|
|
|
32
32
|
import * as StoreReview from 'expo-store-review';
|
|
33
33
|
<% } %>
|
|
34
34
|
|
|
35
|
-
import { Container } from '
|
|
35
|
+
import { Container } from '@/components/Container';
|
|
36
36
|
<% if (props.stylingPackage?.options.selectedComponents.includes('activity-indicator')) { %>
|
|
37
|
-
import { ActivityIndicator } from '
|
|
37
|
+
import { ActivityIndicator } from '@/components/nativewindui/ActivityIndicator';
|
|
38
38
|
<% } %>
|
|
39
39
|
<% if (props.stylingPackage?.options.selectedComponents.includes('avatar')) { %>
|
|
40
|
-
import { Avatar, AvatarFallback, AvatarImage } from '
|
|
40
|
+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/nativewindui/Avatar';
|
|
41
41
|
<% } %>
|
|
42
42
|
<% if (props.stylingPackage?.options.selectedComponents.includes('date-picker')) { %>
|
|
43
|
-
import { DatePicker } from '
|
|
43
|
+
import { DatePicker } from '@/components/nativewindui/DatePicker';
|
|
44
44
|
<% } %>
|
|
45
45
|
<% if (props.stylingPackage?.options.selectedComponents.includes('picker')) { %>
|
|
46
|
-
import { Picker, PickerItem } from '
|
|
46
|
+
import { Picker, PickerItem } from '@/components/nativewindui/Picker';
|
|
47
47
|
<% } %>
|
|
48
48
|
<% if (props.stylingPackage?.options.selectedComponents.includes('progress-indicator')) { %>
|
|
49
|
-
import { ProgressIndicator } from '
|
|
49
|
+
import { ProgressIndicator } from '@/components/nativewindui/ProgressIndicator';
|
|
50
50
|
<% } %>
|
|
51
51
|
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
52
|
-
import { Sheet, useSheetRef } from '
|
|
52
|
+
import { Sheet, useSheetRef } from '@/components/nativewindui/Sheet';
|
|
53
53
|
<% } %>
|
|
54
54
|
<% if (props.stylingPackage?.options.selectedComponents.includes('slider')) { %>
|
|
55
|
-
import { Slider } from '
|
|
55
|
+
import { Slider } from '@/components/nativewindui/Slider';
|
|
56
56
|
<% } %>
|
|
57
|
-
import { Text } from '
|
|
57
|
+
import { Text } from '@/components/nativewindui/Text';
|
|
58
58
|
<% if (props.stylingPackage?.options.selectedComponents.includes('toggle')) { %>
|
|
59
|
-
import { Toggle } from '
|
|
59
|
+
import { Toggle } from '@/components/nativewindui/Toggle';
|
|
60
60
|
<% } %>
|
|
61
|
-
import { useColorScheme } from '
|
|
62
|
-
import { useHeaderSearchBar } from '~/lib/useHeaderSearchBar';
|
|
61
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
63
62
|
|
|
64
63
|
export default function Home() {
|
|
65
64
|
const searchValue = useHeaderSearchBar({ hideWhenScrolling: COMPONENTS.length === 0 });
|
|
@@ -72,7 +71,7 @@ export default function Home() {
|
|
|
72
71
|
<>
|
|
73
72
|
<Stack.Screen options={{ title: 'Home' }} />
|
|
74
73
|
<Container>
|
|
75
|
-
<
|
|
74
|
+
<FlashList
|
|
76
75
|
contentInsetAdjustmentBehavior="automatic"
|
|
77
76
|
keyboardShouldPersistTaps="handled"
|
|
78
77
|
data={data}
|
|
@@ -83,14 +82,13 @@ export default function Home() {
|
|
|
83
82
|
ItemSeparatorComponent={renderItemSeparator}
|
|
84
83
|
renderItem={renderItem}
|
|
85
84
|
ListEmptyComponent={COMPONENTS.length === 0 ? ListEmptyComponent : undefined}
|
|
86
|
-
recycleItems
|
|
87
85
|
/>
|
|
88
86
|
</Container>
|
|
89
87
|
</>
|
|
90
88
|
);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
cssInterop(
|
|
91
|
+
cssInterop(FlashList, {
|
|
94
92
|
className: 'style',
|
|
95
93
|
contentContainerClassName: 'contentContainerStyle',
|
|
96
94
|
});
|
|
@@ -125,7 +123,7 @@ function ListEmptyComponent() {
|
|
|
125
123
|
variant='subhead'
|
|
126
124
|
className='text-primary'
|
|
127
125
|
>
|
|
128
|
-
|
|
126
|
+
NativewindUI
|
|
129
127
|
</Text>
|
|
130
128
|
{' website.'}
|
|
131
129
|
</Text>
|
|
@@ -466,7 +464,7 @@ const COMPONENTS: ComponentItem[] = [
|
|
|
466
464
|
onPress={async () => {
|
|
467
465
|
try {
|
|
468
466
|
const result = await Share.share({
|
|
469
|
-
message: '
|
|
467
|
+
message: 'NativewindUI | Familiar interface, native feel.',
|
|
470
468
|
});
|
|
471
469
|
if (result.action === Share.sharedAction) {
|
|
472
470
|
if (result.activityType) {
|
|
@@ -523,7 +521,7 @@ const COMPONENTS: ComponentItem[] = [
|
|
|
523
521
|
const TWITTER_AVATAR_URI = 'https://pbs.twimg.com/profile_images/1782428433898708992/1voyv4_A_400x400.jpg';
|
|
524
522
|
return (
|
|
525
523
|
<View className='items-center'>
|
|
526
|
-
<Avatar alt="
|
|
524
|
+
<Avatar alt="NativewindUI Avatar">
|
|
527
525
|
<AvatarImage source={{ uri: TWITTER_AVATAR_URI }} />
|
|
528
526
|
<AvatarFallback>
|
|
529
527
|
<Text>NUI</Text>
|
|
@@ -2,23 +2,23 @@ import { Link, Stack } from 'expo-router';
|
|
|
2
2
|
<% if (["nativewind", "nativewindui"].includes(props.stylingPackage?.name)) {%>
|
|
3
3
|
import { Text } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import { Container } from '
|
|
5
|
+
import { Container } from '@/components/Container';
|
|
6
6
|
<% } else if (props.stylingPackage?.name === "unistyles") { %>
|
|
7
7
|
import { createStyleSheet, useStyles } from 'react-native-unistyles'
|
|
8
8
|
import { Text } from 'react-native';
|
|
9
9
|
|
|
10
|
-
import { Container } from '
|
|
10
|
+
import { Container } from '@/components/Container';
|
|
11
11
|
<% } else if (props.stylingPackage?.name === "stylesheet") { %>
|
|
12
12
|
import { StyleSheet, Text } from 'react-native';
|
|
13
13
|
|
|
14
|
-
import { Container } from '
|
|
14
|
+
import { Container } from '@/components/Container';
|
|
15
15
|
<% } else if (props.stylingPackage?.name === "tamagui") { %>
|
|
16
16
|
import { YStack } from "tamagui";
|
|
17
17
|
import { Container, Main, Subtitle, Title } from "../tamagui.config";
|
|
18
18
|
<% } else if (props.stylingPackage?.name === "restyle") { %>
|
|
19
19
|
import { Box, Text, makeStyles } from 'theme';
|
|
20
20
|
|
|
21
|
-
import { Container } from '
|
|
21
|
+
import { Container } from '@/components/Container';
|
|
22
22
|
<% } %>
|
|
23
23
|
|
|
24
24
|
export default function NotFoundScreen() {
|
|
@@ -13,8 +13,8 @@ import { StatusBar } from 'expo-status-bar';
|
|
|
13
13
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
14
14
|
<% } %>
|
|
15
15
|
|
|
16
|
-
import { ThemeToggle } from '
|
|
17
|
-
import { useColorScheme, useInitialAndroidBarSync } from '
|
|
16
|
+
import { ThemeToggle } from '@/components/ThemeToggle';
|
|
17
|
+
import { useColorScheme, useInitialAndroidBarSync } from '@/lib/useColorScheme';
|
|
18
18
|
import { NAV_THEME } from '~/theme';
|
|
19
19
|
|
|
20
20
|
export {
|
|
@@ -2,8 +2,8 @@ import { Icon } from '@roninoss/icons';
|
|
|
2
2
|
import { StatusBar } from 'expo-status-bar';
|
|
3
3
|
import { Linking, Platform, View } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import { Text } from '
|
|
6
|
-
import { useColorScheme } from '
|
|
5
|
+
import { Text } from '@/components/nativewindui/Text';
|
|
6
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
7
7
|
|
|
8
8
|
export default function ModalScreen() {
|
|
9
9
|
const { colors, colorScheme } = useColorScheme();
|
|
@@ -15,7 +15,7 @@ export default function ModalScreen() {
|
|
|
15
15
|
<View className="flex-1 items-center justify-center gap-1 px-12">
|
|
16
16
|
<Icon name="file-plus-outline" size={42} color={colors.grey} />
|
|
17
17
|
<Text variant="title3" className="pb-1 text-center font-semibold">
|
|
18
|
-
|
|
18
|
+
NativewindUI
|
|
19
19
|
</Text>
|
|
20
20
|
<Text color="tertiary" variant="subhead" className="pb-4 text-center">
|
|
21
21
|
You can install any of the free components from the{' '}
|
|
@@ -23,7 +23,7 @@ export default function ModalScreen() {
|
|
|
23
23
|
onPress={() => Linking.openURL('https://nativewindui.com')}
|
|
24
24
|
variant="subhead"
|
|
25
25
|
className="text-primary">
|
|
26
|
-
|
|
26
|
+
NativewindUI
|
|
27
27
|
</Text>
|
|
28
28
|
{' website.'}
|
|
29
29
|
</Text>
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import * as NavigationBar from 'expo-navigation-bar';
|
|
2
1
|
import { useColorScheme as useNativewindColorScheme } from 'nativewind';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Platform } from 'react-native';
|
|
5
2
|
|
|
6
|
-
import { COLORS } from '
|
|
3
|
+
import { COLORS } from '@/theme/colors';
|
|
7
4
|
|
|
8
5
|
function useColorScheme() {
|
|
9
|
-
const { colorScheme, setColorScheme
|
|
10
|
-
|
|
11
|
-
async function setColorScheme(colorScheme: 'light' | 'dark') {
|
|
12
|
-
setNativeWindColorScheme(colorScheme);
|
|
13
|
-
if (Platform.OS !== 'android') return;
|
|
14
|
-
try {
|
|
15
|
-
await setNavigationBar(colorScheme);
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error('useColorScheme.tsx", "setColorScheme', error);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
6
|
+
const { colorScheme, setColorScheme } = useNativewindColorScheme();
|
|
20
7
|
|
|
21
8
|
function toggleColorScheme() {
|
|
22
9
|
return setColorScheme(colorScheme === 'light' ? 'dark' : 'light');
|
|
@@ -31,25 +18,4 @@ function useColorScheme() {
|
|
|
31
18
|
};
|
|
32
19
|
}
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
* Set the Android navigation bar color based on the color scheme.
|
|
36
|
-
*/
|
|
37
|
-
function useInitialAndroidBarSync() {
|
|
38
|
-
const { colorScheme } = useColorScheme();
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
if (Platform.OS !== 'android') return;
|
|
41
|
-
setNavigationBar(colorScheme).catch((error) => {
|
|
42
|
-
console.error('useColorScheme.tsx", "useInitialColorScheme', error);
|
|
43
|
-
});
|
|
44
|
-
}, [colorScheme]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { useColorScheme, useInitialAndroidBarSync };
|
|
48
|
-
|
|
49
|
-
function setNavigationBar(colorScheme: 'light' | 'dark') {
|
|
50
|
-
return Promise.all([
|
|
51
|
-
NavigationBar.setButtonStyleAsync(colorScheme === 'dark' ? 'light' : 'dark'),
|
|
52
|
-
NavigationBar.setPositionAsync('absolute'),
|
|
53
|
-
NavigationBar.setBackgroundColorAsync(colorScheme === 'dark' ? '#00000030' : '#ffffff80'),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
21
|
+
export { useColorScheme };
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
import { ThemeProvider as NavThemeProvider } from '@react-navigation/native';
|
|
4
|
-
import { Icon } from '@roninoss/icons';
|
|
1
|
+
import '@/global.css';
|
|
2
|
+
|
|
5
3
|
<% if (props.stylingPackage?.options.selectedComponents.includes('action-sheet')) { %>
|
|
6
4
|
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
|
|
7
5
|
<% } %>
|
|
8
|
-
|
|
9
|
-
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
10
|
-
<% } %>
|
|
6
|
+
import { ThemeProvider as NavThemeProvider } from '@react-navigation/native';
|
|
11
7
|
import { Link, Stack } from 'expo-router';
|
|
12
8
|
import { StatusBar } from 'expo-status-bar';
|
|
13
|
-
import { Pressable
|
|
14
|
-
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
9
|
+
import { Pressable } from 'react-native';
|
|
15
10
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
16
|
-
<% } %>
|
|
17
11
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { useColorScheme
|
|
21
|
-
import { NAV_THEME } from '
|
|
12
|
+
import { Icon } from '@/components/nativewindui/Icon';
|
|
13
|
+
import { ThemeToggle } from '@/components/nativewindui/ThemeToggle';
|
|
14
|
+
import { useColorScheme } from '@/lib/useColorScheme';
|
|
15
|
+
import { NAV_THEME } from '@/theme';
|
|
22
16
|
|
|
23
17
|
export {
|
|
24
18
|
// Catch any errors thrown by the Layout component.
|
|
@@ -26,7 +20,6 @@ export {
|
|
|
26
20
|
} from 'expo-router';
|
|
27
21
|
|
|
28
22
|
export default function RootLayout() {
|
|
29
|
-
useInitialAndroidBarSync();
|
|
30
23
|
const { colorScheme, isDarkColorScheme } = useColorScheme();
|
|
31
24
|
|
|
32
25
|
return (
|
|
@@ -37,15 +30,12 @@ export default function RootLayout() {
|
|
|
37
30
|
/>
|
|
38
31
|
{/* WRAP YOUR APP WITH ANY ADDITIONAL PROVIDERS HERE */}
|
|
39
32
|
{/* <ExampleProvider> */}
|
|
40
|
-
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
41
33
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
42
|
-
<BottomSheetModalProvider>
|
|
43
|
-
<% } %>
|
|
44
34
|
<% if (props.stylingPackage?.options.selectedComponents.includes('action-sheet')) { %>
|
|
45
35
|
<ActionSheetProvider>
|
|
46
36
|
<% } %>
|
|
47
37
|
<NavThemeProvider value={NAV_THEME[colorScheme]}>
|
|
48
|
-
<Stack
|
|
38
|
+
<Stack>
|
|
49
39
|
<Stack.Screen name="index" options={INDEX_OPTIONS} />
|
|
50
40
|
<Stack.Screen name="modal" options={MODAL_OPTIONS} />
|
|
51
41
|
</Stack>
|
|
@@ -53,35 +43,23 @@ export default function RootLayout() {
|
|
|
53
43
|
<% if (props.stylingPackage?.options.selectedComponents.includes('action-sheet')) { %>
|
|
54
44
|
</ActionSheetProvider>
|
|
55
45
|
<% } %>
|
|
56
|
-
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
57
|
-
</BottomSheetModalProvider>
|
|
58
46
|
</GestureHandlerRootView>
|
|
59
|
-
<% } %>
|
|
60
47
|
{/* </ExampleProvider> */}
|
|
61
48
|
</>
|
|
62
49
|
);
|
|
63
50
|
}
|
|
64
51
|
|
|
65
|
-
const SCREEN_OPTIONS = {
|
|
66
|
-
animation: 'ios_from_right', // for android
|
|
67
|
-
} as const;
|
|
68
|
-
|
|
69
52
|
const INDEX_OPTIONS = {
|
|
70
53
|
headerLargeTitle: true,
|
|
71
|
-
title: '
|
|
54
|
+
title: 'NativewindUI',
|
|
72
55
|
headerRight: () => <SettingsIcon />,
|
|
73
56
|
} as const;
|
|
74
57
|
|
|
75
58
|
function SettingsIcon() {
|
|
76
|
-
const { colors } = useColorScheme();
|
|
77
59
|
return (
|
|
78
60
|
<Link href="/modal" asChild>
|
|
79
|
-
<Pressable className="opacity-80">
|
|
80
|
-
|
|
81
|
-
<View className={cn(pressed ? 'opacity-50' : 'opacity-90')}>
|
|
82
|
-
<Icon name="cog-outline" color={colors.foreground} />
|
|
83
|
-
</View>
|
|
84
|
-
)}
|
|
61
|
+
<Pressable className="opacity-80 active:opacity-50">
|
|
62
|
+
<Icon name="gearshape" className="text-foreground" />
|
|
85
63
|
</Pressable>
|
|
86
64
|
</Link>
|
|
87
65
|
);
|