react-native-paper-dates 0.21.9 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/commonjs/Date/DatePickerInput.js +7 -2
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +9 -3
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/Day.js +38 -4
- package/lib/commonjs/Date/Day.js.map +1 -1
- package/lib/commonjs/Date/Month.js +6 -2
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +3 -1
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +3 -2
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +7 -2
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +9 -3
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/Day.js +38 -4
- package/lib/module/Date/Day.js.map +1 -1
- package/lib/module/Date/Month.js +6 -2
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +3 -1
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +3 -2
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/typescript/Date/DatePickerInput.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
- package/lib/typescript/Date/Day.d.ts.map +1 -1
- package/lib/typescript/Date/Month.d.ts.map +1 -1
- package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
- package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Date/DatePickerInput.tsx +3 -2
- package/src/Date/DatePickerModalContentHeader.tsx +9 -19
- package/src/Date/Day.tsx +38 -23
- package/src/Date/Month.tsx +11 -17
- package/src/Time/AnalogClock.tsx +6 -5
- package/src/Time/TimePickerModal.tsx +9 -11
package/src/Date/Day.tsx
CHANGED
|
@@ -47,24 +47,44 @@ function Day(props: {
|
|
|
47
47
|
onPressDate(new Date(year, month, day))
|
|
48
48
|
}, [onPressDate, year, month, day])
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
// const borderColorV3 =
|
|
51
|
+
const borderColorFallback = theme.dark ? '#fff' : '#000'
|
|
52
|
+
const selectedOrInRangeDarkMode = selected || (inRange && theme.dark)
|
|
53
|
+
const v2BorderColor = selectedOrInRangeDarkMode
|
|
53
54
|
? textColorOnPrimary
|
|
54
|
-
:
|
|
55
|
-
|
|
56
|
-
: '#000'
|
|
55
|
+
: borderColorFallback
|
|
56
|
+
const borderColor = theme.isV3 ? theme.colors.primary : v2BorderColor
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
// TODO: check if this can be simplified
|
|
59
|
+
// converted with Chat-GPT for now from enormous conditional to if-else
|
|
60
|
+
let baseTextColor
|
|
61
|
+
let finalTextColor
|
|
62
|
+
|
|
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
|
+
}
|
|
72
|
+
|
|
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
|
+
}
|
|
79
|
+
} 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
|
+
finalTextColor = baseTextColor
|
|
87
|
+
}
|
|
68
88
|
|
|
69
89
|
let textFont = theme?.isV3
|
|
70
90
|
? theme.fonts.bodySmall
|
|
@@ -99,14 +119,9 @@ function Day(props: {
|
|
|
99
119
|
<Text
|
|
100
120
|
maxFontSizeMultiplier={1.5}
|
|
101
121
|
style={[
|
|
102
|
-
|
|
122
|
+
baseTextColor
|
|
103
123
|
? {
|
|
104
|
-
color:
|
|
105
|
-
theme.isV3 && isToday && selected
|
|
106
|
-
? textColor
|
|
107
|
-
: theme.isV3 && isToday
|
|
108
|
-
? theme.colors.primary
|
|
109
|
-
: textColor,
|
|
124
|
+
color: finalTextColor,
|
|
110
125
|
}
|
|
111
126
|
: undefined,
|
|
112
127
|
{ ...textFont },
|
package/src/Date/Month.tsx
CHANGED
|
@@ -254,6 +254,14 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
254
254
|
? theme.fonts.titleSmall
|
|
255
255
|
: (theme as any as MD2Theme).fonts.medium
|
|
256
256
|
|
|
257
|
+
const iconColor = theme.isV3
|
|
258
|
+
? theme.colors.onSurfaceVariant
|
|
259
|
+
: theme.colors.onSurface
|
|
260
|
+
|
|
261
|
+
const iconSourceV3 = selectingYear ? 'menu-up' : 'menu-down'
|
|
262
|
+
const iconSourceV2 = selectingYear ? 'chevron-up' : 'chevron-down'
|
|
263
|
+
const iconSource = theme.isV3 ? iconSourceV3 : iconSourceV2
|
|
264
|
+
|
|
257
265
|
return (
|
|
258
266
|
<View style={[styles.month, { height: getMonthHeight(scrollMode, index) }]}>
|
|
259
267
|
<View
|
|
@@ -305,24 +313,10 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
305
313
|
<View
|
|
306
314
|
style={[
|
|
307
315
|
styles.iconWrapper,
|
|
308
|
-
isHorizontal ? styles.opacity1 : styles.opacity0
|
|
316
|
+
isHorizontal ? styles.opacity1 : styles.opacity0,
|
|
309
317
|
]}
|
|
310
318
|
>
|
|
311
|
-
<Icon
|
|
312
|
-
size={24}
|
|
313
|
-
color={theme.isV3
|
|
314
|
-
? theme.colors.onSurfaceVariant
|
|
315
|
-
: theme.colors.onSurface
|
|
316
|
-
}
|
|
317
|
-
source={selectingYear
|
|
318
|
-
? theme.isV3
|
|
319
|
-
? 'menu-up'
|
|
320
|
-
: 'chevron-up'
|
|
321
|
-
: theme.isV3
|
|
322
|
-
? 'menu-down'
|
|
323
|
-
: 'chevron-down'
|
|
324
|
-
}
|
|
325
|
-
/>
|
|
319
|
+
<Icon size={24} color={iconColor} source={iconSource} />
|
|
326
320
|
</View>
|
|
327
321
|
</View>
|
|
328
322
|
</TouchableRipple>
|
|
@@ -370,7 +364,7 @@ export const monthHeaderSingleHeight =
|
|
|
370
364
|
|
|
371
365
|
const styles = StyleSheet.create({
|
|
372
366
|
iconWrapper: {
|
|
373
|
-
padding: 8
|
|
367
|
+
padding: 8,
|
|
374
368
|
},
|
|
375
369
|
week: {
|
|
376
370
|
flexDirection: 'row',
|
package/src/Time/AnalogClock.tsx
CHANGED
|
@@ -121,6 +121,11 @@ function AnalogClock({
|
|
|
121
121
|
const dynamicSize = focused === clockTypes.hours && shortPointer ? 33 : 0
|
|
122
122
|
const pointerNumber = focused === clockTypes.hours ? hours : minutes
|
|
123
123
|
const degreesPerNumber = focused === clockTypes.hours ? 30 : 6
|
|
124
|
+
|
|
125
|
+
const v3Color = theme.colors.surfaceVariant
|
|
126
|
+
const v2Color = theme.dark
|
|
127
|
+
? Color(theme.colors.surface).lighten(1.4).hex()
|
|
128
|
+
: Color(theme.colors.surface).darken(0.1).hex()
|
|
124
129
|
return (
|
|
125
130
|
<View
|
|
126
131
|
ref={clockRef}
|
|
@@ -128,11 +133,7 @@ function AnalogClock({
|
|
|
128
133
|
style={[
|
|
129
134
|
styles.clock,
|
|
130
135
|
{
|
|
131
|
-
backgroundColor: theme.isV3
|
|
132
|
-
? theme.colors.surfaceVariant
|
|
133
|
-
: theme.dark
|
|
134
|
-
? Color(theme.colors.surface).lighten(1.4).hex()
|
|
135
|
-
: Color(theme.colors.surface).darken(0.1).hex(),
|
|
136
|
+
backgroundColor: theme.isV3 ? v3Color : v2Color,
|
|
136
137
|
},
|
|
137
138
|
]}
|
|
138
139
|
// @ts-ignore -> https://github.com/necolas/react-native-web/issues/506
|
|
@@ -130,6 +130,14 @@ export function TimePickerModal({
|
|
|
130
130
|
},
|
|
131
131
|
[setFocused, setLocalHours, setLocalMinutes]
|
|
132
132
|
)
|
|
133
|
+
|
|
134
|
+
const v3Color = theme.dark
|
|
135
|
+
? theme.colors.elevation.level3
|
|
136
|
+
: theme.colors.surface
|
|
137
|
+
const v2Color = theme.dark
|
|
138
|
+
? overlay(10, theme.colors.surface)
|
|
139
|
+
: theme.colors.surface
|
|
140
|
+
|
|
133
141
|
return (
|
|
134
142
|
<Modal
|
|
135
143
|
animationType={animationType}
|
|
@@ -162,17 +170,7 @@ export function TimePickerModal({
|
|
|
162
170
|
style={[
|
|
163
171
|
styles.modalContent,
|
|
164
172
|
{
|
|
165
|
-
backgroundColor:
|
|
166
|
-
theme.dark && theme.isV3
|
|
167
|
-
? theme.colors.elevation.level3
|
|
168
|
-
: theme.isV3
|
|
169
|
-
? theme.colors.surface
|
|
170
|
-
: theme.dark
|
|
171
|
-
? overlay(10, theme.colors.surface)
|
|
172
|
-
: theme.colors.surface,
|
|
173
|
-
borderRadius: theme.isV3
|
|
174
|
-
? theme.roundness * 6
|
|
175
|
-
: theme.roundness,
|
|
173
|
+
backgroundColor: theme.isV3 ? v3Color : v2Color,
|
|
176
174
|
},
|
|
177
175
|
]}
|
|
178
176
|
>
|