react-native-boxes 1.4.66 → 1.4.68
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 +526 -3
- package/package.json +1 -1
- package/src/Bar.tsx +2 -2
- package/src/List.tsx +172 -4
- package/src/Modal.tsx +5 -3
package/README.md
CHANGED
|
@@ -1,19 +1,542 @@
|
|
|
1
1
|
# React Native Boxes
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
|
|
7
|
+
A simple to use react library that does all the UI heavy lifting for you so that you can focus on value and not code !
|
|
8
|
+
|
|
9
|
+
Out-of-the box comes with:
|
|
10
|
+
- Themes
|
|
11
|
+
- Layouts (Cards, Vertical, Horizontal, Centered etc.)
|
|
12
|
+
- Texts (Title, Subtitle, Text, Caption etc.)
|
|
13
|
+
- Buttons (Simple, Transparent, Loading etc.)
|
|
14
|
+
- Images and Icons (Icons, Avatars, Images etc.)
|
|
15
|
+
- Font (Specify Regular, Styled and Bold fonts)
|
|
16
|
+
- Bars (Toolbars, Bottom nav bars etc.)
|
|
17
|
+
- Modals (Dialogboxes, Selection bottomsheet, Horizontal selection etc.)
|
|
18
|
+
- Expand box (Animated)
|
|
19
|
+
- Lists (Simple data list)
|
|
20
|
+
- Webview (In app web browser)
|
|
21
|
+
- Internationalization (I18n)
|
|
22
|
+
- Analytics (Clicks, Impression tracking)
|
|
23
|
+
|
|
24
|
+
## Install
|
|
4
25
|
|
|
5
26
|
```
|
|
6
27
|
npm install react-native-boxes
|
|
7
28
|
```
|
|
8
29
|
|
|
9
|
-
|
|
30
|
+
## Dependencies
|
|
10
31
|
|
|
11
|
-
Make sure you have following dependencies installed. The versions can be satisfying version but must not have
|
|
32
|
+
Make sure you have following dependencies installed. The versions can be any satisfying version but must not have any breaking changes.
|
|
12
33
|
|
|
13
34
|
```
|
|
14
35
|
"@expo/vector-icons": "^13.0.0",
|
|
15
36
|
"react": "^18.2.0",
|
|
37
|
+
"@react-native-async-storage/async-storage": "1.23.1",
|
|
16
38
|
"react-native": "^0.73.6",
|
|
17
39
|
"react-native-safe-area-context": "^4.9.0",
|
|
18
40
|
"react-native-gesture-handler":"~2.14.0"
|
|
19
41
|
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
At the root of your app you must add a theme context and thats it! You are good to go.
|
|
45
|
+
```
|
|
46
|
+
import { Colors, DarkColors, Theme } from 'react-native-boxes';
|
|
47
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
48
|
+
|
|
49
|
+
export default function App(){
|
|
50
|
+
const colorScheme = 'dark'
|
|
51
|
+
const theme = new Theme('my-app', colorScheme === 'dark' ? DarkColors : Colors);
|
|
52
|
+
return (
|
|
53
|
+
<ThemeContext.Provider value={theme} >
|
|
54
|
+
<GestureHandlerRootView>
|
|
55
|
+
<WatchlistPage />
|
|
56
|
+
</GestureHandlerRootView>
|
|
57
|
+
</ThemeContext.Provider>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
Optional: If you are also gonna use bottomsheets, Add `GestureHandlerRootView`
|
|
62
|
+
|
|
63
|
+
## Components
|
|
64
|
+
|
|
65
|
+
### Themes
|
|
66
|
+
Dark colors and Light colors come out of the box.
|
|
67
|
+
|
|
68
|
+
Dark Colors
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
Light Colors
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Customizing theme</summary>
|
|
80
|
+
|
|
81
|
+
import { Colors, Theme } from 'react-native-boxes';
|
|
82
|
+
...
|
|
83
|
+
|
|
84
|
+
const MyColors = Object.assign(Colors, {
|
|
85
|
+
accent: '#086CFE',
|
|
86
|
+
accentLight: '#337DFF',
|
|
87
|
+
text: '#444444',
|
|
88
|
+
caption: '#A9A9A9',
|
|
89
|
+
heading: '#222222',
|
|
90
|
+
background: '#E6E6E6',
|
|
91
|
+
forground: '#fff',
|
|
92
|
+
transparent: 'transparent',
|
|
93
|
+
semitransparent: '#111a1a1c',
|
|
94
|
+
info: '#2196F3',
|
|
95
|
+
success: '#4CAF50',
|
|
96
|
+
successBackground: '#388E3C',
|
|
97
|
+
warning: '#FFA726',
|
|
98
|
+
critical: '#F44336',
|
|
99
|
+
invert: {
|
|
100
|
+
text: '#fff',
|
|
101
|
+
caption: '#fff',
|
|
102
|
+
heading: '#fff',
|
|
103
|
+
background: '#1a1a1c'
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
const theme = new Theme('my-app', MyColors);
|
|
107
|
+
return (
|
|
108
|
+
<ThemeContext.Provider value={theme} >
|
|
109
|
+
<WatchlistPage />
|
|
110
|
+
</ThemeContext.Provider>
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
</details>
|
|
114
|
+
|
|
115
|
+
You can also customize sizes, dimensions etc, but it is not recommended.
|
|
116
|
+
<details>
|
|
117
|
+
<summary>Customizing other theme options</summary>
|
|
118
|
+
|
|
119
|
+
const theme = new Theme(
|
|
120
|
+
appname = '',
|
|
121
|
+
colors ,
|
|
122
|
+
dimens ,
|
|
123
|
+
fonts ,
|
|
124
|
+
styles ,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Layouts
|
|
131
|
+
|
|
132
|
+
### VPage
|
|
133
|
+
Your root tag for pages. Consists of vertical alignment and some basic padding.
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
<details>
|
|
138
|
+
<summary>Code sample</summary>
|
|
139
|
+
|
|
140
|
+
<VPage>
|
|
141
|
+
<Title>Watchlist1</Title>
|
|
142
|
+
</VPage>
|
|
143
|
+
|
|
144
|
+
</details>
|
|
145
|
+
|
|
146
|
+
#### Center
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
<details>
|
|
150
|
+
<summary>Code sample</summary>
|
|
151
|
+
|
|
152
|
+
<Center>
|
|
153
|
+
<Title>Watchlist</Title>
|
|
154
|
+
<Caption>Coming soon </Caption>
|
|
155
|
+
</Center>
|
|
156
|
+
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
#### VBox
|
|
160
|
+

|
|
161
|
+
|
|
162
|
+
<details>
|
|
163
|
+
<summary>Code sample</summary>
|
|
164
|
+
|
|
165
|
+
<VBox>
|
|
166
|
+
<Title>Watchlist</Title>
|
|
167
|
+
<Caption>Coming soon </Caption>
|
|
168
|
+
</VBox>
|
|
169
|
+
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
#### HBox
|
|
174
|
+

|
|
175
|
+
|
|
176
|
+
<details>
|
|
177
|
+
<summary>Code sample</summary>
|
|
178
|
+
|
|
179
|
+
<HBox>
|
|
180
|
+
<Title>Watchlist1</Title>
|
|
181
|
+
<Title>Watchlist2</Title>
|
|
182
|
+
</HBox>
|
|
183
|
+
|
|
184
|
+
</details>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Texts
|
|
188
|
+

|
|
189
|
+
|
|
190
|
+
<details>
|
|
191
|
+
<summary>Code sample</summary>
|
|
192
|
+
Icons are from Fontawesome
|
|
193
|
+
https://icons.expo.fyi/Index
|
|
194
|
+
|
|
195
|
+
<Title>Watchlist Title</Title>
|
|
196
|
+
<TextView>
|
|
197
|
+
This is a text with a simple example from a watchlist screen. You can add stocks to your watchlist and see their performance. You can also add alerts to get notified when a stock reaches a certain price.
|
|
198
|
+
</TextView>
|
|
199
|
+
<Subtitle>This is a subtitle for watchlist</Subtitle>
|
|
200
|
+
<TitleText>
|
|
201
|
+
This is a title text that explains what a watchlist is.
|
|
202
|
+
</TitleText>
|
|
203
|
+
<TextView>
|
|
204
|
+
A watchlist is a list of stocks that you are interested in.
|
|
205
|
+
</TextView>
|
|
206
|
+
<TitleText>
|
|
207
|
+
This is a another title text that explains what a watchlist is.
|
|
208
|
+
</TitleText>
|
|
209
|
+
<TextView>
|
|
210
|
+
A watchlist is a list of stocks that you are interested in.
|
|
211
|
+
</TextView>
|
|
212
|
+
<Caption>
|
|
213
|
+
This is a caption. All investments are subject to market risk. Please do your own research before investing in any stock. This app is for educational purposes only.
|
|
214
|
+
</Caption>
|
|
215
|
+
|
|
216
|
+
</details>
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
### Images
|
|
220
|
+
|
|
221
|
+
#### Avatars
|
|
222
|
+
|
|
223
|
+

|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
- With icon
|
|
227
|
+
- With image url
|
|
228
|
+
- With text
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary>Code sample</summary>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
<Avatar iconName='user' />
|
|
235
|
+
<Avatar iconUrl='https://avatars.githubusercontent.com/u/16799797?v=4' />
|
|
236
|
+
<Avatar iconText='SN' />
|
|
237
|
+
|
|
238
|
+
</details>
|
|
239
|
+
|
|
240
|
+
#### Icons
|
|
241
|
+
Support for Fontawesome icon names from https://icons.expo.fyi/
|
|
242
|
+
|
|
243
|
+

|
|
244
|
+
|
|
245
|
+
<details>
|
|
246
|
+
<summary>Code sample</summary>
|
|
247
|
+
|
|
248
|
+
<Icon name='home' size={50} />
|
|
249
|
+
<Title>Light Theme Watchlist</Title>
|
|
250
|
+
|
|
251
|
+
</details>
|
|
252
|
+
|
|
253
|
+
### Buttons
|
|
254
|
+
|
|
255
|
+
<details>
|
|
256
|
+
<summary>Simple button code sample</summary>
|
|
257
|
+
|
|
258
|
+
<ButtonView text='Simple Button' />
|
|
259
|
+
|
|
260
|
+
</details>
|
|
261
|
+
|
|
262
|
+

|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
<details>
|
|
266
|
+
<summary>Transparent button code sample</summary>
|
|
267
|
+
|
|
268
|
+
<TransparentButton text='Transparent Button' />
|
|
269
|
+
|
|
270
|
+
</details>
|
|
271
|
+
|
|
272
|
+

|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
<details>
|
|
276
|
+
<summary>Loading button code sample</summary>
|
|
277
|
+
|
|
278
|
+
const [loading, setLoading] = useState(false)
|
|
279
|
+
|
|
280
|
+
<LoadingButton loading={loading} text='Loading Button' onPress={() => {
|
|
281
|
+
setLoading((prev) => !prev)
|
|
282
|
+
}} />
|
|
283
|
+
|
|
284
|
+
</details>
|
|
285
|
+
|
|
286
|
+

|
|
287
|
+
|
|
288
|
+
### Bottombar
|
|
289
|
+

|
|
290
|
+
|
|
291
|
+
<details>
|
|
292
|
+
<summary>Code sample</summary>
|
|
293
|
+
Icons are from Fontawesome
|
|
294
|
+
https://icons.expo.fyi/Index
|
|
295
|
+
|
|
296
|
+
export default function AppBottomBar() {
|
|
297
|
+
const theme = useContext(ThemeContext)
|
|
298
|
+
const router = useRouter()
|
|
299
|
+
const [selectedId, setSelectedId] = React.useState('watchlist')
|
|
300
|
+
return (
|
|
301
|
+
<BottomNavBar
|
|
302
|
+
selectedId={selectedId}
|
|
303
|
+
options={[
|
|
304
|
+
{
|
|
305
|
+
id: 'watchlist',
|
|
306
|
+
icon: 'bookmark',
|
|
307
|
+
title: 'Watchlist'
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: 'orders',
|
|
311
|
+
icon: 'file-text',
|
|
312
|
+
title: 'Orders'
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
id: 'positions',
|
|
316
|
+
icon: 'briefcase',
|
|
317
|
+
title: 'Positions'
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: 'settings',
|
|
321
|
+
icon: 'gears',
|
|
322
|
+
title: 'Settings'
|
|
323
|
+
}
|
|
324
|
+
]}
|
|
325
|
+
onSelect={(selectedId) => {
|
|
326
|
+
console.log('selected', selectedId)
|
|
327
|
+
setSelectedId(selectedId)
|
|
328
|
+
router.push('/explore')
|
|
329
|
+
}} />
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
</details>
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
### Expand
|
|
337
|
+

|
|
338
|
+
|
|
339
|
+
<details>
|
|
340
|
+
<summary>Code sample</summary>
|
|
341
|
+
|
|
342
|
+
<Expand title='Expand Watchlist' >
|
|
343
|
+
<TextView>INFY</TextView>
|
|
344
|
+
<TextView>TCS</TextView>
|
|
345
|
+
</Expand>
|
|
346
|
+
|
|
347
|
+
</details>
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
### Toolbars
|
|
351
|
+
|
|
352
|
+
### Simple Toolbar
|
|
353
|
+
|
|
354
|
+

|
|
355
|
+
|
|
356
|
+
<details>
|
|
357
|
+
<summary>Code sample</summary>
|
|
358
|
+
|
|
359
|
+
<SimpleToolbar title="Watchlist" />
|
|
360
|
+
|
|
361
|
+
</details>
|
|
362
|
+
|
|
363
|
+
### Transparent Center Toolbar
|
|
364
|
+
|
|
365
|
+

|
|
366
|
+
|
|
367
|
+
<details>
|
|
368
|
+
<summary>Code sample</summary>
|
|
369
|
+
|
|
370
|
+
<SimpleToolbar title="Watchlist" />
|
|
371
|
+
|
|
372
|
+
</details>
|
|
373
|
+
|
|
374
|
+
### Toolbar with buttons
|
|
375
|
+
|
|
376
|
+

|
|
377
|
+
|
|
378
|
+
<details>
|
|
379
|
+
<summary>Code sample</summary>
|
|
380
|
+
|
|
381
|
+
<TransparentCenterToolbar
|
|
382
|
+
homeIcon={"arrow-left"}
|
|
383
|
+
title="Watchlist"
|
|
384
|
+
options={[{
|
|
385
|
+
id: 'search',
|
|
386
|
+
icon: 'search',
|
|
387
|
+
onClick: () => {
|
|
388
|
+
console.log('Search clicked')
|
|
389
|
+
}
|
|
390
|
+
}]}
|
|
391
|
+
/>
|
|
392
|
+
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
### Divider
|
|
398
|
+
|
|
399
|
+

|
|
400
|
+
|
|
401
|
+
<details>
|
|
402
|
+
<summary>Code sample</summary>
|
|
403
|
+
|
|
404
|
+
<Expand title='Expand Watchlist' >
|
|
405
|
+
<TextView>INFY</TextView>
|
|
406
|
+
<TextView>TCS</TextView>
|
|
407
|
+
</Expand>
|
|
408
|
+
|
|
409
|
+
</details>
|
|
410
|
+
|
|
411
|
+
### Modals
|
|
412
|
+
|
|
413
|
+
#### Bottomsheet on mobile
|
|
414
|
+
|
|
415
|
+

|
|
416
|
+
|
|
417
|
+
<details>
|
|
418
|
+
<summary>Code sample</summary>
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
<BottomSheet title="Bottomsheet About Watchlists" visible={showDialog} onDismiss={() => setShowDialog(false)}>
|
|
422
|
+
<TextView>
|
|
423
|
+
This is a simple dialog that can be used to show more information to the user. It is a bottom sheet that can host any content.
|
|
424
|
+
</TextView>
|
|
425
|
+
<HBox />
|
|
426
|
+
<TextView>
|
|
427
|
+
Watchlists are a great way to keep track of your favorite stocks. You can add stocks to your watchlist and see their performance. You can also add alerts to get notified when a stock reaches a certain price.
|
|
428
|
+
</TextView>
|
|
429
|
+
<TertiaryButtonView text='Goto Watchlist' onPress={() => setShowDialog(false)} />
|
|
430
|
+
</BottomSheet>
|
|
431
|
+
|
|
432
|
+
</details>
|
|
433
|
+
|
|
434
|
+
#### Bottomsheet on Desktop (web)
|
|
435
|
+
|
|
436
|
+

|
|
437
|
+
|
|
438
|
+
### Web view
|
|
439
|
+
Opens a webview on native and a `iframe` on Web
|
|
440
|
+
|
|
441
|
+
<details>
|
|
442
|
+
<summary>Code sample</summary>
|
|
443
|
+
|
|
444
|
+
<WebBrowserView url='https://www.google.com' title='Google'/>
|
|
445
|
+
|
|
446
|
+
</details>
|
|
447
|
+
|
|
448
|
+
### Internationalization
|
|
449
|
+
|
|
450
|
+
Install your favorite js library.
|
|
451
|
+
|
|
452
|
+

|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
<details>
|
|
457
|
+
<summary>Code sample</summary>
|
|
458
|
+
|
|
459
|
+
import { I18n } from 'i18n-js';
|
|
460
|
+
|
|
461
|
+
const I18nProvider = new I18n({
|
|
462
|
+
en: {
|
|
463
|
+
watchlist: {
|
|
464
|
+
hello: 'Hello!'
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
hi: {
|
|
468
|
+
watchlist: {
|
|
469
|
+
hello: 'नमस्ते !'
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
hinglish: {
|
|
473
|
+
watchlist: {
|
|
474
|
+
hello: 'Namaste !'
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
es: {
|
|
478
|
+
watchlist: {
|
|
479
|
+
hello: 'Hola!'
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
I18nProvider.missingBehavior = "guess";
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
export default function App(){
|
|
487
|
+
const [locale, setLocale] = useState('en')
|
|
488
|
+
I18nProvider.locale = locale
|
|
489
|
+
const theme = new Theme('appname', colorScheme === 'dark' ? DarkColors : Colors);
|
|
490
|
+
theme.i18n = I18nProvider
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
return (
|
|
494
|
+
<ThemeContext.Provider value={theme} >
|
|
495
|
+
<Center>
|
|
496
|
+
<Title>watchlist.hello</Title>
|
|
497
|
+
</Center>
|
|
498
|
+
<Center>
|
|
499
|
+
<HBox>
|
|
500
|
+
<TransparentButton text='English' onPress={() => {
|
|
501
|
+
setLocale('en')
|
|
502
|
+
}} />
|
|
503
|
+
<TransparentButton text='Hindi' onPress={() => {
|
|
504
|
+
setLocale('hi')
|
|
505
|
+
|
|
506
|
+
}} />
|
|
507
|
+
</HBox>
|
|
508
|
+
<HBox>
|
|
509
|
+
<TransparentButton text='Hinglish' onPress={() => {
|
|
510
|
+
setLocale('hinglish')
|
|
511
|
+
|
|
512
|
+
}} />
|
|
513
|
+
<TransparentButton text='Spanish' onPress={() => {
|
|
514
|
+
setLocale('es')
|
|
515
|
+
|
|
516
|
+
}} />
|
|
517
|
+
</HBox>
|
|
518
|
+
</Center>
|
|
519
|
+
</ThemeContext.Provider>
|
|
520
|
+
)
|
|
521
|
+
}
|
|
522
|
+
</details>
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
### Analytics
|
|
527
|
+
If you wanna track the users clicks and impressions on each component, just add a `onTrack` hook to your theme.
|
|
528
|
+
|
|
529
|
+
```
|
|
530
|
+
action : TrackingActionType = click | view | navigate
|
|
531
|
+
view : TrackingViewType = button | dropdown...
|
|
532
|
+
text : The text related to the component if present
|
|
533
|
+
extra : Depending on component, some contextual info. For e.g. the WebView impression gives {url, title} extra
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
<details>
|
|
537
|
+
|
|
538
|
+
const theme = new Theme('appname', DarkColors);
|
|
539
|
+
theme.onTrack = (action, view, text, extras) => {
|
|
540
|
+
myTracker.track(`${action}-${text}-${text}`, extras)
|
|
541
|
+
}
|
|
542
|
+
</details>
|
package/package.json
CHANGED
package/src/Bar.tsx
CHANGED
|
@@ -171,7 +171,6 @@ export function BottomNavBar(props: ViewProps &
|
|
|
171
171
|
justifyContent: 'center',
|
|
172
172
|
alignItems: 'center',
|
|
173
173
|
margin: 0,
|
|
174
|
-
padding: theme.dimens.space.md,
|
|
175
174
|
paddingTop: !hasText ? theme.dimens.space.lg : theme.dimens.space.md,
|
|
176
175
|
paddingBottom: !hasText ? theme.dimens.space.lg : theme.dimens.space.md,
|
|
177
176
|
}}
|
|
@@ -269,6 +268,7 @@ export type ProgressBarViewProps = ViewProps & {
|
|
|
269
268
|
progressColor?: String
|
|
270
269
|
pendingColor?: String
|
|
271
270
|
}
|
|
271
|
+
|
|
272
272
|
export function ProgressBarView(props: ProgressBarViewProps) {
|
|
273
273
|
const { progress } = props
|
|
274
274
|
const theme = useContext(ThemeContext)
|
|
@@ -292,4 +292,4 @@ export function ProgressBarView(props: ProgressBarViewProps) {
|
|
|
292
292
|
}} />
|
|
293
293
|
</View>
|
|
294
294
|
);
|
|
295
|
-
}
|
|
295
|
+
}
|
package/src/List.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ActivityIndicator, Text, View, ViewProps } from "react-native"
|
|
1
|
+
import { ActivityIndicator, Text, TextStyle, View, ViewProps, ViewStyle } from "react-native"
|
|
2
2
|
import { Box, CardView, Center, HBox, VBox } from "./Box"
|
|
3
|
-
import { getIcon } from "./Image"
|
|
4
|
-
import { Icon } from "@expo/vector-icons/build/createIconSet"
|
|
3
|
+
import { getIcon, Icon } from "./Image"
|
|
5
4
|
import { Caption, Subtitle, TextView, TitleText } from "./Text"
|
|
6
5
|
import { useContext } from "react"
|
|
7
6
|
import { ThemeContext } from "./ThemeContext"
|
|
@@ -121,4 +120,173 @@ export function SimpleDatatlistViewItem(props: SimpleDatatableViewItemProps & Vi
|
|
|
121
120
|
</CardView>
|
|
122
121
|
</PressableView>
|
|
123
122
|
)
|
|
124
|
-
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
export function InfoRow(props: {
|
|
129
|
+
title: string,
|
|
130
|
+
text: string,
|
|
131
|
+
icon?: string | React.ReactNode,
|
|
132
|
+
color?: string,
|
|
133
|
+
style?: ViewStyle,
|
|
134
|
+
textStyle?: TextStyle,
|
|
135
|
+
onPress?: () => void
|
|
136
|
+
}) {
|
|
137
|
+
const theme = useContext(ThemeContext)
|
|
138
|
+
const InfoIcon = getIcon(props.icon)
|
|
139
|
+
return (
|
|
140
|
+
<PressableView onPress={props.onPress} style={{
|
|
141
|
+
opacity: props.onPress ? undefined : 1
|
|
142
|
+
}}>
|
|
143
|
+
<HBox style={{
|
|
144
|
+
paddingStart: theme.dimens.space.sm,
|
|
145
|
+
paddingBottom: theme.dimens.space.sm,
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
}}>
|
|
148
|
+
{InfoIcon && (<InfoIcon
|
|
149
|
+
size={theme.dimens.icon.md * 1.25}
|
|
150
|
+
color={props.color}
|
|
151
|
+
style={{
|
|
152
|
+
paddingEnd: theme.dimens.space.sm,
|
|
153
|
+
paddingStart: theme.dimens.space.sm,
|
|
154
|
+
}} />)}
|
|
155
|
+
<VBox style={[{
|
|
156
|
+
flex: 1,
|
|
157
|
+
paddingStart: theme.dimens.space.sm,
|
|
158
|
+
}, props.style]}>
|
|
159
|
+
<HBox style={{
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
}}>
|
|
162
|
+
|
|
163
|
+
<TitleText style={{
|
|
164
|
+
color: props.color,
|
|
165
|
+
marginBottom: 0,
|
|
166
|
+
paddingBottom: 0,
|
|
167
|
+
flexWrap: 'wrap'
|
|
168
|
+
}}>
|
|
169
|
+
{props.title || ' '}
|
|
170
|
+
</TitleText>
|
|
171
|
+
</HBox>
|
|
172
|
+
<TextView style={[{
|
|
173
|
+
marginTop: 0,
|
|
174
|
+
paddingTop: 0,
|
|
175
|
+
}, props.textStyle]}>
|
|
176
|
+
{props.text || ' '}
|
|
177
|
+
</TextView>
|
|
178
|
+
</VBox>
|
|
179
|
+
</HBox>
|
|
180
|
+
|
|
181
|
+
</PressableView>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
export function IconRow(props: {
|
|
185
|
+
text: string,
|
|
186
|
+
icon?: string | React.ReactNode,
|
|
187
|
+
onPress?: () => void,
|
|
188
|
+
color?: string
|
|
189
|
+
}) {
|
|
190
|
+
const theme = useContext(ThemeContext)
|
|
191
|
+
const LeftIcon = getIcon(props.icon)
|
|
192
|
+
return (
|
|
193
|
+
<PressableView onPress={props.onPress}>
|
|
194
|
+
<HBox style={{
|
|
195
|
+
marginBottom: theme.dimens.space.md,
|
|
196
|
+
alignItems: 'center'
|
|
197
|
+
}}>
|
|
198
|
+
<LeftIcon style={{
|
|
199
|
+
width: theme.dimens.icon.md,
|
|
200
|
+
marginRight: theme.dimens.space.md
|
|
201
|
+
}} color={props.color || theme.colors.text} />
|
|
202
|
+
<TitleText style={{
|
|
203
|
+
color: props.color || theme.colors.text
|
|
204
|
+
}}>{props.text}</TitleText>
|
|
205
|
+
</HBox>
|
|
206
|
+
</PressableView>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
export function SettingRow({
|
|
213
|
+
text,
|
|
214
|
+
icon,
|
|
215
|
+
style,
|
|
216
|
+
color,
|
|
217
|
+
colorDesc,
|
|
218
|
+
description,
|
|
219
|
+
rightIcon,
|
|
220
|
+
onPress,
|
|
221
|
+
}: {
|
|
222
|
+
text: string;
|
|
223
|
+
icon?: string | any;
|
|
224
|
+
color?: string;
|
|
225
|
+
colorDesc?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
rightIcon?: string | any;
|
|
228
|
+
style?: ViewStyle;
|
|
229
|
+
onPress: () => void;
|
|
230
|
+
}) {
|
|
231
|
+
const theme = useContext(ThemeContext);
|
|
232
|
+
const RightIcon = getIcon(rightIcon);
|
|
233
|
+
const LeftIcon = getIcon(icon);
|
|
234
|
+
return (
|
|
235
|
+
|
|
236
|
+
<PressableView onPress={onPress} style={{
|
|
237
|
+
width: '100%',
|
|
238
|
+
|
|
239
|
+
}}>
|
|
240
|
+
<HBox
|
|
241
|
+
style={[
|
|
242
|
+
{
|
|
243
|
+
width: '100%',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
justifyContent: 'space-between',
|
|
246
|
+
paddingTop: theme.dimens.space.lg,
|
|
247
|
+
paddingLeft: theme.dimens.space.lg,
|
|
248
|
+
paddingBottom: theme.dimens.space.md,
|
|
249
|
+
},
|
|
250
|
+
style,
|
|
251
|
+
]}
|
|
252
|
+
>
|
|
253
|
+
<HBox style={{
|
|
254
|
+
flex: 1,
|
|
255
|
+
alignItems: "center",
|
|
256
|
+
}}>
|
|
257
|
+
{icon && (
|
|
258
|
+
typeof icon == 'string' ? <Icon name={icon}
|
|
259
|
+
size={theme.dimens.icon.md}
|
|
260
|
+
color={color || theme.colors.text}
|
|
261
|
+
style={{
|
|
262
|
+
paddingBottom: description ? theme.dimens.space.md : 0,
|
|
263
|
+
}} /> : (LeftIcon && <LeftIcon />)
|
|
264
|
+
)}
|
|
265
|
+
|
|
266
|
+
<VBox style={{
|
|
267
|
+
paddingStart: theme.dimens.space.lg,
|
|
268
|
+
flex: 1
|
|
269
|
+
}}>
|
|
270
|
+
<TitleText
|
|
271
|
+
style={{
|
|
272
|
+
color: color || theme.colors.text,
|
|
273
|
+
fontFamily: theme.fonts.Styled,
|
|
274
|
+
paddingTop: 0,
|
|
275
|
+
paddingBottom: 0,
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
{text}
|
|
279
|
+
</TitleText>
|
|
280
|
+
|
|
281
|
+
{description && <Caption style={{
|
|
282
|
+
color: colorDesc || theme.colors.caption,
|
|
283
|
+
}}>{description}</Caption>}
|
|
284
|
+
</VBox>
|
|
285
|
+
</HBox>
|
|
286
|
+
|
|
287
|
+
{rightIcon && <RightIcon />}
|
|
288
|
+
</HBox>
|
|
289
|
+
|
|
290
|
+
</PressableView>
|
|
291
|
+
);
|
|
292
|
+
}
|
package/src/Modal.tsx
CHANGED
|
@@ -320,7 +320,7 @@ export function Expand(props: ViewProps & {
|
|
|
320
320
|
<Icon
|
|
321
321
|
color={theme.colors.text}
|
|
322
322
|
{...props.iconStyle}
|
|
323
|
-
name={props.iconName || 'chevron-right'}
|
|
323
|
+
name={props.iconName || 'chevron-circle-right'}
|
|
324
324
|
/>
|
|
325
325
|
</Animated.View>
|
|
326
326
|
<HBox style={{
|
|
@@ -350,7 +350,7 @@ export function Expand(props: ViewProps & {
|
|
|
350
350
|
<ExpandIcon />
|
|
351
351
|
<Animated.View
|
|
352
352
|
style={{
|
|
353
|
-
zIndex:
|
|
353
|
+
zIndex: 1,
|
|
354
354
|
transform: [{ translateY: fadeAnim }],
|
|
355
355
|
height: expanded ? 'auto' : 0,
|
|
356
356
|
overflow: 'hidden'
|
|
@@ -358,7 +358,9 @@ export function Expand(props: ViewProps & {
|
|
|
358
358
|
onLayout={onLayoutContent}>
|
|
359
359
|
{
|
|
360
360
|
(expanded || initDone) && (
|
|
361
|
-
<VBox onLayout={onLayoutContent}
|
|
361
|
+
<VBox onLayout={onLayoutContent} style={{
|
|
362
|
+
paddingStart: theme.dimens.space.md * 3
|
|
363
|
+
}}>
|
|
362
364
|
{props.children}
|
|
363
365
|
</VBox>
|
|
364
366
|
)
|