react-native-timer-picker 1.5.3 → 1.6.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 +49 -35
- package/dist/commonjs/components/TimerPicker/DurationScroll.js +7 -4
- package/dist/commonjs/components/TimerPicker/DurationScroll.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/TimerPicker.styles.js +4 -0
- package/dist/commonjs/components/TimerPicker/TimerPicker.styles.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/index.js +6 -0
- package/dist/commonjs/components/TimerPicker/index.js.map +1 -1
- package/dist/commonjs/components/index.js +6 -0
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/module/components/TimerPicker/DurationScroll.js +7 -4
- package/dist/module/components/TimerPicker/DurationScroll.js.map +1 -1
- package/dist/module/components/TimerPicker/TimerPicker.styles.js +4 -0
- package/dist/module/components/TimerPicker/TimerPicker.styles.js.map +1 -1
- package/dist/module/components/TimerPicker/index.js +6 -0
- package/dist/module/components/TimerPicker/index.js.map +1 -1
- package/dist/module/components/index.js +6 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/typescript/components/TimerPicker/DurationScroll.d.ts +1 -0
- package/dist/typescript/components/TimerPicker/TimerPicker.styles.d.ts +2 -0
- package/dist/typescript/components/TimerPicker/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/TimerPicker/DurationScroll.tsx +13 -5
- package/src/components/TimerPicker/TimerPicker.styles.ts +5 -0
- package/src/components/TimerPicker/index.tsx +9 -0
- package/src/components/index.tsx +6 -0
package/package.json
CHANGED
|
@@ -55,6 +55,7 @@ interface DurationScrollProps {
|
|
|
55
55
|
onDurationChange: (duration: number) => void;
|
|
56
56
|
padNumbersWithZero?: boolean;
|
|
57
57
|
disableInfiniteScroll?: boolean;
|
|
58
|
+
isDisabled?: boolean;
|
|
58
59
|
limit?: LimitType;
|
|
59
60
|
aggressivelyGetLatestDuration: boolean;
|
|
60
61
|
is12HourPicker?: boolean;
|
|
@@ -83,6 +84,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
|
|
|
83
84
|
padNumbersWithZero = false,
|
|
84
85
|
disableInfiniteScroll = false,
|
|
85
86
|
limit,
|
|
87
|
+
isDisabled,
|
|
86
88
|
aggressivelyGetLatestDuration,
|
|
87
89
|
allowFontScaling = false,
|
|
88
90
|
is12HourPicker,
|
|
@@ -336,11 +338,16 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
|
|
|
336
338
|
return (
|
|
337
339
|
<View
|
|
338
340
|
testID={testID}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
pointerEvents={isDisabled ? "none" : undefined}
|
|
342
|
+
style={[
|
|
343
|
+
{
|
|
344
|
+
height:
|
|
345
|
+
styles.pickerItemContainer.height *
|
|
346
|
+
numberOfItemsToShow,
|
|
347
|
+
overflow: "visible",
|
|
348
|
+
},
|
|
349
|
+
isDisabled && styles.disabledPickerContainer,
|
|
350
|
+
]}>
|
|
344
351
|
<FlatList
|
|
345
352
|
ref={flatListRef}
|
|
346
353
|
data={data}
|
|
@@ -353,6 +360,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
|
|
|
353
360
|
decelerationRate={0.88}
|
|
354
361
|
scrollEventThrottle={16}
|
|
355
362
|
snapToAlignment="start"
|
|
363
|
+
scrollEnabled={!isDisabled}
|
|
356
364
|
// used in place of snapToOffset due to bug on Android
|
|
357
365
|
snapToOffsets={[...Array(data.length)].map(
|
|
358
366
|
(_, i) => i * styles.pickerItemContainer.height
|
|
@@ -12,6 +12,7 @@ export interface CustomTimerPickerStyles {
|
|
|
12
12
|
pickerAmPmLabel?: any;
|
|
13
13
|
pickerItemContainer?: any;
|
|
14
14
|
pickerItem?: any;
|
|
15
|
+
disabledPickerContainer?: any;
|
|
15
16
|
disabledPickerItem?: any;
|
|
16
17
|
pickerGradientOverlay?: any;
|
|
17
18
|
}
|
|
@@ -101,6 +102,10 @@ export const generateStyles = (
|
|
|
101
102
|
...customStyles?.pickerLabel,
|
|
102
103
|
...customStyles?.pickerAmPmLabel,
|
|
103
104
|
},
|
|
105
|
+
disabledPickerContainer: {
|
|
106
|
+
opacity: 0.4,
|
|
107
|
+
...customStyles?.disabledPickerContainer,
|
|
108
|
+
},
|
|
104
109
|
disabledPickerItem: {
|
|
105
110
|
opacity: 0.2,
|
|
106
111
|
...customStyles?.disabledPickerItem,
|
|
@@ -48,6 +48,9 @@ export interface TimerPickerProps {
|
|
|
48
48
|
hideHours?: boolean;
|
|
49
49
|
hideMinutes?: boolean;
|
|
50
50
|
hideSeconds?: boolean;
|
|
51
|
+
hoursPickerIsDisabled?: boolean;
|
|
52
|
+
minutesPickerIsDisabled?: boolean;
|
|
53
|
+
secondsPickerIsDisabled?: boolean;
|
|
51
54
|
hourLimit?: LimitType;
|
|
52
55
|
minuteLimit?: LimitType;
|
|
53
56
|
secondLimit?: LimitType;
|
|
@@ -76,6 +79,9 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
|
|
|
76
79
|
hideHours = false,
|
|
77
80
|
hideMinutes = false,
|
|
78
81
|
hideSeconds = false,
|
|
82
|
+
hoursPickerIsDisabled = false,
|
|
83
|
+
minutesPickerIsDisabled = false,
|
|
84
|
+
secondsPickerIsDisabled = false,
|
|
79
85
|
hourLimit,
|
|
80
86
|
minuteLimit,
|
|
81
87
|
secondLimit,
|
|
@@ -168,6 +174,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
|
|
|
168
174
|
label={
|
|
169
175
|
hourLabel ?? (!use12HourPicker ? "h" : undefined)
|
|
170
176
|
}
|
|
177
|
+
isDisabled={hoursPickerIsDisabled}
|
|
171
178
|
initialValue={initialHours}
|
|
172
179
|
allowFontScaling={allowFontScaling}
|
|
173
180
|
aggressivelyGetLatestDuration={
|
|
@@ -197,6 +204,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
|
|
|
197
204
|
ref={minutesDurationScrollRef}
|
|
198
205
|
numberOfItems={59}
|
|
199
206
|
label={minuteLabel ?? "m"}
|
|
207
|
+
isDisabled={minutesPickerIsDisabled}
|
|
200
208
|
initialValue={initialMinutes}
|
|
201
209
|
allowFontScaling={allowFontScaling}
|
|
202
210
|
aggressivelyGetLatestDuration={
|
|
@@ -224,6 +232,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
|
|
|
224
232
|
ref={secondsDurationScrollRef}
|
|
225
233
|
numberOfItems={59}
|
|
226
234
|
label={secondLabel ?? "s"}
|
|
235
|
+
isDisabled={secondsPickerIsDisabled}
|
|
227
236
|
initialValue={initialSeconds}
|
|
228
237
|
allowFontScaling={allowFontScaling}
|
|
229
238
|
aggressivelyGetLatestDuration={
|
package/src/components/index.tsx
CHANGED
|
@@ -76,6 +76,9 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
|
|
|
76
76
|
hideHours = false,
|
|
77
77
|
hideMinutes = false,
|
|
78
78
|
hideSeconds = false,
|
|
79
|
+
hoursPickerIsDisabled = false,
|
|
80
|
+
minutesPickerIsDisabled = false,
|
|
81
|
+
secondsPickerIsDisabled = false,
|
|
79
82
|
hourLimit,
|
|
80
83
|
minuteLimit,
|
|
81
84
|
secondLimit,
|
|
@@ -221,6 +224,9 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
|
|
|
221
224
|
hideHours={hideHours}
|
|
222
225
|
hideMinutes={hideMinutes}
|
|
223
226
|
hideSeconds={hideSeconds}
|
|
227
|
+
hoursPickerIsDisabled={hoursPickerIsDisabled}
|
|
228
|
+
minutesPickerIsDisabled={minutesPickerIsDisabled}
|
|
229
|
+
secondsPickerIsDisabled={secondsPickerIsDisabled}
|
|
224
230
|
hourLimit={hourLimit}
|
|
225
231
|
minuteLimit={minuteLimit}
|
|
226
232
|
secondLimit={secondLimit}
|