react-native-timer-picker 2.1.0 → 2.2.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.
Files changed (101) hide show
  1. package/README.md +227 -152
  2. package/dist/commonjs/components/DurationScroll/DurationScroll.js +417 -0
  3. package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +1 -0
  4. package/dist/commonjs/components/DurationScroll/index.js +20 -392
  5. package/dist/commonjs/components/DurationScroll/index.js.map +1 -1
  6. package/dist/commonjs/components/DurationScroll/types.js.map +1 -1
  7. package/dist/commonjs/components/Modal/Modal.js +107 -0
  8. package/dist/commonjs/components/Modal/Modal.js.map +1 -0
  9. package/dist/commonjs/components/Modal/index.js +20 -101
  10. package/dist/commonjs/components/Modal/index.js.map +1 -1
  11. package/dist/commonjs/components/TimerPicker/TimerPicker.js +225 -0
  12. package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +1 -0
  13. package/dist/commonjs/components/TimerPicker/index.js +29 -166
  14. package/dist/commonjs/components/TimerPicker/index.js.map +1 -1
  15. package/dist/commonjs/components/TimerPicker/styles.js +1 -1
  16. package/dist/commonjs/components/TimerPicker/styles.js.map +1 -1
  17. package/dist/commonjs/components/TimerPicker/types.js.map +1 -1
  18. package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js +143 -0
  19. package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
  20. package/dist/commonjs/components/TimerPickerModal/index.js +30 -131
  21. package/dist/commonjs/components/TimerPickerModal/index.js.map +1 -1
  22. package/dist/commonjs/components/TimerPickerModal/types.js.map +1 -1
  23. package/dist/commonjs/index.js +9 -13
  24. package/dist/commonjs/index.js.map +1 -1
  25. package/dist/commonjs/tests/TimerPicker.test.js +4 -1
  26. package/dist/commonjs/tests/TimerPicker.test.js.map +1 -1
  27. package/dist/commonjs/utils/colorToRgba.js +35 -4
  28. package/dist/commonjs/utils/colorToRgba.js.map +1 -1
  29. package/dist/commonjs/utils/generateNumbers.js +67 -0
  30. package/dist/commonjs/utils/generateNumbers.js.map +1 -1
  31. package/dist/commonjs/utils/getAdjustedLimit.js +25 -0
  32. package/dist/commonjs/utils/getAdjustedLimit.js.map +1 -1
  33. package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js +38 -0
  34. package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
  35. package/dist/commonjs/utils/getInitialScrollIndex.js +38 -0
  36. package/dist/commonjs/utils/getInitialScrollIndex.js.map +1 -1
  37. package/dist/commonjs/utils/getSafeInitialValue.js +28 -0
  38. package/dist/commonjs/utils/getSafeInitialValue.js.map +1 -1
  39. package/dist/commonjs/utils/padNumber.js +25 -0
  40. package/dist/commonjs/utils/padNumber.js.map +1 -1
  41. package/dist/module/components/DurationScroll/DurationScroll.js +410 -0
  42. package/dist/module/components/DurationScroll/DurationScroll.js.map +1 -0
  43. package/dist/module/components/DurationScroll/index.js +2 -390
  44. package/dist/module/components/DurationScroll/index.js.map +1 -1
  45. package/dist/module/components/DurationScroll/types.js.map +1 -1
  46. package/dist/module/components/Modal/Modal.js +99 -0
  47. package/dist/module/components/Modal/Modal.js.map +1 -0
  48. package/dist/module/components/Modal/index.js +2 -98
  49. package/dist/module/components/Modal/index.js.map +1 -1
  50. package/dist/module/components/TimerPicker/TimerPicker.js +217 -0
  51. package/dist/module/components/TimerPicker/TimerPicker.js.map +1 -0
  52. package/dist/module/components/TimerPicker/index.js +3 -166
  53. package/dist/module/components/TimerPicker/index.js.map +1 -1
  54. package/dist/module/components/TimerPicker/styles.js +1 -1
  55. package/dist/module/components/TimerPicker/styles.js.map +1 -1
  56. package/dist/module/components/TimerPicker/types.js.map +1 -1
  57. package/dist/module/components/TimerPickerModal/TimerPickerModal.js +135 -0
  58. package/dist/module/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
  59. package/dist/module/components/TimerPickerModal/index.js +3 -130
  60. package/dist/module/components/TimerPickerModal/index.js.map +1 -1
  61. package/dist/module/components/TimerPickerModal/types.js.map +1 -1
  62. package/dist/module/index.js +2 -6
  63. package/dist/module/index.js.map +1 -1
  64. package/dist/module/tests/TimerPicker.test.js +4 -1
  65. package/dist/module/tests/TimerPicker.test.js.map +1 -1
  66. package/dist/module/utils/colorToRgba.js +35 -4
  67. package/dist/module/utils/colorToRgba.js.map +1 -1
  68. package/dist/module/utils/generateNumbers.js +68 -0
  69. package/dist/module/utils/generateNumbers.js.map +1 -1
  70. package/dist/module/utils/getAdjustedLimit.js +25 -0
  71. package/dist/module/utils/getAdjustedLimit.js.map +1 -1
  72. package/dist/module/utils/getDurationAndIndexFromScrollOffset.js +38 -0
  73. package/dist/module/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
  74. package/dist/module/utils/getInitialScrollIndex.js +38 -0
  75. package/dist/module/utils/getInitialScrollIndex.js.map +1 -1
  76. package/dist/module/utils/getSafeInitialValue.js +28 -0
  77. package/dist/module/utils/getSafeInitialValue.js.map +1 -1
  78. package/dist/module/utils/padNumber.js +25 -0
  79. package/dist/module/utils/padNumber.js.map +1 -1
  80. package/dist/typescript/components/DurationScroll/DurationScroll.d.ts +4 -0
  81. package/dist/typescript/components/DurationScroll/index.d.ts +2 -4
  82. package/dist/typescript/components/DurationScroll/types.d.ts +13 -9
  83. package/dist/typescript/components/Modal/Modal.d.ts +5 -0
  84. package/dist/typescript/components/Modal/index.d.ts +2 -5
  85. package/dist/typescript/components/TimerPicker/TimerPicker.d.ts +4 -0
  86. package/dist/typescript/components/TimerPicker/index.d.ts +3 -4
  87. package/dist/typescript/components/TimerPicker/styles.d.ts +1169 -771
  88. package/dist/typescript/components/TimerPicker/types.d.ts +26 -10
  89. package/dist/typescript/components/TimerPickerModal/TimerPickerModal.d.ts +4 -0
  90. package/dist/typescript/components/TimerPickerModal/index.d.ts +3 -4
  91. package/dist/typescript/components/TimerPickerModal/styles.d.ts +722 -474
  92. package/dist/typescript/components/TimerPickerModal/types.d.ts +8 -5
  93. package/dist/typescript/index.d.ts +2 -6
  94. package/dist/typescript/utils/colorToRgba.d.ts +34 -0
  95. package/dist/typescript/utils/generateNumbers.d.ts +66 -0
  96. package/dist/typescript/utils/getAdjustedLimit.d.ts +27 -2
  97. package/dist/typescript/utils/getDurationAndIndexFromScrollOffset.d.ts +38 -0
  98. package/dist/typescript/utils/getInitialScrollIndex.d.ts +38 -0
  99. package/dist/typescript/utils/getSafeInitialValue.d.ts +29 -0
  100. package/dist/typescript/utils/padNumber.d.ts +25 -0
  101. package/package.json +10 -27
package/README.md CHANGED
@@ -14,11 +14,10 @@ Works with Expo and bare React Native apps ✅
14
14
  Includes iOS-style haptic and audio feedback 🍏
15
15
 
16
16
  - [Demos 📱](#demos-)
17
- - [Peer Dependencies 👶](#peer-dependencies-)
18
- - [Linear Gradient](#linear-gradient)
19
- - [Haptic Feedback](#haptic-feedback)
20
- - [Audio Feedback (Click Sound)](#audio-feedback-click-sound)
21
17
  - [Installation 🚀](#installation-)
18
+ - [Peer Dependencies 👶](#peer-dependencies-)
19
+ - [Linear Gradient](#linear-gradient)
20
+ - [Masked View](#masked-view)
22
21
  - [Examples 😎](#examples-)
23
22
  - [Timer Picker Modal (Dark Mode) 🌚](#timer-picker-modal-dark-mode-)
24
23
  - [Timer Picker Modal (Light Mode) 🌞](#timer-picker-modal-light-mode-)
@@ -29,12 +28,16 @@ Includes iOS-style haptic and audio feedback 🍏
29
28
  - [Custom Styles 👗](#custom-styles-)
30
29
  - [Performance](#performance)
31
30
  - [Custom FlatList](#custom-flatlist)
32
- - [Generic feedback](#generic-feedback)
33
31
  - [TimerPickerModal ⏰](#timerpickermodal-)
34
32
  - [Custom Styles 👕](#custom-styles--1)
35
33
  - [Methods 🔄](#methods-)
36
34
  - [TimerPicker](#timerpicker)
37
35
  - [TimerPickerModal](#timerpickermodal)
36
+ - [Picker Feedback](#picker-feedback-)
37
+ - [Audio Feedback](#audio-feedback)
38
+ - [Haptic Feedback](#haptic-feedback)
39
+ - [Feedback Example](#feedback-example)
40
+ - [Expo-Specific Audio/Haptic Feedback (DEPRECATED)](#expo-specific-audiohaptic-feedback-deprecated)
38
41
  - [Contributing 🧑‍🤝‍🧑](#contributing-)
39
42
  - [Dev Setup](#dev-setup)
40
43
  - [GitHub Guidelines](#github-guidelines)
@@ -58,11 +61,27 @@ Includes iOS-style haptic and audio feedback 🍏
58
61
 
59
62
  <br>
60
63
 
61
- ## Peer Dependencies 👶
64
+ ## Installation 🚀
65
+
66
+ Supports React Native >= 0.59.0 and React >= 16.8.0.
62
67
 
63
- This component will work in your React Native Project **_without any peer dependencies_**. However, to enable certain additional features (e.g. fade-out, feedback) you will need to supply various libraries as props. These are detailed below.
68
+ Just run:
64
69
 
65
- ### Linear Gradient
70
+ ```bash
71
+ npm install react-native-timer-picker
72
+ ```
73
+
74
+ or
75
+
76
+ ```bash
77
+ yarn add react-native-timer-picker
78
+ ```
79
+
80
+ ### Peer Dependencies 👶
81
+
82
+ This component will work in your React Native Project **_without any peer dependencies_**. However, to enable certain additional features (e.g. fade-out) you will need to supply various libraries as props. These are detailed below.
83
+
84
+ #### Linear Gradient
66
85
 
67
86
  If you want the numbers to fade in/out at the top and bottom of the picker, you will need to install either:
68
87
 
@@ -71,7 +90,7 @@ If you want the numbers to fade in/out at the top and bottom of the picker, you
71
90
 
72
91
  **To enable the linear gradient, you need to supply the component as a prop to either TimerPickerModal or TimerPicker.**
73
92
 
74
- ### Masked View
93
+ #### Masked View
75
94
 
76
95
  To make the numbers fade in/out on a transparent background (e.g. if the picker is rendered on top of a gradient or image), you will need to install the [@react-native-masked-view/masked-view
77
96
  ](https://www.npmjs.com/package/@react-native-masked-view/masked-view) component. This is as the standard LinearGradient implementation relies on there being a solid background colour. You then just need to set `backgroundColor: "transparent` on the `TimerPicker` styles prop.
@@ -80,47 +99,6 @@ To make the numbers fade in/out on a transparent background (e.g. if the picker
80
99
 
81
100
  **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-))**
82
101
 
83
- ### Haptic Feedback
84
-
85
- Enable haptic feedback with the [expo-haptics](https://www.npmjs.com/package/expo-haptics) module:
86
-
87
- `import * as Haptics from "expo-haptics";`
88
-
89
- **To enable haptic feedback, you need to supply the imported `Haptics` namespace as a prop to either TimerPickerModal or TimerPicker.**
90
-
91
- [Generic feedback](#generic-feedback) support is possible with the `pickerFeeback` prop.
92
-
93
- ### Audio Feedback (Click Sound)
94
-
95
- Enable audio feedback with the [expo-av](https://www.npmjs.com/package/expo-av) module:
96
-
97
- `import { Audio } from "expo-av";`
98
-
99
- **To enable audio feedback, you need to supply the imported `Audio` class as a prop to either TimerPickerModal or TimerPicker.**
100
-
101
- Please note that the default click sound uses a hosted mp3 file. To make the click sound work offline, you need to supply your own
102
- sound asset through the `clickSoundAsset` prop. You can download the default click sound [here](https://drive.google.com/uc?export=download&id=10e1YkbNsRh-vGx1jmS1Nntz8xzkBp4_I).
103
-
104
- [Generic feedback](#generic-feedback) support is possible with the `pickerFeeback` prop.
105
-
106
- <br>
107
-
108
- ## Installation 🚀
109
-
110
- Supports React Native >= 0.59.0 and React >= 16.8.0.
111
-
112
- Just run:
113
-
114
- ```bash
115
- npm install react-native-timer-picker
116
- ```
117
-
118
- or
119
-
120
- ```bash
121
- yarn add react-native-timer-picker
122
- ```
123
-
124
102
  <br>
125
103
 
126
104
  ## Examples 😎
@@ -130,8 +108,6 @@ yarn add react-native-timer-picker
130
108
  ```jsx
131
109
  import { TimerPickerModal } from "react-native-timer-picker";
132
110
  import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
133
- import { Audio } from "expo-av"; // for audio feedback (click sound as you scroll)
134
- import * as Haptics from "expo-haptics"; // for haptic feedback
135
111
 
136
112
  ....
137
113
  const [showPicker, setShowPicker] = useState(false);
@@ -210,9 +186,7 @@ return (
210
186
  modalTitle="Set Alarm"
211
187
  onCancel={() => setShowPicker(false)}
212
188
  closeOnOverlayPress
213
- Audio={Audio}
214
189
  LinearGradient={LinearGradient}
215
- Haptics={Haptics}
216
190
  styles={{
217
191
  theme: "dark",
218
192
  }}
@@ -232,8 +206,6 @@ return (
232
206
  ```jsx
233
207
  import { TimerPickerModal } from "react-native-timer-picker";
234
208
  import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
235
- import { Audio } from "expo-av"; // for audio feedback (click sound as you scroll)
236
- import * as Haptics from "expo-haptics"; // for haptic feedback
237
209
 
238
210
  ....
239
211
  const [showPicker, setShowPicker] = useState(false);
@@ -312,11 +284,7 @@ return (
312
284
  onCancel={() => setShowPicker(false)}
313
285
  closeOnOverlayPress
314
286
  use12HourPicker
315
- Audio={Audio}
316
- // supply your own custom click sound asset
317
- clickSoundAsset={require("./assets/custom_click.mp3")}
318
287
  LinearGradient={LinearGradient}
319
- Haptics={Haptics}
320
288
  styles={{
321
289
  theme: "light",
322
290
  }}
@@ -334,8 +302,6 @@ return (
334
302
  import { TimerPicker } from "react-native-timer-picker";
335
303
  import MaskedView from "@react-native-masked-view/masked-view"; // for transparent fade-out
336
304
  import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
337
- import { Audio } from "expo-av"; // for audio feedback (click sound as you scroll)
338
- import * as Haptics from "expo-haptics"; // for haptic feedback
339
305
 
340
306
  ....
341
307
  const [showPicker, setShowPicker] = useState(false);
@@ -354,9 +320,7 @@ return (
354
320
  hourLabel=":"
355
321
  minuteLabel=":"
356
322
  secondLabel=""
357
- Audio={Audio}
358
323
  LinearGradient={LinearGradient}
359
- Haptics={Haptics}
360
324
  MaskedView={MaskedView}
361
325
  styles={{
362
326
  theme: "dark",
@@ -395,8 +359,6 @@ return (
395
359
  ```jsx
396
360
  import { TimerPicker } from "react-native-timer-picker";
397
361
  import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
398
- import { Audio } from "expo-av"; // for audio feedback (click sound as you scroll)
399
- import * as Haptics from "expo-haptics"; // for haptic feedback
400
362
 
401
363
  ....
402
364
  const [showPicker, setShowPicker] = useState(false);
@@ -411,9 +373,7 @@ return (
411
373
  hideHours
412
374
  minuteLabel="min"
413
375
  secondLabel="sec"
414
- Audio={Audio}
415
376
  LinearGradient={LinearGradient}
416
- Haptics={Haptics}
417
377
  styles={{
418
378
  theme: "light",
419
379
  pickerItem: {
@@ -444,74 +404,83 @@ return (
444
404
 
445
405
  ### TimerPicker ⏲️
446
406
 
447
- | Prop | Description | Type | Default | Required |
448
- | :------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------: | :------: |
449
- | onDurationChange | Callback when the duration changes | `(duration: { hours: number, minutes: number, seconds: number }) => void` | - | false |
450
- | initialValue | Initial value for the picker | `{ hours?: number, minutes?: number, seconds?: number }` | - | false |
451
- | hideHours | Hide the hours picker | Boolean | false | false |
452
- | hideMinutes | Hide the minutes picker | Boolean | false | false |
453
- | hideSeconds | Hide the seconds picker | Boolean | false | false |
454
- | hoursPickerIsDisabled | Disable the hours picker picker | Boolean | false | false |
455
- | minutesPickerIsDisabled | Disable the minutes picker picker | Boolean | false | false |
456
- | secondsPickerIsDisabled | Disable the seconds picker picker | Boolean | false | false |
457
- | hourLimit | Limit on the hours it is possible to select | `{ max?: Number, min?: Number }` | - | false |
458
- | minuteLimit | Limit on the minutes it is possible to select | `{ max?: Number, min?: Number }` | - | false |
459
- | secondLimit | Limit on the seconds it is possible to select | `{ max?: Number, min?: Number }` | - | false |
460
- | maximumHours | The highest value on the hours picker | Number | 23 | false |
461
- | maximumMinutes | The highest value on the minutes picker | Number | 59 | false |
462
- | maximumSeconds | The highest value on the seconds picker | Number | 59 | false |
463
- | hourInterval | The interval between values on the hours picker | Number | 1 | false |
464
- | minuteInterval | The interval between values on the minutes picker | Number | 1 | false |
465
- | secondInterval | The interval between values on the seconds picker | Number | 1 | false |
466
- | hourLabel | Label for the hours picker | String \| React.ReactElement | h | false |
467
- | minuteLabel | Label for the minutes picker | String \| React.ReactElement | m | false |
468
- | secondLabel | Label for the seconds picker | String \| React.ReactElement | s | false |
469
- | padHoursWithZero | Pad single-digit hours in the picker with a zero | Boolean | false | false |
470
- | padMinutesWithZero | Pad single-digit minutes in the picker with a zero | Boolean | true | false |
471
- | padSecondsWithZero | Pad single-digit seconds in the picker with a zero | Boolean | true | false |
472
- | padWithNItems | Number of items to pad the picker with on either side | Number | 1 | false |
473
- | aggressivelyGetLatestDuration | Set to True to ask DurationScroll to aggressively update the latestDuration ref | Boolean | false | false |
474
- | allowFontScaling | Allow font in the picker to scale with accessibility settings | Boolean | false | false |
475
- | use12HourPicker | Switch the hour picker to 12-hour format with an AM / PM label | Boolean | false | false |
476
- | amLabel | Set the AM label if using the 12-hour picker | String | am | false |
477
- | pmLabel | Set the PM label if using the 12-hour picker | String | pm | false |
478
- | repeatHourNumbersNTimes | Set the number of times the list of hours is repeated in the picker | Number | 7 | false |
479
- | repeatMinuteNumbersNTimes | Set the number of times the list of minutes is repeated in the picker | Number | 3 | false |
480
- | repeatSecondNumbersNTimes | Set the number of times the list of seconds is repeated in the picker | Number | 3 | false |
481
- | disableInfiniteScroll | Disable the infinite scroll feature | Boolean | false | false |
482
- | LinearGradient | [Linear Gradient Component (required for picker fade-out)](#linear-gradient) | [expo-linear-gradient](https://www.npmjs.com/package/expo-linear-gradient).LinearGradient or [react-native-linear-gradient](https://www.npmjs.com/package/react-native-linear-gradient).default | - | false |
483
- | MaskedView | [Masked View Component (required for picker fade-out on transparent background)](#masked-view) | [@react-native-masked-view/masked-view](https://www.npmjs.com/package/@react-native-masked-view/masked-view).default | - | false |
484
- | Haptics | [Haptics Namespace (required for Haptic feedback)](#haptic-feedback) | [expo-haptics](https://www.npmjs.com/package/expo-haptics) | - | false |
485
- | Audio | [Audio Class (required for audio feedback i.e. click sound)](#audio-feedback-click-sound) | [expo-av](https://www.npmjs.com/package/expo-av).Audio | - | false |
486
- | pickerFeedback | [Generic picker feedback as alternative to the above Expo feedback support](#generic-feedback) | `() => void \| Promise<void> ` | - | false |
487
- | FlatList | FlatList component used internally to implement each picker (hour, minutes and seconds). More info [below](#custom-flatlist) | [react-native](https://reactnative.dev/docs/flatlist).FlatList | `FlatList` from `react-native` | false |
488
- | clickSoundAsset | Custom sound asset for click sound (required for offline click sound - download default [here](https://drive.google.com/uc?export=download&id=10e1YkbNsRh-vGx1jmS1Nntz8xzkBp4_I)) | require(.../somefolderpath) or {uri: www.someurl} | - | false |
489
- | pickerContainerProps | Props for the picker container | `React.ComponentProps<typeof View>` | - | false |
490
- | pickerGradientOverlayProps | Props for the gradient overlay (supply a different `locations` array to adjust its position) overlays | `Partial<LinearGradientProps>` | - | false |
491
- | styles | Custom styles for the timer picker | [CustomTimerPickerStyles](#custom-styles-) | - | false |
407
+ | Prop | Description | Type | Default | Required |
408
+ | :---------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------: | :------: |
409
+ | onDurationChange | Callback when the duration changes | `(duration: { days: number, hours: number, minutes: number, seconds: number }) => void` | - | false |
410
+ | initialValue | Initial value for the picker | `{ days?: number, hours?: number, minutes?: number, seconds?: number }` | - | false |
411
+ | hideDays | Hide the days picker | Boolean | true | false |
412
+ | hideHours | Hide the hours picker | Boolean | false | false |
413
+ | hideMinutes | Hide the minutes picker | Boolean | false | false |
414
+ | hideSeconds | Hide the seconds picker | Boolean | false | false |
415
+ | daysPickerIsDisabled | Disable the days picker | Boolean | false | false |
416
+ | hoursPickerIsDisabled | Disable the hours picker | Boolean | false | false |
417
+ | minutesPickerIsDisabled | Disable the minutes picker | Boolean | false | false |
418
+ | secondsPickerIsDisabled | Disable the seconds picker | Boolean | false | false |
419
+ | dayLimit | Limit on the days it is possible to select | `{ max?: Number, min?: Number }` | - | false |
420
+ | hourLimit | Limit on the hours it is possible to select | `{ max?: Number, min?: Number }` | - | false |
421
+ | minuteLimit | Limit on the minutes it is possible to select | `{ max?: Number, min?: Number }` | - | false |
422
+ | secondLimit | Limit on the seconds it is possible to select | `{ max?: Number, min?: Number }` | - | false |
423
+ | maximumDays | The highest value on the days picker | Number | 23 | false |
424
+ | maximumHours | The highest value on the hours picker | Number | 23 | false |
425
+ | maximumMinutes | The highest value on the minutes picker | Number | 59 | false |
426
+ | maximumSeconds | The highest value on the seconds picker | Number | 59 | false |
427
+ | dayInterval | The interval between values on the days picker | Number | 1 | false |
428
+ | hourInterval | The interval between values on the hours picker | Number | 1 | false |
429
+ | minuteInterval | The interval between values on the minutes picker | Number | 1 | false |
430
+ | secondInterval | The interval between values on the seconds picker | Number | 1 | false |
431
+ | dayLabel | Label for the days picker | String \| React.ReactElement | d | false |
432
+ | hourLabel | Label for the hours picker | String \| React.ReactElement | h | false |
433
+ | minuteLabel | Label for the minutes picker | String \| React.ReactElement | m | false |
434
+ | secondLabel | Label for the seconds picker | String \| React.ReactElement | s | false |
435
+ | padDaysWithZero | Pad single-digit days in the picker with a zero | Boolean | false | false |
436
+ | padHoursWithZero | Pad single-digit hours in the picker with a zero | Boolean | false | false |
437
+ | padMinutesWithZero | Pad single-digit minutes in the picker with a zero | Boolean | true | false |
438
+ | padSecondsWithZero | Pad single-digit seconds in the picker with a zero | Boolean | true | false |
439
+ | padWithNItems | Number of items to pad the picker with on either side | Number | 1 | false |
440
+ | aggressivelyGetLatestDuration | Set to True to ask DurationScroll to aggressively update the latestDuration ref | Boolean | false | false |
441
+ | allowFontScaling | Allow font in the picker to scale with accessibility settings | Boolean | false | false |
442
+ | use12HourPicker | Switch the hour picker to 12-hour format with an AM / PM label | Boolean | false | false |
443
+ | amLabel | Set the AM label if using the 12-hour picker | String | am | false |
444
+ | pmLabel | Set the PM label if using the 12-hour picker | String | pm | false |
445
+ | repeatDayNumbersNTimes | Set the number of times the list of days is repeated in the picker | Number | 3 | false |
446
+ | repeatHourNumbersNTimes | Set the number of times the list of hours is repeated in the picker | Number | 7 | false |
447
+ | repeatMinuteNumbersNTimes | Set the number of times the list of minutes is repeated in the picker | Number | 3 | false |
448
+ | repeatSecondNumbersNTimes | Set the number of times the list of seconds is repeated in the picker | Number | 3 | false |
449
+ | disableInfiniteScroll | Disable the infinite scroll feature | Boolean | false | false |
450
+ | LinearGradient | [Linear Gradient Component (required for picker fade-out)](#linear-gradient) | [expo-linear-gradient](https://www.npmjs.com/package/expo-linear-gradient).LinearGradient or [react-native-linear-gradient](https://www.npmjs.com/package/react-native-linear-gradient).default | - | false |
451
+ | MaskedView | [Masked View Component (required for picker fade-out on transparent background)](#masked-view) | [@react-native-masked-view/masked-view](https://www.npmjs.com/package/@react-native-masked-view/masked-view).default | - | false |
452
+ | FlatList | FlatList component used internally to implement each picker (day, hour, minutes and seconds). More info [below](#custom-flatlist) | [react-native](https://reactnative.dev/docs/flatlist).FlatList | `FlatList` from `react-native` | false |
453
+ | pickerFeedback | [Callback for providing audio/haptic feedback](#picker-feedback-) (fired whenever the picker ticks over a value) | `() => void \| Promise<void> ` | - | false |
454
+ | Haptics (DEPRECATED) | [Expo Haptics Namespace](#expo-specific-audiohaptic-feedback-deprecated) (please use pickerFeedback instead) | [expo-haptics](https://www.npmjs.com/package/expo-haptics) | - | false |
455
+ | Audio (DEPRECATED) | [Expo AV Audio Class](#expo-specific-audiohaptic-feedback-deprecated) | [expo-av](https://www.npmjs.com/package/expo-av).Audio (please use pickerFeedback instead) | - | false |
456
+ | clickSoundAsset (DEPRECATED) | Custom sound asset for click sound (please use pickerFeedback instead), was required for offline click sound - download default [here](https://drive.google.com/uc?export=download&id=10e1YkbNsRh-vGx1jmS1Nntz8xzkBp4_I) | require(.../somefolderpath) or {uri: www.someurl} | - | false |
457
+ | pickerContainerProps | Props for the picker container | `React.ComponentProps<typeof View>` | - | false |
458
+ | pickerGradientOverlayProps | Props for the gradient overlay (supply a different `locations` array to adjust its position) overlays | `Partial<LinearGradientProps>` | - | false |
459
+ | styles | Custom styles for the timer picker | [CustomTimerPickerStyles](#custom-styles-) | - | false |
460
+ | decelerationRate | Set how quickly the picker decelerates after the user lifts their finger | 'fast', 'normal', or Number | 0.88 | false |
492
461
 
493
462
  #### Custom Styles 👗
494
463
 
495
464
  The following custom styles can be supplied to re-style the component in any way. Various styles are applied by default - you can take a look at these [here](src/components/TimerPicker/styles.ts).
496
465
 
497
- | Style Prop | Description | Type |
498
- | :---------------------: | :------------------------------------------- | :--------------------------------------: |
499
- | theme | Theme of the component | "light" \| "dark" |
500
- | backgroundColor | Main background color | string |
501
- | text | Base text style | TextStyle |
502
- | pickerContainer | Main container for the picker | ViewStyle & { backgroundColor?: string } |
503
- | pickerLabelContainer | Container for the picker's labels | ViewStyle |
504
- | pickerLabel | Style for the picker's labels | TextStyle |
505
- | pickerAmPmContainer | Style for the picker's labels | ViewStyle |
506
- | pickerAmPmLabel | Style for the picker's labels | TextStyle |
507
- | pickerItemContainer | Container for each number in the picker | ViewStyle & { height?: number } |
508
- | pickerItem | Style for each individual picker number | TextStyle |
509
- | disabledPickerItem | Style for any numbers outside any set limits | TextStyle |
510
- | disabledPickerContainer | Style for disabled pickers | ViewStyle |
511
- | pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
512
- | durationScrollFlatList | Style for the Flatlist in each picker | ViewStyle |
513
- | durationScrollFlatListContainer | Style for the View that contains the Flatlist in each picker | ViewStyle |
514
- | durationScrollFlatListContentContainer | Style for the Flatlist's `contentContainerStyle` prop in each picker | ViewStyle |
466
+ | Style Prop | Description | Type |
467
+ | :------------------------------------: | :------------------------------------------------------------------- | :--------------------------------------: |
468
+ | theme | Theme of the component | "light" \| "dark" |
469
+ | backgroundColor | Main background color | string |
470
+ | text | Base text style | TextStyle |
471
+ | pickerContainer | Main container for the picker | ViewStyle & { backgroundColor?: string } |
472
+ | pickerLabelContainer | Container for the picker's labels | ViewStyle |
473
+ | pickerLabel | Style for the picker's labels | TextStyle |
474
+ | pickerAmPmContainer | Style for the picker's labels | ViewStyle |
475
+ | pickerAmPmLabel | Style for the picker's labels | TextStyle |
476
+ | pickerItemContainer | Container for each number in the picker | ViewStyle & { height?: number } |
477
+ | pickerItem | Style for each individual picker number | TextStyle |
478
+ | disabledPickerItem | Style for any numbers outside any set limits | TextStyle |
479
+ | disabledPickerContainer | Style for disabled pickers | ViewStyle |
480
+ | pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
481
+ | durationScrollFlatList | Style for the Flatlist in each picker | ViewStyle |
482
+ | durationScrollFlatListContainer | Style for the View that contains the Flatlist in each picker | ViewStyle |
483
+ | durationScrollFlatListContentContainer | Style for the Flatlist's `contentContainerStyle` prop in each picker | ViewStyle |
515
484
 
516
485
  Note the minor limitations to the allowed styles for `pickerContainer` and `pickerItemContainer`. These are made because these styles are used for internal calculations and all possible `backgroundColor`/`height` types are not supported.
517
486
 
@@ -519,7 +488,7 @@ Note the minor limitations to the allowed styles for `pickerContainer` and `pick
519
488
 
520
489
  When the `disableInfiniteScroll` prop is not set, the picker gives the appearance of an infinitely scrolling picker by auto-scrolling forward/back when you near the start/end of the list. When the picker auto-scrolls, a momentary flicker is visible if you are scrolling very slowly.
521
490
 
522
- To mitigate for this, the list of numbers in each picker is repeated a given number of times based on the length of the list (8 times for the hours picker, and 3 times for the minutes and seconds picker). These have a performance trade-off: higher values mean the picker has to auto-scroll less to maintain the infinite scroll, but has to render a longer list of numbers. The number of repetitions automatically adjusts if the number of items in the picker changes (e.g. if an interval is included, or the maximum value is modified), balancing the trade-off. You can also manually adjust the number of repetitions in each picker with the `repeatHourNumbersNTimes`, `repeatMinuteNumbersNTimes` and `repeatSecondNumbersNTimes` props.
491
+ To mitigate for this, the list of numbers in each picker is repeated a given number of times based on the length of the list (7 times for the hours picker, and 3 times for the days/minutes/seconds picker). These have a performance trade-off: higher values mean the picker has to auto-scroll less to maintain the infinite scroll, but has to render a longer list of numbers. The number of repetitions automatically adjusts if the number of items in the picker changes (e.g. if an interval is included, or the maximum value is modified), balancing the trade-off. You can also manually adjust the number of repetitions in each picker with the `repeatHourNumbersNTimes`, `repeatMinuteNumbersNTimes` and `repeatSecondNumbersNTimes` props.
523
492
 
524
493
  Note that you can avoid the auto-scroll flickering entirely by disabling infinite scroll. You could then set the above props to high values, so that a user has to scroll far down/up the list to reach the end of the list.
525
494
 
@@ -547,23 +516,6 @@ Please note that this solution does not work for all bottom-sheet components (e.
547
516
  **Important**:
548
517
  The custom component needs to have the same interface as React Native's `<FlatList />` in order for it to work as expected. A complete reference of the current usage can be found [here](/src/components/DurationScroll/index.tsx).
549
518
 
550
- #### Generic feedback
551
-
552
- To enable haptic feedback from the non-Expo module [react-native-haptic-feedback](https://github.com/mkuczera/react-native-haptic-feedback) (or provide feedback in any other form) you can use the generic feedback callback prop `pickerFeedback`. This function is called whenever any of the pickers tick onto a new number.
553
-
554
- ```Jsx
555
- import { trigger } from 'react-native-haptic-feedback';
556
- import { TimerPicker } from "react-native-timer-picker";
557
-
558
- // ...
559
-
560
- <TimerPicker
561
- {...props}
562
- pickerFeedback={() => trigger('impactLight')}
563
- />
564
-
565
- ```
566
-
567
519
  ### TimerPickerModal ⏰
568
520
 
569
521
  The TimerPickerModal component accepts all [TimerPicker props](#timerpicker-️), and the below additional props.
@@ -646,10 +598,132 @@ An identical ref is also exposed for the TimerPickerModal component.
646
598
 
647
599
  <br>
648
600
 
601
+ ## Picker Feedback 📳🔉
602
+
603
+ You can use the picker feedback callback prop `pickerFeedback` to provide any form of audio/haptic feedback for the picker. This function is called whenever any of the pickers tick onto a new number.
604
+
605
+ Note that this prop should be used in lieu of the now deprecated expo-specific audio/haptic feedback props.
606
+
607
+ ### Audio Feedack
608
+
609
+ There is a challenge here with audio latency as we need to be able to play the click-sound repeatedly and rapidly when a user scrolls fast. Most React Native sound libraries are designed for playing audio tracks and the latency is too high for this application.
610
+
611
+ Recommended libraries:
612
+
613
+ - [react-native-audio-api](https://www.npmjs.com/package/react-native-audio-api): this is a new library but is built by Software Mansion and has strong potential for our application with low-latency audio. It is not currently straightforward to use a local sound asset with this library; please check out the [Expo example](./examples/example-expo/App.tsx) and [Bare React Native example](./examples/example-bare//App.tsx) for a guide on how to do that. Note that this library will not work in Expo Go (you must create a development build).
614
+
615
+ Libraries to avoid:
616
+
617
+ - [react-native-sound](https://www.npmjs.com/package/react-native-sound): this likely has low enough latency to work but has not been maintained for the 3+ years.
618
+ - [expo-av](https://docs.expo.dev/versions/latest/sdk/av/): the latency is too high to work well. Expo are developing a new audio module [expo-audio](https://docs.expo.dev/versions/latest/sdk/audio/) that may be better, but at the time of writing (May 2025) it does not have the capability to repeatedly play the same sound.
619
+
620
+ ### Haptic Feedback
621
+
622
+ Recommended libraries:
623
+
624
+ - [expo-haptics](https://www.npmjs.com/package/expo-haptics): for Expo apps.
625
+ - [react-native-haptic-feedback](https://github.com/mkuczera/react-native-haptic-feedback): for bare React Native apps.
626
+
627
+ ### Feedback Example
628
+
629
+ ```Jsx
630
+ import { useCallback, useRef } from "react";
631
+ import { TimerPicker } from "react-native-timer-picker";
632
+
633
+ import { AudioContext, type AudioBuffer } from "react-native-audio-api";
634
+ import * as Haptics from 'expo-haptics'; // Expo apps
635
+ import { trigger } from 'react-native-haptic-feedback'; // Bare RN apps
636
+
637
+ // see examples/example-expo and examples/example-bare for how to load a local sound
638
+ import { getClickSound } from "./utils/getClickSound";
639
+
640
+ // ...
641
+
642
+ const audioContextRef = useRef<AudioContext | null>(null);
643
+ const audioBufferRef = useRef<AudioBuffer | null>(null);
644
+
645
+ useEffect(() => {
646
+ const setupAudio = async () => {
647
+ try {
648
+ const context = new AudioContext();
649
+ const arrayBuffer = await getClickSound();
650
+ const buffer = await context.decodeAudioData(arrayBuffer);
651
+
652
+ audioContextRef.current = context;
653
+ audioBufferRef.current = buffer;
654
+ } catch (error) {
655
+ console.warn("Audio setup failed:", error);
656
+ }
657
+ };
658
+
659
+ setupAudio();
660
+
661
+ return () => {
662
+ audioContextRef.current?.close();
663
+ };
664
+ }, []);
665
+
666
+ const pickerFeedback = useCallback(() => {
667
+ try {
668
+ // Audio
669
+ const context = audioContextRef.current;
670
+ const buffer = audioBufferRef.current;
671
+
672
+ if (!context || !buffer) {
673
+ console.warn("Audio not initialized");
674
+ return;
675
+ }
676
+
677
+ const playerNode = context.createBufferSource();
678
+ playerNode.buffer = buffer;
679
+ playerNode.connect(context.destination);
680
+ playerNode.start(context.currentTime);
681
+
682
+ // Haptics (Expo apps)
683
+ Haptics.selectionAsync();
684
+ // Hatpics (Bare RN apps)
685
+ trigger('selection');
686
+ } catch {
687
+ console.warn("Picker feedback failed");
688
+ }
689
+ }, [])
690
+
691
+ <TimerPicker
692
+ {...props}
693
+ pickerFeedback={pickerFeedback}
694
+ />
695
+
696
+ ```
697
+
698
+ ### Expo-Specific Audio/Haptic Feedback (DEPRECATED)
699
+
700
+ **⚠️ This was deprecated in v2.2.0 - please use the [picker feedback](#generic-feedback) prop instead.**
701
+
702
+ Enable haptic feedback with the [expo-haptics](https://www.npmjs.com/package/expo-haptics) module:
703
+
704
+ `import * as Haptics from "expo-haptics";`
705
+
706
+ To enable haptic feedback, you need to supply the imported `Haptics` namespace as a prop to either TimerPickerModal or TimerPicker.
707
+
708
+ <br>
709
+
710
+ Enable audio feedback with the [expo-av](https://www.npmjs.com/package/expo-av) module:
711
+
712
+ `import { Audio } from "expo-av";`
713
+
714
+ To enable audio feedback, you need to supply the imported `Audio` class as a prop to either TimerPickerModal or TimerPicker.
715
+
716
+ Please note that the default click sound uses a hosted mp3 file. To make the click sound work offline, you need to supply your own
717
+ sound asset through the `clickSoundAsset` prop. You can download the default click sound [here](https://drive.google.com/uc?export=download&id=10e1YkbNsRh-vGx1jmS1Nntz8xzkBp4_I).
718
+
719
+ <br>
720
+
649
721
  ## Contributing 🧑‍🤝‍🧑
650
722
 
651
723
  Contributions to this project are more than welcome.
652
724
 
725
+ **N.B. Please submit PRs into `develop`, not `main`.**
726
+
653
727
  ### Dev Setup
654
728
 
655
729
  To get this project running locally:
@@ -659,8 +733,8 @@ To get this project running locally:
659
733
 
660
734
  You can then start either the Expo example or the bare React Native example:
661
735
 
662
- - For Expo, run `yarn start` to start the Expo example in Expo Go.
663
- - For bare React Native, run `yarn start-bare:android` or `start-bare:ios` to start the project on an emulator/device.
736
+ - For Expo, run `yarn start` to start the Expo example in Expo Go. For audio feedback, uncomment the relevant lines in `examples/example-expo/App.tsx` and create a development build with `yarn build:android` or `yarn build:ios`.
737
+ - For bare React Native, run `yarn start-bare:android` or `start-bare:ios` to start the project on an emulator/device (you have to refresh the app once on startup for it to work).
664
738
 
665
739
  ### GitHub Guidelines
666
740
 
@@ -674,7 +748,8 @@ There are two permenant branches: `main` and `develop`. You should never work di
674
748
 
675
749
  ## Limitations ⚠
676
750
 
677
- The project is not compatibile with React Native versions prior to `v0.72.0` due to this [React Native issue](https://github.com/facebook/react-native/issues/36329).
751
+ - The project is not compatibile with React Native versions prior to `v0.72.0` due to this [React Native issue](https://github.com/facebook/react-native/issues/36329).
752
+ - The audio feedback provided by the `Audio` prop with `expo-av` suffers from high latency and doesn't work well when a user scrolls quickly. This has now been deprecated in place of the `pickerFeedback` prop. Please try `react-native-audio-api` for a lower latency audio library.
678
753
 
679
754
  <br>
680
755