react-native-paper-dates 0.22.56 → 0.23.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 (94) hide show
  1. package/lib/commonjs/Date/Calendar.js +1 -10
  2. package/lib/commonjs/Date/Calendar.js.map +1 -1
  3. package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
  4. package/lib/commonjs/Date/DatePickerModalContent.js +1 -3
  5. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  6. package/lib/commonjs/Date/DatePickerModalContentHeader.js +9 -11
  7. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  8. package/lib/commonjs/Date/DatePickerModalHeader.js +1 -1
  9. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  10. package/lib/commonjs/Date/Day.js +12 -30
  11. package/lib/commonjs/Date/Day.js.map +1 -1
  12. package/lib/commonjs/Date/DayName.js +1 -1
  13. package/lib/commonjs/Date/DayName.js.map +1 -1
  14. package/lib/commonjs/Date/Month.js +4 -6
  15. package/lib/commonjs/Date/Month.js.map +1 -1
  16. package/lib/commonjs/Date/YearPicker.js +4 -6
  17. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  18. package/lib/commonjs/Time/AmPmSwitcher.js +2 -9
  19. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  20. package/lib/commonjs/Time/AnalogClock.js +1 -4
  21. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  22. package/lib/commonjs/Time/TimeInput.js +3 -3
  23. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  24. package/lib/commonjs/Time/TimeInputs.js +2 -2
  25. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  26. package/lib/commonjs/Time/TimePickerModal.js +6 -17
  27. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  28. package/lib/commonjs/Time/timeUtils.js +13 -38
  29. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  30. package/lib/commonjs/shared/utils.js +5 -22
  31. package/lib/commonjs/shared/utils.js.map +1 -1
  32. package/lib/module/Date/Calendar.js +3 -12
  33. package/lib/module/Date/Calendar.js.map +1 -1
  34. package/lib/module/Date/DatePickerModal.js.map +1 -1
  35. package/lib/module/Date/DatePickerModalContent.js +1 -3
  36. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  37. package/lib/module/Date/DatePickerModalContentHeader.js +9 -11
  38. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  39. package/lib/module/Date/DatePickerModalHeader.js +1 -1
  40. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  41. package/lib/module/Date/Day.js +12 -30
  42. package/lib/module/Date/Day.js.map +1 -1
  43. package/lib/module/Date/DayName.js +1 -1
  44. package/lib/module/Date/DayName.js.map +1 -1
  45. package/lib/module/Date/Month.js +4 -6
  46. package/lib/module/Date/Month.js.map +1 -1
  47. package/lib/module/Date/YearPicker.js +4 -6
  48. package/lib/module/Date/YearPicker.js.map +1 -1
  49. package/lib/module/Time/AmPmSwitcher.js +3 -9
  50. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  51. package/lib/module/Time/AnalogClock.js +1 -4
  52. package/lib/module/Time/AnalogClock.js.map +1 -1
  53. package/lib/module/Time/TimeInput.js +3 -3
  54. package/lib/module/Time/TimeInput.js.map +1 -1
  55. package/lib/module/Time/TimeInputs.js +2 -2
  56. package/lib/module/Time/TimeInputs.js.map +1 -1
  57. package/lib/module/Time/TimePickerModal.js +7 -18
  58. package/lib/module/Time/TimePickerModal.js.map +1 -1
  59. package/lib/module/Time/timeUtils.js +13 -37
  60. package/lib/module/Time/timeUtils.js.map +1 -1
  61. package/lib/module/shared/utils.js +6 -22
  62. package/lib/module/shared/utils.js.map +1 -1
  63. package/lib/typescript/Date/Calendar.d.ts.map +1 -1
  64. package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
  65. package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
  66. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
  67. package/lib/typescript/Date/Day.d.ts.map +1 -1
  68. package/lib/typescript/Date/DayName.d.ts.map +1 -1
  69. package/lib/typescript/Date/Month.d.ts.map +1 -1
  70. package/lib/typescript/Time/AmPmSwitcher.d.ts.map +1 -1
  71. package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
  72. package/lib/typescript/Time/TimeInput.d.ts.map +1 -1
  73. package/lib/typescript/Time/TimeInputs.d.ts.map +1 -1
  74. package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
  75. package/lib/typescript/Time/timeUtils.d.ts.map +1 -1
  76. package/lib/typescript/shared/utils.d.ts +0 -1
  77. package/lib/typescript/shared/utils.d.ts.map +1 -1
  78. package/package.json +1 -1
  79. package/src/Date/Calendar.tsx +3 -12
  80. package/src/Date/DatePickerModal.tsx +5 -1
  81. package/src/Date/DatePickerModalContent.tsx +1 -3
  82. package/src/Date/DatePickerModalContentHeader.tsx +10 -22
  83. package/src/Date/DatePickerModalHeader.tsx +1 -1
  84. package/src/Date/Day.tsx +13 -34
  85. package/src/Date/DayName.tsx +2 -4
  86. package/src/Date/Month.tsx +5 -19
  87. package/src/Date/YearPicker.tsx +4 -11
  88. package/src/Time/AmPmSwitcher.tsx +4 -18
  89. package/src/Time/AnalogClock.tsx +1 -6
  90. package/src/Time/TimeInput.tsx +6 -9
  91. package/src/Time/TimeInputs.tsx +3 -7
  92. package/src/Time/TimePickerModal.tsx +9 -33
  93. package/src/Time/timeUtils.ts +14 -51
  94. package/src/shared/utils.ts +6 -34
@@ -10,11 +10,10 @@ import {
10
10
  } from './dateUtils'
11
11
 
12
12
  import CalendarHeader from './CalendarHeader'
13
- import { memo, useCallback, useMemo, useState } from 'react'
13
+ import { memo, useCallback, useState } from 'react'
14
14
  import YearPicker from './YearPicker'
15
- import Color from 'color'
16
15
  import { useTheme } from 'react-native-paper'
17
- import { darkenBy, lightenBy, useLatest } from '../shared/utils'
16
+ import { useLatest } from '../shared/utils'
18
17
  import { sharedStyles } from '../shared/styles'
19
18
  import { defaultStartYear, defaultEndYear } from './dateUtils'
20
19
 
@@ -162,15 +161,7 @@ function Calendar(
162
161
  [mode, dateMode, onChangeRef, startDateRef, endDateRef, datesRef]
163
162
  )
164
163
 
165
- const selectColor = useMemo<string>(() => {
166
- if (theme.isV3) {
167
- return theme.colors.primaryContainer
168
- }
169
- if (theme.dark) {
170
- return darkenBy(Color(theme.colors.primary), 0.1).hex()
171
- }
172
- return lightenBy(Color(theme.colors.primary), 0.9).hex()
173
- }, [theme])
164
+ const selectColor = theme.colors.primaryContainer
174
165
 
175
166
  return (
176
167
  <View style={sharedStyles.root}>
@@ -84,7 +84,11 @@ export function DatePickerModal(
84
84
  visible={visible}
85
85
  onRequestClose={rest.onDismiss}
86
86
  presentationStyle={
87
- useFormSheet ? 'formSheet' : shouldUseSheet ? 'pageSheet' : 'overFullScreen'
87
+ useFormSheet
88
+ ? 'formSheet'
89
+ : shouldUseSheet
90
+ ? 'pageSheet'
91
+ : 'overFullScreen'
88
92
  }
89
93
  supportedOrientations={supportedOrientations}
90
94
  statusBarTranslucent={!disableStatusBar}
@@ -15,7 +15,6 @@ import DatePickerModalContentHeader, {
15
15
  } from './DatePickerModalContentHeader'
16
16
  import CalendarEdit from './CalendarEdit'
17
17
  import DatePickerModalHeaderBackground from './DatePickerModalHeaderBackground'
18
- import { useTheme } from 'react-native-paper'
19
18
  import DatePickerModalStatusBar from './DatePickerModalStatusBar'
20
19
  import { memo, useCallback, useEffect, useState } from 'react'
21
20
 
@@ -94,9 +93,8 @@ export function DatePickerModalContent(
94
93
  statusBarOnTopOfBackdrop,
95
94
  startWeekOnMonday,
96
95
  } = props
97
- const theme = useTheme()
98
96
  const anyProps = props as any
99
- const defaultUppercase = !theme.isV3
97
+ const defaultUppercase = false
100
98
 
101
99
  // use local state to add only onConfirm state changes
102
100
  const [state, setState] = useState<LocalState>({
@@ -1,5 +1,5 @@
1
1
  import { StyleSheet, View } from 'react-native'
2
- import { IconButton, MD2Theme, Text, useTheme } from 'react-native-paper'
2
+ import { IconButton, Text, useTheme } from 'react-native-paper'
3
3
  import type { ModeType } from './Calendar'
4
4
  import type { LocalState } from './DatePickerModalContent'
5
5
  import { useHeaderTextColor } from '../shared/utils'
@@ -70,14 +70,10 @@ export default function DatePickerModalContentHeader(
70
70
  const label = getLabel(props.locale, props.mode, props.label)
71
71
  const color = useHeaderTextColor()
72
72
  const isEditingEnabled = allowEditing && mode !== 'multiple'
73
- const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
74
- const textFont = theme?.isV3
75
- ? theme.fonts.labelMedium
76
- : (theme as any as MD2Theme).fonts.medium
77
- const collapsedIcon = theme.isV3 ? 'pencil-outline' : 'pencil'
78
- const expandedIcon = theme.isV3 ? 'calendar-blank' : 'calendar'
79
- const finalCollapsedIcon = editIcon ?? collapsedIcon
80
- const finalExpandedIcon = calendarIcon ?? expandedIcon
73
+ const supportingTextColor = theme.colors.onSurfaceVariant
74
+ const textFont = theme.fonts.labelMedium
75
+ const finalCollapsedIcon = editIcon ?? 'pencil-outline'
76
+ const finalExpandedIcon = calendarIcon ?? 'calendar-blank'
81
77
 
82
78
  return (
83
79
  <View style={styles.header}>
@@ -113,7 +109,7 @@ export default function DatePickerModalContentHeader(
113
109
  ? getTranslation(props.locale, 'typeInDate')
114
110
  : getTranslation(props.locale, 'pickDateFromCalendar')
115
111
  }
116
- iconColor={theme.isV3 ? theme.colors.onSurface : color}
112
+ iconColor={theme.colors.onSurface}
117
113
  onPress={onToggle}
118
114
  />
119
115
  ) : null}
@@ -130,11 +126,7 @@ export function HeaderContentSingle({
130
126
  const theme = useTheme()
131
127
 
132
128
  const lighterColor = Color(color).fade(0.5).rgb().toString()
133
- const dateColor = state.date
134
- ? theme.isV3
135
- ? theme.colors.onSurface
136
- : color
137
- : lighterColor
129
+ const dateColor = state.date ? theme.colors.onSurface : lighterColor
138
130
 
139
131
  const formatter = useMemo(() => {
140
132
  return new Intl.DateTimeFormat(locale, {
@@ -164,11 +156,7 @@ export function HeaderContentMulti({
164
156
 
165
157
  const dateCount = state.dates?.length || 0
166
158
  const lighterColor = Color(color).fade(0.5).rgb().toString()
167
- const dateColor = dateCount
168
- ? theme.isV3
169
- ? theme.colors.onSurface
170
- : color
171
- : lighterColor
159
+ const dateColor = dateCount ? theme.colors.onSurface : lighterColor
172
160
 
173
161
  const formatter = useMemo(() => {
174
162
  return new Intl.DateTimeFormat(locale, {
@@ -208,8 +196,8 @@ export function HeaderContentRange({
208
196
  const theme = useTheme()
209
197
 
210
198
  const lighterColor = Color(color).fade(0.5).rgb().toString()
211
- const startColorFilled = theme.isV3 ? theme.colors.onSurface : color
212
- const endColorFilled = theme.isV3 ? theme.colors.onSurface : color
199
+ const startColorFilled = theme.colors.onSurface
200
+ const endColorFilled = theme.colors.onSurface
213
201
  const startColor = state.startDate ? startColorFilled : lighterColor
214
202
  const endColor = state.endDate ? endColorFilled : lighterColor
215
203
 
@@ -44,7 +44,7 @@ export default function DatePickerModalHeader(
44
44
  testID="react-native-paper-dates-close"
45
45
  />
46
46
  <Button
47
- textColor={theme.isV3 ? theme.colors.primary : color}
47
+ textColor={theme.colors.primary}
48
48
  onPress={props.onSave}
49
49
  disabled={props.saveLabelDisabled ?? false}
50
50
  uppercase={props.uppercase ?? true}
package/src/Date/Day.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { MD2Theme, Text, TouchableRipple } from 'react-native-paper'
1
+ import { Text, TouchableRipple } from 'react-native-paper'
2
2
  import { StyleSheet, View } from 'react-native'
3
3
  import DayRange from './DayRange'
4
4
  import { daySize } from './dateUtils'
@@ -41,54 +41,33 @@ function Day(props: {
41
41
  selectColor,
42
42
  isToday,
43
43
  disabled,
44
- textColorOnPrimary,
45
44
  theme,
46
45
  } = props
47
- const borderColorFallback = theme.dark ? '#fff' : '#000'
48
- const selectedOrInRangeDarkMode = selected || (inRange && theme.dark)
49
- const v2BorderColor = selectedOrInRangeDarkMode
50
- ? textColorOnPrimary
51
- : borderColorFallback
52
- const borderColor = theme.isV3 ? theme.colors.primary : v2BorderColor
46
+ const borderColor = theme.colors.primary
53
47
 
54
48
  const onPress = useCallback(() => {
55
49
  onPressDate(new Date(year, month, day))
56
50
  }, [onPressDate, year, month, day])
57
51
 
58
- // TODO: check if this can be simplified
59
- // converted with Chat-GPT for now from enormous conditional to if-else
52
+ // Determine text colors for M3
60
53
  let baseTextColor
61
54
  let finalTextColor
62
55
 
63
- if (theme.isV3) {
64
- // Theme V3 specific logic for base text color
65
- if (selected) {
66
- baseTextColor = theme.colors.onPrimary
67
- } else if (inRange && theme.dark) {
68
- baseTextColor = theme.colors.onPrimaryContainer
69
- } else {
70
- baseTextColor = theme.colors.onSurface
71
- }
56
+ if (selected) {
57
+ baseTextColor = theme.colors.onPrimary
58
+ } else if (inRange && theme.dark) {
59
+ baseTextColor = theme.colors.onPrimaryContainer
60
+ } else {
61
+ baseTextColor = theme.colors.onSurface
62
+ }
72
63
 
73
- // Theme V3 specific logic for final text color
74
- if (isToday) {
75
- finalTextColor = selected ? baseTextColor : theme.colors.primary
76
- } else {
77
- finalTextColor = baseTextColor
78
- }
64
+ if (isToday) {
65
+ finalTextColor = selected ? baseTextColor : theme.colors.primary
79
66
  } else {
80
- // Logic for themes other than V3
81
- if (selected || (inRange && theme.dark)) {
82
- baseTextColor = textColorOnPrimary
83
- }
84
- // Since there's no additional logic provided for non-V3 themes in the step 2,
85
- // the final text color for non-V3 themes will simply be the base text color.
86
67
  finalTextColor = baseTextColor
87
68
  }
88
69
 
89
- let textFont = theme?.isV3
90
- ? theme.fonts.bodySmall
91
- : (theme as any as MD2Theme).fonts.medium
70
+ const textFont = theme.fonts.bodySmall
92
71
 
93
72
  return (
94
73
  <View style={[styles.root, disabled && styles.disabled]}>
@@ -1,13 +1,11 @@
1
1
  import { memo } from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
- import { MD2Theme, Text, useTheme } from 'react-native-paper'
3
+ import { Text, useTheme } from 'react-native-paper'
4
4
 
5
5
  function DayName({ label }: { label: string }) {
6
6
  const theme = useTheme()
7
7
 
8
- let textFont = theme?.isV3
9
- ? theme.fonts.bodySmall
10
- : (theme as any as MD2Theme).fonts.medium
8
+ const textFont = theme.fonts.bodySmall
11
9
 
12
10
  return (
13
11
  <View style={styles.dayName}>
@@ -1,11 +1,5 @@
1
1
  import { StyleSheet, View } from 'react-native'
2
- import {
3
- Icon,
4
- MD2Theme,
5
- Text,
6
- TouchableRipple,
7
- useTheme,
8
- } from 'react-native-paper'
2
+ import { Icon, Text, TouchableRipple, useTheme } from 'react-native-paper'
9
3
  import Day, { EmptyDay } from './Day'
10
4
 
11
5
  import {
@@ -263,17 +257,11 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
263
257
  endYear,
264
258
  ])
265
259
 
266
- let textFont = theme?.isV3
267
- ? theme.fonts.titleSmall
268
- : (theme as any as MD2Theme).fonts.medium
260
+ const textFont = theme.fonts.titleSmall
269
261
 
270
- const iconColor = theme.isV3
271
- ? theme.colors.onSurfaceVariant
272
- : theme.colors.onSurface
262
+ const iconColor = theme.colors.onSurfaceVariant
273
263
 
274
- const iconSourceV3 = selectingYear ? 'menu-up' : 'menu-down'
275
- const iconSourceV2 = selectingYear ? 'chevron-up' : 'chevron-down'
276
- const iconSource = theme.isV3 ? iconSourceV3 : iconSourceV2
264
+ const iconSource = selectingYear ? 'menu-up' : 'menu-down'
277
265
 
278
266
  return (
279
267
  <View
@@ -324,9 +312,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
324
312
  styles.monthLabel,
325
313
  {
326
314
  ...textFont,
327
- color: theme.isV3
328
- ? theme.colors.onSurfaceVariant
329
- : theme.colors.onSurface,
315
+ color: theme.colors.onSurfaceVariant,
330
316
  },
331
317
  ]}
332
318
  selectable={false}
@@ -1,5 +1,5 @@
1
1
  import { FlatList, ScrollView, StyleSheet, View } from 'react-native'
2
- import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
2
+ import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
3
  import { range } from '../shared/utils'
4
4
  import { memo, useEffect, useRef } from 'react'
5
5
  import { sharedStyles } from '../shared/styles'
@@ -81,9 +81,7 @@ function YearPure({
81
81
  }) {
82
82
  const theme = useTheme()
83
83
 
84
- let textFont = theme?.isV3
85
- ? theme.fonts.bodyLarge
86
- : (theme as any as MD2Theme).fonts.medium
84
+ const textFont = theme.fonts.bodyLarge
87
85
 
88
86
  return (
89
87
  <View style={styles.year}>
@@ -104,13 +102,8 @@ function YearPure({
104
102
  style={[
105
103
  styles.yearLabel,
106
104
  selected
107
- ? // eslint-disable-next-line react-native/no-inline-styles
108
- { color: theme.isV3 ? theme.colors.onPrimary : '#fff' }
109
- : {
110
- color: theme.isV3
111
- ? theme.colors.onSurfaceVariant
112
- : theme.colors.onSurface,
113
- },
105
+ ? { color: theme.colors.onPrimary }
106
+ : { color: theme.colors.onSurfaceVariant },
114
107
  { ...textFont },
115
108
  ]}
116
109
  selectable={false}
@@ -1,7 +1,6 @@
1
1
  import { StyleSheet, View } from 'react-native'
2
- import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
3
- import { useContext, useMemo } from 'react'
4
- import Color from 'color'
2
+ import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
+ import { useContext } from 'react'
5
4
  import { inputTypes, PossibleInputTypes, useSwitchColors } from './timeUtils'
6
5
  import { DisplayModeContext } from '../contexts/DisplayModeContext'
7
6
  import { sharedStyles } from '../shared/styles'
@@ -19,18 +18,7 @@ export default function AmPmSwitcher({
19
18
 
20
19
  const { setMode, mode } = useContext(DisplayModeContext)
21
20
 
22
- const backgroundColor = useMemo<string>(() => {
23
- if (theme.isV3) {
24
- return theme.colors.outline
25
- }
26
- return Color(
27
- theme.dark
28
- ? Color(theme.colors.surface).lighten(1.2).hex()
29
- : theme.colors.surface
30
- )
31
- .darken(0.1)
32
- .hex()
33
- }, [theme])
21
+ const backgroundColor = theme.colors.outline
34
22
 
35
23
  const isAM = mode === 'AM'
36
24
 
@@ -89,9 +77,7 @@ function SwitchButton({
89
77
 
90
78
  const { backgroundColor, color } = useSwitchColors(selected)
91
79
 
92
- let textFont = theme?.isV3
93
- ? theme.fonts.titleMedium
94
- : (theme as any as MD2Theme).fonts.medium
80
+ const textFont = theme.fonts.titleMedium
95
81
 
96
82
  return (
97
83
  <TouchableRipple
@@ -1,4 +1,3 @@
1
- import Color from 'color'
2
1
  import {
3
2
  GestureResponderEvent,
4
3
  PanResponder,
@@ -133,10 +132,6 @@ function AnalogClock({
133
132
  const pointerNumber = focused === clockTypes.hours ? hours : minutes
134
133
  const degreesPerNumber = focused === clockTypes.hours ? 30 : 6
135
134
 
136
- const v3Color = theme.colors.surfaceVariant
137
- const v2Color = theme.dark
138
- ? Color(theme.colors.surface).lighten(1.4).hex()
139
- : Color(theme.colors.surface).darken(0.1).hex()
140
135
  return (
141
136
  <View
142
137
  ref={clockRef}
@@ -144,7 +139,7 @@ function AnalogClock({
144
139
  style={[
145
140
  styles.clock,
146
141
  {
147
- backgroundColor: theme.isV3 ? v3Color : v2Color,
142
+ backgroundColor: theme.colors.surfaceVariant,
148
143
  },
149
144
  ]}
150
145
  // @ts-ignore -> https://github.com/necolas/react-native-web/issues/506
@@ -5,7 +5,7 @@ import {
5
5
  TextInputProps,
6
6
  View,
7
7
  } from 'react-native'
8
- import { MD2Theme, TouchableRipple, useTheme } from 'react-native-paper'
8
+ import { TouchableRipple, useTheme } from 'react-native-paper'
9
9
 
10
10
  import Color from 'color'
11
11
  import {
@@ -77,11 +77,10 @@ function TimeInput(
77
77
  {
78
78
  backgroundColor,
79
79
  borderRadius: theme.roundness * 2,
80
- borderColor:
81
- theme.isV3 && highlighted
82
- ? theme.colors.onPrimaryContainer
83
- : undefined,
84
- borderWidth: theme.isV3 && highlighted ? 2 : 0,
80
+ borderColor: highlighted
81
+ ? theme.colors.onPrimaryContainer
82
+ : undefined,
83
+ borderWidth: highlighted ? 2 : 0,
85
84
  height: inputType === inputTypes.keyboard ? 72 : 80,
86
85
  },
87
86
  ]}
@@ -94,9 +93,7 @@ function TimeInput(
94
93
  // eslint-disable-next-line react-native/no-inline-styles
95
94
  {
96
95
  color,
97
- fontFamily: theme?.isV3
98
- ? theme.fonts.titleMedium.fontFamily
99
- : (theme as any as MD2Theme).fonts.medium.fontFamily,
96
+ fontFamily: theme.fonts.titleMedium.fontFamily,
100
97
  fontSize: inputFontSize,
101
98
  lineHeight:
102
99
  Platform.OS === 'android'
@@ -4,7 +4,7 @@ import {
4
4
  useWindowDimensions,
5
5
  View,
6
6
  } from 'react-native'
7
- import { MD2Theme, Text, useTheme } from 'react-native-paper'
7
+ import { Text, useTheme } from 'react-native-paper'
8
8
 
9
9
  import {
10
10
  clockTypes,
@@ -129,9 +129,7 @@ function TimeInputs({
129
129
  style={[
130
130
  styles.dot,
131
131
  {
132
- backgroundColor: theme?.isV3
133
- ? theme.colors.onSurface
134
- : (theme as any as MD2Theme).colors.text,
132
+ backgroundColor: theme.colors.onSurface,
135
133
  },
136
134
  ]}
137
135
  />
@@ -140,9 +138,7 @@ function TimeInputs({
140
138
  style={[
141
139
  styles.dot,
142
140
  {
143
- backgroundColor: theme?.isV3
144
- ? theme.colors.onSurface
145
- : (theme as any as MD2Theme).colors.text,
141
+ backgroundColor: theme.colors.onSurface,
146
142
  },
147
143
  ]}
148
144
  />
@@ -9,13 +9,7 @@ import {
9
9
  View,
10
10
  } from 'react-native'
11
11
 
12
- import {
13
- Button,
14
- IconButton,
15
- MD2Theme,
16
- overlay,
17
- useTheme,
18
- } from 'react-native-paper'
12
+ import { Button, IconButton, useTheme } from 'react-native-paper'
19
13
 
20
14
  import TimePicker from './TimePicker'
21
15
  import {
@@ -102,29 +96,17 @@ export function TimePickerModal({
102
96
  [setFocused, setLocalHours, setLocalMinutes]
103
97
  )
104
98
 
105
- const defaultUppercase = !theme.isV3
106
- const uppercase = _uppercase ?? defaultUppercase
107
- let textFont
99
+ const uppercase = _uppercase ?? false
100
+ const textFont = theme.fonts.labelMedium
108
101
  let labelText = label
109
102
 
110
- if (theme.isV3) {
111
- textFont = theme.fonts.labelMedium
112
- } else {
113
- textFont = (theme as any as MD2Theme)?.fonts.medium
114
- }
115
-
116
103
  if (inputType === inputTypes.keyboard && !label) {
117
104
  labelText = 'Enter time'
118
105
  }
119
106
 
120
- let color
121
- if (theme.isV3) {
122
- color = theme.dark ? theme.colors.elevation.level3 : theme.colors.surface
123
- } else {
124
- color = theme.dark
125
- ? overlay(10, theme.colors.surface)
126
- : theme.colors.surface
127
- }
107
+ const color = theme.dark
108
+ ? theme.colors.elevation.level3
109
+ : theme.colors.surface
128
110
 
129
111
  return (
130
112
  <Modal
@@ -157,7 +139,7 @@ export function TimePickerModal({
157
139
  // eslint-disable-next-line react-native/no-inline-styles
158
140
  {
159
141
  backgroundColor: color,
160
- borderRadius: theme.isV3 ? 28 : undefined,
142
+ borderRadius: 28,
161
143
  },
162
144
  ]}
163
145
  >
@@ -168,9 +150,7 @@ export function TimePickerModal({
168
150
  styles.label,
169
151
  {
170
152
  ...textFont,
171
- color: theme?.isV3
172
- ? theme.colors.onSurfaceVariant
173
- : (theme as any as MD2Theme).colors.text,
153
+ color: theme.colors.onSurfaceVariant,
174
154
  },
175
155
  ]}
176
156
  >
@@ -192,11 +172,7 @@ export function TimePickerModal({
192
172
  </View>
193
173
  <View style={styles.bottom}>
194
174
  <IconButton
195
- iconColor={
196
- theme?.isV3
197
- ? theme.colors.onBackground
198
- : (theme as any as MD2Theme).colors.text
199
- }
175
+ iconColor={theme.colors.onBackground}
200
176
  icon={getTimeInputTypeIcon(inputType, {
201
177
  keyboard: keyboardIcon,
202
178
  picker: clockIcon,
@@ -1,6 +1,5 @@
1
- import Color from 'color'
2
1
  import { useMemo } from 'react'
3
- import { MD2Theme, useTheme } from 'react-native-paper'
2
+ import { useTheme } from 'react-native-paper'
4
3
 
5
4
  export const circleSize = 256
6
5
 
@@ -159,37 +158,25 @@ export function useSwitchColors(highlighted: boolean) {
159
158
  const backgroundColor = useMemo<string>(() => {
160
159
  if (theme.dark) {
161
160
  if (highlighted) {
162
- return theme.isV3
163
- ? theme.colors.tertiaryContainer
164
- : Color(theme.colors.primary).hex()
161
+ return theme.colors.tertiaryContainer
165
162
  }
166
163
  return theme.colors.backdrop
167
164
  }
168
165
 
169
166
  if (highlighted) {
170
- if (theme.isV3) {
171
- return theme.colors.primaryContainer
172
- }
173
-
174
- return Color(theme.colors.primary).lighten(1).hex()
167
+ return theme.colors.primaryContainer
175
168
  }
176
169
  return theme.colors.surface
177
170
  }, [highlighted, theme])
178
171
 
179
172
  const color = useMemo<string>(() => {
180
173
  if (highlighted && !theme.dark) {
181
- return theme.isV3 ? theme.colors.onSurfaceVariant : theme.colors.primary
174
+ return theme.colors.onSurfaceVariant
182
175
  }
183
176
  if (highlighted && theme.dark) {
184
- return theme.isV3
185
- ? theme.colors.onTertiaryContainer
186
- : theme.colors.background
187
- }
188
- if (theme.isV3) {
189
- return theme.colors.onSurfaceVariant
190
- } else {
191
- return (theme as any as MD2Theme).colors.placeholder
177
+ return theme.colors.onTertiaryContainer
192
178
  }
179
+ return theme.colors.onSurfaceVariant
193
180
  }, [highlighted, theme])
194
181
 
195
182
  return { backgroundColor, color }
@@ -200,47 +187,23 @@ export function useInputColors(highlighted: boolean) {
200
187
  const backgroundColor = useMemo<string>(() => {
201
188
  if (theme.dark) {
202
189
  if (highlighted) {
203
- return theme.isV3
204
- ? theme.colors.primaryContainer
205
- : Color(theme.colors.primary).hex()
190
+ return theme.colors.primaryContainer
206
191
  }
207
- return theme.isV3
208
- ? theme.colors.surfaceVariant
209
- : Color(theme.colors.surface).lighten(1.4).hex()
192
+ return theme.colors.surfaceVariant
210
193
  }
211
194
 
212
195
  if (highlighted) {
213
- if (theme.isV3) {
214
- return theme.colors.secondaryContainer
215
- }
216
- return Color(theme.colors.primary).lighten(1).hex()
217
- }
218
- if (theme.isV3) {
219
- return theme.colors.surfaceVariant
196
+ return theme.colors.secondaryContainer
220
197
  }
221
- return Color(theme.colors.surface).darken(0.1).hex()
198
+ return theme.colors.surfaceVariant
222
199
  }, [highlighted, theme])
223
200
 
224
201
  const color = useMemo<string>(() => {
225
- if (theme.isV3) {
226
- if (!highlighted) {
227
- return theme.isV3 ? theme.colors.onSurface : theme.colors.onBackground
228
- }
229
- return theme.isV3
230
- ? theme.colors.onPrimaryContainer
231
- : theme.colors.onBackground
232
- } else {
233
- const t = theme as any as MD2Theme
234
- if (highlighted && !theme.dark) {
235
- const primary = Color(t.colors.primary)
236
- const background = Color(backgroundColor)
237
- return background.isDark() && primary.isDark()
238
- ? '#ffffffff'
239
- : t.colors.primary
240
- }
241
- return (theme as any as MD2Theme).colors.text
202
+ if (!highlighted) {
203
+ return theme.colors.onSurface
242
204
  }
243
- }, [highlighted, theme, backgroundColor])
205
+ return theme.colors.onPrimaryContainer
206
+ }, [highlighted, theme])
244
207
 
245
208
  return { backgroundColor, color }
246
209
  }