@dreamstack-us/kaal 0.0.1 → 0.0.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/lib/module/components/CalendarGrid/CalendarGrid.js +47 -13
- package/lib/module/components/CalendarGrid/CalendarGrid.js.map +1 -1
- package/lib/module/components/CalendarGrid/CalendarGrid.styles.js +22 -17
- package/lib/module/components/CalendarGrid/CalendarGrid.styles.js.map +1 -1
- package/lib/module/components/CalendarGrid/CalendarGrid.web.js +203 -0
- package/lib/module/components/CalendarGrid/CalendarGrid.web.js.map +1 -0
- package/lib/module/components/CalendarGrid/DayCell.js +64 -52
- package/lib/module/components/CalendarGrid/DayCell.js.map +1 -1
- package/lib/module/components/CalendarGrid/DayCell.web.js +112 -0
- package/lib/module/components/CalendarGrid/DayCell.web.js.map +1 -0
- package/lib/module/components/CalendarGrid/index.js +1 -1
- package/lib/module/components/CalendarGrid/index.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.android.js +17 -8
- package/lib/module/components/DatePicker/DatePicker.android.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.ios.js +17 -8
- package/lib/module/components/DatePicker/DatePicker.ios.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.styles.js +19 -20
- package/lib/module/components/DatePicker/DatePicker.styles.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.web.js +26 -12
- package/lib/module/components/DatePicker/DatePicker.web.js.map +1 -1
- package/lib/module/components/TimePicker/ClockFace.js +27 -7
- package/lib/module/components/TimePicker/ClockFace.js.map +1 -1
- package/lib/module/components/TimePicker/ClockFace.web.js +253 -0
- package/lib/module/components/TimePicker/ClockFace.web.js.map +1 -0
- package/lib/module/components/TimePicker/MaterialTimePicker.js +68 -16
- package/lib/module/components/TimePicker/MaterialTimePicker.js.map +1 -1
- package/lib/module/components/TimePicker/MaterialTimePicker.web.js +231 -0
- package/lib/module/components/TimePicker/MaterialTimePicker.web.js.map +1 -0
- package/lib/module/components/TimePicker/TimePicker.android.js +13 -6
- package/lib/module/components/TimePicker/TimePicker.android.js.map +1 -1
- package/lib/module/components/TimePicker/TimePicker.ios.js +14 -7
- package/lib/module/components/TimePicker/TimePicker.ios.js.map +1 -1
- package/lib/module/components/TimePicker/TimePicker.styles.js +53 -45
- package/lib/module/components/TimePicker/TimePicker.styles.js.map +1 -1
- package/lib/module/components/TimePicker/TimePicker.web.js +24 -12
- package/lib/module/components/TimePicker/TimePicker.web.js.map +1 -1
- package/lib/module/components/TimePicker/TimeWheelPicker.js +45 -10
- package/lib/module/components/TimePicker/TimeWheelPicker.js.map +1 -1
- package/lib/module/components/TimePicker/TimeWheelPicker.web.js +339 -0
- package/lib/module/components/TimePicker/TimeWheelPicker.web.js.map +1 -0
- package/lib/module/components/TimePicker/index.js +3 -3
- package/lib/module/components/TimePicker/index.js.map +1 -1
- package/lib/module/components/WheelPicker/WheelPicker.js +21 -2
- package/lib/module/components/WheelPicker/WheelPicker.js.map +1 -1
- package/lib/module/components/WheelPicker/WheelPicker.styles.js +13 -8
- package/lib/module/components/WheelPicker/WheelPicker.styles.js.map +1 -1
- package/lib/module/components/WheelPicker/WheelPicker.web.js +146 -57
- package/lib/module/components/WheelPicker/WheelPicker.web.js.map +1 -1
- package/lib/module/context/ThemeOverrideContext.js +34 -0
- package/lib/module/context/ThemeOverrideContext.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/validation.js +74 -34
- package/lib/module/utils/validation.js.map +1 -1
- package/lib/typescript/components/CalendarGrid/CalendarGrid.d.ts +9 -0
- package/lib/typescript/components/CalendarGrid/CalendarGrid.d.ts.map +1 -1
- package/lib/typescript/components/CalendarGrid/CalendarGrid.styles.d.ts +12 -10
- package/lib/typescript/components/CalendarGrid/CalendarGrid.styles.d.ts.map +1 -1
- package/lib/typescript/components/CalendarGrid/CalendarGrid.web.d.ts +21 -0
- package/lib/typescript/components/CalendarGrid/CalendarGrid.web.d.ts.map +1 -0
- package/lib/typescript/components/CalendarGrid/DayCell.d.ts.map +1 -1
- package/lib/typescript/components/CalendarGrid/DayCell.web.d.ts +12 -0
- package/lib/typescript/components/CalendarGrid/DayCell.web.d.ts.map +1 -0
- package/lib/typescript/components/DatePicker/DatePicker.android.d.ts.map +1 -1
- package/lib/typescript/components/DatePicker/DatePicker.d.ts +12 -1
- package/lib/typescript/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/typescript/components/DatePicker/DatePicker.ios.d.ts.map +1 -1
- package/lib/typescript/components/DatePicker/DatePicker.styles.d.ts +12 -13
- package/lib/typescript/components/DatePicker/DatePicker.styles.d.ts.map +1 -1
- package/lib/typescript/components/DatePicker/DatePicker.web.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/ClockFace.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/ClockFace.web.d.ts +12 -0
- package/lib/typescript/components/TimePicker/ClockFace.web.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/MaterialTimePicker.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/MaterialTimePicker.web.d.ts +12 -0
- package/lib/typescript/components/TimePicker/MaterialTimePicker.web.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/TimePicker.android.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/TimePicker.ios.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/TimePicker.styles.d.ts +29 -25
- package/lib/typescript/components/TimePicker/TimePicker.styles.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/TimePicker.web.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/TimeWheelPicker.d.ts.map +1 -1
- package/lib/typescript/components/TimePicker/TimeWheelPicker.web.d.ts +11 -0
- package/lib/typescript/components/TimePicker/TimeWheelPicker.web.d.ts.map +1 -0
- package/lib/typescript/components/WheelPicker/WheelPicker.d.ts +14 -1
- package/lib/typescript/components/WheelPicker/WheelPicker.d.ts.map +1 -1
- package/lib/typescript/components/WheelPicker/WheelPicker.styles.d.ts +9 -7
- package/lib/typescript/components/WheelPicker/WheelPicker.styles.d.ts.map +1 -1
- package/lib/typescript/components/WheelPicker/WheelPicker.web.d.ts.map +1 -1
- package/lib/typescript/context/ThemeOverrideContext.d.ts +23 -0
- package/lib/typescript/context/ThemeOverrideContext.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/datepicker.d.ts +41 -0
- package/lib/typescript/types/datepicker.d.ts.map +1 -1
- package/lib/typescript/types/timepicker.d.ts +62 -0
- package/lib/typescript/types/timepicker.d.ts.map +1 -1
- package/lib/typescript/utils/validation.d.ts +47 -27
- package/lib/typescript/utils/validation.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/CalendarGrid/CalendarGrid.styles.ts +21 -17
- package/src/components/CalendarGrid/CalendarGrid.tsx +98 -12
- package/src/components/CalendarGrid/CalendarGrid.web.tsx +305 -0
- package/src/components/CalendarGrid/DayCell.tsx +78 -59
- package/src/components/CalendarGrid/DayCell.web.tsx +129 -0
- package/src/components/DatePicker/DatePicker.android.tsx +14 -8
- package/src/components/DatePicker/DatePicker.ios.tsx +14 -8
- package/src/components/DatePicker/DatePicker.styles.ts +18 -22
- package/src/components/DatePicker/DatePicker.tsx +12 -1
- package/src/components/DatePicker/DatePicker.web.tsx +21 -13
- package/src/components/TimePicker/ClockFace.tsx +34 -8
- package/src/components/TimePicker/ClockFace.web.tsx +303 -0
- package/src/components/TimePicker/MaterialTimePicker.tsx +144 -13
- package/src/components/TimePicker/MaterialTimePicker.web.tsx +271 -0
- package/src/components/TimePicker/TimePicker.android.tsx +9 -1
- package/src/components/TimePicker/TimePicker.ios.tsx +10 -6
- package/src/components/TimePicker/TimePicker.styles.ts +52 -45
- package/src/components/TimePicker/TimePicker.web.tsx +17 -7
- package/src/components/TimePicker/TimeWheelPicker.tsx +60 -6
- package/src/components/TimePicker/TimeWheelPicker.web.tsx +401 -0
- package/src/components/WheelPicker/WheelPicker.styles.ts +12 -8
- package/src/components/WheelPicker/WheelPicker.tsx +24 -2
- package/src/components/WheelPicker/WheelPicker.web.tsx +153 -57
- package/src/context/ThemeOverrideContext.tsx +38 -0
- package/src/index.ts +11 -0
- package/src/types/datepicker.ts +44 -0
- package/src/types/timepicker.ts +74 -0
- package/src/utils/validation.ts +111 -55
- package/lib/module/unistyles.js +0 -9
- package/lib/module/unistyles.js.map +0 -1
- package/lib/typescript/unistyles.d.ts +0 -3
- package/lib/typescript/unistyles.d.ts.map +0 -1
- package/src/unistyles.ts +0 -6
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { Pressable, Text, View } from 'react-native';
|
|
4
|
+
import { useTimePickerOverrides } from '../../context/ThemeOverrideContext';
|
|
4
5
|
import { to12Hour, to24Hour } from '../../hooks/useTimePicker';
|
|
5
6
|
import type { ClockMode, TimePeriod, TimeValue } from '../../types/timepicker';
|
|
6
7
|
import { ClockFace } from './ClockFace';
|
|
7
8
|
import { styles } from './TimePicker.styles';
|
|
8
9
|
|
|
10
|
+
// Default colors (dark theme)
|
|
11
|
+
const DEFAULT_COLORS = {
|
|
12
|
+
containerBackground: '#2C2C2E',
|
|
13
|
+
headerColor: '#8E8E93',
|
|
14
|
+
timeFieldBackground: '#3A3A3C',
|
|
15
|
+
timeFieldActiveBackground: '#4DA6FF',
|
|
16
|
+
textColor: '#FFFFFF',
|
|
17
|
+
separatorColor: '#FFFFFF',
|
|
18
|
+
borderColor: '#48484A',
|
|
19
|
+
periodActiveBackground: 'rgba(77, 166, 255, 0.2)',
|
|
20
|
+
periodTextColor: '#8E8E93',
|
|
21
|
+
periodTextActiveColor: '#4DA6FF',
|
|
22
|
+
actionButtonColor: '#4DA6FF',
|
|
23
|
+
};
|
|
24
|
+
|
|
9
25
|
interface MaterialTimePickerProps {
|
|
10
26
|
value: TimeValue;
|
|
11
27
|
onChange: (time: TimeValue) => void;
|
|
@@ -16,6 +32,7 @@ interface MaterialTimePickerProps {
|
|
|
16
32
|
|
|
17
33
|
export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
18
34
|
({ value, onChange, is24Hour = false, onCancel, onConfirm }) => {
|
|
35
|
+
const overrides = useTimePickerOverrides();
|
|
19
36
|
const [mode, setMode] = useState<ClockMode>('hours');
|
|
20
37
|
const { hour: hour12, period } = to12Hour(value.hours);
|
|
21
38
|
|
|
@@ -45,10 +62,96 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
45
62
|
: hour12.toString().padStart(2, '0');
|
|
46
63
|
const displayMinute = value.minutes.toString().padStart(2, '0');
|
|
47
64
|
|
|
65
|
+
// Build override styles
|
|
66
|
+
const containerStyle = useMemo(
|
|
67
|
+
() => ({
|
|
68
|
+
backgroundColor:
|
|
69
|
+
overrides?.containerBackground ?? DEFAULT_COLORS.containerBackground,
|
|
70
|
+
}),
|
|
71
|
+
[overrides],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const headerStyle = useMemo(
|
|
75
|
+
() => ({
|
|
76
|
+
color: overrides?.headerColor ?? DEFAULT_COLORS.headerColor,
|
|
77
|
+
}),
|
|
78
|
+
[overrides],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const timeFieldStyle = useMemo(
|
|
82
|
+
() => ({
|
|
83
|
+
backgroundColor:
|
|
84
|
+
overrides?.timeFieldBackground ?? DEFAULT_COLORS.timeFieldBackground,
|
|
85
|
+
}),
|
|
86
|
+
[overrides],
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const timeFieldActiveStyle = useMemo(
|
|
90
|
+
() => ({
|
|
91
|
+
backgroundColor:
|
|
92
|
+
overrides?.timeFieldActiveBackground ??
|
|
93
|
+
DEFAULT_COLORS.timeFieldActiveBackground,
|
|
94
|
+
}),
|
|
95
|
+
[overrides],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const textStyle = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
color: overrides?.textColor ?? DEFAULT_COLORS.textColor,
|
|
101
|
+
}),
|
|
102
|
+
[overrides],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const separatorStyle = useMemo(
|
|
106
|
+
() => ({
|
|
107
|
+
color: overrides?.separatorColor ?? DEFAULT_COLORS.separatorColor,
|
|
108
|
+
}),
|
|
109
|
+
[overrides],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const periodContainerStyle = useMemo(
|
|
113
|
+
() => ({
|
|
114
|
+
borderColor: overrides?.periodBorderColor ?? DEFAULT_COLORS.borderColor,
|
|
115
|
+
}),
|
|
116
|
+
[overrides],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const periodActiveStyle = useMemo(
|
|
120
|
+
() => ({
|
|
121
|
+
backgroundColor:
|
|
122
|
+
overrides?.periodActiveBackground ??
|
|
123
|
+
DEFAULT_COLORS.periodActiveBackground,
|
|
124
|
+
}),
|
|
125
|
+
[overrides],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const periodTextStyle = useMemo(
|
|
129
|
+
() => ({
|
|
130
|
+
color: overrides?.periodTextColor ?? DEFAULT_COLORS.periodTextColor,
|
|
131
|
+
}),
|
|
132
|
+
[overrides],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const periodTextActiveStyle = useMemo(
|
|
136
|
+
() => ({
|
|
137
|
+
color:
|
|
138
|
+
overrides?.periodTextActiveColor ??
|
|
139
|
+
DEFAULT_COLORS.periodTextActiveColor,
|
|
140
|
+
}),
|
|
141
|
+
[overrides],
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const actionButtonTextStyle = useMemo(
|
|
145
|
+
() => ({
|
|
146
|
+
color: overrides?.actionButtonColor ?? DEFAULT_COLORS.actionButtonColor,
|
|
147
|
+
}),
|
|
148
|
+
[overrides],
|
|
149
|
+
);
|
|
150
|
+
|
|
48
151
|
return (
|
|
49
|
-
<View style={styles.materialContainer}>
|
|
152
|
+
<View style={[styles.materialContainer, containerStyle]}>
|
|
50
153
|
{/* Header */}
|
|
51
|
-
<Text style={styles.materialHeader}>Select time</Text>
|
|
154
|
+
<Text style={[styles.materialHeader, headerStyle]}>Select time</Text>
|
|
52
155
|
|
|
53
156
|
{/* Time Input Display */}
|
|
54
157
|
<View style={styles.timeInputContainer}>
|
|
@@ -58,12 +161,17 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
58
161
|
onPress={handleHourPress}
|
|
59
162
|
style={[
|
|
60
163
|
styles.timeField,
|
|
61
|
-
|
|
164
|
+
timeFieldStyle,
|
|
165
|
+
mode === 'hours' && [
|
|
166
|
+
styles.timeFieldActive,
|
|
167
|
+
timeFieldActiveStyle,
|
|
168
|
+
],
|
|
62
169
|
]}
|
|
63
170
|
>
|
|
64
171
|
<Text
|
|
65
172
|
style={[
|
|
66
173
|
styles.timeFieldText,
|
|
174
|
+
textStyle,
|
|
67
175
|
mode === 'hours' && styles.timeFieldTextActive,
|
|
68
176
|
]}
|
|
69
177
|
>
|
|
@@ -72,19 +180,24 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
72
180
|
</Pressable>
|
|
73
181
|
|
|
74
182
|
{/* Separator */}
|
|
75
|
-
<Text style={styles.timeSeparator}>:</Text>
|
|
183
|
+
<Text style={[styles.timeSeparator, separatorStyle]}>:</Text>
|
|
76
184
|
|
|
77
185
|
{/* Minute Field */}
|
|
78
186
|
<Pressable
|
|
79
187
|
onPress={handleMinutePress}
|
|
80
188
|
style={[
|
|
81
189
|
styles.timeField,
|
|
82
|
-
|
|
190
|
+
timeFieldStyle,
|
|
191
|
+
mode === 'minutes' && [
|
|
192
|
+
styles.timeFieldActive,
|
|
193
|
+
timeFieldActiveStyle,
|
|
194
|
+
],
|
|
83
195
|
]}
|
|
84
196
|
>
|
|
85
197
|
<Text
|
|
86
198
|
style={[
|
|
87
199
|
styles.timeFieldText,
|
|
200
|
+
textStyle,
|
|
88
201
|
mode === 'minutes' && styles.timeFieldTextActive,
|
|
89
202
|
]}
|
|
90
203
|
>
|
|
@@ -95,19 +208,26 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
95
208
|
|
|
96
209
|
{/* AM/PM Toggle (only for 12-hour format) */}
|
|
97
210
|
{!is24Hour && (
|
|
98
|
-
<View style={styles.periodToggleContainer}>
|
|
211
|
+
<View style={[styles.periodToggleContainer, periodContainerStyle]}>
|
|
99
212
|
<Pressable
|
|
100
213
|
onPress={() => handlePeriodChange('AM')}
|
|
101
214
|
style={[
|
|
102
215
|
styles.periodButton,
|
|
103
216
|
styles.periodButtonTop,
|
|
104
|
-
period === 'AM' &&
|
|
217
|
+
period === 'AM' && [
|
|
218
|
+
styles.periodButtonActive,
|
|
219
|
+
periodActiveStyle,
|
|
220
|
+
],
|
|
105
221
|
]}
|
|
106
222
|
>
|
|
107
223
|
<Text
|
|
108
224
|
style={[
|
|
109
225
|
styles.periodButtonText,
|
|
110
|
-
|
|
226
|
+
periodTextStyle,
|
|
227
|
+
period === 'AM' && [
|
|
228
|
+
styles.periodButtonTextActive,
|
|
229
|
+
periodTextActiveStyle,
|
|
230
|
+
],
|
|
111
231
|
]}
|
|
112
232
|
>
|
|
113
233
|
AM
|
|
@@ -117,13 +237,20 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
117
237
|
onPress={() => handlePeriodChange('PM')}
|
|
118
238
|
style={[
|
|
119
239
|
styles.periodButton,
|
|
120
|
-
period === 'PM' &&
|
|
240
|
+
period === 'PM' && [
|
|
241
|
+
styles.periodButtonActive,
|
|
242
|
+
periodActiveStyle,
|
|
243
|
+
],
|
|
121
244
|
]}
|
|
122
245
|
>
|
|
123
246
|
<Text
|
|
124
247
|
style={[
|
|
125
248
|
styles.periodButtonText,
|
|
126
|
-
|
|
249
|
+
periodTextStyle,
|
|
250
|
+
period === 'PM' && [
|
|
251
|
+
styles.periodButtonTextActive,
|
|
252
|
+
periodTextActiveStyle,
|
|
253
|
+
],
|
|
127
254
|
]}
|
|
128
255
|
>
|
|
129
256
|
PM
|
|
@@ -151,12 +278,16 @@ export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
|
151
278
|
<View style={styles.actionButtonsContainer}>
|
|
152
279
|
{onCancel && (
|
|
153
280
|
<Pressable style={styles.actionButton} onPress={onCancel}>
|
|
154
|
-
<Text style={styles.actionButtonText}>
|
|
281
|
+
<Text style={[styles.actionButtonText, actionButtonTextStyle]}>
|
|
282
|
+
Cancel
|
|
283
|
+
</Text>
|
|
155
284
|
</Pressable>
|
|
156
285
|
)}
|
|
157
286
|
{onConfirm && (
|
|
158
287
|
<Pressable style={styles.actionButton} onPress={onConfirm}>
|
|
159
|
-
<Text style={styles.actionButtonText}>
|
|
288
|
+
<Text style={[styles.actionButtonText, actionButtonTextStyle]}>
|
|
289
|
+
OK
|
|
290
|
+
</Text>
|
|
160
291
|
</Pressable>
|
|
161
292
|
)}
|
|
162
293
|
</View>
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import { memo, useCallback, useState } from 'react';
|
|
4
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
|
+
import { to12Hour, to24Hour } from '../../hooks/useTimePicker';
|
|
6
|
+
import type { ClockMode, TimePeriod, TimeValue } from '../../types/timepicker';
|
|
7
|
+
import { ClockFace } from './ClockFace';
|
|
8
|
+
|
|
9
|
+
interface MaterialTimePickerProps {
|
|
10
|
+
value: TimeValue;
|
|
11
|
+
onChange: (time: TimeValue) => void;
|
|
12
|
+
is24Hour?: boolean;
|
|
13
|
+
onCancel?: () => void;
|
|
14
|
+
onConfirm?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Web-compatible styles (no unistyles dependency)
|
|
18
|
+
const webStyles = StyleSheet.create({
|
|
19
|
+
materialContainer: {
|
|
20
|
+
backgroundColor: '#2C2C2E',
|
|
21
|
+
borderRadius: 28,
|
|
22
|
+
padding: 24,
|
|
23
|
+
width: 320,
|
|
24
|
+
},
|
|
25
|
+
materialHeader: {
|
|
26
|
+
fontSize: 12,
|
|
27
|
+
fontWeight: '500',
|
|
28
|
+
color: '#8E8E93',
|
|
29
|
+
letterSpacing: 0.5,
|
|
30
|
+
marginBottom: 20,
|
|
31
|
+
textTransform: 'uppercase',
|
|
32
|
+
},
|
|
33
|
+
timeInputContainer: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
gap: 12,
|
|
38
|
+
marginBottom: 24,
|
|
39
|
+
},
|
|
40
|
+
timeFieldsContainer: {
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
},
|
|
44
|
+
timeField: {
|
|
45
|
+
backgroundColor: '#3A3A3C',
|
|
46
|
+
borderRadius: 8,
|
|
47
|
+
paddingVertical: 12,
|
|
48
|
+
paddingHorizontal: 8,
|
|
49
|
+
minWidth: 80,
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
},
|
|
52
|
+
timeFieldActive: {
|
|
53
|
+
backgroundColor: '#007AFF',
|
|
54
|
+
},
|
|
55
|
+
timeFieldText: {
|
|
56
|
+
fontSize: 48,
|
|
57
|
+
fontWeight: '400',
|
|
58
|
+
color: '#FFFFFF',
|
|
59
|
+
},
|
|
60
|
+
timeFieldTextActive: {
|
|
61
|
+
color: '#FFFFFF',
|
|
62
|
+
},
|
|
63
|
+
timeSeparator: {
|
|
64
|
+
fontSize: 48,
|
|
65
|
+
fontWeight: '400',
|
|
66
|
+
color: '#FFFFFF',
|
|
67
|
+
marginHorizontal: 4,
|
|
68
|
+
},
|
|
69
|
+
periodToggleContainer: {
|
|
70
|
+
borderWidth: 1,
|
|
71
|
+
borderColor: '#48484A',
|
|
72
|
+
borderRadius: 8,
|
|
73
|
+
overflow: 'hidden',
|
|
74
|
+
},
|
|
75
|
+
periodButton: {
|
|
76
|
+
paddingVertical: 8,
|
|
77
|
+
paddingHorizontal: 12,
|
|
78
|
+
backgroundColor: 'transparent',
|
|
79
|
+
},
|
|
80
|
+
periodButtonActive: {
|
|
81
|
+
backgroundColor: 'rgba(0, 122, 255, 0.2)',
|
|
82
|
+
},
|
|
83
|
+
periodButtonTop: {
|
|
84
|
+
borderBottomWidth: 1,
|
|
85
|
+
borderBottomColor: '#48484A',
|
|
86
|
+
},
|
|
87
|
+
periodButtonText: {
|
|
88
|
+
fontSize: 14,
|
|
89
|
+
fontWeight: '500',
|
|
90
|
+
color: '#8E8E93',
|
|
91
|
+
},
|
|
92
|
+
periodButtonTextActive: {
|
|
93
|
+
color: '#007AFF',
|
|
94
|
+
},
|
|
95
|
+
clockContainer: {
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
marginBottom: 20,
|
|
99
|
+
},
|
|
100
|
+
actionsContainer: {
|
|
101
|
+
flexDirection: 'row',
|
|
102
|
+
justifyContent: 'space-between',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
},
|
|
105
|
+
keyboardButton: {
|
|
106
|
+
padding: 8,
|
|
107
|
+
},
|
|
108
|
+
keyboardButtonText: {
|
|
109
|
+
fontSize: 20,
|
|
110
|
+
color: '#8E8E93',
|
|
111
|
+
},
|
|
112
|
+
actionButtonsContainer: {
|
|
113
|
+
flexDirection: 'row',
|
|
114
|
+
gap: 8,
|
|
115
|
+
},
|
|
116
|
+
actionButton: {
|
|
117
|
+
paddingVertical: 10,
|
|
118
|
+
paddingHorizontal: 16,
|
|
119
|
+
borderRadius: 20,
|
|
120
|
+
},
|
|
121
|
+
actionButtonText: {
|
|
122
|
+
fontSize: 14,
|
|
123
|
+
fontWeight: '500',
|
|
124
|
+
color: '#007AFF',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const MaterialTimePicker: React.FC<MaterialTimePickerProps> = memo(
|
|
129
|
+
({ value, onChange, is24Hour = false, onCancel, onConfirm }) => {
|
|
130
|
+
const [mode, setMode] = useState<ClockMode>('hours');
|
|
131
|
+
const { hour: hour12, period } = to12Hour(value.hours);
|
|
132
|
+
|
|
133
|
+
const handleHourPress = useCallback(() => {
|
|
134
|
+
setMode('hours');
|
|
135
|
+
}, []);
|
|
136
|
+
|
|
137
|
+
const handleMinutePress = useCallback(() => {
|
|
138
|
+
setMode('minutes');
|
|
139
|
+
}, []);
|
|
140
|
+
|
|
141
|
+
const handlePeriodChange = useCallback(
|
|
142
|
+
(newPeriod: TimePeriod) => {
|
|
143
|
+
const newHours = to24Hour(hour12, newPeriod);
|
|
144
|
+
onChange({ hours: newHours, minutes: value.minutes });
|
|
145
|
+
},
|
|
146
|
+
[hour12, value.minutes, onChange],
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const handleModeChange = useCallback((newMode: ClockMode) => {
|
|
150
|
+
setMode(newMode);
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
const displayHour = is24Hour
|
|
154
|
+
? value.hours.toString().padStart(2, '0')
|
|
155
|
+
: hour12.toString().padStart(2, '0');
|
|
156
|
+
const displayMinute = value.minutes.toString().padStart(2, '0');
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<View style={webStyles.materialContainer}>
|
|
160
|
+
<Text style={webStyles.materialHeader}>Select time</Text>
|
|
161
|
+
|
|
162
|
+
<View style={webStyles.timeInputContainer}>
|
|
163
|
+
<View style={webStyles.timeFieldsContainer}>
|
|
164
|
+
<Pressable
|
|
165
|
+
onPress={handleHourPress}
|
|
166
|
+
style={[
|
|
167
|
+
webStyles.timeField,
|
|
168
|
+
mode === 'hours' && webStyles.timeFieldActive,
|
|
169
|
+
]}
|
|
170
|
+
>
|
|
171
|
+
<Text
|
|
172
|
+
style={[
|
|
173
|
+
webStyles.timeFieldText,
|
|
174
|
+
mode === 'hours' && webStyles.timeFieldTextActive,
|
|
175
|
+
]}
|
|
176
|
+
>
|
|
177
|
+
{displayHour}
|
|
178
|
+
</Text>
|
|
179
|
+
</Pressable>
|
|
180
|
+
|
|
181
|
+
<Text style={webStyles.timeSeparator}>:</Text>
|
|
182
|
+
|
|
183
|
+
<Pressable
|
|
184
|
+
onPress={handleMinutePress}
|
|
185
|
+
style={[
|
|
186
|
+
webStyles.timeField,
|
|
187
|
+
mode === 'minutes' && webStyles.timeFieldActive,
|
|
188
|
+
]}
|
|
189
|
+
>
|
|
190
|
+
<Text
|
|
191
|
+
style={[
|
|
192
|
+
webStyles.timeFieldText,
|
|
193
|
+
mode === 'minutes' && webStyles.timeFieldTextActive,
|
|
194
|
+
]}
|
|
195
|
+
>
|
|
196
|
+
{displayMinute}
|
|
197
|
+
</Text>
|
|
198
|
+
</Pressable>
|
|
199
|
+
</View>
|
|
200
|
+
|
|
201
|
+
{!is24Hour && (
|
|
202
|
+
<View style={webStyles.periodToggleContainer}>
|
|
203
|
+
<Pressable
|
|
204
|
+
onPress={() => handlePeriodChange('AM')}
|
|
205
|
+
style={[
|
|
206
|
+
webStyles.periodButton,
|
|
207
|
+
webStyles.periodButtonTop,
|
|
208
|
+
period === 'AM' && webStyles.periodButtonActive,
|
|
209
|
+
]}
|
|
210
|
+
>
|
|
211
|
+
<Text
|
|
212
|
+
style={[
|
|
213
|
+
webStyles.periodButtonText,
|
|
214
|
+
period === 'AM' && webStyles.periodButtonTextActive,
|
|
215
|
+
]}
|
|
216
|
+
>
|
|
217
|
+
AM
|
|
218
|
+
</Text>
|
|
219
|
+
</Pressable>
|
|
220
|
+
<Pressable
|
|
221
|
+
onPress={() => handlePeriodChange('PM')}
|
|
222
|
+
style={[
|
|
223
|
+
webStyles.periodButton,
|
|
224
|
+
period === 'PM' && webStyles.periodButtonActive,
|
|
225
|
+
]}
|
|
226
|
+
>
|
|
227
|
+
<Text
|
|
228
|
+
style={[
|
|
229
|
+
webStyles.periodButtonText,
|
|
230
|
+
period === 'PM' && webStyles.periodButtonTextActive,
|
|
231
|
+
]}
|
|
232
|
+
>
|
|
233
|
+
PM
|
|
234
|
+
</Text>
|
|
235
|
+
</Pressable>
|
|
236
|
+
</View>
|
|
237
|
+
)}
|
|
238
|
+
</View>
|
|
239
|
+
|
|
240
|
+
<ClockFace
|
|
241
|
+
value={value}
|
|
242
|
+
onChange={onChange}
|
|
243
|
+
mode={mode}
|
|
244
|
+
onModeChange={handleModeChange}
|
|
245
|
+
is24Hour={is24Hour}
|
|
246
|
+
/>
|
|
247
|
+
|
|
248
|
+
<View style={webStyles.actionsContainer}>
|
|
249
|
+
<Pressable style={webStyles.keyboardButton}>
|
|
250
|
+
<Text style={webStyles.keyboardButtonText}>⌨️</Text>
|
|
251
|
+
</Pressable>
|
|
252
|
+
|
|
253
|
+
<View style={webStyles.actionButtonsContainer}>
|
|
254
|
+
{onCancel && (
|
|
255
|
+
<Pressable style={webStyles.actionButton} onPress={onCancel}>
|
|
256
|
+
<Text style={webStyles.actionButtonText}>Cancel</Text>
|
|
257
|
+
</Pressable>
|
|
258
|
+
)}
|
|
259
|
+
{onConfirm && (
|
|
260
|
+
<Pressable style={webStyles.actionButton} onPress={onConfirm}>
|
|
261
|
+
<Text style={webStyles.actionButtonText}>OK</Text>
|
|
262
|
+
</Pressable>
|
|
263
|
+
)}
|
|
264
|
+
</View>
|
|
265
|
+
</View>
|
|
266
|
+
</View>
|
|
267
|
+
);
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
MaterialTimePicker.displayName = 'MaterialTimePicker';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Suspense, useCallback } from 'react';
|
|
2
2
|
import { ActivityIndicator, View } from 'react-native';
|
|
3
|
+
import { ThemeOverrideProvider } from '../../context/ThemeOverrideContext';
|
|
3
4
|
import type { TimePickerProps, TimeValue } from '../../types/timepicker';
|
|
4
5
|
import { MaterialTimePicker } from './MaterialTimePicker';
|
|
5
6
|
import { styles } from './TimePicker.styles';
|
|
@@ -50,6 +51,7 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
50
51
|
onChange,
|
|
51
52
|
theme = 'native',
|
|
52
53
|
is24Hour = false,
|
|
54
|
+
themeOverrides,
|
|
53
55
|
}) => {
|
|
54
56
|
const handleTimeChange = useCallback(
|
|
55
57
|
(time: TimeValue) => {
|
|
@@ -75,6 +77,12 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
75
77
|
|
|
76
78
|
// Use Material-style picker for 'android' or 'ios' themes
|
|
77
79
|
return (
|
|
78
|
-
<
|
|
80
|
+
<ThemeOverrideProvider value={{ timePicker: themeOverrides }}>
|
|
81
|
+
<MaterialTimePicker
|
|
82
|
+
value={value}
|
|
83
|
+
onChange={onChange}
|
|
84
|
+
is24Hour={is24Hour}
|
|
85
|
+
/>
|
|
86
|
+
</ThemeOverrideProvider>
|
|
79
87
|
);
|
|
80
88
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Suspense, useCallback } from 'react';
|
|
2
2
|
import { ActivityIndicator, View } from 'react-native';
|
|
3
|
+
import { ThemeOverrideProvider } from '../../context/ThemeOverrideContext';
|
|
3
4
|
import type { TimePickerProps, TimeValue } from '../../types/timepicker';
|
|
4
5
|
import { styles } from './TimePicker.styles';
|
|
5
6
|
import { TimeWheelPicker } from './TimeWheelPicker';
|
|
@@ -53,6 +54,7 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
53
54
|
theme = 'native',
|
|
54
55
|
is24Hour = false,
|
|
55
56
|
minuteInterval = 1,
|
|
57
|
+
themeOverrides,
|
|
56
58
|
}) => {
|
|
57
59
|
const handleTimeChange = useCallback(
|
|
58
60
|
(time: TimeValue) => {
|
|
@@ -78,11 +80,13 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
78
80
|
|
|
79
81
|
// Fallback to wheel picker for other themes
|
|
80
82
|
return (
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
<ThemeOverrideProvider value={{ timePicker: themeOverrides }}>
|
|
84
|
+
<TimeWheelPicker
|
|
85
|
+
value={value}
|
|
86
|
+
onChange={onChange}
|
|
87
|
+
is24Hour={is24Hour}
|
|
88
|
+
minuteInterval={minuteInterval}
|
|
89
|
+
/>
|
|
90
|
+
</ThemeOverrideProvider>
|
|
87
91
|
);
|
|
88
92
|
};
|