@dreamstack-us/kaal 0.0.1 → 0.0.3
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 +165 -0
- package/lib/module/components/CalendarGrid/CalendarGrid.js +125 -29
- 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 +265 -0
- package/lib/module/components/CalendarGrid/CalendarGrid.web.js.map +1 -0
- package/lib/module/components/CalendarGrid/DayCell.js +77 -53
- package/lib/module/components/CalendarGrid/DayCell.js.map +1 -1
- package/lib/module/components/CalendarGrid/DayCell.web.js +124 -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 +53 -21
- package/lib/module/components/DatePicker/DatePicker.android.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.ios.js +55 -23
- 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 +59 -21
- 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 +24 -3
- 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 +33 -0
- package/lib/typescript/components/CalendarGrid/CalendarGrid.web.d.ts.map +1 -0
- package/lib/typescript/components/CalendarGrid/DayCell.d.ts +3 -0
- package/lib/typescript/components/CalendarGrid/DayCell.d.ts.map +1 -1
- package/lib/typescript/components/CalendarGrid/DayCell.web.d.ts +15 -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 +27 -4
- 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 +78 -3
- 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 +265 -85
- package/src/components/CalendarGrid/CalendarGrid.web.tsx +396 -0
- package/src/components/CalendarGrid/DayCell.tsx +122 -61
- package/src/components/CalendarGrid/DayCell.web.tsx +171 -0
- package/src/components/DatePicker/DatePicker.android.tsx +48 -24
- package/src/components/DatePicker/DatePicker.ios.tsx +51 -27
- package/src/components/DatePicker/DatePicker.styles.ts +18 -22
- package/src/components/DatePicker/DatePicker.tsx +35 -4
- package/src/components/DatePicker/DatePicker.web.tsx +55 -23
- 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 +13 -0
- package/src/types/datepicker.ts +87 -3
- 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
|
@@ -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
|
};
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
3
|
const ITEM_HEIGHT = 44;
|
|
4
4
|
const VISIBLE_ITEMS = 5;
|
|
5
5
|
const CONTAINER_HEIGHT = ITEM_HEIGHT * VISIBLE_ITEMS;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Default styles for TimePicker using plain React Native StyleSheet.
|
|
9
|
+
* Colors use dark theme defaults - consumers override via themeOverrides prop.
|
|
10
|
+
*/
|
|
11
|
+
export const styles = StyleSheet.create({
|
|
8
12
|
// Container styles
|
|
9
13
|
container: {
|
|
10
|
-
backgroundColor:
|
|
11
|
-
borderRadius:
|
|
12
|
-
padding:
|
|
14
|
+
backgroundColor: '#2C2C2E',
|
|
15
|
+
borderRadius: 16,
|
|
16
|
+
padding: 16,
|
|
13
17
|
},
|
|
14
18
|
|
|
15
19
|
// ============ Wheel Picker Styles (iOS) ============
|
|
16
20
|
wheelContainer: {
|
|
17
21
|
flexDirection: 'row',
|
|
18
22
|
height: CONTAINER_HEIGHT,
|
|
19
|
-
backgroundColor:
|
|
20
|
-
|
|
21
|
-
backdropFilter: 'blur(20px)',
|
|
22
|
-
borderRadius: theme.radii.card,
|
|
23
|
+
backgroundColor: '#2C2C2E',
|
|
24
|
+
borderRadius: 16,
|
|
23
25
|
overflow: 'hidden',
|
|
24
26
|
alignItems: 'center',
|
|
25
|
-
paddingHorizontal:
|
|
27
|
+
paddingHorizontal: 8,
|
|
26
28
|
},
|
|
27
29
|
|
|
28
30
|
wheelColumn: {
|
|
@@ -38,8 +40,8 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
38
40
|
left: 4,
|
|
39
41
|
right: 4,
|
|
40
42
|
height: ITEM_HEIGHT,
|
|
41
|
-
backgroundColor:
|
|
42
|
-
borderRadius:
|
|
43
|
+
backgroundColor: 'rgba(120, 120, 128, 0.24)',
|
|
44
|
+
borderRadius: 8,
|
|
43
45
|
zIndex: 0,
|
|
44
46
|
},
|
|
45
47
|
|
|
@@ -55,7 +57,7 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
55
57
|
|
|
56
58
|
wheelItemText: {
|
|
57
59
|
fontSize: 22,
|
|
58
|
-
color:
|
|
60
|
+
color: '#FFFFFF',
|
|
59
61
|
fontWeight: '400',
|
|
60
62
|
opacity: 0.5,
|
|
61
63
|
},
|
|
@@ -68,24 +70,24 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
68
70
|
wheelSeparator: {
|
|
69
71
|
fontSize: 22,
|
|
70
72
|
fontWeight: '500',
|
|
71
|
-
color:
|
|
72
|
-
paddingHorizontal:
|
|
73
|
+
color: '#FFFFFF',
|
|
74
|
+
paddingHorizontal: 4,
|
|
73
75
|
},
|
|
74
76
|
|
|
75
77
|
// ============ Material Time Picker Styles ============
|
|
76
78
|
materialContainer: {
|
|
77
|
-
backgroundColor:
|
|
79
|
+
backgroundColor: '#2C2C2E',
|
|
78
80
|
borderRadius: 28,
|
|
79
|
-
padding:
|
|
81
|
+
padding: 24,
|
|
80
82
|
width: 320,
|
|
81
83
|
},
|
|
82
84
|
|
|
83
85
|
materialHeader: {
|
|
84
86
|
fontSize: 12,
|
|
85
87
|
fontWeight: '500',
|
|
86
|
-
color:
|
|
88
|
+
color: '#8E8E93',
|
|
87
89
|
letterSpacing: 0.5,
|
|
88
|
-
marginBottom:
|
|
90
|
+
marginBottom: 20,
|
|
89
91
|
textTransform: 'uppercase',
|
|
90
92
|
},
|
|
91
93
|
|
|
@@ -94,8 +96,8 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
94
96
|
flexDirection: 'row',
|
|
95
97
|
alignItems: 'center',
|
|
96
98
|
justifyContent: 'center',
|
|
97
|
-
gap:
|
|
98
|
-
marginBottom:
|
|
99
|
+
gap: 12,
|
|
100
|
+
marginBottom: 24,
|
|
99
101
|
},
|
|
100
102
|
|
|
101
103
|
timeFieldsContainer: {
|
|
@@ -104,22 +106,22 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
104
106
|
},
|
|
105
107
|
|
|
106
108
|
timeField: {
|
|
107
|
-
backgroundColor:
|
|
108
|
-
borderRadius:
|
|
109
|
-
paddingVertical:
|
|
110
|
-
paddingHorizontal:
|
|
109
|
+
backgroundColor: '#3A3A3C',
|
|
110
|
+
borderRadius: 8,
|
|
111
|
+
paddingVertical: 12,
|
|
112
|
+
paddingHorizontal: 8,
|
|
111
113
|
minWidth: 80,
|
|
112
114
|
alignItems: 'center',
|
|
113
115
|
},
|
|
114
116
|
|
|
115
117
|
timeFieldActive: {
|
|
116
|
-
backgroundColor:
|
|
118
|
+
backgroundColor: '#4DA6FF',
|
|
117
119
|
},
|
|
118
120
|
|
|
119
121
|
timeFieldText: {
|
|
120
122
|
fontSize: 48,
|
|
121
123
|
fontWeight: '400',
|
|
122
|
-
color:
|
|
124
|
+
color: '#FFFFFF',
|
|
123
125
|
fontVariant: ['tabular-nums'],
|
|
124
126
|
},
|
|
125
127
|
|
|
@@ -130,48 +132,48 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
130
132
|
timeSeparator: {
|
|
131
133
|
fontSize: 48,
|
|
132
134
|
fontWeight: '400',
|
|
133
|
-
color:
|
|
134
|
-
marginHorizontal:
|
|
135
|
+
color: '#FFFFFF',
|
|
136
|
+
marginHorizontal: 4,
|
|
135
137
|
},
|
|
136
138
|
|
|
137
139
|
// Period toggle (AM/PM)
|
|
138
140
|
periodToggleContainer: {
|
|
139
141
|
borderWidth: 1,
|
|
140
|
-
borderColor:
|
|
141
|
-
borderRadius:
|
|
142
|
+
borderColor: '#48484A',
|
|
143
|
+
borderRadius: 8,
|
|
142
144
|
overflow: 'hidden',
|
|
143
145
|
},
|
|
144
146
|
|
|
145
147
|
periodButton: {
|
|
146
|
-
paddingVertical:
|
|
147
|
-
paddingHorizontal:
|
|
148
|
+
paddingVertical: 8,
|
|
149
|
+
paddingHorizontal: 12,
|
|
148
150
|
backgroundColor: 'transparent',
|
|
149
151
|
},
|
|
150
152
|
|
|
151
153
|
periodButtonActive: {
|
|
152
|
-
backgroundColor:
|
|
154
|
+
backgroundColor: 'rgba(77, 166, 255, 0.2)',
|
|
153
155
|
},
|
|
154
156
|
|
|
155
157
|
periodButtonTop: {
|
|
156
158
|
borderBottomWidth: 1,
|
|
157
|
-
borderBottomColor:
|
|
159
|
+
borderBottomColor: '#48484A',
|
|
158
160
|
},
|
|
159
161
|
|
|
160
162
|
periodButtonText: {
|
|
161
163
|
fontSize: 14,
|
|
162
164
|
fontWeight: '500',
|
|
163
|
-
color:
|
|
165
|
+
color: '#8E8E93',
|
|
164
166
|
},
|
|
165
167
|
|
|
166
168
|
periodButtonTextActive: {
|
|
167
|
-
color:
|
|
169
|
+
color: '#4DA6FF',
|
|
168
170
|
},
|
|
169
171
|
|
|
170
172
|
// ============ Clock Face Styles ============
|
|
171
173
|
clockContainer: {
|
|
172
174
|
alignItems: 'center',
|
|
173
175
|
justifyContent: 'center',
|
|
174
|
-
marginBottom:
|
|
176
|
+
marginBottom: 20,
|
|
175
177
|
},
|
|
176
178
|
|
|
177
179
|
// ============ Action Buttons ============
|
|
@@ -182,28 +184,33 @@ export const styles = StyleSheet.create((theme) => ({
|
|
|
182
184
|
},
|
|
183
185
|
|
|
184
186
|
keyboardButton: {
|
|
185
|
-
padding:
|
|
187
|
+
padding: 8,
|
|
186
188
|
},
|
|
187
189
|
|
|
188
190
|
keyboardButtonText: {
|
|
189
191
|
fontSize: 20,
|
|
190
|
-
color:
|
|
192
|
+
color: '#8E8E93',
|
|
191
193
|
},
|
|
192
194
|
|
|
193
195
|
actionButtonsContainer: {
|
|
194
196
|
flexDirection: 'row',
|
|
195
|
-
gap:
|
|
197
|
+
gap: 8,
|
|
196
198
|
},
|
|
197
199
|
|
|
198
200
|
actionButton: {
|
|
199
|
-
paddingVertical:
|
|
200
|
-
paddingHorizontal:
|
|
201
|
+
paddingVertical: 10,
|
|
202
|
+
paddingHorizontal: 16,
|
|
201
203
|
borderRadius: 20,
|
|
202
204
|
},
|
|
203
205
|
|
|
204
206
|
actionButtonText: {
|
|
205
207
|
fontSize: 14,
|
|
206
208
|
fontWeight: '500',
|
|
207
|
-
color:
|
|
209
|
+
color: '#4DA6FF',
|
|
208
210
|
},
|
|
209
|
-
})
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// Export constants for use in components
|
|
214
|
+
export const WHEEL_ITEM_HEIGHT = ITEM_HEIGHT;
|
|
215
|
+
export const WHEEL_VISIBLE_ITEMS = VISIBLE_ITEMS;
|
|
216
|
+
export const WHEEL_CONTAINER_HEIGHT = CONTAINER_HEIGHT;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import { ThemeOverrideProvider } from '../../context/ThemeOverrideContext';
|
|
2
3
|
import type { TimePickerProps } from '../../types/timepicker';
|
|
3
4
|
import { MaterialTimePicker } from './MaterialTimePicker';
|
|
4
5
|
import { TimeWheelPicker } from './TimeWheelPicker';
|
|
@@ -15,21 +16,30 @@ export const TimePicker: React.FC<TimePickerProps> = ({
|
|
|
15
16
|
theme = 'ios',
|
|
16
17
|
is24Hour = false,
|
|
17
18
|
minuteInterval = 1,
|
|
19
|
+
themeOverrides,
|
|
18
20
|
}) => {
|
|
19
21
|
// iOS theme uses wheel picker
|
|
20
22
|
if (theme === 'ios') {
|
|
21
23
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
<ThemeOverrideProvider value={{ timePicker: themeOverrides }}>
|
|
25
|
+
<TimeWheelPicker
|
|
26
|
+
value={value}
|
|
27
|
+
onChange={onChange}
|
|
28
|
+
is24Hour={is24Hour}
|
|
29
|
+
minuteInterval={minuteInterval}
|
|
30
|
+
/>
|
|
31
|
+
</ThemeOverrideProvider>
|
|
28
32
|
);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// Android/native theme uses Material clock face
|
|
32
36
|
return (
|
|
33
|
-
<
|
|
37
|
+
<ThemeOverrideProvider value={{ timePicker: themeOverrides }}>
|
|
38
|
+
<MaterialTimePicker
|
|
39
|
+
value={value}
|
|
40
|
+
onChange={onChange}
|
|
41
|
+
is24Hour={is24Hour}
|
|
42
|
+
/>
|
|
43
|
+
</ThemeOverrideProvider>
|
|
34
44
|
);
|
|
35
45
|
};
|