react-native-timer-picker 1.0.0 → 1.1.1
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 +386 -2
- package/package.json +41 -8
- package/dist/components/DurationPicker/DurationPicker.styles.d.ts +0 -26
- package/dist/components/DurationPicker/DurationPicker.styles.js +0 -39
- package/dist/components/DurationPicker/DurationScroll.d.ts +0 -16
- package/dist/components/DurationPicker/DurationScroll.js +0 -121
- package/dist/components/DurationPicker/index.d.ts +0 -27
- package/dist/components/DurationPicker/index.js +0 -55
- package/dist/components/DurationPickerModal.styles.d.ts +0 -23
- package/dist/components/DurationPickerModal.styles.js +0 -40
- package/dist/components/Modal/Modal.styles.d.ts +0 -22
- package/dist/components/Modal/Modal.styles.js +0 -26
- package/dist/components/Modal/index.d.ts +0 -14
- package/dist/components/Modal/index.js +0 -121
- package/dist/components/TimerPicker/DurationScroll.d.ts +0 -16
- package/dist/components/TimerPicker/DurationScroll.js +0 -121
- package/dist/components/TimerPicker/TimerPicker.styles.d.ts +0 -26
- package/dist/components/TimerPicker/TimerPicker.styles.js +0 -40
- package/dist/components/TimerPicker/index.d.ts +0 -27
- package/dist/components/TimerPicker/index.js +0 -56
- package/dist/components/TimerPickerModal.styles.d.ts +0 -23
- package/dist/components/TimerPickerModal.styles.js +0 -41
- package/dist/components/index.d.ts +0 -28
- package/dist/components/index.js +0 -87
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -10
- package/dist/utils/colorToRgba.d.ts +0 -4
- package/dist/utils/colorToRgba.js +0 -48
- package/dist/utils/generateNumbers.d.ts +0 -7
- package/dist/utils/generateNumbers.js +0 -27
- package/dist/utils/padWithZero.d.ts +0 -1
- package/dist/utils/padWithZero.js +0 -12
package/README.md
CHANGED
|
@@ -1,2 +1,386 @@
|
|
|
1
|
-
# React Native Timer Picker
|
|
2
|
-
|
|
1
|
+
# React Native Timer Picker ⏰🕰️⏳
|
|
2
|
+
|
|
3
|
+
[]()
|
|
4
|
+

|
|
5
|
+
[](https://www.npmjs.com/package/react-native-timer-picker)
|
|
6
|
+
[](https://www.npmjs.com/package/react-native-timer-picker)
|
|
7
|
+
|
|
8
|
+
A simple, flexible, performant duration picker component for React Native apps 🔥
|
|
9
|
+
|
|
10
|
+
Great for timers, alarms and duration inputs ⏰🕰️⏳
|
|
11
|
+
|
|
12
|
+
Works with Expo and bare React Native apps.
|
|
13
|
+
|
|
14
|
+
- [Demos 📱](#demos-)
|
|
15
|
+
- [Peer Dependencies 👶](#peer-dependencies-)
|
|
16
|
+
- [Installation 🚀](#installation-)
|
|
17
|
+
- [Examples 😎](#examples-)
|
|
18
|
+
- [Timer Picker Modal (Dark Mode) 🌚](#timer-picker-modal-dark-mode-)
|
|
19
|
+
- [Timer Picker Modal (Light Mode) 🌞](#timer-picker-modal-light-mode-)
|
|
20
|
+
- [Timer Picker with Customisation (Dark Mode) 🌒](#timer-picker-with-customisation-dark-mode-)
|
|
21
|
+
- [Timer Picker with Customisation (Light Mode) 🌔](#timer-picker-with-customisation-light-mode-)
|
|
22
|
+
- [Props 💅](#props-)
|
|
23
|
+
- [TimerPicker ⏲️](#timerpicker-️)
|
|
24
|
+
- [Custom Styles 👗](#custom-styles-)
|
|
25
|
+
- [TimerPickerModal ⏰](#timerpickermodal-)
|
|
26
|
+
- [Custom Styles 👗](#custom-styles--1)
|
|
27
|
+
- [Methods 🔄](#methods-)
|
|
28
|
+
- [TimerPickerModal](#timerpickermodal)
|
|
29
|
+
- [License 📝](#license-)
|
|
30
|
+
|
|
31
|
+
## Demos 📱
|
|
32
|
+
|
|
33
|
+
<p>
|
|
34
|
+
<img src="demos/example1.gif" width="250" height="550" style="margin-right:50px"/>
|
|
35
|
+
<img src="demos/example2.gif" width="250" height="550"/>
|
|
36
|
+
</p>
|
|
37
|
+
<p>
|
|
38
|
+
<img src="demos/example3.gif" width="250" height="550" style="margin-right:50px"/>
|
|
39
|
+
<img src="demos/example4.gif" width="250" height="550"/>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Peer Dependencies 👶
|
|
44
|
+
|
|
45
|
+
This component will work in your React Native Project **without any peer dependencies**.
|
|
46
|
+
|
|
47
|
+
If you want the numbers to fade in/out at the top and bottom of the picker, you will need to install either:
|
|
48
|
+
|
|
49
|
+
- [expo-linear-gradient](https://www.npmjs.com/package/expo-linear-gradient) (if using Expo)
|
|
50
|
+
- [react-native-linear-gradient](https://www.npmjs.com/package/react-native-linear-gradient) (if using in a bare React Native project)
|
|
51
|
+
|
|
52
|
+
To enable the linear gradient, you need to supply the component as a prop to either TimerPickerModal or TimerPicker.
|
|
53
|
+
|
|
54
|
+
## Installation 🚀
|
|
55
|
+
|
|
56
|
+
Supports React Native >= 0.59.0 and React >= 16.8.0.
|
|
57
|
+
|
|
58
|
+
Just run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install react-native-timer-picker
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
or
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
yarn add react-native-timer-picker
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Examples 😎
|
|
71
|
+
|
|
72
|
+
### Timer Picker Modal (Dark Mode) 🌚
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import { TimerPickerModal } from "react-native-timer-picker";
|
|
76
|
+
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
77
|
+
|
|
78
|
+
....
|
|
79
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
80
|
+
const [alarmString, setAlarmString] = useState<
|
|
81
|
+
string | null
|
|
82
|
+
>(null);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<View style={{backgroundColor: "#514242", alignItems: "center", justifyContent: "center"}}>
|
|
86
|
+
<Text style={{fontSize: 18, color: "#F1F1F1"}}>
|
|
87
|
+
{alarmStringExample !== null
|
|
88
|
+
? "Alarm set for"
|
|
89
|
+
: "No alarm set"}
|
|
90
|
+
</Text>
|
|
91
|
+
<TouchableOpacity
|
|
92
|
+
activeOpacity={0.7}
|
|
93
|
+
onPress={() => setShowPicker(true)}>
|
|
94
|
+
<View style={{alignItems: "center"}}>
|
|
95
|
+
{alarmString !== null ? (
|
|
96
|
+
<Text style={{color: "#F1F1F1", fontSize: 48}}>
|
|
97
|
+
{alarmString}
|
|
98
|
+
</Text>
|
|
99
|
+
) : null}
|
|
100
|
+
<TouchableOpacity
|
|
101
|
+
activeOpacity={0.7}
|
|
102
|
+
onPress={() => setShowPicker(true)}>
|
|
103
|
+
<View style={{marginTop: 30}}>
|
|
104
|
+
<Text
|
|
105
|
+
style={{
|
|
106
|
+
paddingVertical: 10,
|
|
107
|
+
paddingHorizontal: 18,
|
|
108
|
+
borderWidth: 1,
|
|
109
|
+
borderRadius: 10,
|
|
110
|
+
fontSize: 16,
|
|
111
|
+
overflow: "hidden",
|
|
112
|
+
borderColor: "#C2C2C2",
|
|
113
|
+
color: "#C2C2C2"
|
|
114
|
+
}}>
|
|
115
|
+
Set Alarm 🔔
|
|
116
|
+
</Text>
|
|
117
|
+
</View>
|
|
118
|
+
</TouchableOpacity>
|
|
119
|
+
</View>
|
|
120
|
+
</TouchableOpacity>
|
|
121
|
+
<TimerPickerModal
|
|
122
|
+
visible={showPicker}
|
|
123
|
+
setIsVisible={setShowPicker}
|
|
124
|
+
onConfirm={(pickedDuration) => {
|
|
125
|
+
setAlarmString(formatTime(pickedDuration));
|
|
126
|
+
setShowPicker(false);
|
|
127
|
+
}}
|
|
128
|
+
modalTitle="Set Alarm"
|
|
129
|
+
onCancel={() => setShowPicker(false)}
|
|
130
|
+
closeOnOverlayPress
|
|
131
|
+
LinearGradient={LinearGradient}
|
|
132
|
+
styles={{
|
|
133
|
+
theme: "dark",
|
|
134
|
+
}}
|
|
135
|
+
modalProps={{
|
|
136
|
+
overlayOpacity: 0.2,
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</View>
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
<img src="demos/example1.gif" width="250" height="550"/>
|
|
144
|
+
|
|
145
|
+
### Timer Picker Modal (Light Mode) 🌞
|
|
146
|
+
|
|
147
|
+
```jsx
|
|
148
|
+
import { TimerPickerModal } from "react-native-timer-picker";
|
|
149
|
+
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
150
|
+
|
|
151
|
+
....
|
|
152
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
153
|
+
const [alarmString, setAlarmString] = useState<
|
|
154
|
+
string | null
|
|
155
|
+
>(null);
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<View style={{backgroundColor: "#F1F1F1", alignItems: "center", justifyContent: "center"}}>
|
|
159
|
+
<Text style={{fontSize: 18, color: "#202020"}}>
|
|
160
|
+
{alarmStringExample !== null
|
|
161
|
+
? "Alarm set for"
|
|
162
|
+
: "No alarm set"}
|
|
163
|
+
</Text>
|
|
164
|
+
<TouchableOpacity
|
|
165
|
+
activeOpacity={0.7}
|
|
166
|
+
onPress={() => setShowPicker(true)}>
|
|
167
|
+
<View style={{alignItems: "center"}}>
|
|
168
|
+
{alarmString !== null ? (
|
|
169
|
+
<Text style={{color: "#202020", fontSize: 48}}>
|
|
170
|
+
{alarmString}
|
|
171
|
+
</Text>
|
|
172
|
+
) : null}
|
|
173
|
+
<TouchableOpacity
|
|
174
|
+
activeOpacity={0.7}
|
|
175
|
+
onPress={() => setShowPicker(true)}>
|
|
176
|
+
<View style={{marginTop: 30}}>
|
|
177
|
+
<Text
|
|
178
|
+
style={{paddingVertical: 10,
|
|
179
|
+
paddingHorizontal: 18,
|
|
180
|
+
borderWidth: 1,
|
|
181
|
+
borderRadius: 10,
|
|
182
|
+
fontSize: 16,
|
|
183
|
+
overflow: "hidden",
|
|
184
|
+
borderColor: "#8C8C8C",
|
|
185
|
+
color: "#8C8C8C"
|
|
186
|
+
}}>
|
|
187
|
+
Set Alarm 🔔
|
|
188
|
+
</Text>
|
|
189
|
+
</View>
|
|
190
|
+
</TouchableOpacity>
|
|
191
|
+
</View>
|
|
192
|
+
</TouchableOpacity>
|
|
193
|
+
<TimerPickerModal
|
|
194
|
+
visible={showPicker}
|
|
195
|
+
setIsVisible={setShowPicker}
|
|
196
|
+
onConfirm={(pickedDuration) => {
|
|
197
|
+
setAlarmString(formatTime(pickedDuration));
|
|
198
|
+
setShowPicker(false);
|
|
199
|
+
}}
|
|
200
|
+
modalTitle="Set Alarm"
|
|
201
|
+
onCancel={() => setShowPicker(false)}
|
|
202
|
+
closeOnOverlayPress
|
|
203
|
+
LinearGradient={LinearGradient}
|
|
204
|
+
styles={{
|
|
205
|
+
theme: "light",
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
</View>
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
<img src="demos/example2.gif" width="250" height="550"/>
|
|
213
|
+
|
|
214
|
+
### Timer Picker with Customisation (Dark Mode) 🌒
|
|
215
|
+
|
|
216
|
+
```jsx
|
|
217
|
+
import { TimerPicker } from "react-native-timer-picker";
|
|
218
|
+
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
219
|
+
|
|
220
|
+
....
|
|
221
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
222
|
+
const [alarmString, setAlarmString] = useState<
|
|
223
|
+
string | null
|
|
224
|
+
>(null);
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<View style={{backgroundColor: "#202020", alignItems: "center", justifyContent: "center"}}>
|
|
228
|
+
<TimerPicker
|
|
229
|
+
padWithNItems={2}
|
|
230
|
+
hourLabel=":"
|
|
231
|
+
minuteLabel=":"
|
|
232
|
+
secondLabel=""
|
|
233
|
+
LinearGradient={LinearGradient}
|
|
234
|
+
styles={{
|
|
235
|
+
theme: "dark",
|
|
236
|
+
backgroundColor: "#202020",
|
|
237
|
+
pickerItem: {
|
|
238
|
+
fontSize: 34,
|
|
239
|
+
},
|
|
240
|
+
pickerLabel: {
|
|
241
|
+
fontSize: 32,
|
|
242
|
+
marginTop: 0,
|
|
243
|
+
},
|
|
244
|
+
pickerContainer: {
|
|
245
|
+
marginRight: 6,
|
|
246
|
+
},
|
|
247
|
+
}}
|
|
248
|
+
/>
|
|
249
|
+
</View>
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
<img src="demos/example3.gif" width="250" height="550"/>
|
|
254
|
+
|
|
255
|
+
### Timer Picker with Customisation (Light Mode) 🌔
|
|
256
|
+
|
|
257
|
+
```jsx
|
|
258
|
+
import { TimerPicker } from "react-native-timer-picker";
|
|
259
|
+
import { LinearGradient } from "expo-linear-gradient"; // or `import LinearGradient from "react-native-linear-gradient"`
|
|
260
|
+
|
|
261
|
+
....
|
|
262
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
263
|
+
const [alarmString, setAlarmString] = useState<
|
|
264
|
+
string | null
|
|
265
|
+
>(null);
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<View style={{backgroundColor: "#F1F1F1", alignItems: "center", justifyContent: "center"}}>
|
|
269
|
+
<TimerPicker
|
|
270
|
+
padWithNItems={3}
|
|
271
|
+
hideHours
|
|
272
|
+
minuteLabel="min"
|
|
273
|
+
secondLabel="sec"
|
|
274
|
+
LinearGradient={LinearGradient}
|
|
275
|
+
styles={{
|
|
276
|
+
theme: "light",
|
|
277
|
+
pickerItem: {
|
|
278
|
+
fontSize: 34,
|
|
279
|
+
},
|
|
280
|
+
pickerLabel: {
|
|
281
|
+
fontSize: 26,
|
|
282
|
+
right: -20,
|
|
283
|
+
},
|
|
284
|
+
pickerLabelContainer: {
|
|
285
|
+
width: 60,
|
|
286
|
+
},
|
|
287
|
+
pickerItemContainer: {
|
|
288
|
+
width: 150,
|
|
289
|
+
},
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
</View>
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
<img src="demos/example4.gif" width="250" height="550"/>
|
|
297
|
+
|
|
298
|
+
## Props 💅
|
|
299
|
+
|
|
300
|
+
### TimerPicker ⏲️
|
|
301
|
+
|
|
302
|
+
| Prop | Description | Type | Default Value | Required |
|
|
303
|
+
| :--------------------------:|:----------------------------------------------------------|:-------------------------------------------------:|:-------------------:|:--------:|
|
|
304
|
+
| onDurationChange | Callback when the duration changes | `(duration: { hours: number, minutes: number, seconds: number }) => void` | - | false |
|
|
305
|
+
| initialHours | Initial value for hours | Number | - | false |
|
|
306
|
+
| initialMinutes | Initial value for minutes | Number | - | false |
|
|
307
|
+
| initialSeconds | Initial value for seconds | Number | - | false |
|
|
308
|
+
| hideHours | Hide the hours picker | Boolean | false | false |
|
|
309
|
+
| hideMinutes | Hide the minutes picker | Boolean | false | false |
|
|
310
|
+
| hideSeconds | Hide the seconds picker | Boolean | false | false |
|
|
311
|
+
| hourLabel | Label for the hours picker | String | h | false |
|
|
312
|
+
| minuteLabel | Label for the minutes picker | String | m | false |
|
|
313
|
+
| secondLabel | Label for the seconds picker | String | s | false |
|
|
314
|
+
| padWithNItems | Number of items to pad the picker with on either side | Number | 1 | false |
|
|
315
|
+
| disableInfiniteScroll | Disable the infinite scroll feature | Boolean | false | false |
|
|
316
|
+
| LinearGradient | Linear Gradient Component | expo-linear-gradient.LinearGradient or react-native-linear-gradient.default | - | false |
|
|
317
|
+
| pickerContainerProps | Props for the picker container | `React.ComponentProps<typeof View>` | - | false |
|
|
318
|
+
| pickerGradientOverlayProps | Props for the gradient overlay | LinearGradientProps | - | false |
|
|
319
|
+
| styles | Custom styles for the timer picker | [CustomTimerPickerStyles](#custom-styles) | - | false |
|
|
320
|
+
|
|
321
|
+
#### Custom Styles 👗
|
|
322
|
+
|
|
323
|
+
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).
|
|
324
|
+
|
|
325
|
+
| Style Prop | Description | Type |
|
|
326
|
+
| :-------------------: | :------------------------------------- | :-----------------------------------: |
|
|
327
|
+
| theme | Theme of the component | "light" \| "dark" |
|
|
328
|
+
| backgroundColor | Main background color | string |
|
|
329
|
+
| textColor | Color for the text elements | string |
|
|
330
|
+
| pickerContainer | Main container for the picker | ViewStyle |
|
|
331
|
+
| pickerLabelContainer | Container for the picker's labels | ViewStyle |
|
|
332
|
+
| pickerLabel | Style for the picker's labels | TextStyle |
|
|
333
|
+
| pickerItemContainer | Container for each number in the picker | ViewStyle |
|
|
334
|
+
| pickerItem | Style for each individual picker number | TextStyle |
|
|
335
|
+
| pickerGradientOverlay | Style for the gradient overlay (fade out) | ViewStyle |
|
|
336
|
+
|
|
337
|
+
### TimerPickerModal ⏰
|
|
338
|
+
|
|
339
|
+
The TimerPickerModal component accepts all [TimerPicker props](#timerpicker), and the below additional props.
|
|
340
|
+
|
|
341
|
+
| Prop | Description | Type | Default Value | Required |
|
|
342
|
+
| :--------------------:|:----------------------------------------------------------|:---------------------------------------------------------:|:-------------------:|:--------:|
|
|
343
|
+
| visible | Determines if the modal is visible | Boolean | - | true |
|
|
344
|
+
| setIsVisible | Callback to set modal visibility | `(isVisible: boolean) => void` | - | true |
|
|
345
|
+
| onConfirm | Callback when the user confirms the selected time | `({ hours, minutes, seconds }: { hours: number, minutes: number, seconds: number }) => void` | - | true |
|
|
346
|
+
| onCancel | Callback when the user cancels the selection | `() => void` | - | false |
|
|
347
|
+
| closeOnOverlayPress | Determines if the modal should close on overlay press | Boolean | - | false |
|
|
348
|
+
| hideCancelButton | Hide the cancel button within the modal | Boolean | - | false |
|
|
349
|
+
| confirmButtonText | Text for the confirm button | String | - | false |
|
|
350
|
+
| cancelButtonText | Text for the cancel button | String | - | false |
|
|
351
|
+
| modalTitle | Title text for the modal | String | - | false |
|
|
352
|
+
| modalProps | Props for the main modal component | `React.ComponentProps<typeof Modal>` | - | false |
|
|
353
|
+
| containerProps | Props for the main container | `React.ComponentProps<typeof View>` | - | false |
|
|
354
|
+
| contentContainerProps | Props for the content container | `React.ComponentProps<typeof View>` | - | false |
|
|
355
|
+
| buttonContainerProps | Props for the button container | `React.ComponentProps<typeof View>` | - | false |
|
|
356
|
+
| modalTitleProps | Props for the modal title text component | `React.ComponentProps<typeof Text>` | - | false |
|
|
357
|
+
| styles | Custom styles for the timer picker modal | [CustomTimerPickerModalStyles](#custom-styles-1) | - | false |
|
|
358
|
+
|
|
359
|
+
#### Custom Styles 👗
|
|
360
|
+
|
|
361
|
+
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). Various styles are applied by default - you can take a look at these [here](src/components/TimerPickerModal.styles.ts).
|
|
362
|
+
|
|
363
|
+
| Style Prop | Description | Type |
|
|
364
|
+
| :---------------: | :------------------------------------- | :-------: |
|
|
365
|
+
| container | Main container's style | ViewStyle |
|
|
366
|
+
| contentContainer | Style for the content's container | ViewStyle |
|
|
367
|
+
| buttonContainer | Style for the container around the buttons | ViewStyle |
|
|
368
|
+
| button | General style for both buttons | ViewStyle |
|
|
369
|
+
| cancelButton | Style for the cancel button | ViewStyle |
|
|
370
|
+
| confirmButton | Style for the confirm button | ViewStyle |
|
|
371
|
+
| modalTitle | Style for the title of the modal | TextStyle |
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
## Methods 🔄
|
|
375
|
+
|
|
376
|
+
### TimerPickerModal
|
|
377
|
+
|
|
378
|
+
`reset` - imperative method to reset the selected duration to their initial values.
|
|
379
|
+
|
|
380
|
+
```javascript
|
|
381
|
+
timerPickerModalRef.current.reset();
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## License 📝
|
|
385
|
+
|
|
386
|
+
This project is licensed under the MIT License.
|
package/package.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-timer-picker",
|
|
3
|
-
"description": "A simple, flexible, performant duration picker for Expo React Native apps
|
|
3
|
+
"description": "A simple, flexible, performant duration picker for Expo React Native apps 🔥\n\nGreat for timers, alarms and duration inputs ⏰🕰️⏳",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Tim Roberts",
|
|
6
6
|
"url": "https://github.com/troberts-28"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.1.1",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
+
"test": "jest --forceExit --silent",
|
|
13
14
|
"build": "tsc",
|
|
14
15
|
"build:dev": "tsc --noEmit",
|
|
15
16
|
"clean": "rm yarn.lock && rm -rf ./node_modules && yarn install",
|
|
16
|
-
"start": "cp -Rf src example && cd example && yarn install && npx expo start"
|
|
17
|
+
"start": "cp -Rf src example && cd example && yarn add expo && npx expo install && npx expo start",
|
|
18
|
+
"lint": "eslint --ext .ts,.tsx .",
|
|
19
|
+
"lint:fix": "eslint --ext .ts,.tsx . --fix"
|
|
17
20
|
},
|
|
18
21
|
"homepage": "https://github.com/troberts-28/react-native-timer-picker",
|
|
19
22
|
"bugs": {
|
|
@@ -43,16 +46,22 @@
|
|
|
43
46
|
"time",
|
|
44
47
|
"timer",
|
|
45
48
|
"alarm",
|
|
49
|
+
"modal",
|
|
46
50
|
"durationpicker",
|
|
47
51
|
"duration-picker",
|
|
52
|
+
"duration-picker-modal",
|
|
48
53
|
"react-native-duration-picker",
|
|
54
|
+
"react-native-duration-picker-modal",
|
|
49
55
|
"timepicker",
|
|
50
56
|
"time-picker",
|
|
51
57
|
"alarmpicker",
|
|
52
58
|
"alarm-picker",
|
|
53
|
-
"
|
|
59
|
+
"alarm-picker-modal",
|
|
60
|
+
"react-native-alarm-picker",
|
|
54
61
|
"timerpicker",
|
|
55
62
|
"timer-picker",
|
|
63
|
+
"timer-picker-modal",
|
|
64
|
+
"react-native-duration-picker-modal",
|
|
56
65
|
"expo-duration-picker",
|
|
57
66
|
"expo-time-picker",
|
|
58
67
|
"expo-timepicker",
|
|
@@ -65,23 +74,47 @@
|
|
|
65
74
|
"engines": {
|
|
66
75
|
"node": ">=16.0.0"
|
|
67
76
|
},
|
|
77
|
+
"jest": {
|
|
78
|
+
"preset": "react-native",
|
|
79
|
+
"moduleFileExtensions": [
|
|
80
|
+
"ts",
|
|
81
|
+
"tsx",
|
|
82
|
+
"js",
|
|
83
|
+
"jsx",
|
|
84
|
+
"json",
|
|
85
|
+
"node"
|
|
86
|
+
],
|
|
87
|
+
"testEnvironment": "node",
|
|
88
|
+
"modulePathIgnorePatterns": [
|
|
89
|
+
"<rootDir>/dist/",
|
|
90
|
+
"<rootDir>/example/"
|
|
91
|
+
],
|
|
92
|
+
"transformIgnorePatterns": []
|
|
93
|
+
},
|
|
68
94
|
"private": false,
|
|
69
95
|
"typings": "./dist/index.d.ts",
|
|
70
96
|
"peerDependencies": {
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"react": ">=18.1.0",
|
|
74
|
-
"react-native": ">=0.70.8"
|
|
97
|
+
"react": ">=16.8.0",
|
|
98
|
+
"react-native": ">=0.59.0"
|
|
75
99
|
},
|
|
76
100
|
"devDependencies": {
|
|
77
101
|
"@babel/core": ">=7.20.0",
|
|
102
|
+
"@babel/plugin-transform-class-properties": "^7.22.5",
|
|
103
|
+
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
|
|
104
|
+
"@babel/plugin-transform-private-methods": "^7.22.5",
|
|
105
|
+
"@testing-library/react-native": "^12.0.0",
|
|
106
|
+
"@types/jest": "^29.0.0",
|
|
78
107
|
"@types/react": ">=18.0.27",
|
|
79
108
|
"@types/react-native": ">=0.70.6",
|
|
80
109
|
"@typescript-eslint/eslint-plugin": ">=5.49.0",
|
|
81
110
|
"@typescript-eslint/parser": ">=5.49.0",
|
|
111
|
+
"babel-jest": "^29.6.2",
|
|
82
112
|
"eslint": ">=8.44.0",
|
|
83
113
|
"eslint-plugin-react": ">=7.33.1",
|
|
84
114
|
"eslint-plugin-react-hooks": ">=4.6.0",
|
|
115
|
+
"jest": "^29.0.0",
|
|
116
|
+
"metro-react-native-babel-preset": "^0.71.1",
|
|
117
|
+
"react-test-renderer": "^18.0.0",
|
|
85
118
|
"typescript": ">=4.9.4"
|
|
86
119
|
}
|
|
87
120
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface CustomDurationPickerStyles {
|
|
2
|
-
theme?: "light" | "dark";
|
|
3
|
-
backgroundColor?: string;
|
|
4
|
-
textColor?: string;
|
|
5
|
-
pickerContainer?: any;
|
|
6
|
-
pickerLabelContainer?: any;
|
|
7
|
-
pickerLabel?: any;
|
|
8
|
-
pickerItemContainer?: any;
|
|
9
|
-
pickerItem?: any;
|
|
10
|
-
buttonContainer?: any;
|
|
11
|
-
button?: any;
|
|
12
|
-
cancelButton?: any;
|
|
13
|
-
confirmButton?: any;
|
|
14
|
-
modalTitle?: any;
|
|
15
|
-
pickerGradientOverlay?: any;
|
|
16
|
-
}
|
|
17
|
-
export declare const generateStyles: (customStyles: CustomDurationPickerStyles | undefined, options: {
|
|
18
|
-
padWithNItems: number;
|
|
19
|
-
}) => {
|
|
20
|
-
pickerContainer: any;
|
|
21
|
-
pickerLabelContainer: any;
|
|
22
|
-
pickerLabel: any;
|
|
23
|
-
pickerItemContainer: any;
|
|
24
|
-
pickerItem: any;
|
|
25
|
-
pickerGradientOverlay: any;
|
|
26
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.generateStyles = void 0;
|
|
15
|
-
var react_native_1 = require("react-native");
|
|
16
|
-
var DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
17
|
-
var DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
18
|
-
var LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
19
|
-
var LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
20
|
-
var generateStyles = function (customStyles, options) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
|
-
return react_native_1.StyleSheet.create({
|
|
23
|
-
pickerContainer: __assign({ flexDirection: "row", marginRight: "8%", backgroundColor: (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.backgroundColor) !== null && _a !== void 0 ? _a : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
24
|
-
? DARK_MODE_BACKGROUND_COLOR
|
|
25
|
-
: LIGHT_MODE_BACKGROUND_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerContainer),
|
|
26
|
-
pickerLabelContainer: __assign({ position: "absolute", right: 4, top: 0, bottom: 0, justifyContent: "center" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabelContainer),
|
|
27
|
-
pickerLabel: __assign({ fontSize: 18, fontWeight: "bold", marginTop: ((_c = (_b = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 25) / 6, color: (_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _d !== void 0 ? _d : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
28
|
-
? DARK_MODE_TEXT_COLOR
|
|
29
|
-
: LIGHT_MODE_TEXT_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabel),
|
|
30
|
-
pickerItemContainer: __assign({ height: 50, justifyContent: "center", alignItems: "center", width: ((_f = (_e = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem) === null || _e === void 0 ? void 0 : _e.fontSize) !== null && _f !== void 0 ? _f : 25) * 3.6 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer),
|
|
31
|
-
pickerItem: __assign({ textAlignVertical: "center", fontSize: 25, color: (_g = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _g !== void 0 ? _g : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
32
|
-
? DARK_MODE_TEXT_COLOR
|
|
33
|
-
: LIGHT_MODE_TEXT_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem),
|
|
34
|
-
pickerGradientOverlay: __assign({ position: "absolute", left: 0, right: 0, height: options.padWithNItems === 0
|
|
35
|
-
? "30%"
|
|
36
|
-
: ((_j = (_h = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer) === null || _h === void 0 ? void 0 : _h.height) !== null && _j !== void 0 ? _j : 50) * 0.8 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerGradientOverlay),
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
exports.generateStyles = generateStyles;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { LinearGradient } from "expo-linear-gradient";
|
|
3
|
-
import { generateStyles } from "./DurationPicker.styles";
|
|
4
|
-
interface DurationScrollProps {
|
|
5
|
-
numberOfItems: number;
|
|
6
|
-
label?: string;
|
|
7
|
-
initialIndex?: number;
|
|
8
|
-
onDurationChange: (duration: number) => void;
|
|
9
|
-
padNumbersWithZero?: boolean;
|
|
10
|
-
disableInfiniteScroll?: boolean;
|
|
11
|
-
padWithNItems: number;
|
|
12
|
-
pickerGradientOverlayProps?: React.ComponentProps<typeof LinearGradient>;
|
|
13
|
-
styles: ReturnType<typeof generateStyles>;
|
|
14
|
-
}
|
|
15
|
-
declare const DurationScroll: ({ numberOfItems, label, initialIndex, onDurationChange, padNumbersWithZero, disableInfiniteScroll, padWithNItems, pickerGradientOverlayProps, styles, }: DurationScrollProps) => React.ReactElement;
|
|
16
|
-
export default DurationScroll;
|