create-expo-stack 2.7.0-next.e19c886 → 2.7.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/README.md +10 -10
- package/build/commands/create-expo-stack.js +62 -15
- package/build/templates/base/app.json.ejs +5 -1
- package/build/templates/base/package.json.ejs +32 -3
- package/build/templates/base/tsconfig.json.ejs +1 -1
- package/build/templates/packages/nativewindui/app/+not-found.tsx.ejs +1 -1
- package/build/templates/packages/nativewindui/app/_layout.tsx.ejs +26 -19
- package/build/templates/packages/nativewindui/app/index.tsx.ejs +665 -123
- package/build/templates/packages/nativewindui/app/modal.tsx.ejs +20 -19
- package/build/templates/packages/nativewindui/components/nativewind-ui/ActivityIndicator.tsx.ejs +10 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/Avatar.tsx.ejs +139 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/DatePicker.android.tsx.ejs +66 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/DatePicker.tsx.ejs +10 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/Picker.tsx.ejs +39 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/ProgressIndicator.tsx.ejs +95 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/SegmentedControl.tsx.ejs +22 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/Sheet.tsx.ejs +59 -0
- package/build/templates/packages/nativewindui/components/nativewind-ui/Slider.tsx.ejs +28 -0
- package/build/templates/packages/nativewindui/components/{Text.tsx.ejs → nativewind-ui/Text.tsx.ejs} +26 -2
- package/build/templates/packages/nativewindui/components/{ThemeToggle.tsx.ejs → nativewind-ui/ThemeToggle.tsx.ejs} +6 -10
- package/build/templates/packages/nativewindui/components/{Toggle.tsx.ejs → nativewind-ui/Toggle.tsx.ejs} +3 -3
- package/build/templates/packages/nativewindui/global.css.ejs +3 -3
- package/build/templates/packages/nativewindui/lib/useColorScheme.tsx.ejs +44 -3
- package/build/templates/packages/nativewindui/lib/useHeaderSearchBar.tsx.ejs +2 -2
- package/build/templates/packages/nativewindui/theme/colors.ts.ejs +8 -8
- package/build/templates/packages/nativewindui/theme/index.ts.ejs +4 -4
- package/build/types/types.d.ts +2 -0
- package/build/types/utilities/clearNavigationPackages.d.ts +2 -0
- package/build/utilities/clearNavigationPackages.js +11 -0
- package/build/utilities/configureProjectFiles.js +64 -35
- package/build/utilities/runCLI.js +80 -26
- package/package.json +67 -67
- package/build/templates/packages/nativewindui/app/bottom-tabs/_layout.tsx.ejs +0 -34
- package/build/templates/packages/nativewindui/app/bottom-tabs/index.tsx.ejs +0 -11
- package/build/templates/packages/nativewindui/app/bottom-tabs/profile.tsx.ejs +0 -11
- package/build/templates/packages/nativewindui/app/drawer/_layout.tsx.ejs +0 -29
- package/build/templates/packages/nativewindui/app/drawer/index.tsx.ejs +0 -11
- package/build/templates/packages/nativewindui/app/top-tabs/_layout.tsx.ejs +0 -71
- package/build/templates/packages/nativewindui/app/top-tabs/following.tsx.ejs +0 -13
- package/build/templates/packages/nativewindui/app/top-tabs/index.tsx.ejs +0 -13
- package/build/templates/packages/nativewindui/app/top-tabs/my-group.tsx.ejs +0 -13
|
@@ -1,165 +1,707 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useHeaderHeight } from '@react-navigation/elements';
|
|
2
|
+
import { FlashList } from '@shopify/flash-list';
|
|
3
|
+
import { cssInterop } from 'nativewind';
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('alert')) { %>
|
|
7
|
+
Alert,
|
|
8
|
+
<% } %>
|
|
9
|
+
<% if (
|
|
10
|
+
props.stylingPackage?.options.selectedComponents.includes('alert') ||
|
|
11
|
+
props.stylingPackage?.options.selectedComponents.includes('action-sheet') ||
|
|
12
|
+
props.stylingPackage?.options.selectedComponents.includes('activity-view') ||
|
|
13
|
+
props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')
|
|
14
|
+
) { %>
|
|
15
|
+
Button as RNButton,
|
|
16
|
+
ButtonProps,
|
|
17
|
+
<% } %>
|
|
18
|
+
Linking,
|
|
19
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('alert') || props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
20
|
+
Platform,
|
|
21
|
+
<% } %>
|
|
22
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('dropdown-menu')) { %>
|
|
23
|
+
Pressable,
|
|
24
|
+
<% } %>
|
|
25
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('activity-view')) { %>
|
|
26
|
+
Share,
|
|
27
|
+
<% } %>
|
|
28
|
+
useWindowDimensions,
|
|
29
|
+
View,
|
|
30
|
+
} from 'react-native';
|
|
31
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
32
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('action-sheet')) { %>
|
|
33
|
+
import { useActionSheet } from '@expo/react-native-action-sheet';
|
|
34
|
+
<% } %>
|
|
35
|
+
import { Icon } from '@roninoss/icons';
|
|
36
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('ratings-indicator')) { %>
|
|
37
|
+
import * as StoreReview from 'expo-store-review';
|
|
38
|
+
<% } %>
|
|
39
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('context-menu')) { %>
|
|
40
|
+
import * as ContextMenu from 'zeego/context-menu';
|
|
41
|
+
<% } %>
|
|
42
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('dropdown-menu')) { %>
|
|
43
|
+
import * as DropdownMenu from 'zeego/dropdown-menu';
|
|
44
|
+
<% } %>
|
|
5
45
|
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
46
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('activity-indicator')) { %>
|
|
47
|
+
import { ActivityIndicator } from '~/components/nativewind-ui/ActivityIndicator';
|
|
48
|
+
<% } %>
|
|
49
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('avatar')) { %>
|
|
50
|
+
import { Avatar, AvatarFallback, AvatarImage } from '~/components/nativewind-ui/Avatar';
|
|
51
|
+
<% } %>
|
|
52
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('date-picker')) { %>
|
|
53
|
+
import { DatePicker } from '~/components/nativewind-ui/DatePicker';
|
|
54
|
+
<% } %>
|
|
55
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('picker')) { %>
|
|
56
|
+
import { Picker, PickerItem } from '~/components/nativewind-ui/Picker';
|
|
57
|
+
<% } %>
|
|
58
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('progress-indicator')) { %>
|
|
59
|
+
import { ProgressIndicator } from '~/components/nativewind-ui/ProgressIndicator';
|
|
60
|
+
<% } %>
|
|
61
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('segmented-control')) { %>
|
|
62
|
+
import { SegmentedControl } from '~/components/nativewind-ui/SegmentedControl';
|
|
63
|
+
<% } %>
|
|
64
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
65
|
+
import { Sheet, useSheetRef } from '~/components/nativewind-ui/Sheet';
|
|
66
|
+
<% } %>
|
|
67
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('slider')) { %>
|
|
68
|
+
import { Slider } from '~/components/nativewind-ui/Slider';
|
|
69
|
+
<% } %>
|
|
70
|
+
import { Text } from '~/components/nativewind-ui/Text';
|
|
71
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('toggle')) { %>
|
|
72
|
+
import { Toggle } from '~/components/nativewind-ui/Toggle';
|
|
73
|
+
<% } %>
|
|
74
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
75
|
+
import { useHeaderSearchBar } from '~/lib/useHeaderSearchBar';
|
|
11
76
|
|
|
12
|
-
|
|
77
|
+
|
|
78
|
+
cssInterop(FlashList, {
|
|
79
|
+
className: 'style',
|
|
80
|
+
contentContainerClassName: 'contentContainerStyle',
|
|
81
|
+
});
|
|
82
|
+
<% if (
|
|
83
|
+
props.stylingPackage?.options.selectedComponents.includes('alert') ||
|
|
84
|
+
props.stylingPackage?.options.selectedComponents.includes('action-sheet') ||
|
|
85
|
+
props.stylingPackage?.options.selectedComponents.includes('activity-view') ||
|
|
86
|
+
props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')
|
|
87
|
+
) { %>
|
|
88
|
+
function DefaultButton({ color, ...props }: ButtonProps) {
|
|
13
89
|
const { colors } = useColorScheme();
|
|
14
|
-
|
|
90
|
+
return <RNButton color={color ?? colors.primary} {...props} />;
|
|
91
|
+
}
|
|
92
|
+
<% } %>
|
|
93
|
+
export default function Screen() {
|
|
94
|
+
const searchValue = useHeaderSearchBar({ hideWhenScrolling: COMPONENTS.length === 0 });
|
|
15
95
|
|
|
16
96
|
const data = searchValue
|
|
17
97
|
? COMPONENTS.filter((c) => c.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
18
98
|
: COMPONENTS;
|
|
19
99
|
|
|
20
|
-
const screens = searchValue
|
|
21
|
-
? FULL_SCREEN_COMPONENTS.filter((c) => c.name.toLowerCase().includes(searchValue.toLowerCase()))
|
|
22
|
-
: FULL_SCREEN_COMPONENTS;
|
|
23
|
-
|
|
24
100
|
return (
|
|
25
|
-
<
|
|
101
|
+
<FlashList
|
|
26
102
|
contentInsetAdjustmentBehavior="automatic"
|
|
103
|
+
keyboardShouldPersistTaps="handled"
|
|
27
104
|
data={data}
|
|
28
|
-
|
|
105
|
+
estimatedItemSize={200}
|
|
106
|
+
contentContainerClassName="py-4 android:pb-12"
|
|
29
107
|
extraData={searchValue}
|
|
108
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('selectable-text')) { %>
|
|
30
109
|
removeClippedSubviews={false} // used for selecting text on android
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<item.component />
|
|
37
|
-
</Card>
|
|
38
|
-
);
|
|
39
|
-
}}
|
|
40
|
-
ListFooterComponent={() => {
|
|
41
|
-
return (
|
|
42
|
-
<FlatList
|
|
43
|
-
ListHeaderComponent={() => (
|
|
44
|
-
<View className={cn('px-4 pb-2 pt-6', screens.length === 0 && 'hidden')}>
|
|
45
|
-
<Text className="text-xs font-semibold opacity-50 ">NAVIGATORS</Text>
|
|
46
|
-
</View>
|
|
47
|
-
)}
|
|
48
|
-
scrollToOverflowEnabled
|
|
49
|
-
scrollEnabled={false}
|
|
50
|
-
contentInsetAdjustmentBehavior="automatic"
|
|
51
|
-
data={screens}
|
|
52
|
-
className="ios:px-4"
|
|
53
|
-
extraData={searchValue}
|
|
54
|
-
keyExtractor={(item) => item.name}
|
|
55
|
-
renderItem={({ index, item }) => {
|
|
56
|
-
const isLast = index === screens.length - 1;
|
|
57
|
-
return (
|
|
58
|
-
<Link href={item.href} asChild>
|
|
59
|
-
<Pressable
|
|
60
|
-
className={cn(
|
|
61
|
-
index === 0 && 'ios:rounded-t-xl border-t',
|
|
62
|
-
isLast && 'ios:rounded-b-xl border-b',
|
|
63
|
-
'bg-card ios:border-l ios:border-r border-border flex-row active:opacity-80'
|
|
64
|
-
)}>
|
|
65
|
-
<View
|
|
66
|
-
className={cn(
|
|
67
|
-
!isLast && 'border-border border-b',
|
|
68
|
-
'flex-1 flex-row items-center justify-between px-4 py-3'
|
|
69
|
-
)}>
|
|
70
|
-
<Text>{item.name}</Text>
|
|
71
|
-
<Icon name="chevron-right" size={18} color={colors.grey} />
|
|
72
|
-
</View>
|
|
73
|
-
</Pressable>
|
|
74
|
-
</Link>
|
|
75
|
-
);
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}}
|
|
110
|
+
<% } %>
|
|
111
|
+
keyExtractor={keyExtractor}
|
|
112
|
+
ItemSeparatorComponent={renderItemSeparator}
|
|
113
|
+
renderItem={renderItem}
|
|
114
|
+
ListEmptyComponent={COMPONENTS.length === 0 ? ListEmptyComponent : undefined}
|
|
80
115
|
/>
|
|
81
116
|
);
|
|
82
117
|
}
|
|
83
118
|
|
|
84
|
-
function
|
|
119
|
+
function ListEmptyComponent() {
|
|
120
|
+
const insets = useSafeAreaInsets();
|
|
121
|
+
const dimensions = useWindowDimensions();
|
|
122
|
+
const headerHeight = useHeaderHeight();
|
|
123
|
+
const { colors } = useColorScheme();
|
|
124
|
+
const height = dimensions.height - headerHeight - insets.bottom - insets.top;
|
|
125
|
+
|
|
85
126
|
return (
|
|
86
|
-
<View className="px-
|
|
87
|
-
<
|
|
88
|
-
<Text className=
|
|
89
|
-
|
|
127
|
+
<View style={{ height }} className="flex-1 items-center justify-center gap-1 px-12">
|
|
128
|
+
<Icon name="file-plus-outline" size={42} color={colors.grey} />
|
|
129
|
+
<Text variant='title3' className='pb-1 text-center font-semibold'>
|
|
130
|
+
No Components Installed
|
|
131
|
+
</Text>
|
|
132
|
+
<Text color='tertiary' variant='subhead' className='pb-4 text-center'>
|
|
133
|
+
You can install any of the free components from the{' '}
|
|
134
|
+
<Text
|
|
135
|
+
onPress={() => Linking.openURL('https://nativewindui.com')}
|
|
136
|
+
variant='subhead'
|
|
137
|
+
className='text-primary'
|
|
138
|
+
>
|
|
139
|
+
NativeWindUI
|
|
140
|
+
</Text>
|
|
141
|
+
{' website.'}
|
|
142
|
+
</Text>
|
|
90
143
|
</View>
|
|
91
|
-
</View>
|
|
92
144
|
);
|
|
93
145
|
}
|
|
94
146
|
|
|
95
|
-
|
|
96
|
-
|
|
147
|
+
type ComponentItem = { name: string; component: React.FC };
|
|
148
|
+
|
|
149
|
+
function keyExtractor(item: ComponentItem) {
|
|
150
|
+
return item.name;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function renderItemSeparator() {
|
|
154
|
+
return <View className="p-2" />;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function renderItem({ item }: { item: ComponentItem }) {
|
|
97
158
|
return (
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
</
|
|
159
|
+
<Card title={item.name}>
|
|
160
|
+
<item.component />
|
|
161
|
+
</Card>
|
|
101
162
|
);
|
|
102
163
|
}
|
|
103
164
|
|
|
104
|
-
|
|
165
|
+
function Card({ children, title }: { children: React.ReactNode; title: string }) {
|
|
166
|
+
return (
|
|
167
|
+
<View className="px-4">
|
|
168
|
+
<View className="gap-4 rounded-xl border border-border bg-card p-4 pb-6 shadow-sm shadow-black/10 dark:shadow-none">
|
|
169
|
+
<Text className="text-center text-sm font-medium tracking-wider opacity-60">{title}</Text>
|
|
170
|
+
{children}
|
|
171
|
+
</View>
|
|
172
|
+
</View>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('ratings-indicator')) { %>
|
|
176
|
+
let hasRequestedReview = false;
|
|
177
|
+
<% } %>
|
|
178
|
+
const COMPONENTS: ComponentItem[] = [
|
|
179
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('picker')) { %>
|
|
180
|
+
{
|
|
181
|
+
name: 'Picker',
|
|
182
|
+
component: function PickerExample() {
|
|
183
|
+
const { colors } = useColorScheme();
|
|
184
|
+
const [picker, setPicker] = React.useState('blue');
|
|
185
|
+
return (
|
|
186
|
+
<Picker
|
|
187
|
+
selectedValue={picker}
|
|
188
|
+
onValueChange={(itemValue) => setPicker(itemValue)}
|
|
189
|
+
>
|
|
190
|
+
<PickerItem
|
|
191
|
+
label='Red'
|
|
192
|
+
value='red'
|
|
193
|
+
color={colors.foreground}
|
|
194
|
+
style={{
|
|
195
|
+
backgroundColor: colors.root,
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
<PickerItem
|
|
199
|
+
label='Blue'
|
|
200
|
+
value='blue'
|
|
201
|
+
color={colors.foreground}
|
|
202
|
+
style={{
|
|
203
|
+
backgroundColor: colors.root,
|
|
204
|
+
}}
|
|
205
|
+
/>
|
|
206
|
+
<PickerItem
|
|
207
|
+
label='Green'
|
|
208
|
+
value='green'
|
|
209
|
+
color={colors.foreground}
|
|
210
|
+
style={{
|
|
211
|
+
backgroundColor: colors.root,
|
|
212
|
+
}}
|
|
213
|
+
/>
|
|
214
|
+
</Picker>
|
|
215
|
+
);
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
<% } %>
|
|
219
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('date-picker')) { %>
|
|
220
|
+
{
|
|
221
|
+
name: 'Date Picker',
|
|
222
|
+
component: function DatePickerExample() {
|
|
223
|
+
const [date, setDate] = React.useState(new Date());
|
|
224
|
+
return (
|
|
225
|
+
<View className='items-center'>
|
|
226
|
+
<DatePicker
|
|
227
|
+
value={date}
|
|
228
|
+
mode='datetime'
|
|
229
|
+
onChange={(ev) => {
|
|
230
|
+
setDate(new Date(ev.nativeEvent.timestamp));
|
|
231
|
+
}}
|
|
232
|
+
/>
|
|
233
|
+
</View>
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
<% } %>
|
|
238
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('segmented-control')) { %>
|
|
239
|
+
{
|
|
240
|
+
name: 'Segmented Controls',
|
|
241
|
+
component: function SegmentedControlsExample() {
|
|
242
|
+
const [segment, setSegment] = React.useState(0);
|
|
243
|
+
return (
|
|
244
|
+
<SegmentedControl
|
|
245
|
+
values={['red', 'green', 'blue']}
|
|
246
|
+
selectedIndex={segment}
|
|
247
|
+
onChange={(event) => {
|
|
248
|
+
setSegment(event.nativeEvent.selectedSegmentIndex);
|
|
249
|
+
}}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
<% } %>
|
|
255
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('slider')) { %>
|
|
256
|
+
{
|
|
257
|
+
name: 'Slider',
|
|
258
|
+
component: function SliderExample() {
|
|
259
|
+
const [sliderValue, setSliderValue] = React.useState(0.5);
|
|
260
|
+
return <Slider value={sliderValue} onValueChange={setSliderValue} />;
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
<% } %>
|
|
264
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('toggle')) { %>
|
|
105
265
|
{
|
|
106
266
|
name: 'Toggle',
|
|
107
|
-
component: ToggleExample
|
|
267
|
+
component: function ToggleExample() {
|
|
268
|
+
const [switchValue, setSwitchValue] = React.useState(true);
|
|
269
|
+
return (
|
|
270
|
+
<View className='items-center'>
|
|
271
|
+
<Toggle value={switchValue} onValueChange={setSwitchValue} />
|
|
272
|
+
</View>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
<% } %>
|
|
277
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('context-menu')) { %>
|
|
278
|
+
{
|
|
279
|
+
name: 'Context Menu',
|
|
280
|
+
component: function ContextMenuExample() {
|
|
281
|
+
const [isChecked, setIsChecked] = React.useState(true);
|
|
282
|
+
return (
|
|
283
|
+
<View>
|
|
284
|
+
<ContextMenu.Root style={{ borderRadius: 12 }}>
|
|
285
|
+
<ContextMenu.Trigger>
|
|
286
|
+
<View className='w-full h-36 rounded-xl border border-foreground border-dashed justify-center items-center'>
|
|
287
|
+
<Text>Press and hold me</Text>
|
|
288
|
+
</View>
|
|
289
|
+
</ContextMenu.Trigger>
|
|
290
|
+
<ContextMenu.Content>
|
|
291
|
+
<ContextMenu.Label children='Label 1' />
|
|
292
|
+
<ContextMenu.Item key='item-1'>
|
|
293
|
+
<ContextMenu.ItemTitle>Item 1</ContextMenu.ItemTitle>
|
|
294
|
+
</ContextMenu.Item>
|
|
295
|
+
<ContextMenu.Group>
|
|
296
|
+
<ContextMenu.Item key='item-2'>
|
|
297
|
+
<ContextMenu.ItemTitle>Item 2</ContextMenu.ItemTitle>
|
|
298
|
+
</ContextMenu.Item>
|
|
299
|
+
<ContextMenu.CheckboxItem
|
|
300
|
+
key='checkbox-example'
|
|
301
|
+
value={isChecked}
|
|
302
|
+
onValueChange={(val) => {
|
|
303
|
+
setIsChecked(val === 'on');
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<ContextMenu.ItemTitle>Item 3</ContextMenu.ItemTitle>
|
|
307
|
+
<ContextMenu.ItemIndicator />
|
|
308
|
+
</ContextMenu.CheckboxItem>
|
|
309
|
+
</ContextMenu.Group>
|
|
310
|
+
<ContextMenu.Separator />
|
|
311
|
+
</ContextMenu.Content>
|
|
312
|
+
</ContextMenu.Root>
|
|
313
|
+
</View>
|
|
314
|
+
);
|
|
315
|
+
},
|
|
108
316
|
},
|
|
317
|
+
<% } %>
|
|
318
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('dropdown-menu')) { %>
|
|
319
|
+
{
|
|
320
|
+
name: 'Dropdown Menu',
|
|
321
|
+
component: function DropdownMenuExample() {
|
|
322
|
+
const { colors } = useColorScheme();
|
|
323
|
+
const [menu, setMenu] = React.useState<'primary' | 'destructive'>('primary');
|
|
109
324
|
|
|
325
|
+
return (
|
|
326
|
+
<View className='items-center'>
|
|
327
|
+
<DropdownMenu.Root>
|
|
328
|
+
<DropdownMenu.Trigger>
|
|
329
|
+
<Pressable className='flex-row items-center gap-1.5 android:gap-3'>
|
|
330
|
+
<Text>
|
|
331
|
+
Selected: <Text style={{ color: colors[menu] }}>{menu}</Text>
|
|
332
|
+
</Text>
|
|
333
|
+
<View className='pl-0.5 opacity-70'>
|
|
334
|
+
<Icon
|
|
335
|
+
name='chevron-down'
|
|
336
|
+
color={colors.foreground}
|
|
337
|
+
size={21}
|
|
338
|
+
/>
|
|
339
|
+
</View>
|
|
340
|
+
</Pressable>
|
|
341
|
+
</DropdownMenu.Trigger>
|
|
342
|
+
<DropdownMenu.Content>
|
|
343
|
+
<DropdownMenu.CheckboxItem
|
|
344
|
+
key='destructive'
|
|
345
|
+
value={menu === 'destructive'}
|
|
346
|
+
onValueChange={() => {
|
|
347
|
+
setMenu('destructive');
|
|
348
|
+
}}
|
|
349
|
+
>
|
|
350
|
+
<DropdownMenu.ItemIndicator />
|
|
351
|
+
<DropdownMenu.ItemTitle children='destructive' />
|
|
352
|
+
</DropdownMenu.CheckboxItem>
|
|
353
|
+
<DropdownMenu.CheckboxItem
|
|
354
|
+
key='primary'
|
|
355
|
+
value={menu === 'primary'}
|
|
356
|
+
onValueChange={() => {
|
|
357
|
+
setMenu('primary');
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
<DropdownMenu.ItemIndicator />
|
|
361
|
+
<DropdownMenu.ItemTitle children='primary' />
|
|
362
|
+
</DropdownMenu.CheckboxItem>
|
|
363
|
+
</DropdownMenu.Content>
|
|
364
|
+
</DropdownMenu.Root>
|
|
365
|
+
</View>
|
|
366
|
+
);
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
<% } %>
|
|
370
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('progress-indicator')) { %>
|
|
371
|
+
{
|
|
372
|
+
name: 'Progress Indicator',
|
|
373
|
+
component: function ProgressIndicatorExample() {
|
|
374
|
+
const [progress, setProgress] = React.useState(13);
|
|
375
|
+
let id: ReturnType<typeof setInterval> | null = null;
|
|
376
|
+
React.useEffect(() => {
|
|
377
|
+
if (!id) {
|
|
378
|
+
id = setInterval(() => {
|
|
379
|
+
setProgress((prev) => (prev >= 99 ? 0 : prev + 5));
|
|
380
|
+
}, 1000);
|
|
381
|
+
}
|
|
382
|
+
return () => {
|
|
383
|
+
if (id) clearInterval(id);
|
|
384
|
+
};
|
|
385
|
+
}, []);
|
|
386
|
+
return (
|
|
387
|
+
<View className='p-4'>
|
|
388
|
+
<ProgressIndicator value={progress} />
|
|
389
|
+
</View>
|
|
390
|
+
);
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
<% } %>
|
|
394
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('activity-indicator')) { %>
|
|
395
|
+
{
|
|
396
|
+
name: 'Activity Indicator',
|
|
397
|
+
component: function ActivityIndicatorExample() {
|
|
398
|
+
return (
|
|
399
|
+
<View className='p-4 items-center'>
|
|
400
|
+
<ActivityIndicator />
|
|
401
|
+
</View>
|
|
402
|
+
);
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
<% } %>
|
|
406
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('alert')) { %>
|
|
407
|
+
{
|
|
408
|
+
name: 'Alert',
|
|
409
|
+
component: function AlertExample() {
|
|
410
|
+
const { colors } = useColorScheme();
|
|
411
|
+
return (
|
|
412
|
+
<View className='items-center'>
|
|
413
|
+
<DefaultButton
|
|
414
|
+
color={colors.destructive}
|
|
415
|
+
onPress={() => {
|
|
416
|
+
if (Platform.OS === 'ios') {
|
|
417
|
+
Alert.prompt(
|
|
418
|
+
'Delete account?',
|
|
419
|
+
'Enter your password to delete your account.',
|
|
420
|
+
[
|
|
421
|
+
{
|
|
422
|
+
text: 'Cancel',
|
|
423
|
+
onPress: () => console.log('Cancel Pressed'),
|
|
424
|
+
style: 'cancel',
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
text: 'Delete',
|
|
428
|
+
style: 'destructive',
|
|
429
|
+
onPress: () => console.log('Delete Pressed'),
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
'secure-text',
|
|
433
|
+
'',
|
|
434
|
+
'default'
|
|
435
|
+
);
|
|
436
|
+
} else {
|
|
437
|
+
Alert.alert(
|
|
438
|
+
'Delete account?',
|
|
439
|
+
'Enter your password to delete your account.',
|
|
440
|
+
[
|
|
441
|
+
{
|
|
442
|
+
text: 'Cancel',
|
|
443
|
+
onPress: () => console.log('Cancel Pressed'),
|
|
444
|
+
style: 'cancel',
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
text: 'Delete',
|
|
448
|
+
style: 'destructive',
|
|
449
|
+
onPress: () => console.log('Delete Pressed'),
|
|
450
|
+
},
|
|
451
|
+
]
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
}}
|
|
455
|
+
title='Delete account'
|
|
456
|
+
/>
|
|
457
|
+
</View>
|
|
458
|
+
);
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
<% } %>
|
|
462
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('action-sheet')) { %>
|
|
463
|
+
{
|
|
464
|
+
name: 'Action Sheet',
|
|
465
|
+
component: function ActionSheetExample() {
|
|
466
|
+
const { colorScheme, colors } = useColorScheme();
|
|
467
|
+
const { showActionSheetWithOptions } = useActionSheet();
|
|
468
|
+
return (
|
|
469
|
+
<View className='items-center'>
|
|
470
|
+
<DefaultButton
|
|
471
|
+
color={'grey'}
|
|
472
|
+
onPress={async () => {
|
|
473
|
+
const options = ['Delete', 'Save', 'Cancel'];
|
|
474
|
+
const destructiveButtonIndex = 0;
|
|
475
|
+
const cancelButtonIndex = 2;
|
|
476
|
+
|
|
477
|
+
showActionSheetWithOptions(
|
|
478
|
+
{
|
|
479
|
+
options,
|
|
480
|
+
cancelButtonIndex,
|
|
481
|
+
destructiveButtonIndex,
|
|
482
|
+
containerStyle: {
|
|
483
|
+
backgroundColor: colorScheme === 'dark' ? 'black' : 'white',
|
|
484
|
+
},
|
|
485
|
+
textStyle: {
|
|
486
|
+
color: colors.foreground,
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
(selectedIndex) => {
|
|
490
|
+
switch (selectedIndex) {
|
|
491
|
+
case 1:
|
|
492
|
+
// Save
|
|
493
|
+
break;
|
|
494
|
+
|
|
495
|
+
case destructiveButtonIndex:
|
|
496
|
+
// Delete
|
|
497
|
+
break;
|
|
498
|
+
|
|
499
|
+
case cancelButtonIndex:
|
|
500
|
+
// Canceled
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
}}
|
|
505
|
+
title='Open action sheet'
|
|
506
|
+
/>
|
|
507
|
+
</View>
|
|
508
|
+
);
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
<% } %>
|
|
512
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('text')) { %>
|
|
110
513
|
{
|
|
111
514
|
name: 'Text',
|
|
112
|
-
component: ()
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
515
|
+
component: function TextExample() {
|
|
516
|
+
return (
|
|
517
|
+
<View className='gap-2'>
|
|
518
|
+
<Text variant='largeTitle' className='text-center'>
|
|
519
|
+
Large Title
|
|
520
|
+
</Text>
|
|
521
|
+
<Text variant='title1' className='text-center'>
|
|
522
|
+
Title 1
|
|
523
|
+
</Text>
|
|
524
|
+
<Text variant='title2' className='text-center'>
|
|
525
|
+
Title 2
|
|
526
|
+
</Text>
|
|
527
|
+
<Text variant='title3' className='text-center'>
|
|
528
|
+
Title 3
|
|
529
|
+
</Text>
|
|
530
|
+
<Text variant='heading' className='text-center'>
|
|
531
|
+
Heading
|
|
532
|
+
</Text>
|
|
533
|
+
<Text variant='body' className='text-center'>
|
|
534
|
+
Body
|
|
535
|
+
</Text>
|
|
536
|
+
<Text variant='callout' className='text-center'>
|
|
537
|
+
Callout
|
|
538
|
+
</Text>
|
|
539
|
+
<Text variant='subhead' className='text-center'>
|
|
540
|
+
Subhead
|
|
541
|
+
</Text>
|
|
542
|
+
<Text variant='footnote' className='text-center'>
|
|
543
|
+
Footnote
|
|
544
|
+
</Text>
|
|
545
|
+
<Text variant='caption1' className='text-center'>
|
|
546
|
+
Caption 1
|
|
547
|
+
</Text>
|
|
548
|
+
<Text variant='caption2' className='text-center'>
|
|
549
|
+
Caption 2
|
|
550
|
+
</Text>
|
|
551
|
+
</View>
|
|
552
|
+
);
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
<% } %>
|
|
556
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('selectable-text')) { %>
|
|
557
|
+
{
|
|
558
|
+
name: 'Selectable Text',
|
|
559
|
+
component: function SelectableTextExample() {
|
|
560
|
+
return (
|
|
561
|
+
<Text uiTextView selectable>
|
|
562
|
+
Long press or double press this text
|
|
146
563
|
</Text>
|
|
147
|
-
|
|
148
|
-
|
|
564
|
+
);
|
|
565
|
+
},
|
|
149
566
|
},
|
|
150
|
-
|
|
567
|
+
<% } %>
|
|
568
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('ratings-indicator')) { %>
|
|
569
|
+
{
|
|
570
|
+
name: 'Ratings Indicator',
|
|
571
|
+
component: function RatingsIndicatorExample() {
|
|
572
|
+
React.useEffect(() => {
|
|
573
|
+
async function showRequestReview() {
|
|
574
|
+
if (hasRequestedReview) return;
|
|
575
|
+
try {
|
|
576
|
+
if (await StoreReview.hasAction()) {
|
|
577
|
+
await StoreReview.requestReview();
|
|
578
|
+
}
|
|
579
|
+
} catch (error) {
|
|
580
|
+
console.log(
|
|
581
|
+
'FOR ANDROID: Make sure you meet all conditions to be able to test and use it: https://developer.android.com/guide/playcore/in-app-review/test#troubleshooting',
|
|
582
|
+
error
|
|
583
|
+
);
|
|
584
|
+
} finally {
|
|
585
|
+
hasRequestedReview = true;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const timeout = setTimeout(() => {
|
|
589
|
+
showRequestReview();
|
|
590
|
+
}, 1000);
|
|
591
|
+
|
|
592
|
+
return () => clearTimeout(timeout);
|
|
593
|
+
}, []);
|
|
151
594
|
|
|
152
|
-
|
|
595
|
+
return (
|
|
596
|
+
<View className="gap-3">
|
|
597
|
+
<Text className="pb-2 text-center font-semibold">Please follow the guidelines.</Text>
|
|
598
|
+
<View className="flex-row">
|
|
599
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
600
|
+
<View className="flex-1">
|
|
601
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
602
|
+
Don't call StoreReview.requestReview() from a button
|
|
603
|
+
</Text>
|
|
604
|
+
</View>
|
|
605
|
+
</View>
|
|
606
|
+
<View className="flex-row">
|
|
607
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
608
|
+
<View className="flex-1">
|
|
609
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
610
|
+
Don't request a review when the user is doing something time sensitive.
|
|
611
|
+
</Text>
|
|
612
|
+
</View>
|
|
613
|
+
</View>
|
|
614
|
+
<View className="flex-row">
|
|
615
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
616
|
+
<View className="flex-1">
|
|
617
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
618
|
+
Don't ask the user any questions before or while presenting the rating button or
|
|
619
|
+
card.
|
|
620
|
+
</Text>
|
|
621
|
+
</View>
|
|
622
|
+
</View>
|
|
623
|
+
</View>
|
|
624
|
+
);
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
<% } %>
|
|
628
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('activity-view')) { %>
|
|
153
629
|
{
|
|
154
|
-
name: '
|
|
155
|
-
|
|
630
|
+
name: 'Activity View',
|
|
631
|
+
component: function ActivityViewExample() {
|
|
632
|
+
return (
|
|
633
|
+
<View className='items-center'>
|
|
634
|
+
<DefaultButton
|
|
635
|
+
onPress={async () => {
|
|
636
|
+
try {
|
|
637
|
+
const result = await Share.share({
|
|
638
|
+
message: 'NativeWindUI | Familiar interface, native feel.',
|
|
639
|
+
});
|
|
640
|
+
if (result.action === Share.sharedAction) {
|
|
641
|
+
if (result.activityType) {
|
|
642
|
+
// shared with activity type of result.activityType
|
|
643
|
+
} else {
|
|
644
|
+
// shared
|
|
645
|
+
}
|
|
646
|
+
} else if (result.action === Share.dismissedAction) {
|
|
647
|
+
// dismissed
|
|
648
|
+
}
|
|
649
|
+
} catch (error: any) {
|
|
650
|
+
Alert.alert(error.message);
|
|
651
|
+
}
|
|
652
|
+
}}
|
|
653
|
+
title='Share a message'
|
|
654
|
+
/>
|
|
655
|
+
</View>
|
|
656
|
+
);
|
|
657
|
+
},
|
|
156
658
|
},
|
|
659
|
+
<% } %>
|
|
660
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('bottom-sheet')) { %>
|
|
157
661
|
{
|
|
158
|
-
name: 'Bottom
|
|
159
|
-
|
|
662
|
+
name: 'Bottom Sheet',
|
|
663
|
+
component: function BottomSheetExample() {
|
|
664
|
+
const { colorScheme } = useColorScheme();
|
|
665
|
+
const bottomSheetModalRef = useSheetRef();
|
|
666
|
+
|
|
667
|
+
return (
|
|
668
|
+
<View className='items-center'>
|
|
669
|
+
<DefaultButton
|
|
670
|
+
color={
|
|
671
|
+
colorScheme === 'dark' && Platform.OS === 'ios'
|
|
672
|
+
? 'white'
|
|
673
|
+
: 'black'
|
|
674
|
+
}
|
|
675
|
+
title='Open Bottom Sheet'
|
|
676
|
+
onPress={() => bottomSheetModalRef.current?.present()}
|
|
677
|
+
/>
|
|
678
|
+
<Sheet ref={bottomSheetModalRef} snapPoints={[200]}>
|
|
679
|
+
<View className='flex-1 justify-center items-center pb-8'>
|
|
680
|
+
<Text>@gorhom/bottom-sheet 🎉</Text>
|
|
681
|
+
</View>
|
|
682
|
+
</Sheet>
|
|
683
|
+
</View>
|
|
684
|
+
);
|
|
685
|
+
},
|
|
160
686
|
},
|
|
687
|
+
<% } %>
|
|
688
|
+
<% if (props.stylingPackage?.options.selectedComponents.includes('avatar')) { %>
|
|
161
689
|
{
|
|
162
|
-
name: '
|
|
163
|
-
|
|
690
|
+
name: 'Avatar',
|
|
691
|
+
component: function AvatarExample() {
|
|
692
|
+
const TWITTER_AVATAR_URI = 'https://pbs.twimg.com/profile_images/1782428433898708992/1voyv4_A_400x400.jpg';
|
|
693
|
+
return (
|
|
694
|
+
<View className='items-center'>
|
|
695
|
+
<Avatar alt="NativeWindUI Avatar">
|
|
696
|
+
<AvatarImage source={{ uri: TWITTER_AVATAR_URI }} />
|
|
697
|
+
<AvatarFallback>
|
|
698
|
+
<Text>NUI</Text>
|
|
699
|
+
</AvatarFallback>
|
|
700
|
+
</Avatar>
|
|
701
|
+
</View>
|
|
702
|
+
);
|
|
703
|
+
},
|
|
164
704
|
},
|
|
165
|
-
|
|
705
|
+
<% } %>
|
|
706
|
+
];
|
|
707
|
+
|