nwui-cli 0.3.5
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/src/index.js +41 -0
- package/build/cli/src/install-component.js +42 -0
- package/build/cli/src/login.js +77 -0
- package/build/cli/src/net.js +12 -0
- package/build/cli/src/project-setup.js +1 -0
- package/build/cli/src/prompts.js +119 -0
- package/build/cli/src/utils/local-storage.js +19 -0
- package/build/docs/app/data.js +1380 -0
- package/build/index.js +93 -0
- package/build/install-component.js +308 -0
- package/build/log/index.js +81 -0
- package/build/log.js +81 -0
- package/build/login.js +92 -0
- package/build/net.js +17 -0
- package/build/project-setup.js +1 -0
- package/build/prompts.js +119 -0
- package/build/utils/env.js +29 -0
- package/build/utils/git.js +82 -0
- package/build/utils/interactive.js +2 -0
- package/build/utils/local-storage.js +19 -0
- package/build/utils/opening.js +28 -0
- package/build/utils/prompts.js +138 -0
- package/package.json +39 -0
|
@@ -0,0 +1,1380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.freeComponents = exports.allComponentPreviews = exports.allScreenPreviews = exports.screenSlugs = exports.paidComponentSlugs = exports.freeComponentSlugs = exports.PAYMENT_PAGE = exports.POST_CHECKOUT_OR_LOGIN_PATH = void 0;
|
|
7
|
+
const action_sheet_png_1 = __importDefault(require("./assets/action-sheet.png"));
|
|
8
|
+
const action_sheet_dark_png_1 = __importDefault(require("./assets/action-sheet-dark.png"));
|
|
9
|
+
const activity_indicator_png_1 = __importDefault(require("./assets/activity-indicator.png"));
|
|
10
|
+
const activity_indicator_dark_png_1 = __importDefault(require("./assets/activity-indicator-dark.png"));
|
|
11
|
+
const activity_view_png_1 = __importDefault(require("./assets/activity-view.png"));
|
|
12
|
+
const activity_view_dark_png_1 = __importDefault(require("./assets/activity-view-dark.png"));
|
|
13
|
+
const alert_png_1 = __importDefault(require("./assets/alert.png"));
|
|
14
|
+
const alert_dark_png_1 = __importDefault(require("./assets/alert-dark.png"));
|
|
15
|
+
const avatar_png_1 = __importDefault(require("./assets/avatar.png"));
|
|
16
|
+
const bottom_sheet_png_1 = __importDefault(require("./assets/bottom-sheet.png"));
|
|
17
|
+
const bottom_sheet_dark_png_1 = __importDefault(require("./assets/bottom-sheet-dark.png"));
|
|
18
|
+
const context_menu_png_1 = __importDefault(require("./assets/context-menu.png"));
|
|
19
|
+
const context_menu_dark_png_1 = __importDefault(require("./assets/context-menu-dark.png"));
|
|
20
|
+
const date_picker_png_1 = __importDefault(require("./assets/date-picker.png"));
|
|
21
|
+
const date_picker_dark_png_1 = __importDefault(require("./assets/date-picker-dark.png"));
|
|
22
|
+
const dropdown_menu_png_1 = __importDefault(require("./assets/dropdown-menu.png"));
|
|
23
|
+
const picker_png_1 = __importDefault(require("./assets/picker.png"));
|
|
24
|
+
const picker_dark_png_1 = __importDefault(require("./assets/picker-dark.png"));
|
|
25
|
+
const poggers_indicator_png_1 = __importDefault(require("./assets/poggers-indicator.png"));
|
|
26
|
+
const poggers_indicator_dark_png_1 = __importDefault(require("./assets/poggers-indicator-dark.png"));
|
|
27
|
+
const ratings_indicator_png_1 = __importDefault(require("./assets/ratings-indicator.png"));
|
|
28
|
+
const ratings_indicator_dark_png_1 = __importDefault(require("./assets/ratings-indicator-dark.png"));
|
|
29
|
+
const segmented_control_png_1 = __importDefault(require("./assets/segmented-control.png"));
|
|
30
|
+
const segmented_control_dark_png_1 = __importDefault(require("./assets/segmented-control-dark.png"));
|
|
31
|
+
const selectable_text_png_1 = __importDefault(require("./assets/selectable-text.png"));
|
|
32
|
+
const slider_png_1 = __importDefault(require("./assets/slider.png"));
|
|
33
|
+
const slider_dark_png_1 = __importDefault(require("./assets/slider-dark.png"));
|
|
34
|
+
const text_png_1 = __importDefault(require("./assets/text.png"));
|
|
35
|
+
const text_dark_png_1 = __importDefault(require("./assets/text-dark.png"));
|
|
36
|
+
const toggle_png_1 = __importDefault(require("./assets/toggle.png"));
|
|
37
|
+
exports.POST_CHECKOUT_OR_LOGIN_PATH = '/installation';
|
|
38
|
+
// if env's Product ID is equal to the Test Product ID, use Test Payment Link
|
|
39
|
+
// TODO: could either move PAYMENT_PAGE to environment variable, or determine some other way
|
|
40
|
+
exports.PAYMENT_PAGE = process?.env?.NEXT_PUBLIC_STRIPE_NATIVEWIND_UI_PRODUCT_ID === 'prod_Q7SYGLGcPBEiU0'
|
|
41
|
+
? 'https://buy.stripe.com/test_6oE4jO8IIeqm88geUU'
|
|
42
|
+
: 'https://buy.stripe.com/eVa6q7ctvgdmc7e4gl?prefilled_promo_code=LAUNCH';
|
|
43
|
+
exports.freeComponentSlugs = [
|
|
44
|
+
'action-sheet',
|
|
45
|
+
'activity-indicator',
|
|
46
|
+
'activity-view',
|
|
47
|
+
'avatar',
|
|
48
|
+
'bottom-sheet',
|
|
49
|
+
'date-picker',
|
|
50
|
+
'picker',
|
|
51
|
+
'progress-indicator',
|
|
52
|
+
'ratings-indicator',
|
|
53
|
+
'selectable-text',
|
|
54
|
+
'slider',
|
|
55
|
+
'text',
|
|
56
|
+
'toggle',
|
|
57
|
+
];
|
|
58
|
+
exports.paidComponentSlugs = [
|
|
59
|
+
'alert',
|
|
60
|
+
'badge',
|
|
61
|
+
'bottom-tabs',
|
|
62
|
+
'button',
|
|
63
|
+
'checkbox',
|
|
64
|
+
'context-menu',
|
|
65
|
+
'drawer-content',
|
|
66
|
+
'dropdown-menu',
|
|
67
|
+
'form',
|
|
68
|
+
'list',
|
|
69
|
+
'stepper',
|
|
70
|
+
'search-input',
|
|
71
|
+
'segmented-control',
|
|
72
|
+
'text-field',
|
|
73
|
+
'toolbar',
|
|
74
|
+
];
|
|
75
|
+
exports.screenSlugs = ['authentication-flow', 'consent-welcome-screen'];
|
|
76
|
+
exports.allScreenPreviews = [
|
|
77
|
+
{
|
|
78
|
+
slug: 'authentication-flow',
|
|
79
|
+
name: 'Authentication Flow',
|
|
80
|
+
description: 'Authentication Flow screens.',
|
|
81
|
+
videoSrcAndroid: '/authentication-flow-android.mp4',
|
|
82
|
+
videoSrcIos: '/authentication-flow-ios.mp4',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
slug: 'consent-welcome-screen',
|
|
86
|
+
name: 'Consent Welcome Screen',
|
|
87
|
+
description: 'Consent Welcome Screen',
|
|
88
|
+
videoSrcAndroid: '/consent-welcome-screen-android.png',
|
|
89
|
+
videoSrcIos: '/consent-welcome-screen-ios.png',
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
exports.allComponentPreviews = [
|
|
93
|
+
{
|
|
94
|
+
slug: 'action-sheet',
|
|
95
|
+
name: 'Action Sheet',
|
|
96
|
+
previewCard: action_sheet_png_1.default.src,
|
|
97
|
+
previewCardDark: action_sheet_dark_png_1.default.src,
|
|
98
|
+
videoSrcAndroid: '/action-sheet-android.mp4',
|
|
99
|
+
videoSrcIos: '/action-sheet-ios.mov',
|
|
100
|
+
description: 'A modal view that presents choices related to an action people initiate.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
slug: 'activity-indicator',
|
|
104
|
+
name: 'Activity Indicator',
|
|
105
|
+
previewCard: activity_indicator_png_1.default.src,
|
|
106
|
+
previewCardDark: activity_indicator_dark_png_1.default.src,
|
|
107
|
+
videoSrcAndroid: '/activity-indicator-android.mp4',
|
|
108
|
+
videoSrcIos: '/activity-indicator-ios.mov',
|
|
109
|
+
description: "Lets people know that your app isn't stalled while it loads content or performs lengthy operations.",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
slug: 'activity-view',
|
|
113
|
+
name: 'Activity View',
|
|
114
|
+
previewCard: activity_view_png_1.default.src,
|
|
115
|
+
previewCardDark: activity_view_dark_png_1.default.src,
|
|
116
|
+
videoSrcAndroid: '/activity-view-android.mp4',
|
|
117
|
+
videoSrcIos: '/activity-view-ios.mov',
|
|
118
|
+
description: 'Often called a share sheet, an activity view presents a range of tasks that people can perform in the current context.',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
slug: 'alert',
|
|
122
|
+
name: 'Alert',
|
|
123
|
+
new: true,
|
|
124
|
+
paid: true,
|
|
125
|
+
previewCard: alert_png_1.default.src,
|
|
126
|
+
previewCardDark: alert_dark_png_1.default.src,
|
|
127
|
+
videoSrcAndroid: '/alert-pro-android.mp4',
|
|
128
|
+
videoSrcIos: '/alert-pro-ios.mp4',
|
|
129
|
+
description: 'An alert gives people critical information they need right away.',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
slug: 'avatar',
|
|
133
|
+
name: 'Avatar',
|
|
134
|
+
previewCard: avatar_png_1.default.src,
|
|
135
|
+
previewCardDark: avatar_png_1.default.src,
|
|
136
|
+
videoSrcAndroid: '/avatar-android.png',
|
|
137
|
+
videoSrcIos: '/avatar-ios.mov',
|
|
138
|
+
description: 'An image that represents a person on your platform.',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
slug: 'bottom-sheet',
|
|
142
|
+
name: 'Bottom Sheet',
|
|
143
|
+
previewCard: bottom_sheet_png_1.default.src,
|
|
144
|
+
previewCardDark: bottom_sheet_dark_png_1.default.src,
|
|
145
|
+
videoSrcAndroid: '/bottom-sheet-android.mp4',
|
|
146
|
+
videoSrcIos: '/bottom-sheet-ios.mov',
|
|
147
|
+
description: "A bottom sheet helps people perform a scoped task that's closely related to their current context.",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
slug: 'badge',
|
|
151
|
+
name: 'Badge',
|
|
152
|
+
paid: true,
|
|
153
|
+
// previewCard: Badge.src,
|
|
154
|
+
// previewCardDark: Badge.src,
|
|
155
|
+
videoSrcAndroid: '/badge-android.png',
|
|
156
|
+
videoSrcIos: '/badge-ios.png',
|
|
157
|
+
description: 'Badges are small status descriptors for UI elements.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
slug: 'bottom-tabs',
|
|
161
|
+
name: 'Bottom Tabs',
|
|
162
|
+
new: true,
|
|
163
|
+
paid: true,
|
|
164
|
+
// previewCard: BottomTabs.src,
|
|
165
|
+
// previewCardDark: BottomTabs.src,
|
|
166
|
+
// videoSrcAndroid: '/bottom-tabs-android.mp4',
|
|
167
|
+
// videoSrcIos: '/bottom-tabs-ios.mov',
|
|
168
|
+
description: '',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
slug: 'button',
|
|
172
|
+
name: 'Button',
|
|
173
|
+
paid: true,
|
|
174
|
+
// previewCard: Button.src,
|
|
175
|
+
// previewCardDark: Button.src,
|
|
176
|
+
videoSrcAndroid: '/button-android.mp4',
|
|
177
|
+
videoSrcIos: '/button-ios.mp4',
|
|
178
|
+
description: 'A button initiates an instantaneous action.',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
slug: 'checkbox',
|
|
182
|
+
name: 'Checkbox',
|
|
183
|
+
paid: true,
|
|
184
|
+
// previewCard: Checkbox.src,
|
|
185
|
+
// previewCardDark: Checkbox.src,
|
|
186
|
+
videoSrcAndroid: '/checkbox-android.mp4',
|
|
187
|
+
videoSrcIos: '/checkbox-ios.mp4',
|
|
188
|
+
description: 'Checkboxes allow the selection of multiple options from a set.',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
slug: 'context-menu',
|
|
192
|
+
name: 'Context Menu',
|
|
193
|
+
new: true,
|
|
194
|
+
paid: true,
|
|
195
|
+
previewCard: context_menu_png_1.default.src,
|
|
196
|
+
previewCardDark: context_menu_dark_png_1.default.src,
|
|
197
|
+
videoSrcAndroid: '/context-menu-pro-android.mp4',
|
|
198
|
+
videoSrcIos: '/context-menu-pro-ios.mp4',
|
|
199
|
+
description: "A context menu provides access to functionality that's directly related to an item, without cluttering the interface.",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
slug: 'date-picker',
|
|
203
|
+
name: 'Date Picker',
|
|
204
|
+
previewCard: date_picker_png_1.default.src,
|
|
205
|
+
previewCardDark: date_picker_dark_png_1.default.src,
|
|
206
|
+
videoSrcAndroid: '/date-picker-android.mp4',
|
|
207
|
+
videoSrcIos: '/date-picker-ios.mov',
|
|
208
|
+
description: 'A control for selecting an absolute date.',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
slug: 'drawer-content',
|
|
212
|
+
name: 'Drawer Content',
|
|
213
|
+
paid: true,
|
|
214
|
+
// previewCard: DrawerContent.src,
|
|
215
|
+
// previewCardDark: DrawerContent.src,
|
|
216
|
+
videoSrcAndroid: '/drawer-android.mp4',
|
|
217
|
+
videoSrcIos: '/drawer-ios.mp4',
|
|
218
|
+
description: 'Drawer content is a container for the content of a drawer.',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
slug: 'dropdown-menu',
|
|
222
|
+
name: 'Dropdown Menu',
|
|
223
|
+
new: true,
|
|
224
|
+
paid: true,
|
|
225
|
+
previewCard: dropdown_menu_png_1.default.src,
|
|
226
|
+
previewCardDark: dropdown_menu_png_1.default.src,
|
|
227
|
+
videoSrcAndroid: '/dropdown-menu-pro-android.mp4',
|
|
228
|
+
videoSrcIos: '/dropdown-menu-pro-ios.mp4',
|
|
229
|
+
description: "A dropdown menu displays a menu of items or actions that directly relate to the button's purpose.",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
slug: 'form',
|
|
233
|
+
name: 'Form',
|
|
234
|
+
paid: true,
|
|
235
|
+
// previewCard: Form.src,
|
|
236
|
+
// previewCardDark: Form.src,
|
|
237
|
+
// videoSrcAndroid: '/form-android.mp4',
|
|
238
|
+
// videoSrcIos: '/form-ios.mov',
|
|
239
|
+
description: 'Forms are used to collect user input.',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
slug: 'list',
|
|
243
|
+
name: 'List',
|
|
244
|
+
paid: true,
|
|
245
|
+
// previewCard: List.src,
|
|
246
|
+
// previewCardDark: List.src,
|
|
247
|
+
videoSrcAndroid: '/list-android.mp4',
|
|
248
|
+
videoSrcIos: '/list-ios.png',
|
|
249
|
+
description: 'Lists present data in one or more of rows.',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
slug: 'picker',
|
|
253
|
+
name: 'Picker',
|
|
254
|
+
previewCard: picker_png_1.default.src,
|
|
255
|
+
previewCardDark: picker_dark_png_1.default.src,
|
|
256
|
+
videoSrcIos: '/picker-ios.mov',
|
|
257
|
+
videoSrcAndroid: '/picker-android.mp4',
|
|
258
|
+
description: 'A picker displays one or more scrollable lists of distinct values that people can choose from.',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
slug: 'progress-indicator',
|
|
262
|
+
name: 'Progress Indicator',
|
|
263
|
+
previewCard: poggers_indicator_png_1.default.src,
|
|
264
|
+
previewCardDark: poggers_indicator_dark_png_1.default.src,
|
|
265
|
+
videoSrcAndroid: '/progress-indicator-android.mp4',
|
|
266
|
+
videoSrcIos: '/progress-indicator-ios.mov',
|
|
267
|
+
description: 'Progress indicators let people know that your app isn’t stalled while it loads content or performs lengthy operations.',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
slug: 'ratings-indicator',
|
|
271
|
+
name: 'Ratings Indicator',
|
|
272
|
+
previewCard: ratings_indicator_png_1.default.src,
|
|
273
|
+
previewCardDark: ratings_indicator_dark_png_1.default.src,
|
|
274
|
+
videoSrcAndroid: '/ratings-indicator-android.png',
|
|
275
|
+
videoSrcIos: '/ratings-indicator-ios.mov',
|
|
276
|
+
description: 'Asks the user to rate the app in the iOS App Store or Google Play store directly from within the app.',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
slug: 'segmented-control',
|
|
280
|
+
name: 'Segmented Control',
|
|
281
|
+
new: true,
|
|
282
|
+
paid: true,
|
|
283
|
+
previewCard: segmented_control_png_1.default.src,
|
|
284
|
+
previewCardDark: segmented_control_dark_png_1.default.src,
|
|
285
|
+
videoSrcAndroid: '/segmented-control-pro-android.mp4',
|
|
286
|
+
videoSrcIos: '/segmented-control-pro-ios.mp4',
|
|
287
|
+
description: 'A segmented control is a linear set of two or more segments, each of which functions as a button.',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
slug: 'search-input',
|
|
291
|
+
name: 'Search Input',
|
|
292
|
+
paid: true,
|
|
293
|
+
// previewCard: SearchInput.src,
|
|
294
|
+
// previewCardDark: SearchInput.src,
|
|
295
|
+
videoSrcAndroid: '/search-input-android.mp4',
|
|
296
|
+
videoSrcIos: '/search-input-ios.mp4',
|
|
297
|
+
description: 'A search input is a text input that allows users to search for content in your app.',
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
slug: 'selectable-text',
|
|
301
|
+
name: 'Selectable Text',
|
|
302
|
+
previewCard: selectable_text_png_1.default.src,
|
|
303
|
+
previewCardDark: selectable_text_png_1.default.src,
|
|
304
|
+
videoSrcAndroid: '/selectable-text-android.mp4',
|
|
305
|
+
videoSrcIos: '/selectable-text-ios.mov',
|
|
306
|
+
description: 'A selectable text region.',
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
slug: 'slider',
|
|
310
|
+
name: 'Slider',
|
|
311
|
+
previewCard: slider_png_1.default.src,
|
|
312
|
+
previewCardDark: slider_dark_png_1.default.src,
|
|
313
|
+
videoSrcAndroid: '/slider-android.mp4',
|
|
314
|
+
videoSrcIos: '/slider-ios.mov',
|
|
315
|
+
description: 'A slider is a horizontal track with a control, called a thumb, that people can adjust between a minimum and maximum value.',
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
slug: 'stepper',
|
|
319
|
+
name: 'Stepper',
|
|
320
|
+
paid: true,
|
|
321
|
+
// previewCard: Stepper.src,
|
|
322
|
+
// previewCardDark: Stepper.src,
|
|
323
|
+
videoSrcAndroid: '/stepper-android.mp4',
|
|
324
|
+
videoSrcIos: '/stepper-ios.mp4',
|
|
325
|
+
description: 'A stepper is a two-segment control that people use to increase or decrease an incremental value.',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
slug: 'text',
|
|
329
|
+
name: 'Text',
|
|
330
|
+
previewCard: text_png_1.default.src,
|
|
331
|
+
previewCardDark: text_dark_png_1.default.src,
|
|
332
|
+
videoSrcIos: '/text-ios.mov',
|
|
333
|
+
videoSrcAndroid: '/text-android.png',
|
|
334
|
+
description: 'Display, nest, style, and handle touch events for text.',
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
slug: 'text-field',
|
|
338
|
+
name: 'Text Field',
|
|
339
|
+
paid: true,
|
|
340
|
+
// previewCard: TextField.src,
|
|
341
|
+
// previewCardDark: TextField.src,
|
|
342
|
+
videoSrcAndroid: '/text-field-android.mp4',
|
|
343
|
+
videoSrcIos: '/text-field-ios.mp4',
|
|
344
|
+
description: 'A text field is a rectangular area in which people enter or edit small, specific pieces of text.',
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
slug: 'toggle',
|
|
348
|
+
name: 'Toggle',
|
|
349
|
+
previewCard: toggle_png_1.default.src,
|
|
350
|
+
previewCardDark: toggle_png_1.default.src,
|
|
351
|
+
videoSrcAndroid: '/toggle-android.mp4',
|
|
352
|
+
videoSrcIos: '/toggle-ios.mov',
|
|
353
|
+
description: 'A toggle lets people choose between a pair of opposing states, like on and off, using a different appearance to indicate each state.',
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
slug: 'toolbar',
|
|
357
|
+
name: 'Toolbar',
|
|
358
|
+
paid: true,
|
|
359
|
+
// previewCard: Toolbar.src,
|
|
360
|
+
// previewCardDark: Toolbar.src,
|
|
361
|
+
videoSrcAndroid: '/toolbar-android.mp4',
|
|
362
|
+
videoSrcIos: '/toolbar-ios.mp4',
|
|
363
|
+
description: 'A toolbar provides convenient access to frequently used commands and controls that perform actions relevant to the current view.',
|
|
364
|
+
},
|
|
365
|
+
];
|
|
366
|
+
exports.freeComponents = [
|
|
367
|
+
{
|
|
368
|
+
id: 0,
|
|
369
|
+
slug: 'action-sheet',
|
|
370
|
+
name: 'Action Sheet',
|
|
371
|
+
description: 'A modal view that presents choices related to an action people initiate.',
|
|
372
|
+
dependencies: [
|
|
373
|
+
{
|
|
374
|
+
type: 'library',
|
|
375
|
+
name: '@expo/react-native-action-sheet',
|
|
376
|
+
url: 'https://github.com/expo/react-native-action-sheet?tab=readme-ov-file#installation',
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
implementationCode: `import { Button, View } from 'react-native';
|
|
380
|
+
import { useActionSheet } from '@expo/react-native-action-sheet';
|
|
381
|
+
|
|
382
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
383
|
+
|
|
384
|
+
function ActionSheetExample() {
|
|
385
|
+
const { colorScheme, colors } = useColorScheme();
|
|
386
|
+
const { showActionSheetWithOptions } = useActionSheet();
|
|
387
|
+
return (
|
|
388
|
+
<View className="items-center">
|
|
389
|
+
<Button
|
|
390
|
+
color="grey"
|
|
391
|
+
onPress={async () => {
|
|
392
|
+
const options = ['Delete', 'Save', 'Cancel'];
|
|
393
|
+
const destructiveButtonIndex = 0;
|
|
394
|
+
const cancelButtonIndex = 2;
|
|
395
|
+
|
|
396
|
+
showActionSheetWithOptions(
|
|
397
|
+
{
|
|
398
|
+
options,
|
|
399
|
+
cancelButtonIndex,
|
|
400
|
+
destructiveButtonIndex,
|
|
401
|
+
containerStyle: {
|
|
402
|
+
backgroundColor: colorScheme === 'dark' ? 'black' : 'white',
|
|
403
|
+
},
|
|
404
|
+
textStyle: {
|
|
405
|
+
color: colors.foreground,
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
(selectedIndex) => {
|
|
409
|
+
switch (selectedIndex) {
|
|
410
|
+
case 1:
|
|
411
|
+
// Save
|
|
412
|
+
break;
|
|
413
|
+
|
|
414
|
+
case destructiveButtonIndex:
|
|
415
|
+
// Delete
|
|
416
|
+
break;
|
|
417
|
+
|
|
418
|
+
case cancelButtonIndex:
|
|
419
|
+
// Canceled
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
}}
|
|
424
|
+
title="Open action sheet"
|
|
425
|
+
/>
|
|
426
|
+
</View>
|
|
427
|
+
);
|
|
428
|
+
}`,
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
id: 1,
|
|
432
|
+
slug: 'activity-indicator',
|
|
433
|
+
name: 'Activity Indicator',
|
|
434
|
+
description: "Let's people know that your app isn't stalled while it loads content or performs lengthy operations.",
|
|
435
|
+
additionalFiles: [
|
|
436
|
+
{
|
|
437
|
+
path: '~/components/nativewindui/ActivityIndicator.tsx',
|
|
438
|
+
code: `import * as React from 'react';
|
|
439
|
+
import { ActivityIndicator as RNActivityIndicator } from 'react-native';
|
|
440
|
+
|
|
441
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
442
|
+
|
|
443
|
+
function ActivityIndicator(
|
|
444
|
+
props: React.ComponentPropsWithoutRef<typeof RNActivityIndicator>
|
|
445
|
+
) {
|
|
446
|
+
const { colors } = useColorScheme();
|
|
447
|
+
return <RNActivityIndicator color={colors.primary} {...props} />;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export { ActivityIndicator }`,
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
implementationCode: `import { View } from 'react-native';
|
|
454
|
+
|
|
455
|
+
import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
|
|
456
|
+
|
|
457
|
+
function ActivityIndicatorExample() {
|
|
458
|
+
return (
|
|
459
|
+
<View className="items-center p-4">
|
|
460
|
+
<ActivityIndicator />
|
|
461
|
+
</View>
|
|
462
|
+
);
|
|
463
|
+
}`,
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
id: 2,
|
|
467
|
+
slug: 'activity-view',
|
|
468
|
+
name: 'Activity View',
|
|
469
|
+
description: 'Often called a share sheet, an activity view presents a range of tasks that people can perform in the current context.',
|
|
470
|
+
implementationCode: `import { Alert, Button, Share, View } from 'react-native';
|
|
471
|
+
|
|
472
|
+
function ActivityViewExample() {
|
|
473
|
+
const { colors } = useColorScheme();
|
|
474
|
+
|
|
475
|
+
return (
|
|
476
|
+
<View className="items-center">
|
|
477
|
+
<Button
|
|
478
|
+
color={colors.primary}
|
|
479
|
+
onPress={async () => {
|
|
480
|
+
try {
|
|
481
|
+
const result = await Share.share({
|
|
482
|
+
message: 'NativeWindUI | Familiar interface, native feel.',
|
|
483
|
+
});
|
|
484
|
+
if (result.action === Share.sharedAction) {
|
|
485
|
+
if (result.activityType) {
|
|
486
|
+
// shared with activity type of result.activityType
|
|
487
|
+
} else {
|
|
488
|
+
// shared
|
|
489
|
+
}
|
|
490
|
+
} else if (result.action === Share.dismissedAction) {
|
|
491
|
+
// dismissed
|
|
492
|
+
}
|
|
493
|
+
} catch (error: any) {
|
|
494
|
+
Alert.alert(error.message);
|
|
495
|
+
}
|
|
496
|
+
}}
|
|
497
|
+
title="Share a message"
|
|
498
|
+
/>
|
|
499
|
+
</View>
|
|
500
|
+
);
|
|
501
|
+
}`,
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
id: 4,
|
|
505
|
+
slug: 'avatar',
|
|
506
|
+
name: 'Avatar',
|
|
507
|
+
description: 'An image that represents a person on your platform.',
|
|
508
|
+
additionalFiles: [
|
|
509
|
+
{
|
|
510
|
+
path: '~/components/nativewindui/Avatar.tsx',
|
|
511
|
+
code: `import * as React from 'react';
|
|
512
|
+
import {
|
|
513
|
+
ImageErrorEventData,
|
|
514
|
+
ImageLoadEventData,
|
|
515
|
+
NativeSyntheticEvent,
|
|
516
|
+
Image as RNImage,
|
|
517
|
+
View,
|
|
518
|
+
} from 'react-native';
|
|
519
|
+
|
|
520
|
+
import { cn } from '~/lib/cn';
|
|
521
|
+
|
|
522
|
+
interface AvatarRootProps {
|
|
523
|
+
alt: string;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
interface AvatarImageProps {
|
|
527
|
+
children?: React.ReactNode;
|
|
528
|
+
onLoadingStatusChange?: (status: 'error' | 'loaded') => void;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
type AvatarState = 'loading' | 'error' | 'loaded';
|
|
532
|
+
|
|
533
|
+
interface IRootContext extends AvatarRootProps {
|
|
534
|
+
status: AvatarState;
|
|
535
|
+
setStatus: (status: AvatarState) => void;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const RootContext = React.createContext<IRootContext | null>(null);
|
|
539
|
+
|
|
540
|
+
const Avatar = React.forwardRef<
|
|
541
|
+
React.ElementRef<typeof View>,
|
|
542
|
+
React.ComponentPropsWithoutRef<typeof View> & AvatarRootProps
|
|
543
|
+
>(({ alt, className, ...viewProps }, ref) => {
|
|
544
|
+
const [status, setStatus] = React.useState<AvatarState>('loading');
|
|
545
|
+
|
|
546
|
+
return (
|
|
547
|
+
<RootContext.Provider value={{ alt, status, setStatus }}>
|
|
548
|
+
<View
|
|
549
|
+
ref={ref}
|
|
550
|
+
className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
|
|
551
|
+
{...viewProps}
|
|
552
|
+
/>
|
|
553
|
+
</RootContext.Provider>
|
|
554
|
+
);
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
Avatar.displayName = 'Avatar';
|
|
558
|
+
|
|
559
|
+
function useRootContext() {
|
|
560
|
+
const context = React.useContext(RootContext);
|
|
561
|
+
if (!context) {
|
|
562
|
+
throw new Error('Avatar compound components cannot be rendered outside the Avatar component');
|
|
563
|
+
}
|
|
564
|
+
return context;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const AvatarImage = React.forwardRef<
|
|
568
|
+
React.ElementRef<typeof RNImage>,
|
|
569
|
+
Omit<React.ComponentPropsWithoutRef<typeof RNImage>, 'alt'> & AvatarImageProps
|
|
570
|
+
>(
|
|
571
|
+
(
|
|
572
|
+
{ onLoad: onLoadProps, onError: onErrorProps, onLoadingStatusChange, className, ...props },
|
|
573
|
+
ref
|
|
574
|
+
) => {
|
|
575
|
+
const { alt, setStatus, status } = useRootContext();
|
|
576
|
+
|
|
577
|
+
const onLoad = React.useCallback(
|
|
578
|
+
(e: NativeSyntheticEvent<ImageLoadEventData>) => {
|
|
579
|
+
setStatus('loaded');
|
|
580
|
+
onLoadingStatusChange?.('loaded');
|
|
581
|
+
onLoadProps?.(e);
|
|
582
|
+
},
|
|
583
|
+
[onLoadProps]
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
const onError = React.useCallback(
|
|
587
|
+
(e: NativeSyntheticEvent<ImageErrorEventData>) => {
|
|
588
|
+
setStatus('error');
|
|
589
|
+
onLoadingStatusChange?.('error');
|
|
590
|
+
onErrorProps?.(e);
|
|
591
|
+
},
|
|
592
|
+
[onErrorProps]
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
if (status === 'error') {
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return (
|
|
600
|
+
<RNImage
|
|
601
|
+
ref={ref}
|
|
602
|
+
alt={alt}
|
|
603
|
+
onLoad={onLoad}
|
|
604
|
+
onError={onError}
|
|
605
|
+
className={cn('aspect-square h-full w-full', className)}
|
|
606
|
+
{...props}
|
|
607
|
+
/>
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
AvatarImage.displayName = 'AvatarImage';
|
|
612
|
+
|
|
613
|
+
const AvatarFallback = React.forwardRef<
|
|
614
|
+
React.ElementRef<typeof View>,
|
|
615
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
616
|
+
>(({ className, ...props }, ref) => {
|
|
617
|
+
const { alt, status } = useRootContext();
|
|
618
|
+
|
|
619
|
+
if (status !== 'error') {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return (
|
|
624
|
+
<View
|
|
625
|
+
ref={ref}
|
|
626
|
+
role="img"
|
|
627
|
+
aria-label={alt}
|
|
628
|
+
className={cn(
|
|
629
|
+
'flex h-full w-full items-center justify-center rounded-full bg-muted',
|
|
630
|
+
className
|
|
631
|
+
)}
|
|
632
|
+
{...props}
|
|
633
|
+
/>
|
|
634
|
+
);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
AvatarFallback.displayName = 'AvatarFallback';
|
|
638
|
+
|
|
639
|
+
export { Avatar, AvatarFallback, AvatarImage };`,
|
|
640
|
+
},
|
|
641
|
+
],
|
|
642
|
+
implementationCode: `import { Text, View } from 'react-native';
|
|
643
|
+
|
|
644
|
+
import { Avatar, AvatarFallback, AvatarImage } from '~/components/nativewindui/Avatar';
|
|
645
|
+
|
|
646
|
+
const TWITTER_AVATAR_URI =
|
|
647
|
+
'https://pbs.twimg.com/profile_images/1782428433898708992/1voyv4_A_400x400.jpg';
|
|
648
|
+
|
|
649
|
+
function AvatarExample() {
|
|
650
|
+
return (
|
|
651
|
+
<View className="items-center">
|
|
652
|
+
<Avatar alt="NativeWindUI Avatar">
|
|
653
|
+
<AvatarImage source={{ uri: TWITTER_AVATAR_URI }} />
|
|
654
|
+
<AvatarFallback>
|
|
655
|
+
<Text className="text-foreground">NUI</Text>
|
|
656
|
+
</AvatarFallback>
|
|
657
|
+
</Avatar>
|
|
658
|
+
</View>
|
|
659
|
+
);
|
|
660
|
+
}`,
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
id: 5,
|
|
664
|
+
slug: 'bottom-sheet',
|
|
665
|
+
name: 'Bottom Sheet',
|
|
666
|
+
description: "A bottom sheet helps people perform a scoped task that's closely related to their current context.",
|
|
667
|
+
additionalFiles: [
|
|
668
|
+
{
|
|
669
|
+
path: '~/app/_layout.tsx',
|
|
670
|
+
code: `import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
671
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
672
|
+
|
|
673
|
+
export default function Layout({ children }) {
|
|
674
|
+
return (
|
|
675
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
676
|
+
<BottomSheetModalProvider>
|
|
677
|
+
{children}
|
|
678
|
+
</BottomSheetModalProvider>
|
|
679
|
+
</GestureHandlerRootView>
|
|
680
|
+
);
|
|
681
|
+
}`,
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
path: '~/components/nativewindui/Sheet.tsx',
|
|
685
|
+
code: `import {
|
|
686
|
+
BottomSheetBackdrop,
|
|
687
|
+
BottomSheetBackdropProps,
|
|
688
|
+
BottomSheetModal,
|
|
689
|
+
} from '@gorhom/bottom-sheet';
|
|
690
|
+
import * as React from 'react';
|
|
691
|
+
|
|
692
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
693
|
+
|
|
694
|
+
const Sheet = React.forwardRef<
|
|
695
|
+
BottomSheetModal,
|
|
696
|
+
React.ComponentPropsWithoutRef<typeof BottomSheetModal>
|
|
697
|
+
>(({ index = 0, backgroundStyle, style, handleIndicatorStyle, ...props }, ref) => {
|
|
698
|
+
const { colors } = useColorScheme();
|
|
699
|
+
|
|
700
|
+
const renderBackdrop = React.useCallback(
|
|
701
|
+
(props: BottomSheetBackdropProps) => <BottomSheetBackdrop {...props} disappearsOnIndex={-1} />,
|
|
702
|
+
[]
|
|
703
|
+
);
|
|
704
|
+
return (
|
|
705
|
+
<BottomSheetModal
|
|
706
|
+
ref={ref}
|
|
707
|
+
index={0}
|
|
708
|
+
backgroundStyle={
|
|
709
|
+
backgroundStyle ?? {
|
|
710
|
+
backgroundColor: colors.card,
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
style={
|
|
714
|
+
style ?? {
|
|
715
|
+
borderWidth: 1,
|
|
716
|
+
borderColor: colors.grey5,
|
|
717
|
+
borderTopStartRadius: 16,
|
|
718
|
+
borderTopEndRadius: 16,
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
handleIndicatorStyle={
|
|
722
|
+
handleIndicatorStyle ?? {
|
|
723
|
+
backgroundColor: colors.grey4,
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
backdropComponent={renderBackdrop}
|
|
727
|
+
{...props}
|
|
728
|
+
/>
|
|
729
|
+
);
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
function useSheetRef() {
|
|
733
|
+
return React.useRef<BottomSheetModal>(null);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
export { Sheet, useSheetRef };`,
|
|
737
|
+
},
|
|
738
|
+
],
|
|
739
|
+
dependencies: [
|
|
740
|
+
{
|
|
741
|
+
type: 'library',
|
|
742
|
+
name: '@gorhom/bottom-sheet',
|
|
743
|
+
url: 'https://ui.gorhom.dev/components/bottom-sheet/',
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
type: 'library',
|
|
747
|
+
name: 'react-native-gesture-handler',
|
|
748
|
+
url: 'https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation#js',
|
|
749
|
+
},
|
|
750
|
+
],
|
|
751
|
+
implementationCode: `import { Button, Platform, Text, View } from 'react-native';
|
|
752
|
+
import { Sheet, useSheetRef } from '~/components/nativewindui/Sheet';
|
|
753
|
+
|
|
754
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
755
|
+
|
|
756
|
+
function BottomSheetExample() {
|
|
757
|
+
const { colorScheme } = useColorScheme();
|
|
758
|
+
const bottomSheetModalRef = useSheetRef();
|
|
759
|
+
|
|
760
|
+
return (
|
|
761
|
+
<View className="items-center">
|
|
762
|
+
<Button
|
|
763
|
+
color={colorScheme === 'dark' && Platform.OS === 'ios' ? 'white' : 'black'}
|
|
764
|
+
title="Open Bottom Sheet"
|
|
765
|
+
onPress={() => bottomSheetModalRef.current?.present()}
|
|
766
|
+
/>
|
|
767
|
+
<Sheet ref={bottomSheetModalRef} snapPoints={[200]}>
|
|
768
|
+
<View className="flex-1 items-center justify-center pb-8">
|
|
769
|
+
<Text className="text-foreground">@gorhom/bottom-sheet 🎉</Text>
|
|
770
|
+
</View>
|
|
771
|
+
</Sheet>
|
|
772
|
+
</View>
|
|
773
|
+
);
|
|
774
|
+
}`,
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
id: 7,
|
|
778
|
+
slug: 'date-picker',
|
|
779
|
+
name: 'Date Picker',
|
|
780
|
+
description: 'A control for selecting an absolute date.',
|
|
781
|
+
additionalFiles: [
|
|
782
|
+
{
|
|
783
|
+
path: '~/components/nativewindui/DatePicker/DatePicker.tsx',
|
|
784
|
+
code: `import DateTimePicker from '@react-native-community/datetimepicker';
|
|
785
|
+
import * as React from 'react';
|
|
786
|
+
|
|
787
|
+
export function DatePicker(
|
|
788
|
+
props: React.ComponentProps<typeof DateTimePicker> & {
|
|
789
|
+
mode: 'date' | 'time' | 'datetime';
|
|
790
|
+
}
|
|
791
|
+
) {
|
|
792
|
+
return <DateTimePicker {...props} />;
|
|
793
|
+
}`,
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
path: '~/components/nativewindui/DatePicker/DatePicker.android.tsx',
|
|
797
|
+
code: `import DateTimePicker, { DateTimePickerAndroid } from '@react-native-community/datetimepicker';
|
|
798
|
+
import * as React from 'react';
|
|
799
|
+
import { Pressable, View } from 'react-native';
|
|
800
|
+
|
|
801
|
+
import { Text } from '~/components/nativewindui/Text';
|
|
802
|
+
|
|
803
|
+
export function DatePicker(
|
|
804
|
+
props: React.ComponentProps<typeof DateTimePicker> & {
|
|
805
|
+
mode: 'date' | 'time' | 'datetime';
|
|
806
|
+
}
|
|
807
|
+
) {
|
|
808
|
+
const show = (currentMode: 'time' | 'date') => () => {
|
|
809
|
+
DateTimePickerAndroid.open({
|
|
810
|
+
value: props.value,
|
|
811
|
+
onChange: props.onChange,
|
|
812
|
+
mode: currentMode,
|
|
813
|
+
minimumDate: props.minimumDate,
|
|
814
|
+
maximumDate: props.maximumDate,
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
return (
|
|
819
|
+
<View className="flex-row gap-2.5">
|
|
820
|
+
{props.mode.includes('date') && (
|
|
821
|
+
<View className="relative pt-1.5">
|
|
822
|
+
<Pressable
|
|
823
|
+
onPress={show('date')}
|
|
824
|
+
className="rounded-md border border-border px-5 py-3 active:opacity-80">
|
|
825
|
+
<Text variant="subhead">
|
|
826
|
+
{new Intl.DateTimeFormat('en-US', {
|
|
827
|
+
dateStyle: 'medium',
|
|
828
|
+
}).format(props.value)}
|
|
829
|
+
</Text>
|
|
830
|
+
</Pressable>
|
|
831
|
+
<View className="absolute left-2 top-0 bg-card px-1">
|
|
832
|
+
<Text variant="caption2" className="text-[10px] opacity-60">
|
|
833
|
+
Date
|
|
834
|
+
</Text>
|
|
835
|
+
</View>
|
|
836
|
+
</View>
|
|
837
|
+
)}
|
|
838
|
+
{props.mode.includes('time') && (
|
|
839
|
+
<View className="relative pt-1.5">
|
|
840
|
+
<Pressable
|
|
841
|
+
onPress={show('time')}
|
|
842
|
+
className="rounded-md border border-border px-5 py-3 active:opacity-80">
|
|
843
|
+
<Text variant="subhead">
|
|
844
|
+
{new Intl.DateTimeFormat('en-US', {
|
|
845
|
+
timeStyle: 'short',
|
|
846
|
+
}).format(props.value)}
|
|
847
|
+
</Text>
|
|
848
|
+
</Pressable>
|
|
849
|
+
<View className="absolute left-2 top-0 bg-card px-1">
|
|
850
|
+
<Text variant="caption2" className="text-[10px] opacity-60">
|
|
851
|
+
Time
|
|
852
|
+
</Text>
|
|
853
|
+
</View>
|
|
854
|
+
</View>
|
|
855
|
+
)}
|
|
856
|
+
</View>
|
|
857
|
+
);
|
|
858
|
+
}`,
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
path: '~/components/nativewindui/DatePicker/index.ts',
|
|
862
|
+
code: "export * from './DatePicker';",
|
|
863
|
+
},
|
|
864
|
+
],
|
|
865
|
+
dependencies: [
|
|
866
|
+
{
|
|
867
|
+
type: 'library',
|
|
868
|
+
name: '@react-native-community/datetimepicker',
|
|
869
|
+
url: 'https://github.com/react-native-datetimepicker/datetimepicker?tab=readme-ov-file#getting-started',
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
type: 'component',
|
|
873
|
+
name: 'Text',
|
|
874
|
+
url: '/component/text',
|
|
875
|
+
},
|
|
876
|
+
],
|
|
877
|
+
implementationCode: `import * as React from 'react';
|
|
878
|
+
import { View } from 'react-native';
|
|
879
|
+
|
|
880
|
+
import { DatePicker } from '~/components/nativewindui/DatePicker';
|
|
881
|
+
|
|
882
|
+
function DatePickerExample() {
|
|
883
|
+
const [date, setDate] = React.useState(new Date());
|
|
884
|
+
return (
|
|
885
|
+
<View className='items-center'>
|
|
886
|
+
<DatePicker
|
|
887
|
+
value={date}
|
|
888
|
+
mode='datetime'
|
|
889
|
+
onChange={(ev) => {
|
|
890
|
+
setDate(new Date(ev.nativeEvent.timestamp));
|
|
891
|
+
}}
|
|
892
|
+
/>
|
|
893
|
+
</View>
|
|
894
|
+
);
|
|
895
|
+
}`,
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
id: 9,
|
|
899
|
+
slug: 'picker',
|
|
900
|
+
name: 'Picker',
|
|
901
|
+
description: 'A picker displays one or more scrollable lists of distinct values that people can choose from.',
|
|
902
|
+
additionalFiles: [
|
|
903
|
+
{
|
|
904
|
+
path: '~/components/nativewindui/Picker.tsx',
|
|
905
|
+
code: `import { Picker as RNPicker } from '@react-native-picker/picker';
|
|
906
|
+
import { View } from 'react-native';
|
|
907
|
+
|
|
908
|
+
import { cn } from '~/lib/cn';
|
|
909
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
910
|
+
|
|
911
|
+
function Picker<T>({
|
|
912
|
+
mode = 'dropdown',
|
|
913
|
+
style,
|
|
914
|
+
dropdownIconColor,
|
|
915
|
+
dropdownIconRippleColor,
|
|
916
|
+
className,
|
|
917
|
+
...props
|
|
918
|
+
}: React.ComponentPropsWithoutRef<typeof RNPicker<T>>) {
|
|
919
|
+
const { colors } = useColorScheme();
|
|
920
|
+
|
|
921
|
+
return (
|
|
922
|
+
<View
|
|
923
|
+
className={cn(
|
|
924
|
+
'ios:shadow-sm ios:shadow-black/5 rounded-md border border-background bg-background',
|
|
925
|
+
className
|
|
926
|
+
)}
|
|
927
|
+
>
|
|
928
|
+
<RNPicker
|
|
929
|
+
mode={mode}
|
|
930
|
+
style={
|
|
931
|
+
style ?? {
|
|
932
|
+
backgroundColor: colors.root,
|
|
933
|
+
borderRadius: 8,
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
dropdownIconColor={dropdownIconColor ?? colors.foreground}
|
|
937
|
+
dropdownIconRippleColor={dropdownIconRippleColor ?? colors.foreground}
|
|
938
|
+
{...props}
|
|
939
|
+
/>
|
|
940
|
+
</View>
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
const PickerItem = RNPicker.Item;
|
|
945
|
+
|
|
946
|
+
export { Picker, PickerItem };`,
|
|
947
|
+
},
|
|
948
|
+
],
|
|
949
|
+
dependencies: [
|
|
950
|
+
{
|
|
951
|
+
type: 'library',
|
|
952
|
+
name: '@react-native-picker/picker',
|
|
953
|
+
url: 'https://github.com/react-native-picker/picker?tab=readme-ov-file#getting-started',
|
|
954
|
+
},
|
|
955
|
+
],
|
|
956
|
+
implementationCode: `import * as React from 'react';
|
|
957
|
+
|
|
958
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
959
|
+
import { Picker, PickerItem } from '~/components/nativewindui/Picker';
|
|
960
|
+
|
|
961
|
+
function PickerExample() {
|
|
962
|
+
const { colors } = useColorScheme();
|
|
963
|
+
const [picker, setPicker] = React.useState('blue');
|
|
964
|
+
return (
|
|
965
|
+
<Picker selectedValue={picker} onValueChange={(itemValue) => setPicker(itemValue)}>
|
|
966
|
+
<PickerItem
|
|
967
|
+
label="Red"
|
|
968
|
+
value="red"
|
|
969
|
+
color={colors.foreground}
|
|
970
|
+
style={{
|
|
971
|
+
backgroundColor: colors.root,
|
|
972
|
+
}}
|
|
973
|
+
/>
|
|
974
|
+
<PickerItem
|
|
975
|
+
label="Blue"
|
|
976
|
+
value="blue"
|
|
977
|
+
color={colors.foreground}
|
|
978
|
+
style={{
|
|
979
|
+
backgroundColor: colors.root,
|
|
980
|
+
}}
|
|
981
|
+
/>
|
|
982
|
+
<PickerItem
|
|
983
|
+
label="Green"
|
|
984
|
+
value="green"
|
|
985
|
+
color={colors.foreground}
|
|
986
|
+
style={{
|
|
987
|
+
backgroundColor: colors.root,
|
|
988
|
+
}}
|
|
989
|
+
/>
|
|
990
|
+
</Picker>
|
|
991
|
+
);
|
|
992
|
+
}`,
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
id: 10,
|
|
996
|
+
slug: 'progress-indicator',
|
|
997
|
+
name: 'Progress Indicator',
|
|
998
|
+
description: 'Progress indicators let people know that your app isn’t stalled while it loads content or performs lengthy operations.',
|
|
999
|
+
additionalFiles: [
|
|
1000
|
+
{
|
|
1001
|
+
path: '~/components/nativewindui/ProgressIndicator.tsx',
|
|
1002
|
+
code: "import * as React from 'react';\nimport { View } from 'react-native';\nimport Animated, {\n Extrapolation,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { cn } from '~/lib/cn';\n\nconst DEFAULT_MAX = 100;\n\nconst ProgressIndicator = React.forwardRef<\n React.ElementRef<typeof View>,\n React.ComponentPropsWithoutRef<typeof View> & {\n value?: number;\n max?: number;\n getValueLabel?: (value: number, max: number) => string;\n }\n>(\n (\n {\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n className,\n children,\n ...props\n },\n ref\n ) => {\n const max = maxProp ?? DEFAULT_MAX;\n const value = isValidValueNumber(valueProp, max) ? valueProp : 0;\n const progress = useDerivedValue(() => value ?? 0);\n\n const indicator = useAnimatedStyle(() => {\n return {\n width: withSpring(\n `${interpolate(progress.value, [0, 100], [1, 100], Extrapolation.CLAMP)}%`,\n { overshootClamping: true }\n ),\n };\n });\n\n return (\n <View\n role=\"progressbar\"\n ref={ref}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={value}\n aria-valuetext={getValueLabel(value, max)}\n accessibilityValue={{\n min: 0,\n max,\n now: value,\n text: getValueLabel(value, max),\n }}\n className={cn('relative h-1 w-full overflow-hidden rounded-full', className)}\n {...props}>\n <View className=\"absolute bottom-0 left-0 right-0 top-0 bg-muted opacity-20\" />\n <Animated.View role=\"presentation\" style={indicator} className={cn('h-full bg-primary')} /></View> );\n }\n);\n\nProgressIndicator.displayName = 'ProgressIndicator';\n\nexport { ProgressIndicator };\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`;\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n return typeof value === 'number' && !isNaN(value) && value <= max && value >= 0;\n}\n",
|
|
1003
|
+
},
|
|
1004
|
+
],
|
|
1005
|
+
implementationCode: `import * as React from 'react';
|
|
1006
|
+
import { View } from 'react-native';
|
|
1007
|
+
|
|
1008
|
+
import { ProgressIndicator } from '~/components/nativewindui/ProgressIndicator';
|
|
1009
|
+
|
|
1010
|
+
function ProgressIndicatorExample() {
|
|
1011
|
+
const [progress, setProgress] = React.useState(13);
|
|
1012
|
+
let id: ReturnType<typeof setInterval> | null = null;
|
|
1013
|
+
React.useEffect(() => {
|
|
1014
|
+
if (!id) {
|
|
1015
|
+
id = setInterval(() => {
|
|
1016
|
+
setProgress((prev) => (prev >= 99 ? 0 : prev + 5));
|
|
1017
|
+
}, 1000);
|
|
1018
|
+
}
|
|
1019
|
+
return () => {
|
|
1020
|
+
if (id) clearInterval(id);
|
|
1021
|
+
};
|
|
1022
|
+
}, []);
|
|
1023
|
+
return (
|
|
1024
|
+
<View className="p-4">
|
|
1025
|
+
<ProgressIndicator value={progress} />
|
|
1026
|
+
</View>
|
|
1027
|
+
);
|
|
1028
|
+
}`,
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
id: 11,
|
|
1032
|
+
slug: 'ratings-indicator',
|
|
1033
|
+
name: 'Ratings Indicator',
|
|
1034
|
+
description: 'Asks the user to rate the app in the iOS App Store or Google Play store directly from within the app.',
|
|
1035
|
+
dependencies: [
|
|
1036
|
+
{
|
|
1037
|
+
type: 'library',
|
|
1038
|
+
name: 'expo-store-review',
|
|
1039
|
+
url: 'https://docs.expo.dev/versions/latest/sdk/storereview/#installation',
|
|
1040
|
+
},
|
|
1041
|
+
],
|
|
1042
|
+
implementationCode: `import * as StoreReview from 'expo-store-review';
|
|
1043
|
+
import * as React from 'react';
|
|
1044
|
+
import { View, Text } from 'react-native';
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
let hasRequestedReview = false;
|
|
1048
|
+
|
|
1049
|
+
function RatingsIndicatorExample() {
|
|
1050
|
+
React.useEffect(() => {
|
|
1051
|
+
async function showRequestReview() {
|
|
1052
|
+
if (hasRequestedReview) return;
|
|
1053
|
+
try {
|
|
1054
|
+
if (await StoreReview.hasAction()) {
|
|
1055
|
+
await StoreReview.requestReview();
|
|
1056
|
+
}
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
console.log(
|
|
1059
|
+
'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',
|
|
1060
|
+
error
|
|
1061
|
+
);
|
|
1062
|
+
} finally {
|
|
1063
|
+
hasRequestedReview = true;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const timeout = setTimeout(() => {
|
|
1067
|
+
showRequestReview();
|
|
1068
|
+
}, 1000);
|
|
1069
|
+
|
|
1070
|
+
return () => clearTimeout(timeout);
|
|
1071
|
+
}, []);
|
|
1072
|
+
|
|
1073
|
+
return (
|
|
1074
|
+
<View className="gap-3">
|
|
1075
|
+
<Text className="text-foreground pb-2 text-center font-semibold">Please follow the guidelines.</Text>
|
|
1076
|
+
<View className="flex-row">
|
|
1077
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
1078
|
+
<View className="flex-1">
|
|
1079
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
1080
|
+
Don't call StoreReview.requestReview() from a button
|
|
1081
|
+
</Text>
|
|
1082
|
+
</View>
|
|
1083
|
+
</View>
|
|
1084
|
+
<View className="flex-row">
|
|
1085
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
1086
|
+
<View className="flex-1">
|
|
1087
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
1088
|
+
Don't request a review when the user is doing something time sensitive.
|
|
1089
|
+
</Text>
|
|
1090
|
+
</View>
|
|
1091
|
+
</View>
|
|
1092
|
+
<View className="flex-row">
|
|
1093
|
+
<Text className="w-6 text-center text-muted-foreground">·</Text>
|
|
1094
|
+
<View className="flex-1">
|
|
1095
|
+
<Text variant="caption1" className="text-muted-foreground">
|
|
1096
|
+
Don't ask the user any questions before or while presenting the rating button or
|
|
1097
|
+
card.
|
|
1098
|
+
</Text>
|
|
1099
|
+
</View>
|
|
1100
|
+
</View>
|
|
1101
|
+
</View>
|
|
1102
|
+
);
|
|
1103
|
+
}`,
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
id: 13,
|
|
1107
|
+
slug: 'selectable-text',
|
|
1108
|
+
name: 'Selectable Text',
|
|
1109
|
+
description: 'A selectable text region.',
|
|
1110
|
+
additionalFiles: [
|
|
1111
|
+
{
|
|
1112
|
+
path: '~/components/nativewindui/Text.tsx',
|
|
1113
|
+
code: `import * as React from 'react';
|
|
1114
|
+
import { Text as RNText } from 'react-native';
|
|
1115
|
+
import { VariantProps, cva } from 'class-variance-authority';
|
|
1116
|
+
|
|
1117
|
+
import { cn } from '~/lib/cn';
|
|
1118
|
+
|
|
1119
|
+
const textVariants = cva('text-foreground', {
|
|
1120
|
+
variants: {
|
|
1121
|
+
variant: {
|
|
1122
|
+
largeTitle: 'text-4xl',
|
|
1123
|
+
title1: 'text-2xl',
|
|
1124
|
+
title2: 'text-[22px] leading-7',
|
|
1125
|
+
title3: 'text-xl',
|
|
1126
|
+
heading: 'text-[17px] leading-6 font-semibold',
|
|
1127
|
+
body: 'text-[17px] leading-6',
|
|
1128
|
+
callout: 'text-base',
|
|
1129
|
+
subhead: 'text-[15px] leading-6',
|
|
1130
|
+
footnote: 'text-[13px] leading-5',
|
|
1131
|
+
caption1: 'text-xs',
|
|
1132
|
+
caption2: 'text-[11px] leading-4',
|
|
1133
|
+
},
|
|
1134
|
+
color: {
|
|
1135
|
+
primary: '',
|
|
1136
|
+
secondary: 'text-secondary-foreground/90',
|
|
1137
|
+
tertiary: 'text-muted-foreground/90',
|
|
1138
|
+
quarternary: 'text-muted-foreground/50',
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
defaultVariants: {
|
|
1142
|
+
variant: 'body',
|
|
1143
|
+
color: 'primary',
|
|
1144
|
+
},
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
const TextClassContext = React.createContext<string | undefined>(undefined);
|
|
1148
|
+
|
|
1149
|
+
function Text({
|
|
1150
|
+
className,
|
|
1151
|
+
variant,
|
|
1152
|
+
color,
|
|
1153
|
+
...props
|
|
1154
|
+
}: React.ComponentPropsWithoutRef<typeof RNText> & VariantProps<typeof textVariants>) {
|
|
1155
|
+
const textClassName = React.useContext(TextClassContext);
|
|
1156
|
+
return (
|
|
1157
|
+
<RNText className={cn(textVariants({ variant, color }), textClassName, className)} {...props} />
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
export { Text, TextClassContext, textVariants };`,
|
|
1162
|
+
},
|
|
1163
|
+
],
|
|
1164
|
+
dependencies: [
|
|
1165
|
+
{
|
|
1166
|
+
type: 'library',
|
|
1167
|
+
name: 'react-native-uitextview',
|
|
1168
|
+
url: 'https://github.com/bluesky-social/react-native-uitextview?tab=readme-ov-file#installation',
|
|
1169
|
+
},
|
|
1170
|
+
],
|
|
1171
|
+
implementationCode: `import Text from '~/components/nativewindui/Text';
|
|
1172
|
+
|
|
1173
|
+
function SelectableTextExample() {
|
|
1174
|
+
return (
|
|
1175
|
+
<Text uiTextView selectable>
|
|
1176
|
+
Long press or double press this text
|
|
1177
|
+
</Text>
|
|
1178
|
+
);
|
|
1179
|
+
}`,
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
id: 14,
|
|
1183
|
+
slug: 'slider',
|
|
1184
|
+
name: 'Slider',
|
|
1185
|
+
description: 'A slider is a horizontal track with a control, called a thumb, that people can adjust between a minimum and maximum value.',
|
|
1186
|
+
additionalFiles: [
|
|
1187
|
+
{
|
|
1188
|
+
path: '~/components/nativewindui/Slider.tsx',
|
|
1189
|
+
code: `import RNSlider from '@react-native-community/slider';
|
|
1190
|
+
import { Platform } from 'react-native';
|
|
1191
|
+
|
|
1192
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
1193
|
+
import { COLORS } from '~/theme/colors';
|
|
1194
|
+
|
|
1195
|
+
function Slider({
|
|
1196
|
+
thumbTintColor,
|
|
1197
|
+
minimumTrackTintColor,
|
|
1198
|
+
maximumTrackTintColor,
|
|
1199
|
+
...props
|
|
1200
|
+
}: React.ComponentPropsWithoutRef<typeof RNSlider>) {
|
|
1201
|
+
const { colors } = useColorScheme();
|
|
1202
|
+
return (
|
|
1203
|
+
<RNSlider
|
|
1204
|
+
thumbTintColor={thumbTintColor ?? Platform.OS === 'ios' ? COLORS.white : colors.primary}
|
|
1205
|
+
minimumTrackTintColor={minimumTrackTintColor ?? colors.primary}
|
|
1206
|
+
maximumTrackTintColor={
|
|
1207
|
+
maximumTrackTintColor ?? Platform.OS === 'android' ? colors.primary : undefined
|
|
1208
|
+
}
|
|
1209
|
+
{...props}
|
|
1210
|
+
/>
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
export { Slider };`,
|
|
1215
|
+
},
|
|
1216
|
+
],
|
|
1217
|
+
dependencies: [
|
|
1218
|
+
{
|
|
1219
|
+
type: 'library',
|
|
1220
|
+
name: '@react-native-community/slider',
|
|
1221
|
+
url: 'https://github.com/callstack/react-native-slider?tab=readme-ov-file#installation--usage',
|
|
1222
|
+
},
|
|
1223
|
+
],
|
|
1224
|
+
implementationCode: `import * as React from 'react';
|
|
1225
|
+
|
|
1226
|
+
import { Slider } from '~/components/nativewindui/Slider';
|
|
1227
|
+
|
|
1228
|
+
function SliderExample() {
|
|
1229
|
+
const [sliderValue, setSliderValue] = React.useState(0.5);
|
|
1230
|
+
return <Slider value={sliderValue} onValueChange={setSliderValue} />;
|
|
1231
|
+
}`,
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
id: 15,
|
|
1235
|
+
slug: 'text',
|
|
1236
|
+
name: 'Text',
|
|
1237
|
+
description: 'Display, nest, style, and handle touch events for text.',
|
|
1238
|
+
additionalFiles: [
|
|
1239
|
+
{
|
|
1240
|
+
path: '~/components/nativewindui/Text.tsx',
|
|
1241
|
+
code: `import { VariantProps, cva } from 'class-variance-authority';
|
|
1242
|
+
import * as React from 'react';
|
|
1243
|
+
import { Text as RNText } from 'react-native';
|
|
1244
|
+
|
|
1245
|
+
import { cn } from '~/lib/cn';
|
|
1246
|
+
|
|
1247
|
+
const textVariants = cva('text-foreground', {
|
|
1248
|
+
variants: {
|
|
1249
|
+
variant: {
|
|
1250
|
+
largeTitle: 'text-4xl',
|
|
1251
|
+
title1: 'text-2xl',
|
|
1252
|
+
title2: 'text-[22px] leading-7',
|
|
1253
|
+
title3: 'text-xl',
|
|
1254
|
+
heading: 'text-[17px] leading-6 font-semibold',
|
|
1255
|
+
body: 'text-[17px] leading-6',
|
|
1256
|
+
callout: 'text-base',
|
|
1257
|
+
subhead: 'text-[15px] leading-6',
|
|
1258
|
+
footnote: 'text-[13px] leading-5',
|
|
1259
|
+
caption1: 'text-xs',
|
|
1260
|
+
caption2: 'text-[11px] leading-4',
|
|
1261
|
+
},
|
|
1262
|
+
color: {
|
|
1263
|
+
primary: '',
|
|
1264
|
+
secondary: 'text-secondary-foreground/90',
|
|
1265
|
+
tertiary: 'text-muted-foreground/90',
|
|
1266
|
+
quarternary: 'text-muted-foreground/50',
|
|
1267
|
+
},
|
|
1268
|
+
},
|
|
1269
|
+
defaultVariants: {
|
|
1270
|
+
variant: 'body',
|
|
1271
|
+
color: 'primary',
|
|
1272
|
+
},
|
|
1273
|
+
});
|
|
1274
|
+
|
|
1275
|
+
const TextClassContext = React.createContext<string | undefined>(undefined);
|
|
1276
|
+
|
|
1277
|
+
function Text({
|
|
1278
|
+
className,
|
|
1279
|
+
variant,
|
|
1280
|
+
color,
|
|
1281
|
+
...props
|
|
1282
|
+
}: React.ComponentPropsWithoutRef<typeof RNText> & VariantProps<typeof textVariants>) {
|
|
1283
|
+
const textClassName = React.useContext(TextClassContext);
|
|
1284
|
+
return (
|
|
1285
|
+
<RNText className={cn(textVariants({ variant, color }), textClassName, className)} {...props} />
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
export { Text, TextClassContext, textVariants };`,
|
|
1290
|
+
},
|
|
1291
|
+
],
|
|
1292
|
+
implementationCode: `import { View } from 'react-native';
|
|
1293
|
+
|
|
1294
|
+
import { Text } from '~/components/nativewindui/Text';
|
|
1295
|
+
|
|
1296
|
+
function TextExample() {
|
|
1297
|
+
return (
|
|
1298
|
+
<View className="gap-2">
|
|
1299
|
+
<Text variant="largeTitle" className="text-center">
|
|
1300
|
+
Large Title
|
|
1301
|
+
</Text>
|
|
1302
|
+
<Text variant="title1" className="text-center">
|
|
1303
|
+
Title 1
|
|
1304
|
+
</Text>
|
|
1305
|
+
<Text variant="title2" className="text-center">
|
|
1306
|
+
Title 2
|
|
1307
|
+
</Text>
|
|
1308
|
+
<Text variant="title3" className="text-center">
|
|
1309
|
+
Title 3
|
|
1310
|
+
</Text>
|
|
1311
|
+
<Text variant="heading" className="text-center">
|
|
1312
|
+
Heading
|
|
1313
|
+
</Text>
|
|
1314
|
+
<Text variant="body" className="text-center">
|
|
1315
|
+
Body
|
|
1316
|
+
</Text>
|
|
1317
|
+
<Text variant="callout" className="text-center">
|
|
1318
|
+
Callout
|
|
1319
|
+
</Text>
|
|
1320
|
+
<Text variant="subhead" className="text-center">
|
|
1321
|
+
Subhead
|
|
1322
|
+
</Text>
|
|
1323
|
+
<Text variant="footnote" className="text-center">
|
|
1324
|
+
Footnote
|
|
1325
|
+
</Text>
|
|
1326
|
+
<Text variant="caption1" className="text-center">
|
|
1327
|
+
Caption 1
|
|
1328
|
+
</Text>
|
|
1329
|
+
<Text variant="caption2" className="text-center">
|
|
1330
|
+
Caption 2
|
|
1331
|
+
</Text>
|
|
1332
|
+
</View>
|
|
1333
|
+
);
|
|
1334
|
+
}`,
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
id: 16,
|
|
1338
|
+
slug: 'toggle',
|
|
1339
|
+
name: 'Toggle',
|
|
1340
|
+
description: 'A toggle lets people choose between a pair of opposing states, like on and off, using a different appearance to indicate each state.',
|
|
1341
|
+
additionalFiles: [
|
|
1342
|
+
{
|
|
1343
|
+
path: '~/components/nativewindui/Toggle.tsx',
|
|
1344
|
+
code: `import { Switch } from 'react-native';
|
|
1345
|
+
|
|
1346
|
+
import { useColorScheme } from '~/lib/useColorScheme';
|
|
1347
|
+
import { COLORS } from '~/theme/colors';
|
|
1348
|
+
|
|
1349
|
+
function Toggle(props: React.ComponentPropsWithoutRef<typeof Switch>) {
|
|
1350
|
+
const { colors } = useColorScheme();
|
|
1351
|
+
return (
|
|
1352
|
+
<Switch
|
|
1353
|
+
trackColor={{
|
|
1354
|
+
true: colors.primary,
|
|
1355
|
+
false: colors.grey,
|
|
1356
|
+
}}
|
|
1357
|
+
thumbColor={COLORS.white}
|
|
1358
|
+
{...props}
|
|
1359
|
+
/>
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
export { Toggle };`,
|
|
1364
|
+
},
|
|
1365
|
+
],
|
|
1366
|
+
implementationCode: `import * as React from 'react';
|
|
1367
|
+
import { View } from 'react-native';
|
|
1368
|
+
|
|
1369
|
+
import { Toggle } from '~/components/nativewindui/Toggle';
|
|
1370
|
+
|
|
1371
|
+
function ToggleExample() {
|
|
1372
|
+
const [switchValue, setSwitchValue] = React.useState(true);
|
|
1373
|
+
return (
|
|
1374
|
+
<View className="items-center">
|
|
1375
|
+
<Toggle value={switchValue} onValueChange={setSwitchValue} />
|
|
1376
|
+
</View>
|
|
1377
|
+
);
|
|
1378
|
+
}`,
|
|
1379
|
+
},
|
|
1380
|
+
];
|