react-native-paper-dates 0.22.14 → 0.22.16

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 (277) hide show
  1. package/lib/commonjs/Date/AnimatedCrossView.js +41 -42
  2. package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
  3. package/lib/commonjs/Date/AutoSizer.js +10 -14
  4. package/lib/commonjs/Date/AutoSizer.js.map +1 -1
  5. package/lib/commonjs/Date/Calendar.js +69 -76
  6. package/lib/commonjs/Date/Calendar.js.map +1 -1
  7. package/lib/commonjs/Date/CalendarEdit.js +67 -72
  8. package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
  9. package/lib/commonjs/Date/CalendarHeader.js +38 -36
  10. package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
  11. package/lib/commonjs/Date/DatePickerInput.js +15 -15
  12. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  13. package/lib/commonjs/Date/DatePickerInputWithoutModal.js +49 -43
  14. package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
  15. package/lib/commonjs/Date/DatePickerModal.js +49 -45
  16. package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
  17. package/lib/commonjs/Date/DatePickerModalContent.js +73 -68
  18. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  19. package/lib/commonjs/Date/DatePickerModalContentHeader.js +86 -101
  20. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  21. package/lib/commonjs/Date/DatePickerModalHeader.js +32 -63
  22. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  23. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +8 -7
  24. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  25. package/lib/commonjs/Date/DatePickerModalStatusBar.js +16 -13
  26. package/lib/commonjs/Date/DatePickerModalStatusBar.js.map +1 -1
  27. package/lib/commonjs/Date/Day.js +57 -57
  28. package/lib/commonjs/Date/Day.js.map +1 -1
  29. package/lib/commonjs/Date/DayName.js +17 -14
  30. package/lib/commonjs/Date/DayName.js.map +1 -1
  31. package/lib/commonjs/Date/DayNames.js +14 -13
  32. package/lib/commonjs/Date/DayNames.js.map +1 -1
  33. package/lib/commonjs/Date/DayRange.js +25 -26
  34. package/lib/commonjs/Date/DayRange.js.map +1 -1
  35. package/lib/commonjs/Date/Month.js +74 -76
  36. package/lib/commonjs/Date/Month.js.map +1 -1
  37. package/lib/commonjs/Date/Swiper.js +67 -64
  38. package/lib/commonjs/Date/Swiper.js.map +1 -1
  39. package/lib/commonjs/Date/Swiper.native.js +67 -63
  40. package/lib/commonjs/Date/Swiper.native.js.map +1 -1
  41. package/lib/commonjs/Date/SwiperUtils.js +3 -5
  42. package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
  43. package/lib/commonjs/Date/YearPicker.js +58 -58
  44. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  45. package/lib/commonjs/Date/dateUtils.js +13 -11
  46. package/lib/commonjs/Date/dateUtils.js.map +1 -1
  47. package/lib/commonjs/Date/inputUtils.js +8 -10
  48. package/lib/commonjs/Date/inputUtils.js.map +1 -1
  49. package/lib/commonjs/TextInputMask.js +11 -11
  50. package/lib/commonjs/TextInputMask.js.map +1 -1
  51. package/lib/commonjs/Time/AmPmSwitcher.js +51 -49
  52. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  53. package/lib/commonjs/Time/AnalogClock.js +69 -64
  54. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  55. package/lib/commonjs/Time/AnalogClockHours.js +46 -53
  56. package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
  57. package/lib/commonjs/Time/AnalogClockMinutes.js +45 -60
  58. package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
  59. package/lib/commonjs/Time/AnimatedClockSwitcher.js +34 -30
  60. package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
  61. package/lib/commonjs/Time/TimeInput.js +55 -54
  62. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  63. package/lib/commonjs/Time/TimeInputs.js +118 -114
  64. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  65. package/lib/commonjs/Time/TimePicker.js +40 -36
  66. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  67. package/lib/commonjs/Time/TimePickerModal.js +118 -114
  68. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  69. package/lib/commonjs/Time/timeUtils.js +5 -8
  70. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  71. package/lib/commonjs/contexts/DisplayModeContext.js +2 -4
  72. package/lib/commonjs/contexts/DisplayModeContext.js.map +1 -1
  73. package/lib/commonjs/shared/styles.js +25 -0
  74. package/lib/commonjs/shared/styles.js.map +1 -0
  75. package/lib/commonjs/{utils.js → shared/utils.js} +4 -4
  76. package/lib/commonjs/shared/utils.js.map +1 -0
  77. package/lib/module/Date/AnimatedCrossView.js +43 -42
  78. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  79. package/lib/module/Date/AutoSizer.js +12 -15
  80. package/lib/module/Date/AutoSizer.js.map +1 -1
  81. package/lib/module/Date/Calendar.js +71 -76
  82. package/lib/module/Date/Calendar.js.map +1 -1
  83. package/lib/module/Date/CalendarEdit.js +68 -71
  84. package/lib/module/Date/CalendarEdit.js.map +1 -1
  85. package/lib/module/Date/CalendarHeader.js +39 -36
  86. package/lib/module/Date/CalendarHeader.js.map +1 -1
  87. package/lib/module/Date/DatePickerInput.js +15 -14
  88. package/lib/module/Date/DatePickerInput.js.map +1 -1
  89. package/lib/module/Date/DatePickerInputWithoutModal.js +50 -42
  90. package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
  91. package/lib/module/Date/DatePickerModal.js +49 -44
  92. package/lib/module/Date/DatePickerModal.js.map +1 -1
  93. package/lib/module/Date/DatePickerModalContent.js +74 -67
  94. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  95. package/lib/module/Date/DatePickerModalContentHeader.js +87 -100
  96. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  97. package/lib/module/Date/DatePickerModalHeader.js +33 -61
  98. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  99. package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -5
  100. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  101. package/lib/module/Date/DatePickerModalStatusBar.js +18 -13
  102. package/lib/module/Date/DatePickerModalStatusBar.js.map +1 -1
  103. package/lib/module/Date/Day.js +58 -56
  104. package/lib/module/Date/Day.js.map +1 -1
  105. package/lib/module/Date/DayName.js +17 -14
  106. package/lib/module/Date/DayName.js.map +1 -1
  107. package/lib/module/Date/DayNames.js +13 -12
  108. package/lib/module/Date/DayNames.js.map +1 -1
  109. package/lib/module/Date/DayRange.js +27 -26
  110. package/lib/module/Date/DayRange.js.map +1 -1
  111. package/lib/module/Date/Month.js +76 -76
  112. package/lib/module/Date/Month.js.map +1 -1
  113. package/lib/module/Date/Swiper.js +69 -64
  114. package/lib/module/Date/Swiper.js.map +1 -1
  115. package/lib/module/Date/Swiper.native.js +69 -62
  116. package/lib/module/Date/Swiper.native.js.map +1 -1
  117. package/lib/module/Date/SwiperUtils.js +3 -3
  118. package/lib/module/Date/SwiperUtils.js.map +1 -1
  119. package/lib/module/Date/YearPicker.js +59 -58
  120. package/lib/module/Date/YearPicker.js.map +1 -1
  121. package/lib/module/Date/dateUtils.js +13 -9
  122. package/lib/module/Date/dateUtils.js.map +1 -1
  123. package/lib/module/Date/inputUtils.js +8 -8
  124. package/lib/module/Date/inputUtils.js.map +1 -1
  125. package/lib/module/TextInputMask.js +12 -11
  126. package/lib/module/TextInputMask.js.map +1 -1
  127. package/lib/module/Time/AmPmSwitcher.js +53 -49
  128. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  129. package/lib/module/Time/AnalogClock.js +71 -64
  130. package/lib/module/Time/AnalogClock.js.map +1 -1
  131. package/lib/module/Time/AnalogClockHours.js +48 -53
  132. package/lib/module/Time/AnalogClockHours.js.map +1 -1
  133. package/lib/module/Time/AnalogClockMinutes.js +46 -60
  134. package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
  135. package/lib/module/Time/AnimatedClockSwitcher.js +35 -30
  136. package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
  137. package/lib/module/Time/TimeInput.js +56 -53
  138. package/lib/module/Time/TimeInput.js.map +1 -1
  139. package/lib/module/Time/TimeInputs.js +120 -113
  140. package/lib/module/Time/TimeInputs.js.map +1 -1
  141. package/lib/module/Time/TimePicker.js +42 -36
  142. package/lib/module/Time/TimePicker.js.map +1 -1
  143. package/lib/module/Time/TimePickerModal.js +118 -112
  144. package/lib/module/Time/TimePickerModal.js.map +1 -1
  145. package/lib/module/Time/timeUtils.js +5 -6
  146. package/lib/module/Time/timeUtils.js.map +1 -1
  147. package/lib/module/contexts/DisplayModeContext.js +2 -2
  148. package/lib/module/contexts/DisplayModeContext.js.map +1 -1
  149. package/lib/module/shared/styles.js +19 -0
  150. package/lib/module/shared/styles.js.map +1 -0
  151. package/lib/module/{utils.js → shared/utils.js} +3 -2
  152. package/lib/module/shared/utils.js.map +1 -0
  153. package/lib/typescript/Date/AnimatedCrossView.d.ts +1 -1
  154. package/lib/typescript/Date/AnimatedCrossView.d.ts.map +1 -1
  155. package/lib/typescript/Date/AutoSizer.d.ts +1 -1
  156. package/lib/typescript/Date/AutoSizer.d.ts.map +1 -1
  157. package/lib/typescript/Date/Calendar.d.ts +1 -1
  158. package/lib/typescript/Date/Calendar.d.ts.map +1 -1
  159. package/lib/typescript/Date/CalendarEdit.d.ts +1 -1
  160. package/lib/typescript/Date/CalendarEdit.d.ts.map +1 -1
  161. package/lib/typescript/Date/CalendarHeader.d.ts +1 -1
  162. package/lib/typescript/Date/CalendarHeader.d.ts.map +1 -1
  163. package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
  164. package/lib/typescript/Date/DatePickerInput.d.ts.map +1 -1
  165. package/lib/typescript/Date/DatePickerInput.shared.d.ts +3 -3
  166. package/lib/typescript/Date/DatePickerInput.shared.d.ts.map +1 -1
  167. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +59 -58
  168. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts.map +1 -1
  169. package/lib/typescript/Date/DatePickerModal.d.ts +1 -1
  170. package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
  171. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
  172. package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
  173. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts +1 -1
  174. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
  175. package/lib/typescript/Date/DatePickerModalHeader.d.ts +1 -1
  176. package/lib/typescript/Date/DatePickerModalHeader.d.ts.map +1 -1
  177. package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts +1 -1
  178. package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts.map +1 -1
  179. package/lib/typescript/Date/DatePickerModalStatusBar.d.ts +1 -1
  180. package/lib/typescript/Date/DatePickerModalStatusBar.d.ts.map +1 -1
  181. package/lib/typescript/Date/Day.d.ts +2 -2
  182. package/lib/typescript/Date/Day.d.ts.map +1 -1
  183. package/lib/typescript/Date/DayName.d.ts +1 -1
  184. package/lib/typescript/Date/DayName.d.ts.map +1 -1
  185. package/lib/typescript/Date/DayNames.d.ts +1 -1
  186. package/lib/typescript/Date/DayNames.d.ts.map +1 -1
  187. package/lib/typescript/Date/DayRange.d.ts +1 -1
  188. package/lib/typescript/Date/DayRange.d.ts.map +1 -1
  189. package/lib/typescript/Date/Month.d.ts +1 -1
  190. package/lib/typescript/Date/Month.d.ts.map +1 -1
  191. package/lib/typescript/Date/Swiper.d.ts +1 -1
  192. package/lib/typescript/Date/Swiper.d.ts.map +1 -1
  193. package/lib/typescript/Date/Swiper.native.d.ts +1 -1
  194. package/lib/typescript/Date/Swiper.native.d.ts.map +1 -1
  195. package/lib/typescript/Date/SwiperUtils.d.ts +1 -1
  196. package/lib/typescript/Date/SwiperUtils.d.ts.map +1 -1
  197. package/lib/typescript/Date/YearPicker.d.ts +1 -1
  198. package/lib/typescript/Date/YearPicker.d.ts.map +1 -1
  199. package/lib/typescript/Date/dateUtils.d.ts.map +1 -1
  200. package/lib/typescript/Date/inputUtils.d.ts.map +1 -1
  201. package/lib/typescript/TextInputMask.d.ts +24 -24
  202. package/lib/typescript/TextInputMask.d.ts.map +1 -1
  203. package/lib/typescript/Time/AmPmSwitcher.d.ts +1 -1
  204. package/lib/typescript/Time/AmPmSwitcher.d.ts.map +1 -1
  205. package/lib/typescript/Time/AnalogClock.d.ts +1 -1
  206. package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
  207. package/lib/typescript/Time/AnalogClockHours.d.ts +1 -1
  208. package/lib/typescript/Time/AnalogClockHours.d.ts.map +1 -1
  209. package/lib/typescript/Time/AnalogClockMinutes.d.ts +1 -1
  210. package/lib/typescript/Time/AnalogClockMinutes.d.ts.map +1 -1
  211. package/lib/typescript/Time/AnimatedClockSwitcher.d.ts +5 -3
  212. package/lib/typescript/Time/AnimatedClockSwitcher.d.ts.map +1 -1
  213. package/lib/typescript/Time/TimeInput.d.ts +1 -1
  214. package/lib/typescript/Time/TimeInput.d.ts.map +1 -1
  215. package/lib/typescript/Time/TimeInputs.d.ts +1 -1
  216. package/lib/typescript/Time/TimeInputs.d.ts.map +1 -1
  217. package/lib/typescript/Time/TimePicker.d.ts +1 -1
  218. package/lib/typescript/Time/TimePicker.d.ts.map +1 -1
  219. package/lib/typescript/Time/TimePickerModal.d.ts +1 -1
  220. package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
  221. package/lib/typescript/Time/timeUtils.d.ts.map +1 -1
  222. package/lib/typescript/contexts/DisplayModeContext.d.ts +4 -4
  223. package/lib/typescript/contexts/DisplayModeContext.d.ts.map +1 -1
  224. package/lib/typescript/shared/styles.d.ts +18 -0
  225. package/lib/typescript/shared/styles.d.ts.map +1 -0
  226. package/lib/typescript/{utils.d.ts → shared/utils.d.ts} +2 -2
  227. package/lib/typescript/shared/utils.d.ts.map +1 -0
  228. package/package.json +17 -17
  229. package/src/Date/AnimatedCrossView.tsx +9 -10
  230. package/src/Date/AutoSizer.tsx +12 -13
  231. package/src/Date/Calendar.tsx +29 -35
  232. package/src/Date/CalendarEdit.tsx +18 -15
  233. package/src/Date/CalendarHeader.tsx +9 -18
  234. package/src/Date/DatePickerInput.shared.tsx +3 -3
  235. package/src/Date/DatePickerInput.tsx +11 -8
  236. package/src/Date/DatePickerInputWithoutModal.tsx +3 -4
  237. package/src/Date/DatePickerModal.tsx +14 -23
  238. package/src/Date/DatePickerModalContent.tsx +10 -13
  239. package/src/Date/DatePickerModalContentHeader.tsx +31 -43
  240. package/src/Date/DatePickerModalHeader.tsx +4 -23
  241. package/src/Date/DatePickerModalHeaderBackground.tsx +3 -2
  242. package/src/Date/DatePickerModalStatusBar.tsx +4 -4
  243. package/src/Date/Day.tsx +22 -24
  244. package/src/Date/DayName.tsx +12 -4
  245. package/src/Date/DayNames.tsx +7 -6
  246. package/src/Date/DayRange.tsx +6 -11
  247. package/src/Date/Month.tsx +24 -21
  248. package/src/Date/Swiper.native.tsx +19 -20
  249. package/src/Date/Swiper.tsx +32 -29
  250. package/src/Date/SwiperUtils.ts +3 -4
  251. package/src/Date/YearPicker.tsx +11 -16
  252. package/src/Date/dateUtils.tsx +18 -11
  253. package/src/Date/inputUtils.ts +7 -5
  254. package/src/TextInputMask.tsx +10 -11
  255. package/src/Time/AmPmSwitcher.tsx +9 -7
  256. package/src/Time/AnalogClock.tsx +38 -24
  257. package/src/Time/AnalogClockHours.tsx +10 -20
  258. package/src/Time/AnalogClockMinutes.tsx +19 -32
  259. package/src/Time/AnimatedClockSwitcher.tsx +9 -5
  260. package/src/Time/TimeInput.tsx +22 -19
  261. package/src/Time/TimeInputs.tsx +28 -34
  262. package/src/Time/TimePicker.tsx +15 -10
  263. package/src/Time/TimePickerModal.tsx +48 -72
  264. package/src/Time/timeUtils.ts +5 -6
  265. package/src/contexts/DisplayModeContext.tsx +3 -3
  266. package/src/shared/styles.tsx +19 -0
  267. package/src/{utils.ts → shared/utils.ts} +16 -2
  268. package/lib/commonjs/Date/Week.js +0 -10
  269. package/lib/commonjs/Date/Week.js.map +0 -1
  270. package/lib/commonjs/utils.js.map +0 -1
  271. package/lib/module/Date/Week.js +0 -4
  272. package/lib/module/Date/Week.js.map +0 -1
  273. package/lib/module/utils.js.map +0 -1
  274. package/lib/typescript/Date/Week.d.ts +0 -2
  275. package/lib/typescript/Date/Week.d.ts.map +0 -1
  276. package/lib/typescript/utils.d.ts.map +0 -1
  277. package/src/Date/Week.tsx +0 -3
@@ -17,12 +17,18 @@ import {
17
17
  hourTypes,
18
18
  PossibleClockTypes,
19
19
  } from './timeUtils'
20
- import * as React from 'react'
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
- const { mode } = React.useContext(DisplayModeContext)
52
+
53
+ const { mode } = useContext(DisplayModeContext)
54
+
45
55
  // used to make pointer shorter if hours are selected and above 12
46
- const shortPointer = hours >= 12 && is24Hour
47
- const clockRef = React.useRef<View | null>(null)
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
- const onPointerMove = React.useCallback(
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 = React.useRef(
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
- clock: {
193
- height: circleSize,
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
- bottom: -23,
223
+ width: 48,
213
224
  },
214
225
  line: {
215
- position: 'absolute',
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
- function returnTrue() {
221
- return true
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.outerHourRoot,
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.outerHourInner}>
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.innerHourRoot,
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.innerHourInner}>
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
- outerHourRoot: {
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
- outerHourInner: { borderRadius: 24 },
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 React.memo(AnalogClockHours)
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
- export default React.memo(AnalogClockMinutes)
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: any
12
- minutes: any
13
+ hours: ReactElement<typeof AnalogClockHours>
14
+ minutes: ReactElement<typeof AnalogClockMinutes>
13
15
  }) {
14
16
  const collapsed = focused === clockTypes.hours
15
- const animatedCollapsed = React.useRef<Animated.Value>(
17
+
18
+ const animatedCollapsed = useRef<Animated.Value>(
16
19
  new Animated.Value(collapsed ? 1 : 0)
17
20
  )
18
- React.useEffect(() => {
21
+
22
+ useEffect(() => {
19
23
  Animated.timing(animatedCollapsed.current, {
20
24
  toValue: collapsed ? 1 : 0,
21
25
  duration: 250,
@@ -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 [controlledValue, setControlledValue] = React.useState<string>(
44
- `${value}`
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
- styles.buttonOverlay,
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
- buttonOverlay: { overflow: 'hidden' },
136
+ root: {
137
+ height: 80,
138
+ position: 'relative',
139
+ width: 96,
140
+ },
138
141
  })
139
142
 
140
- export default React.forwardRef(TimeInput)
143
+ export default forwardRef(TimeInput)
@@ -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 startInput = React.useRef<TextInputNative | null>(null)
49
- const endInput = React.useRef<TextInputNative | null>(null)
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 theme = useTheme()
56
+ const minutesRef = useLatest(minutes)
53
57
 
54
- const onSubmitStartInput = React.useCallback(() => {
58
+ const onSubmitStartInput = useCallback(() => {
55
59
  if (endInput.current) {
56
60
  endInput.current.focus()
57
61
  }
58
62
  }, [endInput])
59
63
 
60
- const onSubmitEndInput = React.useCallback(() => {
64
+ const onSubmitEndInput = useCallback(() => {
61
65
  // TODO: close modal and persist time
62
66
  }, [])
63
67
 
64
- const minutesRef = useLatest(minutes)
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={styles.spaceDot} />
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={styles.spaceDot} />
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
- spaceBetweenInputsAndSwitcher: { width: 12 },
207
- inputContainer: {
208
- flexDirection: 'row',
209
- alignItems: 'center',
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
- spaceDot: {
220
- flex: 1,
221
- },
222
- dot: {
223
- width: 7,
224
- height: 7,
225
- borderRadius: 7 / 2,
217
+ inputContainer: {
218
+ flexDirection: 'row',
219
+ alignItems: 'center',
226
220
  },
227
- betweenDot: {
228
- height: 12,
221
+ spaceBetweenInputsAndSwitcher: {
222
+ width: 12,
229
223
  },
230
224
  })
231
225
 
232
- export default React.memo(TimeInputs)
226
+ export default memo(TimeInputs)
@@ -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 = React.useMemo(() => {
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
- React.useEffect(() => {
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 = React.useCallback<onChangeFunc>(
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 React.memo(TimePicker)
153
+ export default memo(TimePicker)