react-native-timer-picker 2.3.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -116
- package/dist/commonjs/components/DurationScroll/DurationScroll.js +15 -27
- package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +1 -1
- package/dist/commonjs/components/DurationScroll/types.js.map +1 -1
- package/dist/commonjs/components/PickerItem/PickerItem.js +47 -0
- package/dist/commonjs/components/PickerItem/PickerItem.js.map +1 -0
- package/dist/commonjs/components/PickerItem/index.js +14 -0
- package/dist/commonjs/components/PickerItem/index.js.map +1 -0
- package/dist/commonjs/components/TimerPicker/TimerPicker.js +11 -7
- package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/styles.js +45 -18
- package/dist/commonjs/components/TimerPicker/styles.js.map +1 -1
- package/dist/commonjs/components/TimerPickerModal/styles.js +4 -15
- package/dist/commonjs/components/TimerPickerModal/styles.js.map +1 -1
- package/dist/commonjs/tests/Modal.test.js +2 -22
- package/dist/commonjs/tests/Modal.test.js.map +1 -1
- package/dist/commonjs/tests/TimerPickerModal.test.js +53 -53
- package/dist/commonjs/tests/TimerPickerModal.test.js.map +1 -1
- package/dist/commonjs/tests/generateNumbers.test.js +35 -35
- package/dist/commonjs/tests/generateNumbers.test.js.map +1 -1
- package/dist/commonjs/tests/padNumber.test.js +18 -18
- package/dist/commonjs/tests/padNumber.test.js.map +1 -1
- package/dist/commonjs/utils/generateNumbers.js +4 -3
- package/dist/commonjs/utils/generateNumbers.js.map +1 -1
- package/dist/commonjs/utils/padNumber.js +7 -7
- package/dist/commonjs/utils/padNumber.js.map +1 -1
- package/dist/module/components/DurationScroll/DurationScroll.js +14 -27
- package/dist/module/components/DurationScroll/DurationScroll.js.map +1 -1
- package/dist/module/components/DurationScroll/types.js.map +1 -1
- package/dist/module/components/PickerItem/PickerItem.js +40 -0
- package/dist/module/components/PickerItem/PickerItem.js.map +1 -0
- package/dist/module/components/PickerItem/index.js +2 -0
- package/dist/module/components/PickerItem/index.js.map +1 -0
- package/dist/module/components/TimerPicker/TimerPicker.js +11 -7
- package/dist/module/components/TimerPicker/TimerPicker.js.map +1 -1
- package/dist/module/components/TimerPicker/styles.js +45 -18
- package/dist/module/components/TimerPicker/styles.js.map +1 -1
- package/dist/module/components/TimerPickerModal/styles.js +4 -15
- package/dist/module/components/TimerPickerModal/styles.js.map +1 -1
- package/dist/module/tests/Modal.test.js +2 -22
- package/dist/module/tests/Modal.test.js.map +1 -1
- package/dist/module/tests/TimerPickerModal.test.js +9 -9
- package/dist/module/tests/TimerPickerModal.test.js.map +1 -1
- package/dist/module/tests/generateNumbers.test.js +35 -35
- package/dist/module/tests/generateNumbers.test.js.map +1 -1
- package/dist/module/tests/padNumber.test.js +18 -18
- package/dist/module/tests/padNumber.test.js.map +1 -1
- package/dist/module/utils/generateNumbers.js +4 -3
- package/dist/module/utils/generateNumbers.js.map +1 -1
- package/dist/module/utils/padNumber.js +7 -7
- package/dist/module/utils/padNumber.js.map +1 -1
- package/dist/typescript/components/DurationScroll/types.d.ts +1 -0
- package/dist/typescript/components/PickerItem/PickerItem.d.ts +15 -0
- package/dist/typescript/components/PickerItem/index.d.ts +1 -0
- package/dist/typescript/components/TimerPicker/styles.d.ts +153 -25
- package/dist/typescript/components/TimerPickerModal/styles.d.ts +256 -254
- package/dist/typescript/utils/padNumber.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[]()
|
|
4
4
|

|
|
5
5
|
[](https://www.npmjs.com/package/react-native-timer-picker)
|
|
6
|
-
|
|
6
|
+
[](https://www.npmjs.com/package/react-native-timer-picker)
|
|
7
7
|
|
|
8
8
|
A simple, flexible, performant duration picker component for React Native apps 🔥
|
|
9
9
|
|
|
@@ -13,37 +13,37 @@ Works with Expo and bare React Native apps ✅
|
|
|
13
13
|
|
|
14
14
|
Includes iOS-style haptic and audio feedback 🍏
|
|
15
15
|
|
|
16
|
-
- [Demos 📱](#demos-)
|
|
17
|
-
- [Installation 🚀](#installation-)
|
|
18
|
-
- [Peer Dependencies 👶](#peer-dependencies-)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- [Examples 😎](#examples-)
|
|
22
|
-
- [Timer Picker Modal (Dark Mode) 🌚](#timer-picker-modal-dark-mode-)
|
|
23
|
-
- [Timer Picker Modal (Light Mode) 🌞](#timer-picker-modal-light-mode-)
|
|
24
|
-
- [Timer Picker Modal with Custom Buttons 🎨](#timer-picker-modal-with-custom-buttons-)
|
|
25
|
-
- [Timer Picker with Transparent Fade-Out (Dark Mode) 🌒](#timer-picker-with-transparent-fade-out-dark-mode-)
|
|
26
|
-
- [Timer Picker with Customisation (Light Mode) 🌔](#timer-picker-with-customisation-light-mode-)
|
|
27
|
-
- [Props 💅](#props-)
|
|
28
|
-
- [TimerPicker ⏲️](#timerpicker-️)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- [TimerPickerModal ⏰](#timerpickermodal-)
|
|
33
|
-
|
|
34
|
-
- [Methods 🔄](#methods-)
|
|
35
|
-
- [TimerPicker](#timerpicker)
|
|
36
|
-
- [TimerPickerModal](#timerpickermodal)
|
|
37
|
-
- [Picker Feedback 📳🔉](#picker-feedback-)
|
|
38
|
-
- [Audio Feedack](#audio-feedack)
|
|
39
|
-
- [Haptic Feedback](#haptic-feedback)
|
|
40
|
-
- [Feedback Example](#feedback-example)
|
|
41
|
-
- [Expo-Specific Audio/Haptic Feedback (DEPRECATED)](#expo-specific-audiohaptic-feedback-deprecated)
|
|
42
|
-
- [Contributing 🧑🤝🧑](#contributing-)
|
|
43
|
-
- [Dev Setup](#dev-setup)
|
|
44
|
-
- [GitHub Guidelines](#github-guidelines)
|
|
45
|
-
- [Limitations ⚠](#limitations-)
|
|
46
|
-
- [License 📝](#license-)
|
|
16
|
+
- [Demos 📱](#demos-)
|
|
17
|
+
- [Installation 🚀](#installation-)
|
|
18
|
+
- [Peer Dependencies 👶](#peer-dependencies-)
|
|
19
|
+
- [Linear Gradient](#linear-gradient)
|
|
20
|
+
- [Masked View](#masked-view)
|
|
21
|
+
- [Examples 😎](#examples-)
|
|
22
|
+
- [Timer Picker Modal (Dark Mode) 🌚](#timer-picker-modal-dark-mode-)
|
|
23
|
+
- [Timer Picker Modal (Light Mode) 🌞](#timer-picker-modal-light-mode-)
|
|
24
|
+
- [Timer Picker Modal with Custom Buttons 🎨](#timer-picker-modal-with-custom-buttons-)
|
|
25
|
+
- [Timer Picker with Transparent Fade-Out (Dark Mode) 🌒](#timer-picker-with-transparent-fade-out-dark-mode-)
|
|
26
|
+
- [Timer Picker with Customisation (Light Mode) 🌔](#timer-picker-with-customisation-light-mode-)
|
|
27
|
+
- [Props 💅](#props-)
|
|
28
|
+
- [TimerPicker ⏲️](#timerpicker-️)
|
|
29
|
+
- [Custom Styles 👗](#custom-styles-)
|
|
30
|
+
- [Performance](#performance)
|
|
31
|
+
- [Custom FlatList](#custom-flatlist)
|
|
32
|
+
- [TimerPickerModal ⏰](#timerpickermodal-)
|
|
33
|
+
- [Custom Styles 👕](#custom-styles--1)
|
|
34
|
+
- [Methods 🔄](#methods-)
|
|
35
|
+
- [TimerPicker](#timerpicker)
|
|
36
|
+
- [TimerPickerModal](#timerpickermodal)
|
|
37
|
+
- [Picker Feedback 📳🔉](#picker-feedback-)
|
|
38
|
+
- [Audio Feedack](#audio-feedack)
|
|
39
|
+
- [Haptic Feedback](#haptic-feedback)
|
|
40
|
+
- [Feedback Example](#feedback-example)
|
|
41
|
+
- [Expo-Specific Audio/Haptic Feedback (DEPRECATED)](#expo-specific-audiohaptic-feedback-deprecated)
|
|
42
|
+
- [Contributing 🧑🤝🧑](#contributing-)
|
|
43
|
+
- [Dev Setup](#dev-setup)
|
|
44
|
+
- [GitHub Guidelines](#github-guidelines)
|
|
45
|
+
- [Limitations ⚠](#limitations-)
|
|
46
|
+
- [License 📝](#license-)
|
|
47
47
|
|
|
48
48
|
<br>
|
|
49
49
|
|
|
@@ -99,7 +99,7 @@ To make the numbers fade in/out on a transparent background (e.g. if the picker
|
|
|
99
99
|
|
|
100
100
|
`import MaskedView from "@react-native-masked-view/masked-view";`
|
|
101
101
|
|
|
102
|
-
**To enable the fade-out on a transparent background, you need to supply the imported `MaskedView` component AND one of the LinearGradient components as props to either TimerPickerModal or TimerPicker
|
|
102
|
+
**To enable the fade-out on a transparent background, you need to supply the imported `MaskedView` component AND one of the LinearGradient components as props to either TimerPickerModal or TimerPicker (see [this example](#timer-picker-with-transparent-fade-out-dark-mode-)).**
|
|
103
103
|
|
|
104
104
|
<br>
|
|
105
105
|
|
|
@@ -146,7 +146,7 @@ const formatTime = ({
|
|
|
146
146
|
return (
|
|
147
147
|
<View style={{backgroundColor: "#514242", alignItems: "center", justifyContent: "center"}}>
|
|
148
148
|
<Text style={{fontSize: 18, color: "#F1F1F1"}}>
|
|
149
|
-
{
|
|
149
|
+
{alarmString !== null
|
|
150
150
|
? "Alarm set for"
|
|
151
151
|
: "No alarm set"}
|
|
152
152
|
</Text>
|
|
@@ -181,22 +181,22 @@ return (
|
|
|
181
181
|
</View>
|
|
182
182
|
</TouchableOpacity>
|
|
183
183
|
<TimerPickerModal
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
closeOnOverlayPress
|
|
185
|
+
LinearGradient={LinearGradient}
|
|
186
|
+
modalProps={{
|
|
187
|
+
overlayOpacity: 0.2,
|
|
188
|
+
}}
|
|
189
|
+
modalTitle="Set Alarm"
|
|
190
|
+
onCancel={() => setShowPicker(false)}
|
|
186
191
|
onConfirm={(pickedDuration) => {
|
|
187
192
|
setAlarmString(formatTime(pickedDuration));
|
|
188
193
|
setShowPicker(false);
|
|
189
194
|
}}
|
|
190
|
-
|
|
191
|
-
onCancel={() => setShowPicker(false)}
|
|
192
|
-
closeOnOverlayPress
|
|
193
|
-
LinearGradient={LinearGradient}
|
|
195
|
+
setIsVisible={setShowPicker}
|
|
194
196
|
styles={{
|
|
195
197
|
theme: "dark",
|
|
196
198
|
}}
|
|
197
|
-
|
|
198
|
-
overlayOpacity: 0.2,
|
|
199
|
-
}}
|
|
199
|
+
visible={showPicker}
|
|
200
200
|
/>
|
|
201
201
|
</View>
|
|
202
202
|
)
|
|
@@ -244,7 +244,7 @@ const formatTime = ({
|
|
|
244
244
|
return (
|
|
245
245
|
<View style={{backgroundColor: "#F1F1F1", alignItems: "center", justifyContent: "center"}}>
|
|
246
246
|
<Text style={{fontSize: 18, color: "#202020"}}>
|
|
247
|
-
{
|
|
247
|
+
{alarmString !== null
|
|
248
248
|
? "Alarm set for"
|
|
249
249
|
: "No alarm set"}
|
|
250
250
|
</Text>
|
|
@@ -271,27 +271,27 @@ return (
|
|
|
271
271
|
borderColor: "#8C8C8C",
|
|
272
272
|
color: "#8C8C8C"
|
|
273
273
|
}}>
|
|
274
|
-
Set Alarm 🔔
|
|
274
|
+
{"Set Alarm 🔔"}
|
|
275
275
|
</Text>
|
|
276
276
|
</View>
|
|
277
277
|
</TouchableOpacity>
|
|
278
278
|
</View>
|
|
279
279
|
</TouchableOpacity>
|
|
280
280
|
<TimerPickerModal
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
closeOnOverlayPress
|
|
282
|
+
LinearGradient={LinearGradient}
|
|
283
|
+
modalTitle="Set Alarm"
|
|
284
|
+
onCancel={() => setShowPicker(false)}
|
|
283
285
|
onConfirm={(pickedDuration) => {
|
|
284
286
|
setAlarmString(formatTime(pickedDuration));
|
|
285
287
|
setShowPicker(false);
|
|
286
288
|
}}
|
|
287
|
-
|
|
288
|
-
onCancel={() => setShowPicker(false)}
|
|
289
|
-
closeOnOverlayPress
|
|
290
|
-
use12HourPicker
|
|
291
|
-
LinearGradient={LinearGradient}
|
|
289
|
+
setIsVisible={setShowPicker}
|
|
292
290
|
styles={{
|
|
293
291
|
theme: "light",
|
|
294
292
|
}}
|
|
293
|
+
use12HourPicker
|
|
294
|
+
visible={showPicker}
|
|
295
295
|
/>
|
|
296
296
|
</View>
|
|
297
297
|
)
|
|
@@ -305,15 +305,15 @@ return (
|
|
|
305
305
|
```jsx
|
|
306
306
|
import { TimerPickerModal } from "react-native-timer-picker";
|
|
307
307
|
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
308
|
-
import { TouchableOpacity, Text, StyleSheet
|
|
308
|
+
import { TouchableOpacity, Text, StyleSheet } from "react-native";
|
|
309
309
|
|
|
310
310
|
// Custom Button Component
|
|
311
|
-
interface
|
|
311
|
+
interface CustomButtonProps {
|
|
312
312
|
label: string;
|
|
313
313
|
onPress?: () => void;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
const
|
|
316
|
+
const CustomButton: React.FC<CustomButtonProps> = ({ label, onPress }) => {
|
|
317
317
|
return (
|
|
318
318
|
<TouchableOpacity onPress={onPress} style={styles.customButtonContainer}>
|
|
319
319
|
<LinearGradient
|
|
@@ -410,23 +410,24 @@ return (
|
|
|
410
410
|
</View>
|
|
411
411
|
</TouchableOpacity>
|
|
412
412
|
<TimerPickerModal
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
cancelButton={<CustomButton label="Cancel" />}
|
|
414
|
+
closeOnOverlayPress
|
|
415
|
+
confirmButton={<CustomButton label="Confirm" />}
|
|
416
|
+
LinearGradient={LinearGradient}
|
|
417
|
+
modalProps={{
|
|
418
|
+
overlayOpacity: 0.2,
|
|
419
|
+
}}
|
|
420
|
+
modalTitle="Set Alarm"
|
|
421
|
+
onCancel={() => setShowPicker(false)}
|
|
415
422
|
onConfirm={(pickedDuration) => {
|
|
416
423
|
setAlarmString(formatTime(pickedDuration));
|
|
417
424
|
setShowPicker(false);
|
|
418
425
|
}}
|
|
419
|
-
|
|
420
|
-
onCancel={() => setShowPicker(false)}
|
|
421
|
-
closeOnOverlayPress
|
|
422
|
-
use12HourPicker
|
|
423
|
-
LinearGradient={LinearGradient}
|
|
424
|
-
// Custom buttons
|
|
425
|
-
cancelButton={<MyCustomButton label="Cancel" />}
|
|
426
|
-
confirmButton={<MyCustomButton label="Confirm" />}
|
|
426
|
+
setIsVisible={setShowPicker}
|
|
427
427
|
styles={{
|
|
428
|
-
theme: "
|
|
428
|
+
theme: "dark",
|
|
429
429
|
}}
|
|
430
|
+
visible={showPicker}
|
|
430
431
|
/>
|
|
431
432
|
</View>
|
|
432
433
|
)
|
|
@@ -443,46 +444,36 @@ import MaskedView from "@react-native-masked-view/masked-view"; // for transpare
|
|
|
443
444
|
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
444
445
|
|
|
445
446
|
....
|
|
446
|
-
const [showPicker, setShowPicker] = useState(false);
|
|
447
|
-
const [alarmString, setAlarmString] = useState<
|
|
448
|
-
string | null
|
|
449
|
-
>(null);
|
|
450
447
|
|
|
451
448
|
return (
|
|
452
449
|
<LinearGradient
|
|
453
450
|
colors={["#202020", "#220578"]}
|
|
454
|
-
start={{ x: 0, y: 0 }}
|
|
455
451
|
end={{ x: 1, y: 1 }}
|
|
452
|
+
start={{ x: 0, y: 0 }}
|
|
456
453
|
style={{alignItems: "center", justifyContent: "center"}}>
|
|
457
454
|
<TimerPicker
|
|
458
|
-
padWithNItems={2}
|
|
459
455
|
hourLabel=":"
|
|
460
|
-
minuteLabel=":"
|
|
461
|
-
secondLabel=""
|
|
462
456
|
LinearGradient={LinearGradient}
|
|
463
457
|
MaskedView={MaskedView}
|
|
458
|
+
minuteLabel=":"
|
|
459
|
+
padWithNItems={2}
|
|
460
|
+
secondLabel=""
|
|
464
461
|
styles={{
|
|
465
462
|
theme: "dark",
|
|
466
|
-
backgroundColor: "transparent",
|
|
463
|
+
backgroundColor: "transparent",
|
|
467
464
|
pickerItem: {
|
|
468
465
|
fontSize: 34,
|
|
469
466
|
},
|
|
467
|
+
pickerLabelContainer: {
|
|
468
|
+
marginTop: -4,
|
|
469
|
+
right: 0,
|
|
470
|
+
left: undefined,
|
|
471
|
+
},
|
|
470
472
|
pickerLabel: {
|
|
471
473
|
fontSize: 32,
|
|
472
|
-
marginTop: 0,
|
|
473
474
|
},
|
|
474
475
|
pickerContainer: {
|
|
475
|
-
|
|
476
|
-
},
|
|
477
|
-
pickerItemContainer: {
|
|
478
|
-
width: 100
|
|
479
|
-
},
|
|
480
|
-
pickerLabelContainer: {
|
|
481
|
-
right: -20,
|
|
482
|
-
top: 0,
|
|
483
|
-
bottom: 6,
|
|
484
|
-
width: 40,
|
|
485
|
-
alignItems: "center",
|
|
476
|
+
paddingHorizontal: 50,
|
|
486
477
|
},
|
|
487
478
|
}}
|
|
488
479
|
/>
|
|
@@ -500,33 +491,26 @@ import { TimerPicker } from "react-native-timer-picker";
|
|
|
500
491
|
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
501
492
|
|
|
502
493
|
....
|
|
503
|
-
const [showPicker, setShowPicker] = useState(false);
|
|
504
|
-
const [alarmString, setAlarmString] = useState<
|
|
505
|
-
string | null
|
|
506
|
-
>(null);
|
|
507
494
|
|
|
508
495
|
return (
|
|
509
496
|
<View style={{backgroundColor: "#F1F1F1", alignItems: "center", justifyContent: "center"}}>
|
|
510
497
|
<TimerPicker
|
|
511
|
-
padWithNItems={3}
|
|
512
498
|
hideHours
|
|
499
|
+
LinearGradient={LinearGradient}
|
|
513
500
|
minuteLabel="min"
|
|
501
|
+
padWithNItems={3}
|
|
514
502
|
secondLabel="sec"
|
|
515
|
-
LinearGradient={LinearGradient}
|
|
516
503
|
styles={{
|
|
517
504
|
theme: "light",
|
|
505
|
+
labelOffsetPercentage: 0,
|
|
518
506
|
pickerItem: {
|
|
519
507
|
fontSize: 34,
|
|
520
508
|
},
|
|
521
509
|
pickerLabel: {
|
|
522
510
|
fontSize: 26,
|
|
523
|
-
right: -20,
|
|
524
511
|
},
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
pickerItemContainer: {
|
|
529
|
-
width: 150,
|
|
512
|
+
pickerContainer: {
|
|
513
|
+
paddingHorizontal: 50,
|
|
530
514
|
},
|
|
531
515
|
}}
|
|
532
516
|
/>
|
|
@@ -598,28 +582,35 @@ return (
|
|
|
598
582
|
|
|
599
583
|
#### Custom Styles 👗
|
|
600
584
|
|
|
601
|
-
The
|
|
585
|
+
The component should look good straight out of the box, but you can use these styles to make it fit in with your App's theme:
|
|
586
|
+
|
|
587
|
+
| Style Prop | Description | Type |
|
|
588
|
+
| :-------------------: | :----------------------------------------------------------------------- | :---------------: |
|
|
589
|
+
| theme | Theme of the component | "light" \| "dark" |
|
|
590
|
+
| backgroundColor | Main background color | string |
|
|
591
|
+
| text | Base text style | TextStyle |
|
|
592
|
+
| labelOffsetPercentage | Percentage offset for horizonal label positioning relative to the picker | number |
|
|
593
|
+
|
|
594
|
+
For deeper style customization, you can supply the following custom styles to adjust the component in any way. These are applied on top of the default styling so take a look at those [styles](src/components/TimerPicker/styles.ts) if something isn't adjusting in the way you'd expect.
|
|
602
595
|
|
|
603
596
|
| Style Prop | Description | Type |
|
|
604
597
|
| :------------------------------------: | :------------------------------------------------------------------- | :--------------------------------------: |
|
|
605
|
-
| theme | Theme of the component | "light" \| "dark" |
|
|
606
|
-
| backgroundColor | Main background color | string |
|
|
607
|
-
| text | Base text style | TextStyle |
|
|
608
598
|
| pickerContainer | Main container for the picker | ViewStyle & { backgroundColor?: string } |
|
|
609
599
|
| pickerLabelContainer | Container for the picker's labels | ViewStyle |
|
|
610
600
|
| pickerLabel | Style for the picker's labels | TextStyle |
|
|
611
601
|
| pickerAmPmContainer | Style for the picker's labels | ViewStyle |
|
|
612
602
|
| pickerAmPmLabel | Style for the picker's labels | TextStyle |
|
|
613
603
|
| pickerItemContainer | Container for each number in the picker | ViewStyle & { height?: number } |
|
|
614
|
-
| pickerItem | Style for each
|
|
604
|
+
| pickerItem | Style for each number | TextStyle |
|
|
615
605
|
| disabledPickerItem | Style for any numbers outside any set limits | TextStyle |
|
|
606
|
+
| selectedPickerItem | Style for the currently selected number | TextStyle |
|
|
616
607
|
| disabledPickerContainer | Style for disabled pickers | ViewStyle |
|
|
617
608
|
| pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
|
|
618
609
|
| durationScrollFlatList | Style for the Flatlist in each picker | ViewStyle |
|
|
619
610
|
| durationScrollFlatListContainer | Style for the View that contains the Flatlist in each picker | ViewStyle |
|
|
620
611
|
| durationScrollFlatListContentContainer | Style for the Flatlist's `contentContainerStyle` prop in each picker | ViewStyle |
|
|
621
612
|
|
|
622
|
-
Note
|
|
613
|
+
**Note:** There are minor limitations on `pickerContainer.backgroundColor` and `pickerItemContainer.height`. These properties must be simple values (string and number respectively) as they are used in internal calculations for scroll positioning, gradient overlays, and snap behavior. Complex computed values or union types are not supported for these specific properties.
|
|
623
614
|
|
|
624
615
|
#### Performance
|
|
625
616
|
|
|
@@ -680,17 +671,18 @@ The TimerPickerModal component accepts all [TimerPicker props](#timerpicker-️)
|
|
|
680
671
|
|
|
681
672
|
#### Custom Styles 👕
|
|
682
673
|
|
|
683
|
-
The following custom styles can be supplied to re-style the component in any way. You can also supply all of the styles specified in [CustomTimerPickerStyles](#custom-styles-).
|
|
684
|
-
|
|
685
|
-
| Style Prop | Description
|
|
686
|
-
| :--------------: |
|
|
687
|
-
| container |
|
|
688
|
-
| contentContainer | Style for the content's container
|
|
689
|
-
| buttonContainer | Style for the container
|
|
690
|
-
| button | General style for both buttons
|
|
691
|
-
| cancelButton | Style for the cancel button
|
|
692
|
-
| confirmButton | Style for the confirm button
|
|
693
|
-
| modalTitle | Style for the title of the modal
|
|
674
|
+
The following custom styles can be supplied to re-style the component in any way. You can also supply all of the styles specified in [CustomTimerPickerStyles](#custom-styles-). These are applied on top of the default styling so take a look at those [styles](src/components/TimerPickerModal/styles.ts) if something isn't adjusting in the way you'd expect.
|
|
675
|
+
|
|
676
|
+
| Style Prop | Description | Type |
|
|
677
|
+
| :--------------: | :--------------------------------------------------------------- | :-------: |
|
|
678
|
+
| container | Style for the modal container | ViewStyle |
|
|
679
|
+
| contentContainer | Style for the modal content's container | ViewStyle |
|
|
680
|
+
| buttonContainer | Style for the container for the buttons | ViewStyle |
|
|
681
|
+
| button | General style for both buttons | TextStyle |
|
|
682
|
+
| cancelButton | Style for the cancel button | TextStyle |
|
|
683
|
+
| confirmButton | Style for the confirm button | TextStyle |
|
|
684
|
+
| modalTitle | Style for the title of the modal | TextStyle |
|
|
685
|
+
| ... | Supply any of [TimerPicker's custom styles](<(#custom-styles-)>) | - |
|
|
694
686
|
|
|
695
687
|
<br>
|
|
696
688
|
|
|
@@ -11,6 +11,8 @@ var _generateNumbers = require("../../utils/generateNumbers");
|
|
|
11
11
|
var _getAdjustedLimit = require("../../utils/getAdjustedLimit");
|
|
12
12
|
var _getDurationAndIndexFromScrollOffset = require("../../utils/getDurationAndIndexFromScrollOffset");
|
|
13
13
|
var _getInitialScrollIndex = require("../../utils/getInitialScrollIndex");
|
|
14
|
+
var _PickerItem = _interopRequireDefault(require("../PickerItem"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
17
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -43,6 +45,7 @@ const DurationScroll = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
43
45
|
pmLabel,
|
|
44
46
|
repeatNumbersNTimes = 3,
|
|
45
47
|
repeatNumbersNTimesNotExplicitlySet,
|
|
48
|
+
selectedValue,
|
|
46
49
|
styles,
|
|
47
50
|
testID
|
|
48
51
|
} = props;
|
|
@@ -150,32 +153,17 @@ const DurationScroll = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
150
153
|
}, [clickSound]);
|
|
151
154
|
const renderItem = (0, _react.useCallback)(({
|
|
152
155
|
item
|
|
153
|
-
}) => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
165
|
-
key: item,
|
|
166
|
-
style: styles.pickerItemContainer,
|
|
167
|
-
testID: "picker-item"
|
|
168
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
169
|
-
allowFontScaling: allowFontScaling,
|
|
170
|
-
style: [styles.pickerItem, intItem > adjustedLimited.max || intItem < adjustedLimited.min ? styles.disabledPickerItem : {}]
|
|
171
|
-
}, stringItem), is12HourPicker ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
172
|
-
pointerEvents: "none",
|
|
173
|
-
style: styles.pickerAmPmContainer
|
|
174
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
175
|
-
allowFontScaling: allowFontScaling,
|
|
176
|
-
style: [styles.pickerAmPmLabel]
|
|
177
|
-
}, isAm ? amLabel : pmLabel)) : null);
|
|
178
|
-
}, [adjustedLimited.max, adjustedLimited.min, allowFontScaling, amLabel, is12HourPicker, pmLabel, styles.disabledPickerItem, styles.pickerAmPmContainer, styles.pickerAmPmLabel, styles.pickerItem, styles.pickerItemContainer]);
|
|
156
|
+
}) => /*#__PURE__*/_react.default.createElement(_PickerItem.default, {
|
|
157
|
+
adjustedLimitedMax: adjustedLimited.max,
|
|
158
|
+
adjustedLimitedMin: adjustedLimited.min,
|
|
159
|
+
allowFontScaling: allowFontScaling,
|
|
160
|
+
amLabel: amLabel,
|
|
161
|
+
is12HourPicker: is12HourPicker,
|
|
162
|
+
item: item,
|
|
163
|
+
pmLabel: pmLabel,
|
|
164
|
+
selectedValue: selectedValue,
|
|
165
|
+
styles: styles
|
|
166
|
+
}), [adjustedLimited.max, adjustedLimited.min, allowFontScaling, amLabel, is12HourPicker, pmLabel, selectedValue, styles]);
|
|
179
167
|
const onScroll = (0, _react.useCallback)(e => {
|
|
180
168
|
// this function is only used when the picker is in a modal and/or has Haptic/Audio feedback
|
|
181
169
|
// it is used to ensure that the modal gets the latest duration on clicking
|
|
@@ -375,7 +363,7 @@ const DurationScroll = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
375
363
|
allowFontScaling: allowFontScaling,
|
|
376
364
|
style: styles.pickerLabel
|
|
377
365
|
}, label) : label ?? null));
|
|
378
|
-
}, [FlatList, allowFontScaling, flatListRenderKey, getItemLayout, initialScrollIndex, isDisabled, label, numberOfItemsToShow, numbersForFlatList, onMomentumScrollEnd, onScroll, renderItem, styles.durationScrollFlatList, styles.durationScrollFlatListContentContainer, styles.pickerItemContainer.height, styles.pickerLabel, styles.pickerLabelContainer, viewabilityConfigCallbackPairs
|
|
366
|
+
}, [FlatList, allowFontScaling, decelerationRate, flatListRenderKey, getItemLayout, initialScrollIndex, isDisabled, label, numberOfItemsToShow, numbersForFlatList, onMomentumScrollEnd, onScroll, renderItem, styles.durationScrollFlatList, styles.durationScrollFlatListContentContainer, styles.pickerItemContainer.height, styles.pickerLabel, styles.pickerLabelContainer, viewabilityConfigCallbackPairs]);
|
|
379
367
|
const renderLinearGradient = (0, _react.useMemo)(() => {
|
|
380
368
|
if (!LinearGradient) {
|
|
381
369
|
return null;
|