react-native-boxes 1.4.83 → 1.4.84

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.
@@ -0,0 +1,1158 @@
1
+ # AI Instructions for React Native Boxes Components
2
+
3
+ This document provides detailed information about the input props and usage for each component in the react-native-boxes library.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Theme & Context](#theme--context)
8
+ 2. [Layout Components](#layout-components)
9
+ 3. [Text Components](#text-components)
10
+ 4. [Button Components](#button-components)
11
+ 5. [Image Components](#image-components)
12
+ 6. [Input Components](#input-components)
13
+ 7. [Bar Components](#bar-components)
14
+ 8. [Modal Components](#modal-components)
15
+ 9. [List Components](#list-components)
16
+ 10. [Message Components](#message-components)
17
+ 11. [Utilities](#utilities)
18
+
19
+ ---
20
+
21
+ ## Theme & Context
22
+
23
+ ### Theme
24
+
25
+ The `Theme` class is used to configure the application's appearance and behavior.
26
+
27
+ **Constructor Parameters:**
28
+ - `name` (string): Theme name
29
+ - `colors` (typeof Colors): Color scheme object (default: `Colors`)
30
+ - `dimens` (typeof Dimens): Dimensions object (default: `Dimens`)
31
+ - `fonts` (typeof Fonts): Fonts configuration (default: `Fonts`)
32
+ - `styles` (StyleSheet): Custom styles (default: auto-generated)
33
+ - `i18n` (I18n): Internationalization instance (optional)
34
+ - `onTrack` (AnalyticTracker): Analytics tracking function (optional)
35
+
36
+ **Properties:**
37
+ - `name`: Theme name
38
+ - `colors`: Color configuration
39
+ - `dimens`: Dimension configuration
40
+ - `fonts`: Font configuration
41
+ - `styles`: StyleSheet
42
+ - `i18n`: Internationalization instance
43
+ - `onTrack`: Analytics tracker function
44
+ - `insets`: Safe area insets (EdgeInsets)
45
+ - `randomColor`: Function to generate random colors
46
+
47
+ **Methods:**
48
+ - `setInsets(insets: EdgeInsets)`: Set safe area insets
49
+ - `setTracking(onTrack: AnalyticTracker)`: Set analytics tracker
50
+
51
+ **Usage:**
52
+ ```typescript
53
+ import { Theme, ThemeContext, Colors, DarkColors } from 'react-native-boxes';
54
+
55
+ const theme = new Theme('my-app', DarkColors);
56
+ theme.onTrack = (action, view, text, extras) => {
57
+ console.log('Track:', action, view, text, extras);
58
+ };
59
+
60
+ <ThemeContext.Provider value={theme}>
61
+ {/* Your app components */}
62
+ </ThemeContext.Provider>
63
+ ```
64
+
65
+ ### Colors
66
+
67
+ **Light Colors (default):**
68
+ - `accent`: '#086CFE'
69
+ - `accentLight`: '#337DFF'
70
+ - `text`: '#444444'
71
+ - `caption`: '#A9A9A9'
72
+ - `heading`: '#222222'
73
+ - `background`: '#E6E6E6'
74
+ - `forground`: '#fff'
75
+ - `transparent`: 'transparent'
76
+ - `info`: '#2196F3'
77
+ - `success`: '#4CAF50'
78
+ - `warning`: '#FFA726'
79
+ - `critical`: '#F44336'
80
+ - `invert`: Object with inverted colors
81
+
82
+ **Dark Colors:**
83
+ Same structure with adjusted values for dark theme.
84
+
85
+ ### Dimens
86
+
87
+ - `space`: { xs: 1, sm: 5, md: 10, lg: 20, xl: 50 }
88
+ - `font`: { sm: 12, md: 14, lg: 16, xl: 24 }
89
+ - `icon`: { sm: 12, md: 20, lg: 30, xl: 50, xxl: 80 }
90
+
91
+ ### Fonts
92
+
93
+ - `Regular`: 'Regular'
94
+ - `Bold`: 'Bold'
95
+ - `Styled`: 'Styled'
96
+
97
+ ---
98
+
99
+ ## Layout Components
100
+
101
+ ### Box
102
+
103
+ Basic container component with padding and optional random background color.
104
+
105
+ **Props:** Extends `ViewProps`
106
+ - All standard React Native View props
107
+
108
+ **Usage:**
109
+ ```tsx
110
+ <Box style={{ backgroundColor: 'white' }}>
111
+ {/* Content */}
112
+ </Box>
113
+ ```
114
+
115
+ ### VBox
116
+
117
+ Vertical box with column flex direction.
118
+
119
+ **Props:** Extends `ViewProps`
120
+ - All standard React Native View props
121
+
122
+ **Usage:**
123
+ ```tsx
124
+ <VBox>
125
+ <Text>Item 1</Text>
126
+ <Text>Item 2</Text>
127
+ </VBox>
128
+ ```
129
+
130
+ ### HBox
131
+
132
+ Horizontal box with row flex direction.
133
+
134
+ **Props:** Extends `ViewProps`
135
+ - All standard React Native View props
136
+
137
+ **Usage:**
138
+ ```tsx
139
+ <HBox>
140
+ <Text>Left</Text>
141
+ <Text>Right</Text>
142
+ </HBox>
143
+ ```
144
+
145
+ ### Center
146
+
147
+ Centers content both horizontally and vertically.
148
+
149
+ **Props:** Extends `ViewProps`
150
+ - All standard React Native View props
151
+
152
+ **Usage:**
153
+ ```tsx
154
+ <Center>
155
+ <Text>Centered Content</Text>
156
+ </Center>
157
+ ```
158
+
159
+ ### VPage
160
+
161
+ Full-screen vertical page container with background color.
162
+
163
+ **Props:** Extends `ViewProps`
164
+ - All standard React Native View props
165
+
166
+ **Usage:**
167
+ ```tsx
168
+ <VPage>
169
+ <Text>Page Content</Text>
170
+ </VPage>
171
+ ```
172
+
173
+ ### CardView
174
+
175
+ Card-style container with padding, border radius, and elevated appearance.
176
+
177
+ **Props:** Extends `ViewProps`
178
+ - All standard React Native View props
179
+
180
+ **Usage:**
181
+ ```tsx
182
+ <CardView>
183
+ <Text>Card Content</Text>
184
+ </CardView>
185
+ ```
186
+
187
+ ### KeyboardAvoidingScrollView
188
+
189
+ ScrollView that automatically adjusts for keyboard and safe areas.
190
+
191
+ **Props:** Extends `ScrollViewProps`
192
+ - All standard React Native ScrollView props
193
+
194
+ **Note:** Must be wrapped with SafeAreaView somewhere in parent tree
195
+
196
+ **Usage:**
197
+ ```tsx
198
+ <KeyboardAvoidingScrollView>
199
+ <TextInput placeholder="Type here" />
200
+ </KeyboardAvoidingScrollView>
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Text Components
206
+
207
+ ### TextView
208
+
209
+ Base text component with internationalization support.
210
+
211
+ **Props:** Extends `TextProps`
212
+ - `skipI18n` (boolean): Skip internationalization
213
+ - `value` (string): Text value (alternative to children)
214
+ - `text` (string): Text value (alternative to children)
215
+ - All standard React Native Text props
216
+
217
+ **Usage:**
218
+ ```tsx
219
+ <TextView>Hello World</TextView>
220
+ <TextView text="Hello World" />
221
+ <TextView value="Hello World" skipI18n={true} />
222
+ ```
223
+
224
+ ### Title
225
+
226
+ Large heading text component.
227
+
228
+ **Props:** Extends `TextProps`
229
+ - All standard React Native Text props
230
+
231
+ **Usage:**
232
+ ```tsx
233
+ <Title>Page Title</Title>
234
+ ```
235
+
236
+ ### Subtitle
237
+
238
+ Subtitle text component.
239
+
240
+ **Props:** Extends `TextProps`
241
+ - All standard React Native Text props
242
+
243
+ **Usage:**
244
+ ```tsx
245
+ <Subtitle>This is a subtitle</Subtitle>
246
+ ```
247
+
248
+ ### Caption
249
+
250
+ Small caption text component.
251
+
252
+ **Props:** Extends `TextProps`
253
+ - All standard React Native Text props
254
+
255
+ **Usage:**
256
+ ```tsx
257
+ <Caption>Small caption text</Caption>
258
+ ```
259
+
260
+ ### TitleText
261
+
262
+ Bold title text component.
263
+
264
+ **Props:** Extends `TextProps`
265
+ - All standard React Native Text props
266
+
267
+ **Usage:**
268
+ ```tsx
269
+ <TitleText>Bold Title</TitleText>
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Button Components
275
+
276
+ ### ButtonView
277
+
278
+ Primary button component with customizable styling.
279
+
280
+ **Props:** Extends `TextProps` & `TouchableHighlightProps`
281
+ - `icon` (any): Icon to display (string name or component)
282
+ - `text` (string): Button text
283
+ - `textStyle` (TextStyle): Custom text styling
284
+ - `children` (any): Button content
285
+ - All TouchableHighlight props
286
+
287
+ **Usage:**
288
+ ```tsx
289
+ <ButtonView text="Click Me" onPress={() => console.log('Clicked')} />
290
+ <ButtonView icon="home" text="Home" onPress={handlePress} />
291
+ ```
292
+
293
+ ### TransparentButton
294
+
295
+ Transparent button with accent color text.
296
+
297
+ **Props:** Extends `TextProps` & `TouchableHighlightProps`
298
+ - `icon` (any): Icon to display
299
+ - `text` (string): Button text
300
+ - All TouchableHighlight props
301
+
302
+ **Usage:**
303
+ ```tsx
304
+ <TransparentButton text="Cancel" onPress={handleCancel} />
305
+ ```
306
+
307
+ ### TertiaryButtonView
308
+
309
+ Button with transparent background and accent text.
310
+
311
+ **Props:** Same as `ButtonView`
312
+
313
+ **Usage:**
314
+ ```tsx
315
+ <TertiaryButtonView text="Learn More" onPress={handleLearnMore} />
316
+ ```
317
+
318
+ ### LoadingButton
319
+
320
+ Button with loading state indicator.
321
+
322
+ **Props:** Extends `TextProps` & `TouchableHighlightProps`
323
+ - `loading` (boolean): Show loading indicator
324
+ - `icon` (any): Icon to display when not loading
325
+ - `text` (string): Button text
326
+ - `loaderStyle` ('normal' | 'transparent'): Loading indicator style
327
+ - `underlayColor` (string): Underlay color when pressed
328
+ - All TouchableHighlight props
329
+
330
+ **Usage:**
331
+ ```tsx
332
+ <LoadingButton
333
+ loading={isLoading}
334
+ text="Submit"
335
+ onPress={handleSubmit}
336
+ loaderStyle="normal"
337
+ />
338
+ ```
339
+
340
+ ### RightIconButton
341
+
342
+ Button with icon positioned on the right side.
343
+
344
+ **Props:** Same as `ButtonView`
345
+
346
+ **Usage:**
347
+ ```tsx
348
+ <RightIconButton
349
+ text="Next"
350
+ icon="arrow-right"
351
+ onPress={handleNext}
352
+ />
353
+ ```
354
+
355
+ ### PressableView
356
+
357
+ Wrapper for React Native Pressable with opacity effect.
358
+
359
+ **Props:** Extends `PressableProps`
360
+ - All standard React Native Pressable props
361
+
362
+ **Usage:**
363
+ ```tsx
364
+ <PressableView onPress={handlePress}>
365
+ <Text>Pressable Content</Text>
366
+ </PressableView>
367
+ ```
368
+
369
+ ### SwitchView
370
+
371
+ Switch component with optional label.
372
+
373
+ **Props:** Extends `SwitchProps`
374
+ - `text` (string): Label text
375
+ - `orientation` ('row' | 'column' | 'row-reverse' | 'column-reverse'): Layout orientation
376
+ - `textStyle` (TextStyle): Text styling
377
+ - All React Native Switch props
378
+
379
+ **Usage:**
380
+ ```tsx
381
+ <SwitchView
382
+ value={isEnabled}
383
+ onValueChange={setIsEnabled}
384
+ text="Enable notifications"
385
+ />
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Image Components
391
+
392
+ ### Icon
393
+
394
+ FontAwesome icon component.
395
+
396
+ **Props:** Extends `ViewProps`
397
+ - `name` (any): FontAwesome icon name (required)
398
+ - `size` (number): Icon size
399
+ - `color` (string): Icon color
400
+ - `onPress` (() => void): Press handler
401
+
402
+ **Usage:**
403
+ ```tsx
404
+ <Icon name="home" size={24} color="#086CFE" />
405
+ <Icon name="user" onPress={handleIconPress} />
406
+ ```
407
+
408
+ ### Avatar
409
+
410
+ Circular avatar component supporting images, icons, or text.
411
+
412
+ **Props:** Extends `ViewProps`
413
+ - `onPress` (Function): Press handler
414
+ - `iconUrl` (string): URL for avatar image
415
+ - `iconName` (string): FontAwesome icon name
416
+ - `iconText` (string): Text to display (shows first 2 characters)
417
+ - `iconNameProps` (IconProps): Icon configuration
418
+ - `style` (any): Custom styles
419
+
420
+ **Note:** Provide one of: `iconUrl`, `iconName`, or `iconText`
421
+
422
+ **Usage:**
423
+ ```tsx
424
+ <Avatar iconUrl="https://example.com/avatar.jpg" />
425
+ <Avatar iconName="user" />
426
+ <Avatar iconText="JD" />
427
+ ```
428
+
429
+ ### Spinner
430
+
431
+ Loading spinner component.
432
+
433
+ **Props:** Extends `ActivityIndicatorProps`
434
+ - All React Native ActivityIndicator props
435
+
436
+ **Usage:**
437
+ ```tsx
438
+ <Spinner />
439
+ <Spinner size="large" color="#086CFE" />
440
+ ```
441
+
442
+ ### StatusIcon
443
+
444
+ Icon that changes based on status.
445
+
446
+ **Props:** Extends `ViewProps`
447
+ - `status` (string | any): Status value (required)
448
+ - `colorMap` (Array): Custom status mappings
449
+ - Each item: `{ status: string, icon: string, color: string }`
450
+
451
+ **Built-in statuses:**
452
+ - 'SUCCESS': green check
453
+ - 'FAILED': red close
454
+ - 'PARTIAL_SUCCESS': yellow warning
455
+ - 'IN_PROGRESS': blue play
456
+ - 'PAUSED': gray pause
457
+
458
+ **Usage:**
459
+ ```tsx
460
+ <StatusIcon status="SUCCESS" />
461
+ <StatusIcon
462
+ status="CUSTOM"
463
+ colorMap={[
464
+ { status: 'CUSTOM', icon: 'star', color: '#FFD700' }
465
+ ]}
466
+ />
467
+ ```
468
+
469
+ ---
470
+
471
+ ## Input Components
472
+
473
+ ### TextInputView
474
+
475
+ Basic text input with pattern validation.
476
+
477
+ **Props:** Extends `TextInputProps`
478
+ - `initialText` (string): Initial text value
479
+ - `pattern` (string): Regex pattern for validation
480
+ - All React Native TextInput props
481
+
482
+ **Usage:**
483
+ ```tsx
484
+ <TextInputView
485
+ placeholder="Enter text"
486
+ initialText=""
487
+ onChangeText={setText}
488
+ />
489
+ <TextInputView
490
+ pattern="[0-9]*"
491
+ placeholder="Numbers only"
492
+ />
493
+ ```
494
+
495
+ ### CompositeTextInputView
496
+
497
+ Enhanced text input with label, icon, and alert text.
498
+
499
+ **Props:** Extends `TextInputProps`
500
+ - `hint` (string): Hint text
501
+ - `alertText` (string): Error/alert message
502
+ - `alertTextColor` (string): Alert text color
503
+ - `pattern` (string): Regex pattern for validation
504
+ - `initialText` (string): Initial text value
505
+ - `leftIcon` (string | React.Component): Left-side icon
506
+ - `icon` (string | React.Component): Right-side icon ('close', 'eye', etc.)
507
+ - `onIconPress` ((event) => void): Icon press handler
508
+ - `textInputProps` (TextInputProps): Additional TextInput props
509
+ - `onDone` ((txt: string) => void): Handler when input is done
510
+ - All React Native TextInput props
511
+
512
+ **Note:** If input is inside ScrollView, add `keyboardShouldPersistTaps={'handled'}` to the ScrollView.
513
+
514
+ **Usage:**
515
+ ```tsx
516
+ <CompositeTextInputView
517
+ placeholder="Email"
518
+ icon="close"
519
+ leftIcon="envelope"
520
+ alertText="Invalid email"
521
+ alertTextColor="#F44336"
522
+ onChangeText={setEmail}
523
+ />
524
+ ```
525
+
526
+ ---
527
+
528
+ ## Bar Components
529
+
530
+ ### SimpleToolbar
531
+
532
+ Basic toolbar with title and optional buttons.
533
+
534
+ **Props:** Extends `ViewProps`
535
+ - `title` (String): Toolbar title
536
+ - `hideStatusBar` (boolean): Hide status bar
537
+ - `backgroundColor` (string): Background color
538
+ - `statusbarBackgroundColor` (string): Status bar background
539
+ - `forgroundColor` (string): Text/icon color
540
+ - `homeIcon` (string | typeof Icon): Home/back icon
541
+ - `onHomePress` (() => void): Home button press handler
542
+ - `textStyle` (TextStyle): Title text style
543
+ - `options` (Option[]): Array of toolbar options
544
+ - `id` (string): Option identifier
545
+ - `title` (string): Option title
546
+ - `icon` (string | any): Option icon
547
+ - `onClick` ((id: string) => void): Click handler
548
+
549
+ **Usage:**
550
+ ```tsx
551
+ <SimpleToolbar title="Home" />
552
+ <SimpleToolbar
553
+ title="Settings"
554
+ homeIcon="arrow-left"
555
+ onHomePress={() => navigation.goBack()}
556
+ options={[
557
+ { id: 'search', icon: 'search', onClick: handleSearch }
558
+ ]}
559
+ />
560
+ ```
561
+
562
+ ### TransparentCenterToolbar
563
+
564
+ Toolbar with transparent background and centered title.
565
+
566
+ **Props:** Same as `SimpleToolbar`
567
+
568
+ **Usage:**
569
+ ```tsx
570
+ <TransparentCenterToolbar
571
+ title="Profile"
572
+ homeIcon="arrow-left"
573
+ onHomePress={handleBack}
574
+ />
575
+ ```
576
+
577
+ ### BottomNavBar
578
+
579
+ Bottom navigation bar with multiple options.
580
+
581
+ **Props:** Extends `ViewProps`
582
+ - `options` (Option[]): Navigation options (required)
583
+ - `id` (string): Option identifier
584
+ - `title` (string): Option title (optional)
585
+ - `icon` (string | any): Option icon
586
+ - `onClick` ((id: string) => void): Click handler (optional)
587
+ - `selectedId` (string): Currently selected option ID (required)
588
+ - `onSelect` ((id: string) => void): Selection handler (required)
589
+ - `onDimens` ((width: number, height: number) => void): Dimension callback
590
+
591
+ **Usage:**
592
+ ```tsx
593
+ <BottomNavBar
594
+ selectedId={selectedId}
595
+ options={[
596
+ { id: 'home', icon: 'home', title: 'Home' },
597
+ { id: 'search', icon: 'search', title: 'Search' },
598
+ { id: 'profile', icon: 'user', title: 'Profile' }
599
+ ]}
600
+ onSelect={setSelectedId}
601
+ />
602
+ ```
603
+
604
+ ### DividerView
605
+
606
+ Horizontal divider with optional text.
607
+
608
+ **Props:** Extends `ViewProps`
609
+ - `text` (string): Text to display in divider
610
+
611
+ **Usage:**
612
+ ```tsx
613
+ <DividerView />
614
+ <DividerView text="OR" />
615
+ ```
616
+
617
+ ### ProgressBarView
618
+
619
+ Horizontal progress bar.
620
+
621
+ **Props:** Extends `ViewProps`
622
+ - `progress` (number): Progress percentage (0-100) (required)
623
+ - `progressColor` (String): Color of progress bar
624
+ - `pendingColor` (String): Color of remaining portion
625
+
626
+ **Usage:**
627
+ ```tsx
628
+ <ProgressBarView progress={75} />
629
+ <ProgressBarView
630
+ progress={50}
631
+ progressColor="#4CAF50"
632
+ pendingColor="#E0E0E0"
633
+ />
634
+ ```
635
+
636
+ ---
637
+
638
+ ## Modal Components
639
+
640
+ ### BottomSheet
641
+
642
+ Bottom sheet modal that slides up from bottom.
643
+
644
+ **Props:**
645
+ - `visible` (boolean): Show/hide modal (required)
646
+ - `title` (string | React.Component): Sheet title
647
+ - `cancellable` (boolean): Allow dismissal (default: true)
648
+ - `children` (any): Sheet content (required)
649
+ - `onDismiss` (Function): Dismiss callback
650
+ - `backgroundColor` (string): Background color
651
+ - `closeIcon` (string | React.ReactNode): Custom close icon
652
+ - `swipeToCloseDisabled` (boolean): Disable swipe to close
653
+
654
+ **Note:** Set `swipeToCloseDisabled = true` if facing scrolling issues.
655
+
656
+ **Usage:**
657
+ ```tsx
658
+ <BottomSheet
659
+ visible={isVisible}
660
+ title="Options"
661
+ onDismiss={() => setIsVisible(false)}
662
+ >
663
+ <Text>Sheet content</Text>
664
+ </BottomSheet>
665
+ ```
666
+
667
+ ### Expand
668
+
669
+ Animated expandable/collapsible container.
670
+
671
+ **Props:** Extends `ViewProps`
672
+ - `title` (string): Header title
673
+ - `iconName` (string): Custom icon name
674
+ - `iconPosition` ('left' | 'right'): Icon position
675
+ - `leftPadding` (number): Content left padding
676
+ - `titleStyle` (StyleProp<TextStyle>): Title styling
677
+ - `titleBackgroundColor` (string): Title background
678
+ - `iconStyle` (IconProps): Icon styling
679
+ - `initialExpand` (boolean): Initial expanded state
680
+ - `duration` (number): Animation duration (ms)
681
+ - `onExpand` ((isExpanded: boolean) => void): Expand callback
682
+ - `onChange` ((isExpanded: boolean) => void): Change callback
683
+
684
+ **Usage:**
685
+ ```tsx
686
+ <Expand title="Show Details" initialExpand={false}>
687
+ <Text>Hidden content</Text>
688
+ </Expand>
689
+ ```
690
+
691
+ ### DropDownView
692
+
693
+ Dropdown selector with multiple display modes.
694
+
695
+ **Props:** Extends `CompositeTextInputViewProps`
696
+ - `listType` ('sheet' | 'horizontal-list'): Display style
697
+ - `options` (DropDownViewOption[]): Options array (required)
698
+ - `id` (string): Option ID
699
+ - `value` (any): Option value
700
+ - `title` (string): Display title
701
+ - `selectedId` (string): Selected option ID (required)
702
+ - `onSelect` ((selectedId: string, opt: DropDownViewOption) => void): Selection handler (required)
703
+ - `initialVisile` (Boolean): Initial visibility
704
+ - `title` (string): Dropdown title
705
+ - `displayType` ('button' | 'input'): Display type
706
+ - `onRenderList` ((opts, onSelect) => any): Custom list renderer
707
+ - `onRenderOption` ((opt, setSelected) => any): Custom option renderer
708
+ - `onEmptyListPlaceholder` ((dismiss?) => React.ReactNode): Empty state
709
+ - `forceDialogSelectOnWeb` (Boolean): Force dialog on web
710
+ - `swipeToCloseDisabled` (boolean): Disable swipe to close
711
+
712
+ **Note:** Set `swipeToCloseDisabled = true` if facing scrolling issues.
713
+
714
+ **Usage:**
715
+ ```tsx
716
+ <DropDownView
717
+ title="Select Country"
718
+ selectedId={selectedCountry}
719
+ options={[
720
+ { id: 'us', value: 'us', title: 'United States' },
721
+ { id: 'uk', value: 'uk', title: 'United Kingdom' }
722
+ ]}
723
+ onSelect={(id, opt) => setSelectedCountry(id)}
724
+ />
725
+ ```
726
+
727
+ ### ConfirmationDialog
728
+
729
+ Confirmation dialog with confirm/cancel buttons.
730
+
731
+ **Props:**
732
+ - `visible` (boolean): Show/hide dialog (required)
733
+ - `title` (string | React.Component): Dialog title
734
+ - `cancellable` (boolean): Allow dismissal
735
+ - `onDismiss` (Function): Dismiss callback
736
+ - `onConfirm` (() => void): Confirm handler (required)
737
+ - `onCancel` (() => void): Cancel handler
738
+ - `message` (string): Dialog message
739
+ - `confirmText` (String): Confirm button text (default: 'common.confirm')
740
+ - `cancelText` (String): Cancel button text (default: 'common.cancel')
741
+ - `children` (any): Custom content
742
+ - `noSheet` (boolean): Render without bottom sheet
743
+ - `style` (ViewStyle): Custom styles
744
+
745
+ **Usage:**
746
+ ```tsx
747
+ <ConfirmationDialog
748
+ visible={showConfirm}
749
+ title="Confirm Delete"
750
+ message="Are you sure you want to delete this item?"
751
+ onConfirm={handleDelete}
752
+ onDismiss={() => setShowConfirm(false)}
753
+ />
754
+ ```
755
+
756
+ ### GenericDialog
757
+
758
+ Generic dialog with customizable buttons.
759
+
760
+ **Props:** Same as `ConfirmationDialog`
761
+
762
+ **Usage:**
763
+ ```tsx
764
+ <GenericDialog
765
+ visible={showDialog}
766
+ title="Information"
767
+ confirmText="OK"
768
+ onConfirm={handleOk}
769
+ onDismiss={() => setShowDialog(false)}
770
+ />
771
+ ```
772
+
773
+ ### WebBrowserView
774
+
775
+ In-app web browser component.
776
+
777
+ **Props:**
778
+ - `url` (string): URL to open (required)
779
+ - `title` (string): Page title
780
+ - `openMessage` (string): Opening message
781
+ - `retryMessage` (string): Retry button text
782
+ - `cancelMessage` (string): Cancel button text
783
+ - `onCancel` (() => void): Cancel handler (required)
784
+ - `navigation` (object): Navigation object (required)
785
+ - `navigate` ((path: string, params: any) => void)
786
+
787
+ **Usage:**
788
+ ```tsx
789
+ <WebBrowserView
790
+ url="https://example.com"
791
+ title="External Link"
792
+ onCancel={() => navigation.goBack()}
793
+ navigation={navigation}
794
+ />
795
+ ```
796
+
797
+ ---
798
+
799
+ ## List Components
800
+
801
+ ### SimpleDatalistView
802
+
803
+ Data list view with customizable item rendering.
804
+
805
+ **Props:** Extends `ViewProps`
806
+ - `items` (any[]): Array of items (required)
807
+ - `itemAdapter` ((item, idx, list) => SimpleDatatableViewItemProps): Item adapter function
808
+ - `loading` (boolean): Show loading spinner
809
+ - `onRender` ((item, idx, list) => Component): Custom render function
810
+
811
+ **Note:** Must provide either `itemAdapter` or `onRender`.
812
+
813
+ **Usage:**
814
+ ```tsx
815
+ <SimpleDatalistView
816
+ items={users}
817
+ itemAdapter={(user) => ({
818
+ title: user.name,
819
+ subtitle: user.email,
820
+ icon: 'user'
821
+ })}
822
+ />
823
+ ```
824
+
825
+ ### SimpleDatatlistViewItem
826
+
827
+ Individual list item component.
828
+
829
+ **Props:** Extends `ViewProps`
830
+ - `title` (string): Item title
831
+ - `icon` (string | any): Item icon
832
+ - `subtitle` (string | React.ReactNode): Item subtitle
833
+ - `body` (string | React.ReactNode): Item body text
834
+ - `action` (React.ReactNode): Action component (e.g., button)
835
+ - `onPress` (() => void): Press handler
836
+ - `flexRatio` ([number, number, number]): Width ratios [icon, content, action]
837
+
838
+ **Usage:**
839
+ ```tsx
840
+ <SimpleDatatlistViewItem
841
+ title="John Doe"
842
+ subtitle="Software Engineer"
843
+ body="john@example.com"
844
+ icon="user"
845
+ onPress={handlePress}
846
+ />
847
+ ```
848
+
849
+ ### InfoRow
850
+
851
+ Information row with icon, title, and text.
852
+
853
+ **Props:**
854
+ - `title` (string): Row title (required)
855
+ - `text` (string): Row text (required)
856
+ - `icon` (string | React.ReactNode): Icon
857
+ - `color` (string): Text color
858
+ - `style` (ViewStyle): Container style
859
+ - `textStyle` (TextStyle): Text style
860
+ - `onPress` (() => void): Press handler
861
+
862
+ **Usage:**
863
+ ```tsx
864
+ <InfoRow
865
+ title="Email"
866
+ text="user@example.com"
867
+ icon="envelope"
868
+ onPress={handleEmailPress}
869
+ />
870
+ ```
871
+
872
+ ### IconRow
873
+
874
+ Row with icon and text.
875
+
876
+ **Props:**
877
+ - `text` (string): Row text (required)
878
+ - `icon` (string | React.ReactNode): Icon
879
+ - `onPress` (() => void): Press handler
880
+ - `color` (string): Text/icon color
881
+
882
+ **Usage:**
883
+ ```tsx
884
+ <IconRow
885
+ text="Settings"
886
+ icon="cog"
887
+ onPress={handleSettings}
888
+ />
889
+ ```
890
+
891
+ ### SettingRow
892
+
893
+ Settings row with optional description and right icon.
894
+
895
+ **Props:**
896
+ - `text` (string): Setting name (required)
897
+ - `icon` (string | any): Left icon
898
+ - `color` (string): Text color
899
+ - `colorDesc` (string): Description color
900
+ - `description` (string): Setting description
901
+ - `rightIcon` (string | any): Right icon
902
+ - `style` (ViewStyle): Container style
903
+ - `onPress` (() => void): Press handler (required)
904
+
905
+ **Usage:**
906
+ ```tsx
907
+ <SettingRow
908
+ text="Notifications"
909
+ icon="bell"
910
+ description="Manage notification settings"
911
+ rightIcon="chevron-right"
912
+ onPress={handleNotifications}
913
+ />
914
+ ```
915
+
916
+ ---
917
+
918
+ ## Message Components
919
+
920
+ ### AlertMessage
921
+
922
+ Alert message component with different types.
923
+
924
+ **Props:**
925
+ - `text` (string): Alert message (required)
926
+ - `type` ('info' | 'success' | 'warning' | 'critical'): Alert type
927
+ - `color` (string): Custom text color
928
+ - `onDismiss` (() => void): Dismiss handler
929
+ - `action` (React.ReactNode): Custom action component
930
+ - `style` (ViewStyle): Container style
931
+ - `onPress` (() => void): Press handler
932
+
933
+ **Usage:**
934
+ ```tsx
935
+ <AlertMessage
936
+ text="Operation successful"
937
+ type="success"
938
+ onDismiss={() => setShowAlert(false)}
939
+ />
940
+ <AlertMessage
941
+ text="An error occurred"
942
+ type="critical"
943
+ />
944
+ ```
945
+
946
+ ---
947
+
948
+ ## Utilities
949
+
950
+ ### Analytics
951
+
952
+ **TrackingActionType:**
953
+ - `CLICK`: 'click'
954
+ - `VIEW`: 'view'
955
+ - `NAVIGATE`: 'navigate'
956
+
957
+ **TrackingViewType:**
958
+ - `BUTTON`: 'button'
959
+ - `TEXT`: 'text'
960
+ - `DIALOG`: 'dialog'
961
+ - `DROPDOWN`: 'dropdown'
962
+ - `WEBVIEW`: 'webview'
963
+ - `BOX`: 'box'
964
+ - `SWITCH`: 'switch'
965
+ - `IMAGE`: 'image'
966
+ - `TOOLBAR`: 'toolbar'
967
+ - `BOTTOMBAR`: 'bottombar'
968
+ - `PAGE`: 'page'
969
+
970
+ **AnalyticTracker Type:**
971
+ ```typescript
972
+ type AnalyticTracker = (
973
+ action: string,
974
+ view: string,
975
+ text?: string,
976
+ extra?: any
977
+ ) => void
978
+ ```
979
+
980
+ **Usage:**
981
+ ```typescript
982
+ theme.onTrack = (action, view, text, extras) => {
983
+ analytics.track(`${action}-${view}`, {
984
+ text,
985
+ ...extras
986
+ });
987
+ };
988
+ ```
989
+
990
+ ### I18n
991
+
992
+ **Type:**
993
+ ```typescript
994
+ type I18n = {
995
+ t: (id?: string, placeholders?: any) => string | undefined
996
+ }
997
+ ```
998
+
999
+ **Usage:**
1000
+ ```typescript
1001
+ import { I18n } from 'i18n-js';
1002
+
1003
+ const i18n = new I18n({
1004
+ en: { hello: 'Hello!' },
1005
+ es: { hello: 'Hola!' }
1006
+ });
1007
+
1008
+ theme.i18n = i18n;
1009
+ ```
1010
+
1011
+ ### Storage
1012
+
1013
+ Async storage utilities.
1014
+
1015
+ **Methods:**
1016
+ - `getKeyAsync(key: string)`: Get stored value
1017
+ - `setKeyAsync(key: string, value?: string)`: Set/remove stored value
1018
+
1019
+ **Usage:**
1020
+ ```typescript
1021
+ import { Storage } from 'react-native-boxes';
1022
+
1023
+ const value = await Storage.getKeyAsync('myKey');
1024
+ await Storage.setKeyAsync('myKey', 'myValue');
1025
+ await Storage.setKeyAsync('myKey', undefined); // Remove
1026
+ ```
1027
+
1028
+ ### Utility Functions
1029
+
1030
+ **isWeb()**: Returns true if running on web platform
1031
+ **isNative()**: Returns true if running on native platform
1032
+ **isAndroid()**: Returns true if running on Android
1033
+ **isIOS()**: Returns true if running on iOS
1034
+ **isDesktop()**: Returns true if window width > height
1035
+ **randomColor()**: Generates random hex color (currently returns undefined)
1036
+
1037
+ **Usage:**
1038
+ ```typescript
1039
+ import { isWeb, isNative, isDesktop } from 'react-native-boxes';
1040
+
1041
+ if (isWeb()) {
1042
+ // Web-specific code
1043
+ }
1044
+ ```
1045
+
1046
+ ### getNavParamsFromDeeplink
1047
+
1048
+ Parse deep link URL into navigation parameters.
1049
+
1050
+ **Parameters:**
1051
+ - `url` (string): Deep link URL
1052
+
1053
+ **Returns:** `[root: string, params: object]`
1054
+
1055
+ **Usage:**
1056
+ ```typescript
1057
+ import { getNavParamsFromDeeplink } from 'react-native-boxes';
1058
+
1059
+ const [route, params] = getNavParamsFromDeeplink('myapp://profile/123?tab=posts');
1060
+ // route: 'myapp'
1061
+ // params: { screen: 'profile', params: { ... } }
1062
+ ```
1063
+
1064
+ ---
1065
+
1066
+ ## Complete Usage Example
1067
+
1068
+ ```typescript
1069
+ import React, { useState } from 'react';
1070
+ import {
1071
+ Theme,
1072
+ ThemeContext,
1073
+ DarkColors,
1074
+ VPage,
1075
+ SimpleToolbar,
1076
+ VBox,
1077
+ Title,
1078
+ TextView,
1079
+ ButtonView,
1080
+ TextInputView,
1081
+ BottomSheet,
1082
+ AlertMessage
1083
+ } from 'react-native-boxes';
1084
+ import { GestureHandlerRootView } from 'react-native-gesture-handler';
1085
+
1086
+ export default function App() {
1087
+ const theme = new Theme('my-app', DarkColors);
1088
+ const [showSheet, setShowSheet] = useState(false);
1089
+ const [text, setText] = useState('');
1090
+
1091
+ theme.onTrack = (action, view, text, extras) => {
1092
+ console.log('Analytics:', action, view, text, extras);
1093
+ };
1094
+
1095
+ return (
1096
+ <ThemeContext.Provider value={theme}>
1097
+ <GestureHandlerRootView style={{ flex: 1 }}>
1098
+ <VPage>
1099
+ <SimpleToolbar title="My App" />
1100
+
1101
+ <VBox style={{ padding: 20 }}>
1102
+ <Title>Welcome</Title>
1103
+ <TextView>This is a sample app using react-native-boxes.</TextView>
1104
+
1105
+ <TextInputView
1106
+ placeholder="Enter text"
1107
+ value={text}
1108
+ onChangeText={setText}
1109
+ />
1110
+
1111
+ <ButtonView
1112
+ text="Open Sheet"
1113
+ onPress={() => setShowSheet(true)}
1114
+ />
1115
+
1116
+ <AlertMessage
1117
+ text="This is an info message"
1118
+ type="info"
1119
+ />
1120
+ </VBox>
1121
+
1122
+ <BottomSheet
1123
+ visible={showSheet}
1124
+ title="Bottom Sheet"
1125
+ onDismiss={() => setShowSheet(false)}
1126
+ >
1127
+ <TextView>Sheet content goes here</TextView>
1128
+ </BottomSheet>
1129
+ </VPage>
1130
+ </GestureHandlerRootView>
1131
+ </ThemeContext.Provider>
1132
+ );
1133
+ }
1134
+ ```
1135
+
1136
+ ---
1137
+
1138
+ ## Notes
1139
+
1140
+ 1. **Theme Context**: Always wrap your app with `ThemeContext.Provider` to use components properly.
1141
+
1142
+ 2. **GestureHandler**: Wrap with `GestureHandlerRootView` when using bottom sheets or gesture-based components.
1143
+
1144
+ 3. **Safe Areas**: Some components like `KeyboardAvoidingScrollView` and toolbars require safe area context. Either use `SafeAreaView` or set `theme.insets` manually.
1145
+
1146
+ 4. **Internationalization**: Text components automatically use `theme.i18n.t()` unless `skipI18n` is set to true.
1147
+
1148
+ 5. **Analytics**: Components automatically track user interactions if `theme.onTrack` is configured.
1149
+
1150
+ 6. **Icons**: Icon names come from FontAwesome. See https://icons.expo.fyi/ for available icons.
1151
+
1152
+ 7. **Fonts**: Load custom fonts with names 'Regular', 'Bold', and 'Styled' for proper component styling.
1153
+
1154
+ 8. **Web Platform**: Some components have platform-specific behavior (web vs native). Use utility functions like `isWeb()` to check platform.
1155
+
1156
+ 9. **TypeScript**: All components are TypeScript-ready with full type definitions.
1157
+
1158
+ 10. **Customization**: Most components accept standard React Native props (`style`, event handlers, etc.) for full customization.
package/README.md CHANGED
@@ -52,7 +52,8 @@ Make sure you have following dependencies installed. The versions can be any sat
52
52
  "@react-native-async-storage/async-storage": "1.23.1",
53
53
  "react-native": "^0.73.6",
54
54
  "react-native-safe-area-context": "^4.9.0",
55
- "react-native-gesture-handler":"~2.14.0"
55
+ "react-native-gesture-handler":"~2.14.0",
56
+ "expo-web-browser": "^13.0.3"
56
57
  ```
57
58
 
58
59
  ## Usage
@@ -132,7 +133,7 @@ You can also customize sizes, dimensions etc, but it is not recommended.
132
133
  <summary>Customizing other theme options</summary>
133
134
 
134
135
  const theme = new Theme(
135
- appname = '',
136
+ name = '',
136
137
  colors ,
137
138
  dimens ,
138
139
  fonts ,
@@ -515,7 +516,7 @@ Install your favorite js library.
515
516
  export default function App(){
516
517
  const [locale, setLocale] = useState('en')
517
518
  I18nProvider.locale = locale
518
- const theme = new Theme('appname', colorScheme === 'dark' ? DarkColors : Colors);
519
+ const theme = new Theme('dark', colorScheme === 'dark' ? DarkColors : Colors);
519
520
  theme.i18n = I18nProvider
520
521
 
521
522
 
@@ -588,7 +589,7 @@ extra : Depending on component, some contextual info. For e.g. the WebView impre
588
589
 
589
590
  <details>
590
591
 
591
- const theme = new Theme('appname', DarkColors);
592
+ const theme = new Theme('dark', DarkColors);
592
593
  theme.onTrack = (action, view, text, extras) => {
593
594
  myTracker.track(`${action}-${text}-${text}`, extras)
594
595
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-boxes",
3
- "version": "1.4.83",
3
+ "version": "1.4.84",
4
4
  "description": "A react native library for rapid development of UI using boxes",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -37,4 +37,4 @@
37
37
  "expo-web-browser": "^13.0.3"
38
38
  },
39
39
  "dependencies": {}
40
- }
40
+ }
@@ -6,7 +6,8 @@ import { EdgeInsets } from "react-native-safe-area-context"
6
6
  import { AnalyticTracker } from "./Analytics"
7
7
  const DEFAULT_STYLE = createStyle(Dimens, Colors, Fonts)
8
8
  export class Theme {
9
- appname: string = ''
9
+ private appname: string = 'deprecated-field'
10
+ name: string = ''
10
11
  styles: typeof DEFAULT_STYLE
11
12
  dimens: typeof Dimens
12
13
  colors: typeof Colors
@@ -15,14 +16,15 @@ export class Theme {
15
16
  onTrack: AnalyticTracker
16
17
  insets?: EdgeInsets
17
18
  randomColor = randomColor
18
- constructor(appname = '',
19
+ constructor(name = '',
19
20
  colors = Colors,
20
21
  dimens = Dimens,
21
22
  fonts = Fonts,
22
23
  styles = DEFAULT_STYLE,
23
24
  i18n = _i18n,
24
25
  onTrack = () => { }) {
25
- this.appname = appname
26
+ this.name = name
27
+ this.appname = name
26
28
  this.fonts = fonts ?? Fonts
27
29
  this.colors = colors ?? Colors
28
30
  this.dimens = dimens ?? Dimens