react-native-paper-dates 0.22.15 → 0.22.17
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/lib/commonjs/Date/AnimatedCrossView.js +41 -42
- package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
- package/lib/commonjs/Date/AutoSizer.js +10 -14
- package/lib/commonjs/Date/AutoSizer.js.map +1 -1
- package/lib/commonjs/Date/Calendar.js +69 -76
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/CalendarEdit.js +67 -72
- package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
- package/lib/commonjs/Date/CalendarHeader.js +38 -36
- package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInput.js +15 -15
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js +49 -43
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModal.js +49 -45
- package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContent.js +73 -68
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +86 -101
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +32 -63
- package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +8 -7
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalStatusBar.js +16 -13
- package/lib/commonjs/Date/DatePickerModalStatusBar.js.map +1 -1
- package/lib/commonjs/Date/Day.js +57 -57
- package/lib/commonjs/Date/Day.js.map +1 -1
- package/lib/commonjs/Date/DayName.js +17 -14
- package/lib/commonjs/Date/DayName.js.map +1 -1
- package/lib/commonjs/Date/DayNames.js +14 -13
- package/lib/commonjs/Date/DayNames.js.map +1 -1
- package/lib/commonjs/Date/DayRange.js +25 -26
- package/lib/commonjs/Date/DayRange.js.map +1 -1
- package/lib/commonjs/Date/Month.js +74 -76
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/Swiper.js +67 -64
- package/lib/commonjs/Date/Swiper.js.map +1 -1
- package/lib/commonjs/Date/Swiper.native.js +67 -63
- package/lib/commonjs/Date/Swiper.native.js.map +1 -1
- package/lib/commonjs/Date/SwiperUtils.js +3 -5
- package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
- package/lib/commonjs/Date/YearPicker.js +58 -58
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/Date/dateUtils.js +12 -10
- package/lib/commonjs/Date/dateUtils.js.map +1 -1
- package/lib/commonjs/Date/inputUtils.js +8 -10
- package/lib/commonjs/Date/inputUtils.js.map +1 -1
- package/lib/commonjs/TextInputMask.js +11 -11
- package/lib/commonjs/TextInputMask.js.map +1 -1
- package/lib/commonjs/Time/AmPmSwitcher.js +51 -49
- package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +69 -64
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockHours.js +46 -53
- package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockMinutes.js +45 -60
- package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/commonjs/Time/AnimatedClockSwitcher.js +34 -30
- package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
- package/lib/commonjs/Time/TimeInput.js +55 -54
- package/lib/commonjs/Time/TimeInput.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +118 -114
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePicker.js +40 -36
- package/lib/commonjs/Time/TimePicker.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +118 -114
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/commonjs/Time/timeUtils.js +5 -8
- package/lib/commonjs/Time/timeUtils.js.map +1 -1
- package/lib/commonjs/contexts/DisplayModeContext.js +2 -4
- package/lib/commonjs/contexts/DisplayModeContext.js.map +1 -1
- package/lib/commonjs/shared/styles.js +25 -0
- package/lib/commonjs/shared/styles.js.map +1 -0
- package/lib/commonjs/{utils.js → shared/utils.js} +4 -4
- package/lib/commonjs/shared/utils.js.map +1 -0
- package/lib/module/Date/AnimatedCrossView.js +43 -42
- package/lib/module/Date/AnimatedCrossView.js.map +1 -1
- package/lib/module/Date/AutoSizer.js +12 -15
- package/lib/module/Date/AutoSizer.js.map +1 -1
- package/lib/module/Date/Calendar.js +71 -76
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/CalendarEdit.js +68 -71
- package/lib/module/Date/CalendarEdit.js.map +1 -1
- package/lib/module/Date/CalendarHeader.js +39 -36
- package/lib/module/Date/CalendarHeader.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +15 -14
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Date/DatePickerInputWithoutModal.js +50 -42
- package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/module/Date/DatePickerModal.js +49 -44
- package/lib/module/Date/DatePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContent.js +74 -67
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +87 -100
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +33 -61
- package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -5
- package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/module/Date/DatePickerModalStatusBar.js +18 -13
- package/lib/module/Date/DatePickerModalStatusBar.js.map +1 -1
- package/lib/module/Date/Day.js +58 -56
- package/lib/module/Date/Day.js.map +1 -1
- package/lib/module/Date/DayName.js +17 -14
- package/lib/module/Date/DayName.js.map +1 -1
- package/lib/module/Date/DayNames.js +13 -12
- package/lib/module/Date/DayNames.js.map +1 -1
- package/lib/module/Date/DayRange.js +27 -26
- package/lib/module/Date/DayRange.js.map +1 -1
- package/lib/module/Date/Month.js +76 -76
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/Swiper.js +69 -64
- package/lib/module/Date/Swiper.js.map +1 -1
- package/lib/module/Date/Swiper.native.js +69 -62
- package/lib/module/Date/Swiper.native.js.map +1 -1
- package/lib/module/Date/SwiperUtils.js +3 -3
- package/lib/module/Date/SwiperUtils.js.map +1 -1
- package/lib/module/Date/YearPicker.js +59 -58
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/Date/dateUtils.js +12 -8
- package/lib/module/Date/dateUtils.js.map +1 -1
- package/lib/module/Date/inputUtils.js +8 -8
- package/lib/module/Date/inputUtils.js.map +1 -1
- package/lib/module/TextInputMask.js +12 -11
- package/lib/module/TextInputMask.js.map +1 -1
- package/lib/module/Time/AmPmSwitcher.js +53 -49
- package/lib/module/Time/AmPmSwitcher.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +71 -64
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/AnalogClockHours.js +48 -53
- package/lib/module/Time/AnalogClockHours.js.map +1 -1
- package/lib/module/Time/AnalogClockMinutes.js +46 -60
- package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/module/Time/AnimatedClockSwitcher.js +35 -30
- package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
- package/lib/module/Time/TimeInput.js +56 -53
- package/lib/module/Time/TimeInput.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +120 -113
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePicker.js +42 -36
- package/lib/module/Time/TimePicker.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +118 -112
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Time/timeUtils.js +5 -6
- package/lib/module/Time/timeUtils.js.map +1 -1
- package/lib/module/contexts/DisplayModeContext.js +2 -2
- package/lib/module/contexts/DisplayModeContext.js.map +1 -1
- package/lib/module/shared/styles.js +19 -0
- package/lib/module/shared/styles.js.map +1 -0
- package/lib/module/{utils.js → shared/utils.js} +3 -2
- package/lib/module/shared/utils.js.map +1 -0
- package/lib/typescript/Date/AnimatedCrossView.d.ts +1 -1
- package/lib/typescript/Date/AnimatedCrossView.d.ts.map +1 -1
- package/lib/typescript/Date/AutoSizer.d.ts +1 -1
- package/lib/typescript/Date/AutoSizer.d.ts.map +1 -1
- package/lib/typescript/Date/Calendar.d.ts +1 -1
- package/lib/typescript/Date/Calendar.d.ts.map +1 -1
- package/lib/typescript/Date/CalendarEdit.d.ts +1 -1
- package/lib/typescript/Date/CalendarEdit.d.ts.map +1 -1
- package/lib/typescript/Date/CalendarHeader.d.ts +1 -1
- package/lib/typescript/Date/CalendarHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
- package/lib/typescript/Date/DatePickerInput.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInput.shared.d.ts +3 -3
- package/lib/typescript/Date/DatePickerInput.shared.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +59 -58
- package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModal.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalHeader.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModalHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalStatusBar.d.ts +1 -1
- package/lib/typescript/Date/DatePickerModalStatusBar.d.ts.map +1 -1
- package/lib/typescript/Date/Day.d.ts +2 -2
- package/lib/typescript/Date/Day.d.ts.map +1 -1
- package/lib/typescript/Date/DayName.d.ts +1 -1
- package/lib/typescript/Date/DayName.d.ts.map +1 -1
- package/lib/typescript/Date/DayNames.d.ts +1 -1
- package/lib/typescript/Date/DayNames.d.ts.map +1 -1
- package/lib/typescript/Date/DayRange.d.ts +1 -1
- package/lib/typescript/Date/DayRange.d.ts.map +1 -1
- package/lib/typescript/Date/Month.d.ts +1 -1
- package/lib/typescript/Date/Month.d.ts.map +1 -1
- package/lib/typescript/Date/Swiper.d.ts +1 -1
- package/lib/typescript/Date/Swiper.d.ts.map +1 -1
- package/lib/typescript/Date/Swiper.native.d.ts +1 -1
- package/lib/typescript/Date/Swiper.native.d.ts.map +1 -1
- package/lib/typescript/Date/SwiperUtils.d.ts +1 -1
- package/lib/typescript/Date/SwiperUtils.d.ts.map +1 -1
- package/lib/typescript/Date/YearPicker.d.ts +1 -1
- package/lib/typescript/Date/YearPicker.d.ts.map +1 -1
- package/lib/typescript/Date/dateUtils.d.ts.map +1 -1
- package/lib/typescript/Date/inputUtils.d.ts.map +1 -1
- package/lib/typescript/TextInputMask.d.ts +24 -24
- package/lib/typescript/TextInputMask.d.ts.map +1 -1
- package/lib/typescript/Time/AmPmSwitcher.d.ts +1 -1
- package/lib/typescript/Time/AmPmSwitcher.d.ts.map +1 -1
- package/lib/typescript/Time/AnalogClock.d.ts +1 -1
- package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
- package/lib/typescript/Time/AnalogClockHours.d.ts +1 -1
- package/lib/typescript/Time/AnalogClockHours.d.ts.map +1 -1
- package/lib/typescript/Time/AnalogClockMinutes.d.ts +1 -1
- package/lib/typescript/Time/AnalogClockMinutes.d.ts.map +1 -1
- package/lib/typescript/Time/AnimatedClockSwitcher.d.ts +5 -3
- package/lib/typescript/Time/AnimatedClockSwitcher.d.ts.map +1 -1
- package/lib/typescript/Time/TimeInput.d.ts +1 -1
- package/lib/typescript/Time/TimeInput.d.ts.map +1 -1
- package/lib/typescript/Time/TimeInputs.d.ts +1 -1
- package/lib/typescript/Time/TimeInputs.d.ts.map +1 -1
- package/lib/typescript/Time/TimePicker.d.ts +1 -1
- package/lib/typescript/Time/TimePicker.d.ts.map +1 -1
- package/lib/typescript/Time/TimePickerModal.d.ts +1 -1
- package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
- package/lib/typescript/Time/timeUtils.d.ts.map +1 -1
- package/lib/typescript/contexts/DisplayModeContext.d.ts +4 -4
- package/lib/typescript/contexts/DisplayModeContext.d.ts.map +1 -1
- package/lib/typescript/shared/styles.d.ts +18 -0
- package/lib/typescript/shared/styles.d.ts.map +1 -0
- package/lib/typescript/{utils.d.ts → shared/utils.d.ts} +2 -2
- package/lib/typescript/shared/utils.d.ts.map +1 -0
- package/package.json +17 -17
- package/src/Date/AnimatedCrossView.tsx +9 -10
- package/src/Date/AutoSizer.tsx +12 -13
- package/src/Date/Calendar.tsx +29 -35
- package/src/Date/CalendarEdit.tsx +18 -15
- package/src/Date/CalendarHeader.tsx +9 -18
- package/src/Date/DatePickerInput.shared.tsx +3 -3
- package/src/Date/DatePickerInput.tsx +11 -8
- package/src/Date/DatePickerInputWithoutModal.tsx +3 -4
- package/src/Date/DatePickerModal.tsx +14 -23
- package/src/Date/DatePickerModalContent.tsx +10 -13
- package/src/Date/DatePickerModalContentHeader.tsx +31 -43
- package/src/Date/DatePickerModalHeader.tsx +4 -23
- package/src/Date/DatePickerModalHeaderBackground.tsx +3 -2
- package/src/Date/DatePickerModalStatusBar.tsx +4 -4
- package/src/Date/Day.tsx +22 -24
- package/src/Date/DayName.tsx +12 -4
- package/src/Date/DayNames.tsx +7 -6
- package/src/Date/DayRange.tsx +6 -11
- package/src/Date/Month.tsx +24 -21
- package/src/Date/Swiper.native.tsx +19 -20
- package/src/Date/Swiper.tsx +32 -29
- package/src/Date/SwiperUtils.ts +3 -4
- package/src/Date/YearPicker.tsx +11 -16
- package/src/Date/dateUtils.tsx +15 -8
- package/src/Date/inputUtils.ts +7 -5
- package/src/TextInputMask.tsx +10 -11
- package/src/Time/AmPmSwitcher.tsx +9 -7
- package/src/Time/AnalogClock.tsx +38 -24
- package/src/Time/AnalogClockHours.tsx +10 -20
- package/src/Time/AnalogClockMinutes.tsx +19 -32
- package/src/Time/AnimatedClockSwitcher.tsx +9 -5
- package/src/Time/TimeInput.tsx +22 -19
- package/src/Time/TimeInputs.tsx +28 -34
- package/src/Time/TimePicker.tsx +15 -10
- package/src/Time/TimePickerModal.tsx +48 -72
- package/src/Time/timeUtils.ts +5 -6
- package/src/contexts/DisplayModeContext.tsx +3 -3
- package/src/shared/styles.tsx +19 -0
- package/src/{utils.ts → shared/utils.ts} +16 -2
- package/lib/commonjs/Date/Week.js +0 -10
- package/lib/commonjs/Date/Week.js.map +0 -1
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/module/Date/Week.js +0 -4
- package/lib/module/Date/Week.js.map +0 -1
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/Date/Week.d.ts +0 -2
- package/lib/typescript/Date/Week.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts.map +0 -1
- package/src/Date/Week.tsx +0 -3
package/src/Time/AnalogClock.tsx
CHANGED
|
@@ -17,12 +17,18 @@ import {
|
|
|
17
17
|
hourTypes,
|
|
18
18
|
PossibleClockTypes,
|
|
19
19
|
} from './timeUtils'
|
|
20
|
-
import
|
|
21
|
-
import { useLatest } from '../utils'
|
|
20
|
+
import { useLatest } from '../shared/utils'
|
|
22
21
|
import AnalogClockHours from './AnalogClockHours'
|
|
23
22
|
import AnimatedClockSwitcher from './AnimatedClockSwitcher'
|
|
24
23
|
import AnalogClockMinutes from './AnalogClockMinutes'
|
|
25
24
|
import { DisplayModeContext } from '../contexts/DisplayModeContext'
|
|
25
|
+
import { memo, useCallback, useContext, useRef } from 'react'
|
|
26
|
+
import React from 'react'
|
|
27
|
+
|
|
28
|
+
function returnTrue() {
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
function AnalogClock({
|
|
27
33
|
hours,
|
|
28
34
|
minutes,
|
|
@@ -40,11 +46,15 @@ function AnalogClock({
|
|
|
40
46
|
focused?: undefined | PossibleClockTypes
|
|
41
47
|
}) => any
|
|
42
48
|
}) {
|
|
49
|
+
const shortPointer = hours >= 12 && is24Hour
|
|
50
|
+
|
|
43
51
|
const theme = useTheme()
|
|
44
|
-
|
|
52
|
+
|
|
53
|
+
const { mode } = useContext(DisplayModeContext)
|
|
54
|
+
|
|
45
55
|
// used to make pointer shorter if hours are selected and above 12
|
|
46
|
-
const
|
|
47
|
-
|
|
56
|
+
const clockRef = useRef<View | null>(null)
|
|
57
|
+
|
|
48
58
|
// Hooks are nice, sometimes... :-)..
|
|
49
59
|
// We need the latest values, since the onPointerMove uses a closure to the function
|
|
50
60
|
const hoursRef = useLatest(hours)
|
|
@@ -53,7 +63,8 @@ function AnalogClock({
|
|
|
53
63
|
const focusedRef = useLatest(focused)
|
|
54
64
|
const is24HourRef = useLatest(is24Hour)
|
|
55
65
|
const modeRef = useLatest(mode)
|
|
56
|
-
|
|
66
|
+
|
|
67
|
+
const onPointerMove = useCallback(
|
|
57
68
|
(e: GestureResponderEvent, final: boolean) => {
|
|
58
69
|
let x = e.nativeEvent.locationX
|
|
59
70
|
let y = e.nativeEvent.locationY
|
|
@@ -105,7 +116,7 @@ function AnalogClock({
|
|
|
105
116
|
},
|
|
106
117
|
[focusedRef, is24HourRef, hoursRef, onChangeRef, minutesRef, modeRef]
|
|
107
118
|
)
|
|
108
|
-
const panResponder =
|
|
119
|
+
const panResponder = useRef(
|
|
109
120
|
PanResponder.create({
|
|
110
121
|
onPanResponderGrant: (e) => onPointerMove(e, false),
|
|
111
122
|
onPanResponderMove: (e) => onPointerMove(e, false),
|
|
@@ -118,6 +129,7 @@ function AnalogClock({
|
|
|
118
129
|
onShouldBlockNativeResponder: returnTrue,
|
|
119
130
|
})
|
|
120
131
|
).current
|
|
132
|
+
|
|
121
133
|
const dynamicSize = focused === clockTypes.hours && shortPointer ? 33 : 0
|
|
122
134
|
const pointerNumber = focused === clockTypes.hours ? hours : minutes
|
|
123
135
|
const degreesPerNumber = focused === clockTypes.hours ? 30 : 6
|
|
@@ -188,36 +200,38 @@ function AnalogClock({
|
|
|
188
200
|
</View>
|
|
189
201
|
)
|
|
190
202
|
}
|
|
203
|
+
|
|
191
204
|
const styles = StyleSheet.create({
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
width: circleSize,
|
|
195
|
-
position: 'relative',
|
|
205
|
+
center: {
|
|
206
|
+
alignItems: 'center',
|
|
196
207
|
justifyContent: 'center',
|
|
208
|
+
},
|
|
209
|
+
clock: {
|
|
197
210
|
alignItems: 'center',
|
|
198
211
|
borderRadius: circleSize / 2,
|
|
212
|
+
height: circleSize,
|
|
213
|
+
justifyContent: 'center',
|
|
214
|
+
position: 'relative',
|
|
215
|
+
width: circleSize,
|
|
199
216
|
},
|
|
200
|
-
middlePoint: {
|
|
201
|
-
borderRadius: 4,
|
|
202
|
-
height: 8,
|
|
203
|
-
width: 8,
|
|
204
|
-
},
|
|
205
|
-
center: { justifyContent: 'center', alignItems: 'center' },
|
|
206
217
|
endPoint: {
|
|
207
218
|
borderRadius: 24,
|
|
219
|
+
bottom: -23,
|
|
208
220
|
height: 48,
|
|
209
|
-
width: 48,
|
|
210
221
|
position: 'absolute',
|
|
211
222
|
right: 0,
|
|
212
|
-
|
|
223
|
+
width: 48,
|
|
213
224
|
},
|
|
214
225
|
line: {
|
|
215
|
-
|
|
226
|
+
borderRadius: 4,
|
|
216
227
|
height: 2,
|
|
228
|
+
position: 'absolute',
|
|
229
|
+
},
|
|
230
|
+
middlePoint: {
|
|
217
231
|
borderRadius: 4,
|
|
232
|
+
height: 8,
|
|
233
|
+
width: 8,
|
|
218
234
|
},
|
|
219
235
|
})
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
export default React.memo(AnalogClock)
|
|
236
|
+
|
|
237
|
+
export default memo(AnalogClock)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import { View, StyleSheet } from 'react-native'
|
|
3
2
|
import { Text } from 'react-native-paper'
|
|
4
3
|
import { circleSize } from './timeUtils'
|
|
5
|
-
import { useTextColorOnPrimary } from '../utils'
|
|
4
|
+
import { useTextColorOnPrimary } from '../shared/utils'
|
|
5
|
+
import React, { memo } from 'react'
|
|
6
6
|
|
|
7
7
|
function AnalogClockHours({
|
|
8
8
|
is24Hour,
|
|
@@ -22,14 +22,14 @@ function AnalogClockHours({
|
|
|
22
22
|
key={i}
|
|
23
23
|
pointerEvents="none"
|
|
24
24
|
style={[
|
|
25
|
-
styles.
|
|
25
|
+
styles.hourRoot,
|
|
26
26
|
{
|
|
27
27
|
top: a[1] || 0,
|
|
28
28
|
left: a[0] || 0,
|
|
29
29
|
},
|
|
30
30
|
]}
|
|
31
31
|
>
|
|
32
|
-
<View style={styles.
|
|
32
|
+
<View style={styles.hourInner}>
|
|
33
33
|
{/* Display 00 instead of 12 for AM hours */}
|
|
34
34
|
<Text
|
|
35
35
|
maxFontSizeMultiplier={1.5}
|
|
@@ -54,14 +54,14 @@ function AnalogClockHours({
|
|
|
54
54
|
key={i}
|
|
55
55
|
pointerEvents="none"
|
|
56
56
|
style={[
|
|
57
|
-
styles.
|
|
57
|
+
styles.hourRoot,
|
|
58
58
|
{
|
|
59
59
|
top: a[1] || 0,
|
|
60
60
|
left: a[0] || 0,
|
|
61
61
|
},
|
|
62
62
|
]}
|
|
63
63
|
>
|
|
64
|
-
<View style={styles.
|
|
64
|
+
<View style={styles.hourInner}>
|
|
65
65
|
<Text
|
|
66
66
|
maxFontSizeMultiplier={1.5}
|
|
67
67
|
selectable={false}
|
|
@@ -83,30 +83,20 @@ function AnalogClockHours({
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const styles = StyleSheet.create({
|
|
86
|
-
|
|
87
|
-
position: 'absolute',
|
|
88
|
-
justifyContent: 'center',
|
|
89
|
-
alignItems: 'center',
|
|
90
|
-
zIndex: 20,
|
|
91
|
-
width: 48,
|
|
92
|
-
height: 48,
|
|
93
|
-
marginLeft: -24,
|
|
94
|
-
marginTop: -24,
|
|
86
|
+
hourInner: {
|
|
95
87
|
borderRadius: 24,
|
|
96
88
|
},
|
|
97
|
-
|
|
98
|
-
innerHourRoot: {
|
|
89
|
+
hourRoot: {
|
|
99
90
|
position: 'absolute',
|
|
100
|
-
zIndex: 20,
|
|
101
91
|
justifyContent: 'center',
|
|
102
92
|
alignItems: 'center',
|
|
93
|
+
zIndex: 20,
|
|
103
94
|
width: 48,
|
|
104
95
|
height: 48,
|
|
105
96
|
marginLeft: -24,
|
|
106
97
|
marginTop: -24,
|
|
107
98
|
borderRadius: 24,
|
|
108
99
|
},
|
|
109
|
-
innerHourInner: { borderRadius: 24 },
|
|
110
100
|
})
|
|
111
101
|
|
|
112
102
|
function getHourNumbers(
|
|
@@ -131,4 +121,4 @@ function getHourNumbers(
|
|
|
131
121
|
})
|
|
132
122
|
}
|
|
133
123
|
|
|
134
|
-
export default
|
|
124
|
+
export default memo(AnalogClockHours)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import { View, StyleSheet } from 'react-native'
|
|
3
2
|
import { Text } from 'react-native-paper'
|
|
4
3
|
import { circleSize } from './timeUtils'
|
|
5
|
-
import { useTextColorOnPrimary } from '../utils'
|
|
4
|
+
import { useTextColorOnPrimary } from '../shared/utils'
|
|
5
|
+
import React, { memo } from 'react'
|
|
6
6
|
|
|
7
7
|
function AnalogClockMinutes({ minutes }: { minutes: number }) {
|
|
8
8
|
const range = getMinuteNumbers(circleSize, 12)
|
|
9
9
|
const color = useTextColorOnPrimary()
|
|
10
|
+
|
|
10
11
|
return (
|
|
11
12
|
<>
|
|
12
13
|
{range.map((a, i) => {
|
|
@@ -46,35 +47,6 @@ function AnalogClockMinutes({ minutes }: { minutes: number }) {
|
|
|
46
47
|
)
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
const styles = StyleSheet.create({
|
|
50
|
-
outerHourRoot: {
|
|
51
|
-
position: 'absolute',
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
alignItems: 'center',
|
|
54
|
-
zIndex: 20,
|
|
55
|
-
width: 48,
|
|
56
|
-
height: 48,
|
|
57
|
-
marginLeft: -24,
|
|
58
|
-
marginTop: -24,
|
|
59
|
-
borderRadius: 24,
|
|
60
|
-
},
|
|
61
|
-
outerHourInner: { borderRadius: 24 },
|
|
62
|
-
innerHourRoot: {
|
|
63
|
-
position: 'absolute',
|
|
64
|
-
zIndex: 20,
|
|
65
|
-
justifyContent: 'center',
|
|
66
|
-
alignItems: 'center',
|
|
67
|
-
width: 40,
|
|
68
|
-
height: 40,
|
|
69
|
-
marginLeft: -20,
|
|
70
|
-
marginTop: -20,
|
|
71
|
-
borderRadius: 20,
|
|
72
|
-
},
|
|
73
|
-
innerHourInner: { borderRadius: 20 },
|
|
74
|
-
innerHourText: { fontSize: 13 },
|
|
75
|
-
textWhite: { color: '#fff' },
|
|
76
|
-
})
|
|
77
|
-
|
|
78
50
|
function getMinuteNumbers(size: number, count: number) {
|
|
79
51
|
let angle = 0
|
|
80
52
|
let step = (2 * Math.PI) / count
|
|
@@ -92,4 +64,19 @@ function getMinuteNumbers(size: number, count: number) {
|
|
|
92
64
|
})
|
|
93
65
|
}
|
|
94
66
|
|
|
95
|
-
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
outerHourRoot: {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
zIndex: 20,
|
|
73
|
+
width: 48,
|
|
74
|
+
height: 48,
|
|
75
|
+
marginLeft: -24,
|
|
76
|
+
marginTop: -24,
|
|
77
|
+
borderRadius: 24,
|
|
78
|
+
},
|
|
79
|
+
outerHourInner: { borderRadius: 24 },
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export default memo(AnalogClockMinutes)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import { Animated, StyleSheet, View } from 'react-native'
|
|
3
2
|
import { clockTypes, PossibleClockTypes } from './timeUtils'
|
|
3
|
+
import React, { ReactElement, useEffect, useRef } from 'react'
|
|
4
|
+
import AnalogClockHours from './AnalogClockHours'
|
|
5
|
+
import AnalogClockMinutes from './AnalogClockMinutes'
|
|
4
6
|
|
|
5
7
|
export default function AnimatedClockSwitcher({
|
|
6
8
|
focused,
|
|
@@ -8,14 +10,16 @@ export default function AnimatedClockSwitcher({
|
|
|
8
10
|
minutes,
|
|
9
11
|
}: {
|
|
10
12
|
focused: PossibleClockTypes
|
|
11
|
-
hours:
|
|
12
|
-
minutes:
|
|
13
|
+
hours: ReactElement<typeof AnalogClockHours>
|
|
14
|
+
minutes: ReactElement<typeof AnalogClockMinutes>
|
|
13
15
|
}) {
|
|
14
16
|
const collapsed = focused === clockTypes.hours
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
const animatedCollapsed = useRef<Animated.Value>(
|
|
16
19
|
new Animated.Value(collapsed ? 1 : 0)
|
|
17
20
|
)
|
|
18
|
-
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
19
23
|
Animated.timing(animatedCollapsed.current, {
|
|
20
24
|
toValue: collapsed ? 1 : 0,
|
|
21
25
|
duration: 250,
|
package/src/Time/TimeInput.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import {
|
|
3
2
|
View,
|
|
4
3
|
TextInput,
|
|
@@ -15,6 +14,9 @@ import {
|
|
|
15
14
|
PossibleInputTypes,
|
|
16
15
|
useInputColors,
|
|
17
16
|
} from './timeUtils'
|
|
17
|
+
import { forwardRef, useEffect, useState } from 'react'
|
|
18
|
+
import React from 'react'
|
|
19
|
+
import { sharedStyles } from '../shared/styles'
|
|
18
20
|
|
|
19
21
|
interface TimeInputProps
|
|
20
22
|
extends Omit<Omit<TextInputProps, 'value'>, 'onFocus'> {
|
|
@@ -40,9 +42,18 @@ function TimeInput(
|
|
|
40
42
|
}: TimeInputProps,
|
|
41
43
|
ref: any
|
|
42
44
|
) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const theme = useTheme()
|
|
46
|
+
const [inputFocused, setInputFocused] = useState<boolean>(false)
|
|
47
|
+
|
|
48
|
+
const [controlledValue, setControlledValue] = useState(`${value}`)
|
|
49
|
+
|
|
50
|
+
const highlighted = inputType === inputTypes.picker ? pressed : inputFocused
|
|
51
|
+
|
|
52
|
+
const { color, backgroundColor } = useInputColors(highlighted)
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setControlledValue(`${value}`)
|
|
56
|
+
}, [value])
|
|
46
57
|
|
|
47
58
|
const onInnerChange = (text: string) => {
|
|
48
59
|
setControlledValue(text)
|
|
@@ -51,17 +62,6 @@ function TimeInput(
|
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
setControlledValue(`${value}`)
|
|
56
|
-
}, [value])
|
|
57
|
-
|
|
58
|
-
const theme = useTheme()
|
|
59
|
-
const [inputFocused, setInputFocused] = React.useState<boolean>(false)
|
|
60
|
-
|
|
61
|
-
const highlighted = inputType === inputTypes.picker ? pressed : inputFocused
|
|
62
|
-
|
|
63
|
-
const { color, backgroundColor } = useInputColors(highlighted)
|
|
64
|
-
|
|
65
65
|
let formattedValue = controlledValue
|
|
66
66
|
if (!inputFocused) {
|
|
67
67
|
formattedValue =
|
|
@@ -107,7 +107,7 @@ function TimeInput(
|
|
|
107
107
|
<TouchableRipple
|
|
108
108
|
style={[
|
|
109
109
|
StyleSheet.absoluteFill,
|
|
110
|
-
|
|
110
|
+
sharedStyles.overflowHidden,
|
|
111
111
|
{
|
|
112
112
|
borderRadius: theme.roundness,
|
|
113
113
|
},
|
|
@@ -128,13 +128,16 @@ function TimeInput(
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
const styles = StyleSheet.create({
|
|
131
|
-
root: { position: 'relative', height: 80, width: 96 },
|
|
132
131
|
input: {
|
|
133
132
|
textAlign: 'center',
|
|
134
133
|
textAlignVertical: 'center',
|
|
135
134
|
width: 96,
|
|
136
135
|
},
|
|
137
|
-
|
|
136
|
+
root: {
|
|
137
|
+
height: 80,
|
|
138
|
+
position: 'relative',
|
|
139
|
+
width: 96,
|
|
140
|
+
},
|
|
138
141
|
})
|
|
139
142
|
|
|
140
|
-
export default
|
|
143
|
+
export default forwardRef(TimeInput)
|
package/src/Time/TimeInputs.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import {
|
|
3
2
|
View,
|
|
4
3
|
StyleSheet,
|
|
@@ -16,9 +15,12 @@ import {
|
|
|
16
15
|
} from './timeUtils'
|
|
17
16
|
import TimeInput from './TimeInput'
|
|
18
17
|
import AmPmSwitcher from './AmPmSwitcher'
|
|
19
|
-
import { useLatest } from '../utils'
|
|
18
|
+
import { useLatest } from '../shared/utils'
|
|
20
19
|
import Color from 'color'
|
|
21
20
|
import { getTranslation } from '../translations/utils'
|
|
21
|
+
import { memo, useCallback, useRef } from 'react'
|
|
22
|
+
import React from 'react'
|
|
23
|
+
import { sharedStyles } from '../shared/styles'
|
|
22
24
|
|
|
23
25
|
function TimeInputs({
|
|
24
26
|
hours,
|
|
@@ -45,24 +47,25 @@ function TimeInputs({
|
|
|
45
47
|
inputFontSize?: number
|
|
46
48
|
locale?: string
|
|
47
49
|
}) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
+
const theme = useTheme()
|
|
51
|
+
|
|
52
|
+
const startInput = useRef<TextInputNative | null>(null)
|
|
53
|
+
const endInput = useRef<TextInputNative | null>(null)
|
|
50
54
|
const dimensions = useWindowDimensions()
|
|
51
55
|
const isLandscape = dimensions.width > dimensions.height
|
|
52
|
-
const
|
|
56
|
+
const minutesRef = useLatest(minutes)
|
|
53
57
|
|
|
54
|
-
const onSubmitStartInput =
|
|
58
|
+
const onSubmitStartInput = useCallback(() => {
|
|
55
59
|
if (endInput.current) {
|
|
56
60
|
endInput.current.focus()
|
|
57
61
|
}
|
|
58
62
|
}, [endInput])
|
|
59
63
|
|
|
60
|
-
const onSubmitEndInput =
|
|
64
|
+
const onSubmitEndInput = useCallback(() => {
|
|
61
65
|
// TODO: close modal and persist time
|
|
62
66
|
}, [])
|
|
63
67
|
|
|
64
|
-
const
|
|
65
|
-
const onChangeHours = React.useCallback(
|
|
68
|
+
const onChangeHours = useCallback(
|
|
66
69
|
(newHours: number) => {
|
|
67
70
|
onChange({
|
|
68
71
|
hours: newHours,
|
|
@@ -74,12 +77,7 @@ function TimeInputs({
|
|
|
74
77
|
)
|
|
75
78
|
|
|
76
79
|
return (
|
|
77
|
-
<View
|
|
78
|
-
style={[
|
|
79
|
-
styles.inputContainer,
|
|
80
|
-
isLandscape && styles.inputContainerLandscape,
|
|
81
|
-
]}
|
|
82
|
-
>
|
|
80
|
+
<View style={[styles.inputContainer, isLandscape && sharedStyles.root]}>
|
|
83
81
|
<View style={styles.column}>
|
|
84
82
|
<TimeInput
|
|
85
83
|
ref={startInput}
|
|
@@ -127,7 +125,7 @@ function TimeInputs({
|
|
|
127
125
|
{ marginBottom: inputType === 'keyboard' ? 24 : 0 },
|
|
128
126
|
]}
|
|
129
127
|
>
|
|
130
|
-
<View style={
|
|
128
|
+
<View style={sharedStyles.root} />
|
|
131
129
|
<View
|
|
132
130
|
style={[
|
|
133
131
|
styles.dot,
|
|
@@ -149,7 +147,7 @@ function TimeInputs({
|
|
|
149
147
|
},
|
|
150
148
|
]}
|
|
151
149
|
/>
|
|
152
|
-
<View style={
|
|
150
|
+
<View style={sharedStyles.root} />
|
|
153
151
|
</View>
|
|
154
152
|
<View style={styles.column}>
|
|
155
153
|
<TimeInput
|
|
@@ -200,33 +198,29 @@ function TimeInputs({
|
|
|
200
198
|
}
|
|
201
199
|
|
|
202
200
|
const styles = StyleSheet.create({
|
|
201
|
+
betweenDot: {
|
|
202
|
+
height: 12,
|
|
203
|
+
},
|
|
203
204
|
column: {
|
|
204
205
|
flexDirection: 'column',
|
|
205
206
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
inputContainerLandscape: {
|
|
212
|
-
flex: 1,
|
|
207
|
+
dot: {
|
|
208
|
+
width: 7,
|
|
209
|
+
height: 7,
|
|
210
|
+
borderRadius: 7 / 2,
|
|
213
211
|
},
|
|
214
212
|
hoursAndMinutesSeparator: {
|
|
215
213
|
fontSize: 65,
|
|
216
214
|
width: 24,
|
|
217
215
|
alignItems: 'center',
|
|
218
216
|
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
dot: {
|
|
223
|
-
width: 7,
|
|
224
|
-
height: 7,
|
|
225
|
-
borderRadius: 7 / 2,
|
|
217
|
+
inputContainer: {
|
|
218
|
+
flexDirection: 'row',
|
|
219
|
+
alignItems: 'center',
|
|
226
220
|
},
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
spaceBetweenInputsAndSwitcher: {
|
|
222
|
+
width: 12,
|
|
229
223
|
},
|
|
230
224
|
})
|
|
231
225
|
|
|
232
|
-
export default
|
|
226
|
+
export default memo(TimeInputs)
|
package/src/Time/TimePicker.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
1
|
import { View, StyleSheet, useWindowDimensions } from 'react-native'
|
|
3
|
-
|
|
2
|
+
import React, { memo } from 'react'
|
|
4
3
|
import {
|
|
5
4
|
inputTypes,
|
|
6
5
|
PossibleClockTypes,
|
|
@@ -13,6 +12,7 @@ import AnalogClock from './AnalogClock'
|
|
|
13
12
|
import { circleSize } from './timeUtils'
|
|
14
13
|
import TimeInputs from './TimeInputs'
|
|
15
14
|
import { DisplayModeContext } from '../contexts/DisplayModeContext'
|
|
15
|
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
16
16
|
|
|
17
17
|
type onChangeFunc = ({
|
|
18
18
|
hours,
|
|
@@ -45,14 +45,15 @@ function TimePicker({
|
|
|
45
45
|
use24HourClock?: boolean
|
|
46
46
|
inputFontSize?: number
|
|
47
47
|
}) {
|
|
48
|
-
const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
|
|
49
|
-
undefined
|
|
50
|
-
)
|
|
51
48
|
const dimensions = useWindowDimensions()
|
|
52
49
|
const isLandscape = dimensions.width > dimensions.height
|
|
53
50
|
|
|
51
|
+
const [displayMode, setDisplayMode] = useState<'AM' | 'PM' | undefined>(
|
|
52
|
+
undefined
|
|
53
|
+
)
|
|
54
|
+
|
|
54
55
|
// method to check whether we have 24 hours in clock or 12
|
|
55
|
-
const is24Hour =
|
|
56
|
+
const is24Hour = useMemo(() => {
|
|
56
57
|
if (use24HourClock !== undefined) {
|
|
57
58
|
return use24HourClock
|
|
58
59
|
}
|
|
@@ -66,7 +67,7 @@ function TimePicker({
|
|
|
66
67
|
}, [locale, use24HourClock])
|
|
67
68
|
|
|
68
69
|
// Initialize display Mode according the hours value
|
|
69
|
-
|
|
70
|
+
useEffect(() => {
|
|
70
71
|
if (hours >= 12) {
|
|
71
72
|
setDisplayMode('PM')
|
|
72
73
|
} else {
|
|
@@ -75,7 +76,7 @@ function TimePicker({
|
|
|
75
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
77
|
}, [])
|
|
77
78
|
|
|
78
|
-
const onInnerChange =
|
|
79
|
+
const onInnerChange = useCallback<onChangeFunc>(
|
|
79
80
|
(params) => {
|
|
80
81
|
params.hours = toHourOutputFormat(params.hours, hours, is24Hour)
|
|
81
82
|
onChange(params)
|
|
@@ -133,6 +134,11 @@ function TimePicker({
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
const styles = StyleSheet.create({
|
|
137
|
+
clockContainer: {
|
|
138
|
+
paddingTop: 36,
|
|
139
|
+
paddingLeft: 12,
|
|
140
|
+
paddingRight: 12,
|
|
141
|
+
},
|
|
136
142
|
rootLandscape: {
|
|
137
143
|
flexDirection: 'row',
|
|
138
144
|
alignItems: 'center',
|
|
@@ -142,7 +148,6 @@ const styles = StyleSheet.create({
|
|
|
142
148
|
alignItems: 'center',
|
|
143
149
|
justifyContent: 'center',
|
|
144
150
|
},
|
|
145
|
-
clockContainer: { paddingTop: 36, paddingLeft: 12, paddingRight: 12 },
|
|
146
151
|
})
|
|
147
152
|
|
|
148
|
-
export default
|
|
153
|
+
export default memo(TimePicker)
|