react-native-paper-dates 0.9.2 → 0.10.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.
Files changed (128) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/Date/AnimatedCrossView.js +1 -4
  3. package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
  4. package/lib/commonjs/Date/Calendar.js +1 -1
  5. package/lib/commonjs/Date/Calendar.js.map +1 -1
  6. package/lib/commonjs/Date/DatePickerInput.js +4 -2
  7. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  8. package/lib/commonjs/Date/DatePickerInput.shared.js.map +1 -1
  9. package/lib/commonjs/Date/DatePickerInputWithoutModal.js +17 -13
  10. package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
  11. package/lib/commonjs/Date/DatePickerModalContentHeader.js +5 -2
  12. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  13. package/lib/commonjs/Date/DatePickerModalHeader.js +11 -12
  14. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  15. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +7 -8
  16. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  17. package/lib/commonjs/Date/Day.js +5 -4
  18. package/lib/commonjs/Date/Day.js.map +1 -1
  19. package/lib/commonjs/Date/DayName.js +3 -1
  20. package/lib/commonjs/Date/DayName.js.map +1 -1
  21. package/lib/commonjs/Date/Month.js +3 -1
  22. package/lib/commonjs/Date/Month.js.map +1 -1
  23. package/lib/commonjs/Date/Swiper.js +1 -2
  24. package/lib/commonjs/Date/Swiper.js.map +1 -1
  25. package/lib/commonjs/Date/YearPicker.js +4 -2
  26. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  27. package/lib/commonjs/TextInputMask.js +9 -4
  28. package/lib/commonjs/TextInputMask.js.map +1 -1
  29. package/lib/commonjs/Time/AmPmSwitcher.js +3 -2
  30. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  31. package/lib/commonjs/Time/AnalogClock.js +1 -1
  32. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  33. package/lib/commonjs/Time/TimeInputs.js +7 -4
  34. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  35. package/lib/commonjs/Time/TimePicker.js +4 -1
  36. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  37. package/lib/commonjs/Time/TimePickerModal.js +15 -4
  38. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  39. package/lib/commonjs/Time/timeUtils.js +35 -3
  40. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  41. package/lib/commonjs/translations/utils.js +2 -2
  42. package/lib/commonjs/translations/utils.js.map +1 -1
  43. package/lib/commonjs/utils.js.map +1 -1
  44. package/lib/module/Date/AnimatedCrossView.js +1 -3
  45. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  46. package/lib/module/Date/Calendar.js +1 -1
  47. package/lib/module/Date/Calendar.js.map +1 -1
  48. package/lib/module/Date/DatePickerInput.js +4 -2
  49. package/lib/module/Date/DatePickerInput.js.map +1 -1
  50. package/lib/module/Date/DatePickerInput.shared.js.map +1 -1
  51. package/lib/module/Date/DatePickerInputWithoutModal.js +17 -13
  52. package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
  53. package/lib/module/Date/DatePickerModalContentHeader.js +6 -3
  54. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  55. package/lib/module/Date/DatePickerModalHeader.js +11 -13
  56. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  57. package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -9
  58. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  59. package/lib/module/Date/Day.js +5 -4
  60. package/lib/module/Date/Day.js.map +1 -1
  61. package/lib/module/Date/DayName.js +3 -1
  62. package/lib/module/Date/DayName.js.map +1 -1
  63. package/lib/module/Date/Month.js +3 -1
  64. package/lib/module/Date/Month.js.map +1 -1
  65. package/lib/module/Date/Swiper.js +1 -2
  66. package/lib/module/Date/Swiper.js.map +1 -1
  67. package/lib/module/Date/YearPicker.js +4 -2
  68. package/lib/module/Date/YearPicker.js.map +1 -1
  69. package/lib/module/TextInputMask.js +9 -4
  70. package/lib/module/TextInputMask.js.map +1 -1
  71. package/lib/module/Time/AmPmSwitcher.js +3 -2
  72. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  73. package/lib/module/Time/AnalogClock.js +1 -1
  74. package/lib/module/Time/AnalogClock.js.map +1 -1
  75. package/lib/module/Time/TimeInputs.js +6 -4
  76. package/lib/module/Time/TimeInputs.js.map +1 -1
  77. package/lib/module/Time/TimePicker.js +4 -1
  78. package/lib/module/Time/TimePicker.js.map +1 -1
  79. package/lib/module/Time/TimePickerModal.js +15 -4
  80. package/lib/module/Time/TimePickerModal.js.map +1 -1
  81. package/lib/module/Time/timeUtils.js +35 -3
  82. package/lib/module/Time/timeUtils.js.map +1 -1
  83. package/lib/module/translations/utils.js +2 -2
  84. package/lib/module/translations/utils.js.map +1 -1
  85. package/lib/module/utils.js.map +1 -1
  86. package/lib/typescript/Date/AutoSizer.d.ts +1 -1
  87. package/lib/typescript/Date/Calendar.d.ts +10 -10
  88. package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
  89. package/lib/typescript/Date/DatePickerInput.shared.d.ts +2 -1
  90. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +10 -4
  91. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
  92. package/lib/typescript/Date/Day.d.ts +2 -2
  93. package/lib/typescript/Date/SwiperUtils.d.ts +2 -2
  94. package/lib/typescript/Date/dateUtils.d.ts +1 -1
  95. package/lib/typescript/TextInputMask.d.ts +9 -4
  96. package/lib/typescript/Time/TimePicker.d.ts +1 -1
  97. package/lib/typescript/Time/timeUtils.d.ts +7 -7
  98. package/lib/typescript/translations/utils.d.ts +1 -1
  99. package/lib/typescript/utils.d.ts +2 -0
  100. package/package.json +9 -8
  101. package/src/Date/AnimatedCrossView.tsx +0 -4
  102. package/src/Date/Calendar.tsx +2 -2
  103. package/src/Date/DatePickerInput.shared.tsx +1 -0
  104. package/src/Date/DatePickerInput.tsx +2 -1
  105. package/src/Date/DatePickerInputWithoutModal.tsx +36 -35
  106. package/src/Date/DatePickerModalContentHeader.tsx +9 -4
  107. package/src/Date/DatePickerModalHeader.tsx +35 -37
  108. package/src/Date/DatePickerModalHeaderBackground.tsx +6 -7
  109. package/src/Date/Day.tsx +12 -4
  110. package/src/Date/DayName.tsx +7 -5
  111. package/src/Date/Month.tsx +12 -2
  112. package/src/Date/Swiper.tsx +0 -1
  113. package/src/Date/YearPicker.tsx +16 -4
  114. package/src/TextInputMask.tsx +8 -4
  115. package/src/Time/AmPmSwitcher.tsx +11 -3
  116. package/src/Time/AnalogClock.tsx +3 -1
  117. package/src/Time/TimeInputs.tsx +32 -4
  118. package/src/Time/TimePicker.tsx +4 -1
  119. package/src/Time/TimePickerModal.tsx +29 -3
  120. package/src/Time/timeUtils.ts +31 -4
  121. package/src/translations/utils.ts +2 -2
  122. package/src/utils.ts +8 -1
  123. package/lib/commonjs/Date/DateRangeInput.js +0 -86
  124. package/lib/commonjs/Date/DateRangeInput.js.map +0 -1
  125. package/lib/module/Date/DateRangeInput.js +0 -69
  126. package/lib/module/Date/DateRangeInput.js.map +0 -1
  127. package/lib/typescript/Date/DateRangeInput.d.ts +0 -4
  128. package/src/Date/DateRangeInput.tsx +0 -75
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { DefaultTheme, MD3DarkTheme } from 'react-native-paper';
2
3
  import Color from 'color';
4
+ export type PaperTheme = typeof MD3DarkTheme | typeof DefaultTheme;
3
5
  export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
4
6
  export declare function useHeaderBackgroundColor(): string;
5
7
  export declare function useHeaderColorIsLight(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-paper-dates",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "description": "Performant Date Picker for React Native Paper",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -51,25 +51,26 @@
51
51
  "@react-native-community/eslint-config": "^3.1.0",
52
52
  "@release-it/conventional-changelog": "^5.1.0",
53
53
  "@types/color": "^3.0.3",
54
- "@types/jest": "^28.1.8",
55
- "@types/react": "^18.0.17",
56
- "@types/react-native": "^0.69.5",
54
+ "@types/jest": "^29.2.4",
55
+ "@types/react": "^18.0.26",
56
+ "@types/react-native": "^0.70.8",
57
57
  "babel-loader": "^8.2.5",
58
58
  "commitlint": "^17.0.3",
59
59
  "eslint": "^8.22.0",
60
60
  "eslint-config-prettier": "^8.5.0",
61
61
  "eslint-plugin-prettier": "^4.2.1",
62
- "expo-cli": "^6.0.5",
62
+ "expo-cli": "^6.0.8",
63
63
  "husky": "^8.0.1",
64
64
  "jest": "^29.0.0",
65
65
  "pod-install": "^0.1.38",
66
66
  "prettier": "^2.7.1",
67
67
  "react": "^18.2.0",
68
- "react-native": "^0.69.5",
68
+ "react-native": "^0.70.6",
69
69
  "react-native-builder-bob": "^0.18.3",
70
- "react-native-paper": "^4.12.4",
70
+ "react-native-paper": "^5.0.2",
71
+ "react-native-safe-area-context": "^4.4.1",
71
72
  "release-it": "^15.4.0",
72
- "typescript": "^4.7.4"
73
+ "typescript": "^4.9.4"
73
74
  },
74
75
  "peerDependencies": {
75
76
  "react": "*",
@@ -3,14 +3,12 @@ import { Animated, StyleSheet, View } from 'react-native'
3
3
  import { useTheme } from 'react-native-paper'
4
4
 
5
5
  export default function AnimatedCrossView({
6
- // visible,
7
6
  collapsed,
8
7
  calendar,
9
8
  calendarEdit,
10
9
  }: {
11
10
  calendar: any
12
11
  calendarEdit: any
13
- // visible: boolean
14
12
  collapsed: boolean
15
13
  }) {
16
14
  const theme = useTheme()
@@ -18,13 +16,11 @@ export default function AnimatedCrossView({
18
16
  new Animated.Value(collapsed ? 1 : 0)
19
17
  )
20
18
  React.useEffect(() => {
21
- // if (visible) {
22
19
  Animated.timing(calendarOpacity.current, {
23
20
  toValue: collapsed ? 1 : 0,
24
21
  duration: 250,
25
22
  useNativeDriver: true,
26
23
  }).start()
27
- // }
28
24
  }, [collapsed])
29
25
 
30
26
  return (
@@ -34,7 +34,7 @@ export type BaseCalendarProps = {
34
34
  startYear?: number
35
35
  endYear?: number
36
36
 
37
- // here they are optional but in final implemenation they are required
37
+ // here they are optional but in final implementation they are required
38
38
  date?: CalendarDate
39
39
  dates?: CalendarDates
40
40
  startDate?: CalendarDate
@@ -101,7 +101,7 @@ function Calendar(
101
101
 
102
102
  const selectColor = useMemo<string>(() => {
103
103
  if (theme.dark) {
104
- return darkenBy(Color(theme.colors.primary), 0.9).hex()
104
+ return darkenBy(Color(theme.colors.primary), 0.1).hex()
105
105
  }
106
106
  return lightenBy(Color(theme.colors.primary), 0.9).hex()
107
107
  }, [theme])
@@ -11,6 +11,7 @@ export type DatePickerInputProps = {
11
11
  withModal?: boolean
12
12
  withDateFormatInLabel?: boolean
13
13
  calendarIcon?: string
14
+ saveLabel?: string
14
15
  } & Omit<
15
16
  React.ComponentProps<typeof TextInput>,
16
17
  'value' | 'onChange' | 'onChangeText'
@@ -42,7 +42,7 @@ function DatePickerInput(
42
42
  />
43
43
  ) : null
44
44
  }
45
- modal={({ value, locale, inputMode, validRange }) =>
45
+ modal={({ value, locale, inputMode, validRange, saveLabel }) =>
46
46
  withModal ? (
47
47
  <DatePickerModal
48
48
  date={value}
@@ -53,6 +53,7 @@ function DatePickerInput(
53
53
  locale={locale}
54
54
  dateMode={inputMode}
55
55
  validRange={validRange}
56
+ saveLabel={saveLabel}
56
57
  />
57
58
  ) : null
58
59
  }
@@ -18,6 +18,7 @@ function DatePickerInputWithoutModal(
18
18
  withDateFormatInLabel = true,
19
19
  modal,
20
20
  inputButtons,
21
+ saveLabel,
21
22
  ...rest
22
23
  }: DatePickerInputProps & {
23
24
  modal?: (params: {
@@ -25,6 +26,7 @@ function DatePickerInputWithoutModal(
25
26
  locale: DatePickerInputProps['locale']
26
27
  inputMode: DatePickerInputProps['inputMode']
27
28
  validRange: DatePickerInputProps['validRange']
29
+ saveLabel: DatePickerInputProps['saveLabel']
28
30
  }) => any
29
31
  inputButtons?: any
30
32
  },
@@ -42,38 +44,34 @@ function DatePickerInputWithoutModal(
42
44
  return (
43
45
  <>
44
46
  <View style={styles.root}>
45
- <TextInputWithMask
46
- {...rest}
47
- ref={ref}
48
- label={getLabel({
49
- // TODO: support label components?
50
- label: label as any,
51
- inputFormat,
52
- withDateFormatInLabel,
53
- })}
54
- value={formattedValue}
55
- keyboardType={'number-pad'}
56
- placeholder={inputFormat}
57
- mask={inputFormat}
58
- onChangeText={onChangeText}
59
- keyboardAppearance={theme.dark ? 'dark' : 'default'}
60
- error={!!error}
61
- style={[styles.input, style]}
62
- />
63
- {inputButtons}
64
- {!!error ? (
65
- <View style={styles.helperText}>
66
- <HelperText
67
- style={styles.helperText}
68
- type="error"
69
- visible={!!error}
70
- >
71
- {error}
72
- </HelperText>
73
- </View>
47
+ <View style={styles.inputContainer}>
48
+ <TextInputWithMask
49
+ {...rest}
50
+ ref={ref}
51
+ label={getLabel({
52
+ // TODO: support label components?
53
+ label: label as any,
54
+ inputFormat,
55
+ withDateFormatInLabel,
56
+ })}
57
+ value={formattedValue}
58
+ keyboardType={'number-pad'}
59
+ placeholder={inputFormat}
60
+ mask={inputFormat}
61
+ onChangeText={onChangeText}
62
+ keyboardAppearance={theme.dark ? 'dark' : 'default'}
63
+ error={!!error}
64
+ style={[styles.input, style]}
65
+ />
66
+ {inputButtons}
67
+ </View>
68
+ {error ? (
69
+ <HelperText style={styles.helperText} type="error" visible={!!error}>
70
+ {error}
71
+ </HelperText>
74
72
  ) : null}
75
73
  </View>
76
- {modal?.({ value, locale, inputMode, validRange })}
74
+ {modal?.({ value, locale, inputMode, validRange, saveLabel })}
77
75
  </>
78
76
  )
79
77
  }
@@ -95,16 +93,19 @@ function getLabel({
95
93
 
96
94
  const styles = StyleSheet.create({
97
95
  root: {
98
- minWidth: 150,
99
96
  flexGrow: 1,
100
- justifyContent: 'center',
101
97
  },
102
- helperTextContainer: {
98
+ inputContainer: {
99
+ flexGrow: 1,
103
100
  flexDirection: 'row',
101
+ alignItems: 'center',
102
+ justifyContent: 'flex-start',
103
+ },
104
+ input: {
105
+ flexGrow: 1,
104
106
  },
105
107
  helperText: {
106
- flex: 1,
108
+ // flex: 1,
107
109
  },
108
- input: {},
109
110
  })
110
111
  export default React.forwardRef(DatePickerInputWithoutModal)
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { View, StyleSheet } from 'react-native'
3
- import { IconButton, Text } from 'react-native-paper'
3
+ import { IconButton, MD2Theme, Text, useTheme } from 'react-native-paper'
4
4
  import type { ModeType } from './Calendar'
5
5
  import type { LocalState } from './DatePickerModalContent'
6
6
  import { useHeaderTextColor } from '../utils'
@@ -61,15 +61,20 @@ export default function DatePickerModalContentHeader(
61
61
  editIcon = 'pencil',
62
62
  calendarIcon = 'calendar',
63
63
  } = props
64
-
64
+ const theme = useTheme()
65
65
  const label = getLabel(props.locale, props.mode, props.label)
66
66
 
67
67
  const color = useHeaderTextColor()
68
68
  const allowEditing = mode !== 'multiple'
69
+
70
+ let textFont = theme?.isV3
71
+ ? theme.fonts.bodyLarge
72
+ : (theme as any as MD2Theme).fonts.medium
73
+
69
74
  return (
70
75
  <View style={[styles.header]}>
71
76
  <View>
72
- <Text style={[styles.label, { color }]}>
77
+ <Text style={[styles.label, { color, ...textFont }]}>
73
78
  {uppercase ? label.toUpperCase() : label}
74
79
  </Text>
75
80
  <View style={styles.headerContentContainer}>
@@ -97,7 +102,7 @@ export default function DatePickerModalContentHeader(
97
102
  ? getTranslation(props.locale, 'typeInDate')
98
103
  : getTranslation(props.locale, 'pickDateFromCalendar')
99
104
  }
100
- color={color}
105
+ iconColor={color}
101
106
  onPress={onToggle}
102
107
  />
103
108
  ) : null}
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react'
2
- import { Animated, StyleSheet, SafeAreaView } from 'react-native'
2
+ import { Animated, StyleSheet } from 'react-native'
3
3
  import { Appbar, Button } from 'react-native-paper'
4
4
 
5
5
  import { useHeaderTextColor } from '../utils'
6
6
  import { getTranslation } from '../translations/utils'
7
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
7
8
 
8
9
  export interface DatePickerModalHeaderProps {
9
10
  disableSafeTop?: boolean
@@ -22,37 +23,40 @@ export default function DatePickerModalHeader(
22
23
  const { disableSafeTop, locale, closeIcon = 'close' } = props
23
24
  const saveLabel = props.saveLabel || getTranslation(locale, 'save')
24
25
  const color = useHeaderTextColor()
26
+ const insets = useSafeAreaInsets()
27
+
25
28
  return (
26
- <>
27
- <Animated.View style={styles.animated}>
28
- <SafeAreaView
29
- style={[
30
- styles.safeContent,
31
- disableSafeTop && styles.safeContentNoTop,
32
- ]}
29
+ <Animated.View
30
+ style={[
31
+ styles.animated,
32
+ {
33
+ paddingTop: disableSafeTop ? 0 : insets.top,
34
+ paddingLeft: insets.left,
35
+ paddingRight: insets.right,
36
+ },
37
+ ]}
38
+ >
39
+ <Appbar style={styles.appbarHeader}>
40
+ <Appbar.Action
41
+ icon={closeIcon}
42
+ accessibilityLabel={getTranslation(locale, 'close')}
43
+ onPress={props.onDismiss}
44
+ color={color}
45
+ testID="react-native-paper-dates-close"
46
+ />
47
+ <Appbar.Content title={''} />
48
+ <Button
49
+ color={color}
50
+ textColor={color}
51
+ onPress={props.onSave}
52
+ disabled={props.saveLabelDisabled || false}
53
+ uppercase={props.uppercase || true}
54
+ testID="react-native-paper-dates-save"
33
55
  >
34
- <Appbar style={styles.appbarHeader}>
35
- <Appbar.Action
36
- icon={closeIcon}
37
- accessibilityLabel={getTranslation(locale, 'close')}
38
- onPress={props.onDismiss}
39
- color={color}
40
- testID="react-native-paper-dates-close"
41
- />
42
- <Appbar.Content title={''} />
43
- <Button
44
- color={color}
45
- onPress={props.onSave}
46
- disabled={props.saveLabelDisabled || false}
47
- uppercase={props.uppercase || true}
48
- testID="react-native-paper-dates-save"
49
- >
50
- {saveLabel}
51
- </Button>
52
- </Appbar>
53
- </SafeAreaView>
54
- </Animated.View>
55
- </>
56
+ {saveLabel}
57
+ </Button>
58
+ </Appbar>
59
+ </Animated.View>
56
60
  )
57
61
  }
58
62
 
@@ -61,15 +65,9 @@ const styles = StyleSheet.create({
61
65
  flex: 1,
62
66
  },
63
67
  animated: {
64
- paddingBottom: 0,
65
68
  elevation: 4,
66
69
  },
67
- safeContent: {
68
- paddingBottom: 0,
69
- },
70
- safeContentNoTop: {
71
- paddingTop: 0,
72
- },
70
+
73
71
  header: {
74
72
  height: 75,
75
73
  alignItems: 'center',
@@ -1,6 +1,7 @@
1
- import { Animated, SafeAreaView, StyleSheet } from 'react-native'
1
+ import { Animated, StyleSheet } from 'react-native'
2
2
  import * as React from 'react'
3
3
  import { useHeaderBackgroundColor } from '../utils'
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
4
5
 
5
6
  export default function DatePickerModalHeaderBackground({
6
7
  children,
@@ -8,27 +9,25 @@ export default function DatePickerModalHeaderBackground({
8
9
  children: any
9
10
  }) {
10
11
  const backgroundColor = useHeaderBackgroundColor()
11
-
12
+ const insets = useSafeAreaInsets()
12
13
  return (
13
14
  <Animated.View
14
15
  style={[
15
16
  styles.animated,
16
17
  {
17
18
  backgroundColor,
19
+ paddingLeft: insets.left,
20
+ paddingRight: insets.right,
18
21
  },
19
22
  ]}
20
23
  >
21
- <SafeAreaView style={styles.safeContent}>{children}</SafeAreaView>
24
+ {children}
22
25
  </Animated.View>
23
26
  )
24
27
  }
25
28
 
26
29
  const styles = StyleSheet.create({
27
30
  animated: {
28
- paddingBottom: 0,
29
31
  elevation: 4,
30
32
  },
31
- safeContent: {
32
- paddingBottom: 0,
33
- },
34
33
  })
package/src/Date/Day.tsx CHANGED
@@ -1,16 +1,18 @@
1
1
  import * as React from 'react'
2
- import { DarkTheme, Text, TouchableRipple } from 'react-native-paper'
2
+ import { MD2Theme, Text, TouchableRipple } from 'react-native-paper'
3
3
  import { StyleSheet, View } from 'react-native'
4
4
  import DayRange from './DayRange'
5
5
  import { daySize } from './dateUtils'
6
6
 
7
+ import type { PaperTheme } from '../utils'
8
+
7
9
  function EmptyDayPure() {
8
10
  return <View style={styles.empty} />
9
11
  }
10
12
  export const EmptyDay = React.memo(EmptyDayPure)
11
13
 
12
14
  function Day(props: {
13
- theme: typeof DarkTheme
15
+ theme: PaperTheme
14
16
  textColorOnPrimary: string
15
17
  day: number
16
18
  month: number
@@ -41,7 +43,6 @@ function Day(props: {
41
43
  textColorOnPrimary,
42
44
  theme,
43
45
  } = props
44
- // console.log(month, { day })
45
46
  const onPress = React.useCallback(() => {
46
47
  onPressDate(new Date(year, month, day))
47
48
  }, [onPressDate, year, month, day])
@@ -55,6 +56,10 @@ function Day(props: {
55
56
  const textColor =
56
57
  selected || (inRange && theme.dark) ? textColorOnPrimary : undefined
57
58
 
59
+ let textFont = theme?.isV3
60
+ ? theme.fonts.bodyMedium
61
+ : (theme as any as MD2Theme).fonts.medium
62
+
58
63
  return (
59
64
  <View style={[styles.root, disabled && styles.disabled]}>
60
65
  <DayRange
@@ -83,7 +88,10 @@ function Day(props: {
83
88
  ]}
84
89
  >
85
90
  <Text
86
- style={textColor ? { color: textColor } : undefined}
91
+ style={[
92
+ textColor ? { color: textColor } : undefined,
93
+ { ...textFont },
94
+ ]}
87
95
  selectable={false}
88
96
  >
89
97
  {day}
@@ -1,15 +1,17 @@
1
1
  import * as React from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
- import { Text, useTheme } from 'react-native-paper'
3
+ import { MD2Theme, Text, useTheme } from 'react-native-paper'
4
4
 
5
5
  function DayName({ label }: { label: string }) {
6
6
  const theme = useTheme()
7
+
8
+ let textFont = theme?.isV3
9
+ ? theme.fonts.bodyMedium
10
+ : (theme as any as MD2Theme).fonts.medium
11
+
7
12
  return (
8
13
  <View style={styles.dayName}>
9
- <Text
10
- style={[styles.dayNameLabel, theme.fonts.medium]}
11
- selectable={false}
12
- >
14
+ <Text style={[styles.dayNameLabel, { ...textFont }]} selectable={false}>
13
15
  {label}
14
16
  </Text>
15
17
  </View>
@@ -1,6 +1,12 @@
1
1
  import * as React from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
- import { IconButton, Text, useTheme, TouchableRipple } from 'react-native-paper'
3
+ import {
4
+ IconButton,
5
+ Text,
6
+ useTheme,
7
+ TouchableRipple,
8
+ MD2Theme,
9
+ } from 'react-native-paper'
4
10
  import Day, { EmptyDay } from './Day'
5
11
 
6
12
  import {
@@ -244,6 +250,10 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
244
250
  date,
245
251
  ])
246
252
 
253
+ let textFont = theme?.isV3
254
+ ? theme.fonts.bodyMedium
255
+ : (theme as any as MD2Theme).fonts.medium
256
+
247
257
  return (
248
258
  <View style={[styles.month, { height: getMonthHeight(scrollMode, index) }]}>
249
259
  <View
@@ -278,7 +288,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
278
288
  ]}
279
289
  >
280
290
  <Text
281
- style={[styles.monthLabel, theme.fonts.medium]}
291
+ style={[styles.monthLabel, { ...textFont }]}
282
292
  selectable={false}
283
293
  >
284
294
  {monthName} {year}
@@ -157,7 +157,6 @@ function VerticalScroller({
157
157
  right: 0,
158
158
  position: 'absolute',
159
159
  height: getMonthHeight('vertical', visibleIndexes[vi]),
160
- // transform: `translateY(${getMonthsOffset('vertical', vi)}px)`,
161
160
  }}
162
161
  >
163
162
  {renderItem({
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { FlatList, StyleSheet, View } from 'react-native'
3
- import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
+ import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
4
  import { range } from '../utils'
5
5
 
6
6
  const ITEM_HEIGHT = 62
@@ -20,7 +20,10 @@ export default function YearPicker({
20
20
  }) {
21
21
  const theme = useTheme()
22
22
  const flatList = React.useRef<FlatList<number> | null>(null)
23
- const years = range(isNaN(startYear) ? 1800 : startYear, isNaN(endYear) ? 2200 : endYear)
23
+ const years = range(
24
+ isNaN(startYear) ? 1800 : startYear,
25
+ isNaN(endYear) ? 2200 : endYear
26
+ )
24
27
 
25
28
  // scroll to selected year
26
29
  React.useEffect(() => {
@@ -31,7 +34,7 @@ export default function YearPicker({
31
34
  animated: false,
32
35
  })
33
36
  }
34
- }, [flatList, selectedYear])
37
+ }, [flatList, selectedYear, startYear])
35
38
 
36
39
  return (
37
40
  <View
@@ -71,6 +74,11 @@ function YearPure({
71
74
  onPressYear: (newYear: number) => any
72
75
  }) {
73
76
  const theme = useTheme()
77
+
78
+ let textFont = theme?.isV3
79
+ ? theme.fonts.bodyLarge
80
+ : (theme as any as MD2Theme).fonts.medium
81
+
74
82
  return (
75
83
  <View style={styles.year}>
76
84
  <TouchableRipple
@@ -86,7 +94,11 @@ function YearPure({
86
94
  ]}
87
95
  >
88
96
  <Text
89
- style={[styles.yearLabel, selected ? styles.selectedYear : null]}
97
+ style={[
98
+ styles.yearLabel,
99
+ selected ? styles.selectedYear : null,
100
+ { ...textFont },
101
+ ]}
90
102
  selectable={false}
91
103
  >
92
104
  {year}
@@ -72,7 +72,7 @@ function TextInputWithMask(
72
72
  value,
73
73
  mask,
74
74
  ...rest
75
- }: React.ComponentProps<typeof TextInput> & { mask: string },
75
+ }: React.ComponentProps<typeof TextInput> & { mask: string; value: string },
76
76
  ref: any
77
77
  ) {
78
78
  const [controlledValue, setControlledValue] = React.useState<string>(
@@ -80,12 +80,15 @@ function TextInputWithMask(
80
80
  )
81
81
 
82
82
  const onInnerChange = (text: string) => {
83
- const enhancedText = enhanceTextWithMask(text, mask, controlledValue)
84
- setControlledValue(enhancedText)
85
-
86
83
  if (text.length === mask.length) {
87
84
  onChangeText && onChangeText(text)
88
85
  }
86
+ setControlledValue(text)
87
+ }
88
+
89
+ const onInnerBlur = () => {
90
+ const enhancedText = enhanceTextWithMask(value, mask, controlledValue)
91
+ setControlledValue(enhancedText)
89
92
  }
90
93
 
91
94
  React.useEffect(() => {
@@ -98,6 +101,7 @@ function TextInputWithMask(
98
101
  {...rest}
99
102
  value={controlledValue}
100
103
  onChangeText={onInnerChange}
104
+ onBlur={onInnerBlur}
101
105
  />
102
106
  )
103
107
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { View, StyleSheet } from 'react-native'
3
- import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
+ import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
4
  import { useMemo } from 'react'
5
5
  import Color from 'color'
6
6
  import { useSwitchColors } from './timeUtils'
@@ -19,7 +19,11 @@ export default function AmPmSwitcher({
19
19
  if (theme.dark) {
20
20
  return Color(theme.colors.surface).lighten(1.2).hex()
21
21
  }
22
- return Color(theme.colors.surface).darken(0.1).hex()
22
+ return Color(
23
+ theme.isV3 ? theme.colors.inverseOnSurface : theme.colors.surface
24
+ )
25
+ .darken(0.1)
26
+ .hex()
23
27
  }, [theme])
24
28
 
25
29
  const isAM = mode === 'AM'
@@ -74,6 +78,10 @@ function SwitchButton({
74
78
  const theme = useTheme()
75
79
  const { backgroundColor, color } = useSwitchColors(selected)
76
80
 
81
+ let textFont = theme?.isV3
82
+ ? theme.fonts.bodyMedium
83
+ : (theme as any as MD2Theme).fonts.medium
84
+
77
85
  return (
78
86
  <TouchableRipple
79
87
  onPress={onPress}
@@ -92,7 +100,7 @@ function SwitchButton({
92
100
  selectable={false}
93
101
  style={[
94
102
  {
95
- ...theme.fonts.medium,
103
+ ...textFont,
96
104
  color: color,
97
105
  },
98
106
  ]}
@@ -128,7 +128,9 @@ function AnalogClock({
128
128
  styles.clock,
129
129
  {
130
130
  backgroundColor: theme.dark
131
- ? Color(theme.colors.surface).lighten(1.2).hex()
131
+ ? Color(theme.colors.surface).lighten(1.4).hex()
132
+ : theme.isV3
133
+ ? Color(theme.colors.outline).lighten(0.9).hex()
132
134
  : Color(theme.colors.surface).darken(0.1).hex(),
133
135
  },
134
136
  ]}