Skip to content

Commit badd4ff

Browse files
committed
Merge branch 'release/v1.6.0'
2 parents fc0c9f8 + 968042a commit badd4ff

File tree

6 files changed

+52
-20
lines changed

6 files changed

+52
-20
lines changed

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ return (
338338
| hideHours | Hide the hours picker | Boolean | false | false |
339339
| hideMinutes | Hide the minutes picker | Boolean | false | false |
340340
| hideSeconds | Hide the seconds picker | Boolean | false | false |
341+
| hoursPickerIsDisabled | Disable the hours picker picker | Boolean | false | false |
342+
| minutesPickerIsDisabled | Disable the minutes picker picker | Boolean | false | false |
343+
| secondsPickerIsDisabled | Disable the seconds picker picker | Boolean | false | false |
341344
| hourLimit | Limit on the hours it is possible to select | { max?: Number, min?: Number } | - | false |
342345
| minuteLimit | Limit on the minutes it is possible to select | { max?: Number, min?: Number } | - | false |
343346
| secondLimit | Limit on the seconds it is possible to select | { max?: Number, min?: Number } | - | false |
@@ -362,20 +365,21 @@ return (
362365

363366
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/TimerPicker.styles.ts).
364367

365-
| Style Prop | Description | Type |
366-
| :-------------------: | :------------------------------------------- | :---------------: |
367-
| theme | Theme of the component | "light" \| "dark" |
368-
| backgroundColor | Main background color | string |
369-
| text | Base text style | TextStyle |
370-
| pickerContainer | Main container for the picker | ViewStyle |
371-
| pickerLabelContainer | Container for the picker's labels | ViewStyle |
372-
| pickerLabel | Style for the picker's labels | TextStyle |
373-
| pickerAmPmContainer | Style for the picker's labels | ViewStyle |
374-
| pickerAmPmLabel | Style for the picker's labels | TextStyle |
375-
| pickerItemContainer | Container for each number in the picker | ViewStyle |
376-
| pickerItem | Style for each individual picker number | TextStyle |
377-
| disabledPickerItem | Style for any numbers outside any set limits | TextStyle |
378-
| pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
368+
| Style Prop | Description | Type |
369+
| :---------------------: | :------------------------------------------- | :---------------: |
370+
| theme | Theme of the component | "light" \| "dark" |
371+
| backgroundColor | Main background color | string |
372+
| text | Base text style | TextStyle |
373+
| pickerContainer | Main container for the picker | ViewStyle |
374+
| pickerLabelContainer | Container for the picker's labels | ViewStyle |
375+
| pickerLabel | Style for the picker's labels | TextStyle |
376+
| pickerAmPmContainer | Style for the picker's labels | ViewStyle |
377+
| pickerAmPmLabel | Style for the picker's labels | TextStyle |
378+
| pickerItemContainer | Container for each number in the picker | ViewStyle |
379+
| pickerItem | Style for each individual picker number | TextStyle |
380+
| disabledPickerItem | Style for any numbers outside any set limits | TextStyle |
381+
| disabledPickerContainer | Style for disabled pickers | ViewStyle |
382+
| pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
379383

380384
### TimerPickerModal ⏰
381385

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"url": "https://github.com/troberts-28"
77
},
88
"license": "MIT",
9-
"version": "1.5.4",
9+
"version": "1.6.0",
1010
"main": "dist/commonjs/index.js",
1111
"types": "dist/typescript/src/index.d.ts",
1212
"scripts": {

src/components/TimerPicker/DurationScroll.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ interface DurationScrollProps {
5555
onDurationChange: (duration: number) => void;
5656
padNumbersWithZero?: boolean;
5757
disableInfiniteScroll?: boolean;
58+
isDisabled?: boolean;
5859
limit?: LimitType;
5960
aggressivelyGetLatestDuration: boolean;
6061
is12HourPicker?: boolean;
@@ -83,6 +84,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
8384
padNumbersWithZero = false,
8485
disableInfiniteScroll = false,
8586
limit,
87+
isDisabled,
8688
aggressivelyGetLatestDuration,
8789
allowFontScaling = false,
8890
is12HourPicker,
@@ -336,11 +338,16 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
336338
return (
337339
<View
338340
testID={testID}
339-
style={{
340-
height:
341-
styles.pickerItemContainer.height * numberOfItemsToShow,
342-
overflow: "visible",
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+
]}>
344351
<FlatList
345352
ref={flatListRef}
346353
data={data}
@@ -353,6 +360,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
353360
decelerationRate={0.88}
354361
scrollEventThrottle={16}
355362
snapToAlignment="start"
363+
scrollEnabled={!isDisabled}
356364
// used in place of snapToOffset due to bug on Android
357365
snapToOffsets={[...Array(data.length)].map(
358366
(_, i) => i * styles.pickerItemContainer.height

src/components/TimerPicker/TimerPicker.styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface CustomTimerPickerStyles {
1212
pickerAmPmLabel?: any;
1313
pickerItemContainer?: any;
1414
pickerItem?: any;
15+
disabledPickerContainer?: any;
1516
disabledPickerItem?: any;
1617
pickerGradientOverlay?: any;
1718
}
@@ -101,6 +102,10 @@ export const generateStyles = (
101102
...customStyles?.pickerLabel,
102103
...customStyles?.pickerAmPmLabel,
103104
},
105+
disabledPickerContainer: {
106+
opacity: 0.4,
107+
...customStyles?.disabledPickerContainer,
108+
},
104109
disabledPickerItem: {
105110
opacity: 0.2,
106111
...customStyles?.disabledPickerItem,

src/components/TimerPicker/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export interface TimerPickerProps {
4848
hideHours?: boolean;
4949
hideMinutes?: boolean;
5050
hideSeconds?: boolean;
51+
hoursPickerIsDisabled?: boolean;
52+
minutesPickerIsDisabled?: boolean;
53+
secondsPickerIsDisabled?: boolean;
5154
hourLimit?: LimitType;
5255
minuteLimit?: LimitType;
5356
secondLimit?: LimitType;
@@ -76,6 +79,9 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
7679
hideHours = false,
7780
hideMinutes = false,
7881
hideSeconds = false,
82+
hoursPickerIsDisabled = false,
83+
minutesPickerIsDisabled = false,
84+
secondsPickerIsDisabled = false,
7985
hourLimit,
8086
minuteLimit,
8187
secondLimit,
@@ -168,6 +174,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
168174
label={
169175
hourLabel ?? (!use12HourPicker ? "h" : undefined)
170176
}
177+
isDisabled={hoursPickerIsDisabled}
171178
initialValue={initialHours}
172179
allowFontScaling={allowFontScaling}
173180
aggressivelyGetLatestDuration={
@@ -197,6 +204,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
197204
ref={minutesDurationScrollRef}
198205
numberOfItems={59}
199206
label={minuteLabel ?? "m"}
207+
isDisabled={minutesPickerIsDisabled}
200208
initialValue={initialMinutes}
201209
allowFontScaling={allowFontScaling}
202210
aggressivelyGetLatestDuration={
@@ -224,6 +232,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
224232
ref={secondsDurationScrollRef}
225233
numberOfItems={59}
226234
label={secondLabel ?? "s"}
235+
isDisabled={secondsPickerIsDisabled}
227236
initialValue={initialSeconds}
228237
allowFontScaling={allowFontScaling}
229238
aggressivelyGetLatestDuration={

src/components/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
7676
hideHours = false,
7777
hideMinutes = false,
7878
hideSeconds = false,
79+
hoursPickerIsDisabled = false,
80+
minutesPickerIsDisabled = false,
81+
secondsPickerIsDisabled = false,
7982
hourLimit,
8083
minuteLimit,
8184
secondLimit,
@@ -221,6 +224,9 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
221224
hideHours={hideHours}
222225
hideMinutes={hideMinutes}
223226
hideSeconds={hideSeconds}
227+
hoursPickerIsDisabled={hoursPickerIsDisabled}
228+
minutesPickerIsDisabled={minutesPickerIsDisabled}
229+
secondsPickerIsDisabled={secondsPickerIsDisabled}
224230
hourLimit={hourLimit}
225231
minuteLimit={minuteLimit}
226232
secondLimit={secondLimit}

0 commit comments

Comments
 (0)