@ledvance/ui-biz-bundle 1.1.66 → 1.1.68
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/package.json +1 -1
- package/src/navigation/Routers.ts +2 -0
- package/src/newModules/biorhythm/BiorhythmPage.tsx +11 -7
- package/src/newModules/fixedTime/FixedTimePage.tsx +4 -3
- package/src/newModules/randomTime/RandomTimePage.tsx +4 -3
- package/src/newModules/remoteControl/RemoteControlActions.ts +6 -0
- package/src/newModules/remoteControl/RemoteControlPage.tsx +51 -0
- package/src/newModules/remoteControl/Router.ts +16 -0
- package/src/newModules/sleepWakeUp/Interface.ts +70 -0
- package/src/newModules/sleepWakeUp/Router.ts +25 -0
- package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +317 -0
- package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +661 -0
- package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +456 -0
- package/src/newModules/sleepWakeUp/utils.ts +254 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { ScrollView, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
import Page from '@ledvance/base/src/components/Page';
|
|
5
|
+
import I18n from '@ledvance/base/src/i18n';
|
|
6
|
+
import res from '@ledvance/base/src/res';
|
|
7
|
+
import { TimerPicker, Utils } from 'tuya-panel-kit';
|
|
8
|
+
import { useReactive, useUpdateEffect } from 'ahooks';
|
|
9
|
+
import TextField from '@ledvance/base/src/components/TextField';
|
|
10
|
+
import LdvPickerView from '@ledvance/base/src/components/ldvPickerView';
|
|
11
|
+
import LdvWeekView from '@ledvance/base/src/components/weekSelect';
|
|
12
|
+
import {
|
|
13
|
+
convertMinutesTo12HourFormat,
|
|
14
|
+
loopText,
|
|
15
|
+
showDialog,
|
|
16
|
+
} from '@ledvance/base/src/utils/common';
|
|
17
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
18
|
+
import DeleteButton from '@ledvance/base/src/components/DeleteButton';
|
|
19
|
+
import { SleepWakeUpPageRouteParams } from './SleepWakeUpPage';
|
|
20
|
+
import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
|
|
21
|
+
import { cloneDeep, isEqual } from 'lodash';
|
|
22
|
+
import { SleepUIItem, WakeUpUIItem } from './Interface';
|
|
23
|
+
import { useSystemTimeFormate } from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
24
|
+
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
25
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
|
|
26
|
+
import Card from '@ledvance/base/src/components/Card';
|
|
27
|
+
import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
|
|
28
|
+
import { cctToColor } from '@ledvance/base/src/utils/cctUtils';
|
|
29
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks';
|
|
30
|
+
import ColorTempAdjustView from '@ledvance/base/src/components/ColorTempAdjustView';
|
|
31
|
+
import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
|
|
32
|
+
import Summary from '@ledvance/base/src/components/Summary';
|
|
33
|
+
|
|
34
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
35
|
+
const { toFixedString } = Utils.NumberUtils;
|
|
36
|
+
|
|
37
|
+
interface SleepWakeUpDetailPageProps extends SleepWakeUpPageRouteParams {
|
|
38
|
+
mode: 'add' | 'edit';
|
|
39
|
+
isSleep: boolean;
|
|
40
|
+
scheduleItem: any;
|
|
41
|
+
modDeleteTimeSchedule: (
|
|
42
|
+
mode: 'add' | 'edit' | 'del',
|
|
43
|
+
isSleep: boolean,
|
|
44
|
+
sleepWakeUp: SleepUIItem | WakeUpUIItem
|
|
45
|
+
) => Promise<Result<any>>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const SleepWakeUpDetailPage = () => {
|
|
49
|
+
const navigation = useNavigation();
|
|
50
|
+
const props = useParams<SleepWakeUpDetailPageProps>();
|
|
51
|
+
const is24HourClock = useSystemTimeFormate();
|
|
52
|
+
const state = useReactive({
|
|
53
|
+
sleepWakeUp: cloneDeep(props.scheduleItem) as WakeUpUIItem,
|
|
54
|
+
loading: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (props.mode !== 'edit') return;
|
|
59
|
+
if (state.sleepWakeUp.isColorMode) {
|
|
60
|
+
state.sleepWakeUp.brightness = 100;
|
|
61
|
+
} else {
|
|
62
|
+
state.sleepWakeUp.s = 100;
|
|
63
|
+
state.sleepWakeUp.v = 100;
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
67
|
+
useUpdateEffect(() => {
|
|
68
|
+
if (state.sleepWakeUp.delay === 0) {
|
|
69
|
+
state.sleepWakeUp.delay = 1;
|
|
70
|
+
}
|
|
71
|
+
if (state.sleepWakeUp.delay > 24) {
|
|
72
|
+
state.sleepWakeUp.delay = 24;
|
|
73
|
+
}
|
|
74
|
+
}, [state.sleepWakeUp.delay]);
|
|
75
|
+
|
|
76
|
+
useUpdateEffect(() => {
|
|
77
|
+
if (state.sleepWakeUp.last > 24) {
|
|
78
|
+
state.sleepWakeUp.last = 24;
|
|
79
|
+
}
|
|
80
|
+
}, [state.sleepWakeUp.last]);
|
|
81
|
+
|
|
82
|
+
useUpdateEffect(() => {
|
|
83
|
+
const { startTime, endTime, delay, isSleep } = state.sleepWakeUp;
|
|
84
|
+
if (isSleep) {
|
|
85
|
+
state.sleepWakeUp.hour = Math.trunc(startTime / 60);
|
|
86
|
+
state.sleepWakeUp.minute = startTime % 60;
|
|
87
|
+
const endMin = startTime + delay * 5;
|
|
88
|
+
state.sleepWakeUp.endTime = endMin > 1440 ? endMin - 1440 : endMin;
|
|
89
|
+
} else {
|
|
90
|
+
state.sleepWakeUp.hour = Math.trunc(endTime / 60);
|
|
91
|
+
state.sleepWakeUp.minute = endTime % 60;
|
|
92
|
+
const startMin = endTime - delay * 5;
|
|
93
|
+
state.sleepWakeUp.startTime = startMin < 0 ? startMin + 1440 : startMin;
|
|
94
|
+
}
|
|
95
|
+
}, [state.sleepWakeUp.startTime, state.sleepWakeUp.delay, state.sleepWakeUp.endTime]);
|
|
96
|
+
|
|
97
|
+
const getRangeTime = (time: number, isStart?: boolean) => {
|
|
98
|
+
if (isStart) {
|
|
99
|
+
return time < 0 ? 1440 + time : time;
|
|
100
|
+
} else {
|
|
101
|
+
return time > 1440 ? time - 1440 : time;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const getBlockColor = useCallback(() => {
|
|
106
|
+
if (state.sleepWakeUp.isColorMode) {
|
|
107
|
+
const s = Math.round(mapFloatToRange(state.sleepWakeUp.s / 100, 30, 100));
|
|
108
|
+
return hsv2Hex(state.sleepWakeUp.h, s, 100);
|
|
109
|
+
}
|
|
110
|
+
return cctToColor(state.sleepWakeUp.temperature);
|
|
111
|
+
}, [state.sleepWakeUp]);
|
|
112
|
+
|
|
113
|
+
const checkItemChanged = useMemo(() =>{
|
|
114
|
+
const { isColorMode, h, s, v, brightness, temperature } = state.sleepWakeUp;
|
|
115
|
+
const currentSleepWakeUp = {
|
|
116
|
+
...state.sleepWakeUp,
|
|
117
|
+
h: isColorMode ? h : 0,
|
|
118
|
+
s: isColorMode ? s : 0,
|
|
119
|
+
v: isColorMode ? v : 0,
|
|
120
|
+
brightness: isColorMode ? 0 : brightness,
|
|
121
|
+
temperature: isColorMode ? 0 : temperature,
|
|
122
|
+
};
|
|
123
|
+
return isEqual(props.scheduleItem, props.mode === 'add' ? state.sleepWakeUp : currentSleepWakeUp);
|
|
124
|
+
}, [props.scheduleItem, JSON.stringify(state.sleepWakeUp), props.mode])
|
|
125
|
+
|
|
126
|
+
const canSubmit = useMemo(() => {
|
|
127
|
+
return state.sleepWakeUp.name?.length > 0 && state.sleepWakeUp.name?.length < 33 && !checkItemChanged
|
|
128
|
+
}, [state.sleepWakeUp.name, checkItemChanged]);
|
|
129
|
+
|
|
130
|
+
const mixLightCard = useMemo(() => {
|
|
131
|
+
const applyList = props.applyForList.map(item => {
|
|
132
|
+
if (item.type === 'mainLight' && state.sleepWakeUp.isColorMode) {
|
|
133
|
+
return {
|
|
134
|
+
...item,
|
|
135
|
+
enable: false,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (item.type === 'secondaryLight' && !state.sleepWakeUp.isColorMode) {
|
|
139
|
+
return {
|
|
140
|
+
...item,
|
|
141
|
+
enable: false,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return item;
|
|
145
|
+
});
|
|
146
|
+
return (
|
|
147
|
+
<View>
|
|
148
|
+
{applyList.map(item => (
|
|
149
|
+
<View key={item.dp}>
|
|
150
|
+
<Card style={{ marginHorizontal: cx(24) }}>
|
|
151
|
+
<LdvSwitch
|
|
152
|
+
title={item.key}
|
|
153
|
+
color={'#fff'}
|
|
154
|
+
colorAlpha={1}
|
|
155
|
+
enable={
|
|
156
|
+
item.type === 'mainLight'
|
|
157
|
+
? !state.sleepWakeUp.isColorMode
|
|
158
|
+
: state.sleepWakeUp.isColorMode
|
|
159
|
+
}
|
|
160
|
+
setEnable={(enable: boolean) => {
|
|
161
|
+
state.sleepWakeUp.isColorMode = item.type === 'mainLight' ? !enable : enable;
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
{item.type === 'mainLight' && !state.sleepWakeUp.isColorMode ? (
|
|
165
|
+
<View>
|
|
166
|
+
<ColorTempAdjustView
|
|
167
|
+
isSupportBrightness={!!props.isSupportBrightness}
|
|
168
|
+
isSupportTemperature={!!props.isSupportTemperature}
|
|
169
|
+
colorTemp={state.sleepWakeUp.temperature}
|
|
170
|
+
brightness={state.sleepWakeUp.brightness}
|
|
171
|
+
onBrightnessChangeComplete={bright => {
|
|
172
|
+
state.sleepWakeUp.brightness = bright;
|
|
173
|
+
}}
|
|
174
|
+
onCCTChangeComplete={cct => {
|
|
175
|
+
state.sleepWakeUp.temperature = cct;
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
<Spacer height={cx(16)} />
|
|
179
|
+
</View>
|
|
180
|
+
) : item.type === 'secondaryLight' && state.sleepWakeUp.isColorMode ? (
|
|
181
|
+
<View>
|
|
182
|
+
<ColorAdjustView
|
|
183
|
+
h={state.sleepWakeUp.h}
|
|
184
|
+
s={state.sleepWakeUp.s}
|
|
185
|
+
v={state.sleepWakeUp.v}
|
|
186
|
+
reserveSV={true}
|
|
187
|
+
minSaturation={1}
|
|
188
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
189
|
+
state.sleepWakeUp.h = h;
|
|
190
|
+
state.sleepWakeUp.s = s;
|
|
191
|
+
state.sleepWakeUp.v = v;
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
<Spacer />
|
|
195
|
+
</View>
|
|
196
|
+
) : null}
|
|
197
|
+
</Card>
|
|
198
|
+
<Spacer />
|
|
199
|
+
</View>
|
|
200
|
+
))}
|
|
201
|
+
</View>
|
|
202
|
+
);
|
|
203
|
+
}, [props.applyForList, JSON.stringify(state.sleepWakeUp)]);
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<Page
|
|
207
|
+
backText={I18n.getLang('add_sleepschedule_one_source_system_back_text')}
|
|
208
|
+
showBackDialog={!checkItemChanged}
|
|
209
|
+
loading={state.loading}
|
|
210
|
+
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
211
|
+
backDialogContent={I18n.getLang(
|
|
212
|
+
props.isSleep
|
|
213
|
+
? 'cancel_dialog_leave_unsaved_sleepschedule_note'
|
|
214
|
+
: 'cancel_dialog_leave_unsaved_wakeupschedule_note'
|
|
215
|
+
)}
|
|
216
|
+
rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
|
|
217
|
+
rightButtonIconClick={async () => {
|
|
218
|
+
if (!canSubmit || state.loading) return;
|
|
219
|
+
state.loading = true;
|
|
220
|
+
if (state.sleepWakeUp.isColorMode) {
|
|
221
|
+
state.sleepWakeUp.brightness = 0;
|
|
222
|
+
state.sleepWakeUp.temperature = 0;
|
|
223
|
+
} else {
|
|
224
|
+
state.sleepWakeUp.h = 0;
|
|
225
|
+
state.sleepWakeUp.s = 0;
|
|
226
|
+
state.sleepWakeUp.v = 0;
|
|
227
|
+
}
|
|
228
|
+
state.sleepWakeUp.enable = true
|
|
229
|
+
const res = await props.modDeleteTimeSchedule(
|
|
230
|
+
props.mode,
|
|
231
|
+
state.sleepWakeUp.isSleep,
|
|
232
|
+
state.sleepWakeUp
|
|
233
|
+
);
|
|
234
|
+
state.loading = false;
|
|
235
|
+
if (res.success) {
|
|
236
|
+
navigation.goBack();
|
|
237
|
+
}
|
|
238
|
+
}}
|
|
239
|
+
headlineText={I18n.getLang(
|
|
240
|
+
props.isSleep
|
|
241
|
+
? props.mode === 'add'
|
|
242
|
+
? 'add_sleepschedule_one_source_headline_text'
|
|
243
|
+
: 'edit_sleepschedule_headline_text'
|
|
244
|
+
: props.mode === 'add'
|
|
245
|
+
? 'add_wakeupschedule_one_source_headline_text'
|
|
246
|
+
: 'edit_wakeupschedule_headline_text'
|
|
247
|
+
)}
|
|
248
|
+
>
|
|
249
|
+
<ScrollView
|
|
250
|
+
nestedScrollEnabled={true}
|
|
251
|
+
showsHorizontalScrollIndicator={false}
|
|
252
|
+
showsVerticalScrollIndicator={false}
|
|
253
|
+
>
|
|
254
|
+
<TextField
|
|
255
|
+
style={styles.cardContainer}
|
|
256
|
+
value={state.sleepWakeUp.name}
|
|
257
|
+
showError={state.sleepWakeUp.name?.length > 32}
|
|
258
|
+
maxLength={33}
|
|
259
|
+
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
260
|
+
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
261
|
+
onChangeText={(t: string) => {
|
|
262
|
+
state.sleepWakeUp.name = t;
|
|
263
|
+
}}
|
|
264
|
+
/>
|
|
265
|
+
{/* pick */}
|
|
266
|
+
<TimerPicker
|
|
267
|
+
itemTextColor="#aeadb5"
|
|
268
|
+
style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
|
|
269
|
+
is12Hours={!is24HourClock}
|
|
270
|
+
singlePicker={true}
|
|
271
|
+
amText={I18n.getLang('manage_user_calendar_label_am')}
|
|
272
|
+
pmText={I18n.getLang('manage_user_calendar_label_pm')}
|
|
273
|
+
startTime={props.isSleep ? state.sleepWakeUp.startTime : state.sleepWakeUp.endTime}
|
|
274
|
+
symbol={''}
|
|
275
|
+
onTimerChange={time => {
|
|
276
|
+
if (props.isSleep) {
|
|
277
|
+
state.sleepWakeUp.startTime = time;
|
|
278
|
+
} else {
|
|
279
|
+
state.sleepWakeUp.endTime = time;
|
|
280
|
+
}
|
|
281
|
+
}}
|
|
282
|
+
/>
|
|
283
|
+
|
|
284
|
+
{/* week */}
|
|
285
|
+
<View style={styles.week}>
|
|
286
|
+
<LdvWeekView
|
|
287
|
+
value={state.sleepWakeUp.weeks}
|
|
288
|
+
onSelect={(weekIdx: number) => {
|
|
289
|
+
state.sleepWakeUp.weeks = state.sleepWakeUp.weeks.map((week, idx) => {
|
|
290
|
+
if (idx === weekIdx - 1) {
|
|
291
|
+
return week === 1 ? 0 : 1;
|
|
292
|
+
}
|
|
293
|
+
return week;
|
|
294
|
+
});
|
|
295
|
+
}}
|
|
296
|
+
/>
|
|
297
|
+
<Spacer />
|
|
298
|
+
<Text style={{ marginHorizontal: cx(24) }}>{loopText(state.sleepWakeUp.weeks)}</Text>
|
|
299
|
+
<Spacer />
|
|
300
|
+
</View>
|
|
301
|
+
|
|
302
|
+
{/* Apply for */}
|
|
303
|
+
<View style={styles.cardContainer}>
|
|
304
|
+
<Text style={styles.itemTitle}>
|
|
305
|
+
{I18n.getLang('timeschedule_add_schedule_subheadline_text')}
|
|
306
|
+
</Text>
|
|
307
|
+
<View
|
|
308
|
+
style={{
|
|
309
|
+
backgroundColor: '#f6f6f6',
|
|
310
|
+
borderRadius: 4,
|
|
311
|
+
minHeight: cx(50),
|
|
312
|
+
flex: 1,
|
|
313
|
+
justifyContent: 'center',
|
|
314
|
+
}}
|
|
315
|
+
>
|
|
316
|
+
<View
|
|
317
|
+
style={{
|
|
318
|
+
marginHorizontal: cx(8),
|
|
319
|
+
marginTop: cx(8),
|
|
320
|
+
borderRadius: 4,
|
|
321
|
+
}}
|
|
322
|
+
>
|
|
323
|
+
{props.applyForList.map(apply => (
|
|
324
|
+
<View
|
|
325
|
+
style={{
|
|
326
|
+
flexDirection: 'row',
|
|
327
|
+
justifyContent: 'space-between',
|
|
328
|
+
alignItems: 'center',
|
|
329
|
+
backgroundColor: '#fff',
|
|
330
|
+
marginBottom: cx(8),
|
|
331
|
+
}}
|
|
332
|
+
key={apply.dp}
|
|
333
|
+
>
|
|
334
|
+
<Text
|
|
335
|
+
style={{
|
|
336
|
+
color: '#000',
|
|
337
|
+
fontSize: cx(14),
|
|
338
|
+
marginHorizontal: cx(6),
|
|
339
|
+
marginVertical: cx(9),
|
|
340
|
+
}}
|
|
341
|
+
>
|
|
342
|
+
{apply.key}
|
|
343
|
+
</Text>
|
|
344
|
+
</View>
|
|
345
|
+
))}
|
|
346
|
+
</View>
|
|
347
|
+
</View>
|
|
348
|
+
<Spacer />
|
|
349
|
+
</View>
|
|
350
|
+
|
|
351
|
+
{/* Device state */}
|
|
352
|
+
<View>
|
|
353
|
+
<Text style={[styles.itemTitle, styles.cardContainer]}>
|
|
354
|
+
{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}
|
|
355
|
+
</Text>
|
|
356
|
+
{props.isMixLight ? (
|
|
357
|
+
mixLightCard
|
|
358
|
+
) : (
|
|
359
|
+
<Card style={styles.cardContainer}>
|
|
360
|
+
<LdvSwitch
|
|
361
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
362
|
+
color={getBlockColor()}
|
|
363
|
+
colorAlpha={1}
|
|
364
|
+
enable={false}
|
|
365
|
+
showSwitch={false}
|
|
366
|
+
setEnable={() => { }}
|
|
367
|
+
/>
|
|
368
|
+
<LampAdjustView
|
|
369
|
+
isSupportColor={!!props.isSupportColor}
|
|
370
|
+
isSupportTemperature={!!props.isSupportTemperature}
|
|
371
|
+
isSupportBrightness={!!props.isSupportBrightness}
|
|
372
|
+
isColorMode={state.sleepWakeUp.isColorMode}
|
|
373
|
+
reserveSV={true}
|
|
374
|
+
setIsColorMode={() => {
|
|
375
|
+
state.sleepWakeUp.isColorMode = !state.sleepWakeUp.isColorMode;
|
|
376
|
+
}}
|
|
377
|
+
h={state.sleepWakeUp.h}
|
|
378
|
+
s={state.sleepWakeUp.s}
|
|
379
|
+
v={state.sleepWakeUp.v}
|
|
380
|
+
onHSVChange={(h, s, v) => {
|
|
381
|
+
state.sleepWakeUp.h = h;
|
|
382
|
+
state.sleepWakeUp.s = s;
|
|
383
|
+
state.sleepWakeUp.v = v;
|
|
384
|
+
}}
|
|
385
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
386
|
+
state.sleepWakeUp.h = h;
|
|
387
|
+
state.sleepWakeUp.s = s;
|
|
388
|
+
state.sleepWakeUp.v = v;
|
|
389
|
+
}}
|
|
390
|
+
colorTemp={state.sleepWakeUp.temperature}
|
|
391
|
+
brightness={state.sleepWakeUp.brightness}
|
|
392
|
+
onCCTChange={cct => {
|
|
393
|
+
state.sleepWakeUp.temperature = cct;
|
|
394
|
+
}}
|
|
395
|
+
onCCTChangeComplete={cct => {
|
|
396
|
+
state.sleepWakeUp.temperature = cct;
|
|
397
|
+
}}
|
|
398
|
+
onBrightnessChange={brightness => {
|
|
399
|
+
state.sleepWakeUp.brightness = brightness;
|
|
400
|
+
}}
|
|
401
|
+
onBrightnessChangeComplete={brightness => {
|
|
402
|
+
state.sleepWakeUp.brightness = brightness;
|
|
403
|
+
}}
|
|
404
|
+
/>
|
|
405
|
+
</Card>
|
|
406
|
+
)}
|
|
407
|
+
</View>
|
|
408
|
+
<Spacer />
|
|
409
|
+
{/* Settings */}
|
|
410
|
+
<View style={styles.cardContainer}>
|
|
411
|
+
<Text style={styles.itemTitle}>
|
|
412
|
+
{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}
|
|
413
|
+
</Text>
|
|
414
|
+
<Spacer />
|
|
415
|
+
<Text>
|
|
416
|
+
{I18n.getLang(
|
|
417
|
+
props.isSleep
|
|
418
|
+
? 'add_sleepschedule_one_source_settings_text'
|
|
419
|
+
: 'add_wakeupschedule_settings_text'
|
|
420
|
+
)}
|
|
421
|
+
</Text>
|
|
422
|
+
<LdvPickerView
|
|
423
|
+
style={styles.picker}
|
|
424
|
+
hour={toFixedString(Math.trunc((state.sleepWakeUp.delay * 5) / 60), 2)}
|
|
425
|
+
minute={toFixedString((state.sleepWakeUp.delay * 5) % 60, 2)}
|
|
426
|
+
minutesStep={5}
|
|
427
|
+
setHour={v => {
|
|
428
|
+
const m = (state.sleepWakeUp.delay * 5) % 60;
|
|
429
|
+
state.sleepWakeUp.delay = (Number(v) * 60 + m) / 5;
|
|
430
|
+
}}
|
|
431
|
+
setMinute={v => {
|
|
432
|
+
const h = Math.trunc((state.sleepWakeUp.delay * 5) / 60);
|
|
433
|
+
state.sleepWakeUp.delay = (h * 60 + Number(v)) / 5;
|
|
434
|
+
}}
|
|
435
|
+
unit={['h', 'min']}
|
|
436
|
+
maxHour={3}
|
|
437
|
+
/>
|
|
438
|
+
<Text>
|
|
439
|
+
{I18n.formatValue(
|
|
440
|
+
props.isSleep
|
|
441
|
+
? 'add_sleepschedule_one_source_settings_text2'
|
|
442
|
+
: 'add_wakeupschedule_settings_text2',
|
|
443
|
+
`${convertMinutesTo12HourFormat(state.sleepWakeUp.startTime, is24HourClock)}`
|
|
444
|
+
)}
|
|
445
|
+
</Text>
|
|
446
|
+
<Spacer />
|
|
447
|
+
{!props.isSleep && (
|
|
448
|
+
<View style={{ marginHorizontal: -cx(16), marginTop: -cx(20) }}>
|
|
449
|
+
<LdvSwitch
|
|
450
|
+
title={I18n.getLang('add_wakeupschedule_settings_text3')}
|
|
451
|
+
enable={state.sleepWakeUp.last > 0}
|
|
452
|
+
color="#fff"
|
|
453
|
+
colorAlpha={1}
|
|
454
|
+
setEnable={v => {
|
|
455
|
+
state.sleepWakeUp.last = v ? 1 : 0;
|
|
456
|
+
}}
|
|
457
|
+
/>
|
|
458
|
+
</View>
|
|
459
|
+
)}
|
|
460
|
+
{state.sleepWakeUp.last > 0 && (
|
|
461
|
+
<>
|
|
462
|
+
<Text style={{ fontSize: cx(14) }}>
|
|
463
|
+
{I18n.getLang('add_wakeupschedule_settings_text4')}
|
|
464
|
+
</Text>
|
|
465
|
+
<LdvPickerView
|
|
466
|
+
style={styles.picker}
|
|
467
|
+
hour={toFixedString(Math.trunc((state.sleepWakeUp.last * 5) / 60), 2)}
|
|
468
|
+
minute={toFixedString((state.sleepWakeUp.last * 5) % 60, 2)}
|
|
469
|
+
minutesStep={5}
|
|
470
|
+
setHour={v => {
|
|
471
|
+
const m = (state.sleepWakeUp.last * 5) % 60;
|
|
472
|
+
if (Number(v) === 0 && m === 0) {
|
|
473
|
+
state.sleepWakeUp.last = 1;
|
|
474
|
+
} else {
|
|
475
|
+
state.sleepWakeUp.last = (Number(v) * 60 + m) / 5;
|
|
476
|
+
}
|
|
477
|
+
}}
|
|
478
|
+
setMinute={v => {
|
|
479
|
+
const h = Math.trunc((state.sleepWakeUp.last * 5) / 60);
|
|
480
|
+
if (Number(v) === 0 && h === 0) {
|
|
481
|
+
state.sleepWakeUp.last = 1;
|
|
482
|
+
} else {
|
|
483
|
+
state.sleepWakeUp.last = (h * 60 + Number(v)) / 5;
|
|
484
|
+
}
|
|
485
|
+
}}
|
|
486
|
+
unit={['h', 'min']}
|
|
487
|
+
maxHour={3}
|
|
488
|
+
/>
|
|
489
|
+
<Text>
|
|
490
|
+
{I18n.formatValue(
|
|
491
|
+
'add_wakeupschedule_settings_text5',
|
|
492
|
+
`${convertMinutesTo12HourFormat(
|
|
493
|
+
getRangeTime(state.sleepWakeUp.endTime + state.sleepWakeUp.last * 5),
|
|
494
|
+
is24HourClock
|
|
495
|
+
)}`
|
|
496
|
+
)}
|
|
497
|
+
</Text>
|
|
498
|
+
<Spacer />
|
|
499
|
+
</>
|
|
500
|
+
)}
|
|
501
|
+
</View>
|
|
502
|
+
{/* Summary */}
|
|
503
|
+
<Summary
|
|
504
|
+
frequency={loopText(state.sleepWakeUp.weeks)}
|
|
505
|
+
time={`${convertMinutesTo12HourFormat(
|
|
506
|
+
state.sleepWakeUp.startTime,
|
|
507
|
+
is24HourClock
|
|
508
|
+
)} - ${convertMinutesTo12HourFormat(state.sleepWakeUp.endTime, is24HourClock)}`}
|
|
509
|
+
actions={(
|
|
510
|
+
<View>
|
|
511
|
+
<Text style={{ fontSize: cx(12), color: '#000000' }}>
|
|
512
|
+
{I18n.getLang(
|
|
513
|
+
!props.isSleep ? 'feature_summary_action_txt_11' : 'feature_summary_action_txt_10'
|
|
514
|
+
)}
|
|
515
|
+
</Text>
|
|
516
|
+
<View style={styles.filletCorner}>
|
|
517
|
+
<Text style={styles.rightTitle}>
|
|
518
|
+
{props.isMixLight ? (state.sleepWakeUp.isColorMode ? props.applyForList[1].key : props.applyForList[0].key) : props.applyForList[0].key}
|
|
519
|
+
</Text>
|
|
520
|
+
</View>
|
|
521
|
+
<Spacer height={cx(10)} />
|
|
522
|
+
<Text style={{ fontSize: cx(12), color: '#000000' }}>
|
|
523
|
+
{I18n.getLang(
|
|
524
|
+
props.isSleep
|
|
525
|
+
? 'feature_summary_action_txt_2'
|
|
526
|
+
: state.sleepWakeUp.last
|
|
527
|
+
? 'feature_summary_action_txt_12'
|
|
528
|
+
: 'feature_summary_action_txt_1'
|
|
529
|
+
)}
|
|
530
|
+
</Text>
|
|
531
|
+
<View style={styles.filletCorner}>
|
|
532
|
+
<Text style={styles.rightTitle}>
|
|
533
|
+
{convertMinutesTo12HourFormat(
|
|
534
|
+
props.isSleep
|
|
535
|
+
? state.sleepWakeUp.endTime
|
|
536
|
+
: getRangeTime(state.sleepWakeUp.endTime + state.sleepWakeUp.last * 5),
|
|
537
|
+
is24HourClock
|
|
538
|
+
)}
|
|
539
|
+
</Text>
|
|
540
|
+
</View>
|
|
541
|
+
</View>
|
|
542
|
+
)}
|
|
543
|
+
/>
|
|
544
|
+
<Spacer />
|
|
545
|
+
{/* Delete btn */}
|
|
546
|
+
{props.mode === 'edit' && (
|
|
547
|
+
<View style={styles.cardContainer}>
|
|
548
|
+
<DeleteButton
|
|
549
|
+
text={I18n.getLang('edit_timeschedule_bttn_text')}
|
|
550
|
+
onPress={async () => {
|
|
551
|
+
showDialog({
|
|
552
|
+
method: 'confirm',
|
|
553
|
+
title: I18n.getLang(
|
|
554
|
+
props.isSleep
|
|
555
|
+
? 'cancel_dialog_delete_item_sleepschedule_titel'
|
|
556
|
+
: 'cancel_dialog_delete_item_wakeupschedule_titel'
|
|
557
|
+
),
|
|
558
|
+
subTitle: I18n.getLang(
|
|
559
|
+
props.isSleep
|
|
560
|
+
? 'cancel_dialog_delete_item_sleepschedule_description'
|
|
561
|
+
: 'cancel_dialog_delete_item_wakeupschedule_description'
|
|
562
|
+
),
|
|
563
|
+
onConfirm: async (_, { close }) => {
|
|
564
|
+
close();
|
|
565
|
+
if (state.loading) return;
|
|
566
|
+
state.loading = true;
|
|
567
|
+
const res = await props.modDeleteTimeSchedule(
|
|
568
|
+
'del',
|
|
569
|
+
state.sleepWakeUp.isSleep,
|
|
570
|
+
state.sleepWakeUp
|
|
571
|
+
);
|
|
572
|
+
state.loading = false;
|
|
573
|
+
if (res.success) {
|
|
574
|
+
navigation.goBack();
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
}}
|
|
579
|
+
/>
|
|
580
|
+
</View>
|
|
581
|
+
)}
|
|
582
|
+
<Spacer />
|
|
583
|
+
</ScrollView>
|
|
584
|
+
</Page>
|
|
585
|
+
);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const styles = StyleSheet.create({
|
|
589
|
+
cardContainer: {
|
|
590
|
+
marginHorizontal: cx(24),
|
|
591
|
+
},
|
|
592
|
+
textField: {
|
|
593
|
+
marginHorizontal: cx(24),
|
|
594
|
+
},
|
|
595
|
+
picker: {
|
|
596
|
+
marginHorizontal: cx(24),
|
|
597
|
+
marginVertical: cx(15),
|
|
598
|
+
color: 'rgb(35,35,38)',
|
|
599
|
+
},
|
|
600
|
+
week: {},
|
|
601
|
+
itemTitle: {
|
|
602
|
+
color: '#000',
|
|
603
|
+
fontSize: cx(16),
|
|
604
|
+
fontWeight: 'bold',
|
|
605
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
606
|
+
marginBottom: cx(10),
|
|
607
|
+
},
|
|
608
|
+
skillListItem: {
|
|
609
|
+
flexDirection: 'row',
|
|
610
|
+
justifyContent: 'space-between',
|
|
611
|
+
height: cx(30),
|
|
612
|
+
alignItems: 'center',
|
|
613
|
+
marginVertical: cx(5),
|
|
614
|
+
},
|
|
615
|
+
summaryContainer: {
|
|
616
|
+
flexDirection: 'row',
|
|
617
|
+
justifyContent: 'flex-start',
|
|
618
|
+
marginBottom: cx(10),
|
|
619
|
+
marginHorizontal: cx(24),
|
|
620
|
+
},
|
|
621
|
+
summaryImg: {
|
|
622
|
+
height: cx(12),
|
|
623
|
+
width: cx(12),
|
|
624
|
+
tintColor: '#000',
|
|
625
|
+
},
|
|
626
|
+
summaryLeft: {
|
|
627
|
+
flexDirection: 'row',
|
|
628
|
+
alignItems: 'center',
|
|
629
|
+
minWidth: cx(90),
|
|
630
|
+
},
|
|
631
|
+
leftTitle: {
|
|
632
|
+
fontSize: cx(14),
|
|
633
|
+
color: '#000',
|
|
634
|
+
},
|
|
635
|
+
summaryRight: {
|
|
636
|
+
flexDirection: 'column',
|
|
637
|
+
marginLeft: cx(21),
|
|
638
|
+
borderRadius: cx(16),
|
|
639
|
+
backgroundColor: '#cbcbcb',
|
|
640
|
+
},
|
|
641
|
+
rightItem: {
|
|
642
|
+
paddingHorizontal: cx(12),
|
|
643
|
+
color: '#000',
|
|
644
|
+
},
|
|
645
|
+
rightTitle: {
|
|
646
|
+
paddingLeft: cx(12),
|
|
647
|
+
paddingRight: cx(12),
|
|
648
|
+
fontSize: cx(10),
|
|
649
|
+
textAlign: 'center',
|
|
650
|
+
alignSelf: 'flex-start',
|
|
651
|
+
color: '#000'
|
|
652
|
+
},
|
|
653
|
+
filletCorner: {
|
|
654
|
+
flexDirection: 'row',
|
|
655
|
+
backgroundColor: '#cbcbcb',
|
|
656
|
+
borderRadius: cx(16),
|
|
657
|
+
alignSelf: 'flex-start',
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
export default SleepWakeUpDetailPage;
|