react-native-timer-picker 2.3.1 → 2.4.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 +97 -106
- package/dist/commonjs/components/DurationScroll/DurationScroll.js +13 -27
- package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +1 -1
- package/dist/commonjs/components/PickerItem/PickerItem.js +45 -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 +3 -3
- package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/styles.js +36 -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/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 +12 -27
- package/dist/module/components/DurationScroll/DurationScroll.js.map +1 -1
- package/dist/module/components/PickerItem/PickerItem.js +38 -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 +3 -3
- package/dist/module/components/TimerPicker/TimerPicker.js.map +1 -1
- package/dist/module/components/TimerPicker/styles.js +36 -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/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/PickerItem/PickerItem.d.ts +14 -0
- package/dist/typescript/components/PickerItem/index.d.ts +1 -0
- package/dist/typescript/components/TimerPicker/styles.d.ts +26 -25
- package/dist/typescript/components/TimerPickerModal/styles.d.ts +255 -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
|
-
},
|
|
525
|
-
pickerLabelContainer: {
|
|
526
|
-
width: 60,
|
|
527
511
|
},
|
|
528
|
-
|
|
529
|
-
|
|
512
|
+
pickerContainer: {
|
|
513
|
+
paddingHorizontal: 50,
|
|
530
514
|
},
|
|
531
515
|
}}
|
|
532
516
|
/>
|
|
@@ -596,15 +580,21 @@ return (
|
|
|
596
580
|
| styles | Custom styles for the timer picker | [CustomTimerPickerStyles](#custom-styles-) | - | false |
|
|
597
581
|
| decelerationRate | Set how quickly the picker decelerates after the user lifts their finger | 'fast', 'normal', or Number | 0.88 | false |
|
|
598
582
|
|
|
599
|
-
#### Custom Styles 👗
|
|
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:
|
|
602
586
|
|
|
603
587
|
| Style Prop | Description | Type |
|
|
604
588
|
| :------------------------------------: | :------------------------------------------------------------------- | :--------------------------------------: |
|
|
605
589
|
| theme | Theme of the component | "light" \| "dark" |
|
|
606
590
|
| backgroundColor | Main background color | string |
|
|
607
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.
|
|
595
|
+
|
|
596
|
+
| Style Prop | Description | Type |
|
|
597
|
+
| :------------------------------------: | :------------------------------------------------------------------- | :--------------------------------------: |
|
|
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 |
|
|
@@ -619,7 +609,7 @@ The following custom styles can be supplied to re-style the component in any way
|
|
|
619
609
|
| durationScrollFlatListContainer | Style for the View that contains the Flatlist in each picker | ViewStyle |
|
|
620
610
|
| durationScrollFlatListContentContainer | Style for the Flatlist's `contentContainerStyle` prop in each picker | ViewStyle |
|
|
621
611
|
|
|
622
|
-
Note
|
|
612
|
+
**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
613
|
|
|
624
614
|
#### Performance
|
|
625
615
|
|
|
@@ -680,17 +670,18 @@ The TimerPickerModal component accepts all [TimerPicker props](#timerpicker-️)
|
|
|
680
670
|
|
|
681
671
|
#### Custom Styles 👕
|
|
682
672
|
|
|
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-).
|
|
673
|
+
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.
|
|
684
674
|
|
|
685
675
|
| Style Prop | Description | Type |
|
|
686
676
|
| :--------------: | :----------------------------------------- | :-------: |
|
|
687
|
-
| container |
|
|
688
|
-
| contentContainer | Style for the content's container
|
|
689
|
-
| buttonContainer | Style for the container
|
|
677
|
+
| container | Style for the modal container | ViewStyle |
|
|
678
|
+
| contentContainer | Style for the modal content's container | ViewStyle |
|
|
679
|
+
| buttonContainer | Style for the container for the buttons | ViewStyle |
|
|
690
680
|
| button | General style for both buttons | TextStyle |
|
|
691
681
|
| cancelButton | Style for the cancel button | TextStyle |
|
|
692
682
|
| confirmButton | Style for the confirm button | TextStyle |
|
|
693
683
|
| modalTitle | Style for the title of the modal | TextStyle |
|
|
684
|
+
| ... | Supply any of [TimerPicker's custom styles]((#custom-styles-)) | - |
|
|
694
685
|
|
|
695
686
|
<br>
|
|
696
687
|
|
|
@@ -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
|
|
@@ -150,32 +152,16 @@ const DurationScroll = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
150
152
|
}, [clickSound]);
|
|
151
153
|
const renderItem = (0, _react.useCallback)(({
|
|
152
154
|
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]);
|
|
155
|
+
}) => /*#__PURE__*/_react.default.createElement(_PickerItem.default, {
|
|
156
|
+
adjustedLimitedMax: adjustedLimited.max,
|
|
157
|
+
adjustedLimitedMin: adjustedLimited.min,
|
|
158
|
+
allowFontScaling: allowFontScaling,
|
|
159
|
+
amLabel: amLabel,
|
|
160
|
+
is12HourPicker: is12HourPicker,
|
|
161
|
+
item: item,
|
|
162
|
+
pmLabel: pmLabel,
|
|
163
|
+
styles: styles
|
|
164
|
+
}), [adjustedLimited.max, adjustedLimited.min, allowFontScaling, amLabel, is12HourPicker, pmLabel, styles]);
|
|
179
165
|
const onScroll = (0, _react.useCallback)(e => {
|
|
180
166
|
// this function is only used when the picker is in a modal and/or has Haptic/Audio feedback
|
|
181
167
|
// it is used to ensure that the modal gets the latest duration on clicking
|
|
@@ -375,7 +361,7 @@ const DurationScroll = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
375
361
|
allowFontScaling: allowFontScaling,
|
|
376
362
|
style: styles.pickerLabel
|
|
377
363
|
}, 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
|
|
364
|
+
}, [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
365
|
const renderLinearGradient = (0, _react.useMemo)(() => {
|
|
380
366
|
if (!LinearGradient) {
|
|
381
367
|
return null;
|