@ledvance/ui-biz-bundle 1.0.89 → 1.0.90
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
CHANGED
|
@@ -18,394 +18,406 @@ import { JudgeTimeScheduleProps } from "../timeSchedule/TimeScheduleBean";
|
|
|
18
18
|
import { useSleepPlan, useWakeUpPlan } from "./SleepWakeUpActions";
|
|
19
19
|
import { ui_biz_routerKey } from "../../navigation/Routers";
|
|
20
20
|
import { findConflicts } from '@ledvance/base/src/utils/loopsCompare'
|
|
21
|
-
import {useBiorhythm} from '@ledvance/ui-biz-bundle/src/modules/biorhythm/BiorhythmActions'
|
|
21
|
+
import { useBiorhythm } from '@ledvance/ui-biz-bundle/src/modules/biorhythm/BiorhythmActions'
|
|
22
22
|
import { cloneDeep } from "lodash";
|
|
23
23
|
|
|
24
24
|
const cx = Utils.RatioUtils.convertX
|
|
25
25
|
|
|
26
26
|
type dpItem = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
label: string
|
|
28
|
+
value: string
|
|
29
|
+
dpId: string
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface SleepWakeUpPageRouteParams extends JudgeTimeScheduleProps {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
dps: dpItem[]
|
|
34
|
+
dpCodes: Record<string, string>
|
|
35
|
+
getDpValue?: (v: any) => any
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const MAX_SCHEDULE = 4
|
|
39
39
|
const SleepWakeUpPage = () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const deviceInfo = useDeviceInfo()
|
|
41
|
+
const navigation = useNavigation()
|
|
42
|
+
const props = useRoute().params as SleepWakeUpPageRouteParams
|
|
43
|
+
const [sleepPlan, setSleepPlan] = useSleepPlan(props.dpCodes)
|
|
44
|
+
const [wakeUpPlan, setWakeUpPlan] = useWakeUpPlan(props.dpCodes)
|
|
45
|
+
const [biorhythmState, setBiorhythm] = useBiorhythm(props.dpCodes.rhythm_mode)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const state = useReactive({
|
|
49
|
+
showAddSchedulePopover: false,
|
|
50
|
+
sleepTagChecked: false,
|
|
51
|
+
wakeUpTagChecked: false,
|
|
52
|
+
sleepScheduleList: [] as any[],
|
|
53
|
+
wakeUpScheduleList: [] as any[],
|
|
54
|
+
filteredScheduleList: [] as any[],
|
|
55
|
+
flag: Symbol()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const isMaxNum = useMemo(() => {
|
|
59
|
+
return state.sleepScheduleList.length >= MAX_SCHEDULE && state.wakeUpScheduleList >= MAX_SCHEDULE
|
|
60
|
+
}, [state.sleepScheduleList, state.wakeUpScheduleList])
|
|
61
|
+
|
|
62
|
+
const onAddScheduleDialogItemClick = useCallback((isSleep: boolean, mode: 'add' | 'edit', scheduleItem?: any) => {
|
|
63
|
+
if (mode === 'add' && isSleep && state.sleepScheduleList.length === MAX_SCHEDULE) return
|
|
64
|
+
if (mode === 'add' && !isSleep && state.wakeUpScheduleList.length === MAX_SCHEDULE) return
|
|
65
|
+
navigateToEdit({
|
|
66
|
+
...props,
|
|
67
|
+
mode,
|
|
68
|
+
dps: props.dps,
|
|
69
|
+
isSleep,
|
|
70
|
+
scheduleItem: scheduleItem && cloneDeep(scheduleItem),
|
|
71
|
+
setSleepPlan,
|
|
72
|
+
setWakeUpPlan,
|
|
73
|
+
sleepPlan: cloneDeep(state.sleepScheduleList),
|
|
74
|
+
wakeUpPlan: cloneDeep(state.wakeUpScheduleList),
|
|
75
|
+
conflictFn,
|
|
76
|
+
deleteDialog
|
|
56
77
|
})
|
|
78
|
+
state.showAddSchedulePopover = false
|
|
79
|
+
}, [state.filteredScheduleList])
|
|
57
80
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
useUpdateEffect(() => {
|
|
82
|
+
state.sleepScheduleList = sleepPlan
|
|
83
|
+
}, [sleepPlan])
|
|
61
84
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
navigateToEdit({
|
|
66
|
-
...props,
|
|
67
|
-
mode,
|
|
68
|
-
dps: props.dps,
|
|
69
|
-
isSleep,
|
|
70
|
-
scheduleItem: scheduleItem && cloneDeep(scheduleItem),
|
|
71
|
-
setSleepPlan,
|
|
72
|
-
setWakeUpPlan,
|
|
73
|
-
sleepPlan: cloneDeep(state.sleepScheduleList),
|
|
74
|
-
wakeUpPlan: cloneDeep(state.wakeUpScheduleList),
|
|
75
|
-
conflictFn,
|
|
76
|
-
deleteDialog
|
|
77
|
-
})
|
|
78
|
-
state.showAddSchedulePopover = false
|
|
79
|
-
}, [state.filteredScheduleList])
|
|
85
|
+
useUpdateEffect(() => {
|
|
86
|
+
state.wakeUpScheduleList = wakeUpPlan
|
|
87
|
+
}, [wakeUpPlan])
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (state.sleepTagChecked === state.wakeUpTagChecked) {
|
|
91
|
+
state.filteredScheduleList = [...state.sleepScheduleList, ...state.wakeUpScheduleList]
|
|
92
|
+
} else if (state.sleepTagChecked) {
|
|
93
|
+
state.filteredScheduleList = state.sleepScheduleList
|
|
94
|
+
} else {
|
|
95
|
+
state.filteredScheduleList = state.wakeUpScheduleList
|
|
96
|
+
}
|
|
97
|
+
}, [state.sleepTagChecked, state.wakeUpTagChecked, state.sleepScheduleList, state.wakeUpScheduleList])
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
const getTipText = useCallback(() => {
|
|
100
|
+
if (state.sleepScheduleList.length >= MAX_SCHEDULE && state.wakeUpScheduleList.length >= MAX_SCHEDULE) return "both"
|
|
101
|
+
if (state.sleepScheduleList.length >= MAX_SCHEDULE) return "sleep"
|
|
102
|
+
if (state.wakeUpScheduleList.length >= MAX_SCHEDULE) return "wakeup"
|
|
103
|
+
}, [state.sleepScheduleList, state.wakeUpScheduleList])
|
|
88
104
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else if (state.sleepTagChecked) {
|
|
93
|
-
state.filteredScheduleList = state.sleepScheduleList
|
|
94
|
-
} else {
|
|
95
|
-
state.filteredScheduleList = state.wakeUpScheduleList
|
|
96
|
-
}
|
|
97
|
-
}, [state.sleepTagChecked, state.wakeUpTagChecked, state.sleepScheduleList, state.wakeUpScheduleList])
|
|
105
|
+
const hasScheduleList = useCallback(() => {
|
|
106
|
+
return !!(state.sleepScheduleList.length && state.wakeUpScheduleList.length)
|
|
107
|
+
}, [state.sleepScheduleList, state.wakeUpScheduleList])
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (state.wakeUpScheduleList.length >= MAX_SCHEDULE) return "wakeup"
|
|
103
|
-
}, [state.sleepScheduleList, state.wakeUpScheduleList])
|
|
109
|
+
const navigateToEdit = (params) => {
|
|
110
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_sleep_wakeUp_edit, params)
|
|
111
|
+
}
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
const isSleepMax = useMemo(() => {
|
|
114
|
+
return state.sleepScheduleList.length >= MAX_SCHEDULE
|
|
115
|
+
}, [state.sleepScheduleList])
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
const isWakeUpMax = useMemo(() => {
|
|
118
|
+
return state.wakeUpScheduleList.length >= MAX_SCHEDULE
|
|
119
|
+
}, [state.wakeUpScheduleList])
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
121
|
+
const onDelete = async (item) => {
|
|
122
|
+
if (item.isSleep) {
|
|
123
|
+
/// 删除
|
|
124
|
+
const newList = cloneDeep(state.sleepScheduleList)
|
|
125
|
+
const idx = state.sleepScheduleList.findIndex(sleep => sleep.index === item.index)
|
|
126
|
+
newList.splice(idx, 1)
|
|
127
|
+
await setSleepPlan(newList)
|
|
128
|
+
} else {
|
|
129
|
+
const newList = cloneDeep(state.wakeUpScheduleList)
|
|
130
|
+
const idx = state.wakeUpScheduleList.findIndex(wakeup => wakeup.index === item.index)
|
|
131
|
+
newList.splice(idx, 1)
|
|
132
|
+
console.log(newList, '< --- newLIst')
|
|
133
|
+
await setWakeUpPlan(newList)
|
|
127
134
|
}
|
|
135
|
+
}
|
|
128
136
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
const deleteDialog = (item) => {
|
|
138
|
+
return new Promise(resolve => {
|
|
139
|
+
showDialog({
|
|
140
|
+
method: 'confirm',
|
|
141
|
+
title: I18n.getLang('cancel_dialog_delete_item_timeschedule_titel'),
|
|
142
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_timeschedule_description'),
|
|
143
|
+
onConfirm: async (_, { close }) => {
|
|
144
|
+
await onDelete(item)
|
|
145
|
+
close()
|
|
146
|
+
resolve(true)
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
}
|
|
143
151
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
const renderItem = useCallback(({ item }) => {
|
|
153
|
+
return (
|
|
154
|
+
<LdvScheduleItem
|
|
155
|
+
item={item}
|
|
156
|
+
onEnableChange={itemOnValueChange}
|
|
157
|
+
onPress={(item) => onAddScheduleDialogItemClick(item.isSleep, 'edit', item)}
|
|
158
|
+
onLongPress={(item) => {
|
|
159
|
+
deleteDialog(item).then()
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
)
|
|
163
|
+
}, [])
|
|
156
164
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
const updateList = (list, conflictList) => {
|
|
166
|
+
conflictList.forEach((conflict) => {
|
|
167
|
+
const item = list.find((i) => i.index === conflict.index)
|
|
168
|
+
if (item) {
|
|
169
|
+
item.enable = 0
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
return list
|
|
173
|
+
}
|
|
166
174
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
const editTimePlanStatus = (sleepConflict, wakeupConflict, newList, fixItem) => {
|
|
176
|
+
const { isSleep } = fixItem
|
|
177
|
+
if (sleepConflict.length) {
|
|
178
|
+
const listSleep = isSleep ? [...newList] : [...state.sleepScheduleList]
|
|
179
|
+
const updateSleepList = updateList(listSleep, sleepConflict)
|
|
180
|
+
if (!isSleep) {
|
|
181
|
+
setSleepPlan(updateSleepList)
|
|
182
|
+
}
|
|
175
183
|
|
|
176
|
-
}
|
|
177
|
-
if (wakeupConflict.length) {
|
|
178
|
-
const listWakeUp = isSleep ? [...state.wakeUpScheduleList] : [...newList]
|
|
179
|
-
const updateWakeUpList = updateList(listWakeUp, wakeupConflict)
|
|
180
|
-
if (isSleep) {
|
|
181
|
-
setWakeUpPlan(updateWakeUpList)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (fixItem.isSleep) {
|
|
185
|
-
setSleepPlan([...newList])
|
|
186
|
-
} else {
|
|
187
|
-
setWakeUpPlan([...newList])
|
|
188
|
-
}
|
|
189
184
|
}
|
|
185
|
+
if (wakeupConflict.length) {
|
|
186
|
+
const listWakeUp = isSleep ? [...state.wakeUpScheduleList] : [...newList]
|
|
187
|
+
const updateWakeUpList = updateList(listWakeUp, wakeupConflict)
|
|
188
|
+
if (isSleep) {
|
|
189
|
+
setWakeUpPlan(updateWakeUpList)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (fixItem.isSleep) {
|
|
193
|
+
setSleepPlan([...newList])
|
|
194
|
+
} else {
|
|
195
|
+
setWakeUpPlan([...newList])
|
|
196
|
+
}
|
|
197
|
+
}
|
|
190
198
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
})
|
|
199
|
+
const conflictFn = (item, editList, goback: boolean = false) => {
|
|
200
|
+
const sleepTimeList = item.isSleep ? state.sleepScheduleList.filter(sleep => sleep.index !== item.index) : cloneDeep(state.sleepScheduleList)
|
|
201
|
+
const wakeupTimeList = item.isSleep ? cloneDeep(state.wakeUpScheduleList) : state.wakeUpScheduleList.filter(wakeup => wakeup.index !== item.index)
|
|
202
|
+
// 相关冲突校验
|
|
203
|
+
const sleepConflict = findConflicts(sleepTimeList, item)
|
|
204
|
+
const wakeupConflict = findConflicts(wakeupTimeList, item)
|
|
205
|
+
const conflict = [...sleepConflict, ...wakeupConflict]
|
|
206
|
+
// return
|
|
207
|
+
// 存在冲突 || 生物节律为启用状态
|
|
208
|
+
if (conflict.length || biorhythmState.enable) {
|
|
209
|
+
return showDialog({
|
|
210
|
+
method: 'confirm',
|
|
211
|
+
title: I18n.getLang(item.isSleep ? 'conflict_dialog_save_item_sleepschedule_titel' : 'conflict_dialog_save_item_wakeupschedule_titel'),
|
|
212
|
+
subTitle: I18n.getLang(item.isSleep ? 'conflict_dialog_save_item_sleepschedule_description' : 'conflict_dialog_save_item_wakeupschedule_description'),
|
|
213
|
+
onConfirm: (_, { close }) => {
|
|
214
|
+
editTimePlanStatus(sleepConflict, wakeupConflict, editList, item)
|
|
215
|
+
if (biorhythmState.enable) setBiorhythm(deviceInfo.devId, {
|
|
216
|
+
...biorhythmState,
|
|
217
|
+
enable: false,
|
|
218
|
+
})
|
|
219
|
+
close()
|
|
220
|
+
if (goback) navigation.goBack()
|
|
215
221
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
if (item.isSleep) {
|
|
225
|
+
setSleepPlan(editList)
|
|
226
|
+
} else {
|
|
227
|
+
setWakeUpPlan(editList)
|
|
222
228
|
}
|
|
229
|
+
if (goback) navigation.goBack()
|
|
230
|
+
}
|
|
223
231
|
|
|
224
|
-
|
|
232
|
+
const itemOnValueChange = async (item) => {
|
|
225
233
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
const editList = (item.isSleep ? state.sleepScheduleList : state.wakeUpScheduleList).map(schedule => {
|
|
235
|
+
if (schedule.index === item.index) {
|
|
236
|
+
return { ...schedule, enable: item.enable === 1 ? 0 : 1 }
|
|
237
|
+
}
|
|
238
|
+
return schedule
|
|
239
|
+
})
|
|
240
|
+
// 冲突检查
|
|
241
|
+
if (!item.enable) {
|
|
242
|
+
return conflictFn(item, editList)
|
|
243
|
+
}
|
|
236
244
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
245
|
+
if (item.isSleep) {
|
|
246
|
+
setSleepPlan(editList)
|
|
247
|
+
} else {
|
|
248
|
+
setWakeUpPlan(editList)
|
|
242
249
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
</Text>
|
|
310
|
-
</View>
|
|
311
|
-
{!hasScheduleList() &&
|
|
312
|
-
<View style={styles.emptyBtnView}>
|
|
313
|
-
<Spacer />
|
|
314
|
-
<TextButton
|
|
315
|
-
style={styles.emptyBtn}
|
|
316
|
-
textStyle={{ color: '#fff' }}
|
|
317
|
-
text={I18n.getLang('sleepwakeschedule_add_button_text1')}
|
|
318
|
-
onPress={() => onAddScheduleDialogItemClick(true, 'add')}
|
|
319
|
-
/>
|
|
320
|
-
<Spacer />
|
|
321
|
-
<TextButton
|
|
322
|
-
style={styles.emptyBtn}
|
|
323
|
-
textStyle={{ color: '#fff' }}
|
|
324
|
-
text={I18n.getLang('sleepwakeschedule_add_button_text2')}
|
|
325
|
-
onPress={() => onAddScheduleDialogItemClick(false, 'add')}
|
|
326
|
-
/>
|
|
327
|
-
</View>}
|
|
328
|
-
</View>
|
|
250
|
+
}
|
|
251
|
+
return (
|
|
252
|
+
<>
|
|
253
|
+
<Page
|
|
254
|
+
backText={deviceInfo.name}
|
|
255
|
+
onBackClick={navigation.goBack}
|
|
256
|
+
headlineText={I18n.getLang('add_sleepschedule_one_source_system_back_text')}
|
|
257
|
+
headlineIcon={isMaxNum ? undefined : res.device_panel_schedule_add}
|
|
258
|
+
onHeadlineIconClick={() => {
|
|
259
|
+
state.showAddSchedulePopover = !state.showAddSchedulePopover
|
|
260
|
+
}}
|
|
261
|
+
>
|
|
262
|
+
<View style={{ marginHorizontal: cx(24) }}>
|
|
263
|
+
<Text style={{ color: '#000', fontSize: 14 }}>
|
|
264
|
+
{I18n.getLang('timeschedule_overview_description_text')}
|
|
265
|
+
</Text>
|
|
266
|
+
</View>
|
|
267
|
+
<Spacer />
|
|
268
|
+
{!!getTipText() && <View style={{ marginHorizontal: cx(24), marginVertical: cx(10), flexDirection: 'row', alignItems: 'center' }}>
|
|
269
|
+
<Image style={{ width: cx(16), height: cx(16), tintColor: '#ff9500' }} source={res.ic_warning_amber} />
|
|
270
|
+
{getTipText() === "sleep" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_sleep_text')}</Text>}
|
|
271
|
+
{getTipText() === "wakeup" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_wakeup_text')}</Text>}
|
|
272
|
+
{getTipText() === "both" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_both_text')}</Text>}
|
|
273
|
+
<Spacer />
|
|
274
|
+
</View>}
|
|
275
|
+
{hasScheduleList() && <View style={styles.tagLine}>
|
|
276
|
+
<Tag
|
|
277
|
+
checked={state.sleepTagChecked}
|
|
278
|
+
text={I18n.getLang('sleepwakeschedule_field_3_Times_chips2_text')}
|
|
279
|
+
onCheckedChange={checked => {
|
|
280
|
+
state.sleepTagChecked = checked
|
|
281
|
+
}} />
|
|
282
|
+
<Spacer width={cx(8)} height={0} />
|
|
283
|
+
<Tag
|
|
284
|
+
checked={state.wakeUpTagChecked}
|
|
285
|
+
text={I18n.getLang('sleepwakeschedule_field_3_Times_chips_text')}
|
|
286
|
+
onCheckedChange={checked => {
|
|
287
|
+
state.wakeUpTagChecked = checked
|
|
288
|
+
}} />
|
|
289
|
+
</View>}
|
|
290
|
+
{state.filteredScheduleList.length ?
|
|
291
|
+
<FlatList
|
|
292
|
+
data={state.filteredScheduleList}
|
|
293
|
+
renderItem={renderItem}
|
|
294
|
+
ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
|
|
295
|
+
ItemSeparatorComponent={() => (<Spacer />)}
|
|
296
|
+
ListFooterComponent={() => (<Spacer />)}
|
|
297
|
+
keyExtractor={item => `${item.isSleep ? 'sleep' : 'wakeUp'}_${item.index}`}
|
|
298
|
+
/> :
|
|
299
|
+
<View style={styles.emptyListCon}>
|
|
300
|
+
<Spacer height={cx(70)} />
|
|
301
|
+
<Image
|
|
302
|
+
style={styles.emptyImage}
|
|
303
|
+
source={res.scheduleEmpty}
|
|
304
|
+
resizeMode="contain" />
|
|
305
|
+
<Spacer height={cx(20)} />
|
|
306
|
+
<View style={styles.emptyText}>
|
|
307
|
+
<Image
|
|
308
|
+
source={{ uri: res.device_panel_schedule_alert }}
|
|
309
|
+
style={{ width: cx(16), height: cx(16) }}
|
|
310
|
+
/>
|
|
311
|
+
<Text style={styles.emptyNoTime}>
|
|
312
|
+
{
|
|
313
|
+
!hasScheduleList() ?
|
|
314
|
+
I18n.getLang('sleepwakeschedule_empty_information_text') :
|
|
315
|
+
I18n.getLang('sleepwakeschedule_empty_filtering_information_text')
|
|
329
316
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
317
|
+
</Text>
|
|
318
|
+
</View>
|
|
319
|
+
{!hasScheduleList() &&
|
|
320
|
+
<View style={styles.emptyBtnView}>
|
|
321
|
+
<Spacer />
|
|
322
|
+
<TextButton
|
|
323
|
+
style={styles.emptyBtn}
|
|
324
|
+
textStyle={isWakeUpMax ? styles.disableItemText : { color: '#fff' }}
|
|
325
|
+
text={I18n.getLang('sleepwakeschedule_add_button_text1')}
|
|
326
|
+
onPress={() => onAddScheduleDialogItemClick(true, 'add')}
|
|
327
|
+
/>
|
|
328
|
+
<Spacer />
|
|
329
|
+
<TextButton
|
|
330
|
+
style={styles.emptyBtn}
|
|
331
|
+
textStyle={isWakeUpMax ? styles.disableItemText : { color: '#fff' }}
|
|
332
|
+
text={I18n.getLang('sleepwakeschedule_add_button_text2')}
|
|
333
|
+
onPress={() => onAddScheduleDialogItemClick(false, 'add')}
|
|
334
|
+
/>
|
|
335
|
+
</View>}
|
|
336
|
+
</View>
|
|
337
|
+
}
|
|
338
|
+
</Page>
|
|
339
|
+
<CustomListDialog
|
|
340
|
+
show={state.showAddSchedulePopover}
|
|
341
|
+
style={styles.addMoodPopover}
|
|
342
|
+
itemStyle={styles.popoverItem}
|
|
343
|
+
onDismiss={() => {
|
|
344
|
+
state.showAddSchedulePopover = false
|
|
345
|
+
}}
|
|
346
|
+
data={[
|
|
347
|
+
{
|
|
348
|
+
text: I18n.getLang('sleepwakeschedule_add_button_text1'),
|
|
349
|
+
value: true,
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
text: I18n.getLang('sleepwakeschedule_add_button_text2'),
|
|
353
|
+
value: false,
|
|
354
|
+
},
|
|
355
|
+
]}
|
|
356
|
+
onItemPress={(isSleep) => onAddScheduleDialogItemClick(isSleep, 'add')}
|
|
357
|
+
/>
|
|
358
|
+
</>
|
|
359
|
+
)
|
|
352
360
|
}
|
|
353
361
|
|
|
354
362
|
const styles = StyleSheet.create({
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
363
|
+
tagLine: {
|
|
364
|
+
flexDirection: 'row',
|
|
365
|
+
marginHorizontal: cx(24),
|
|
366
|
+
},
|
|
367
|
+
infoLine: {
|
|
368
|
+
marginHorizontal: cx(24),
|
|
369
|
+
},
|
|
370
|
+
addMoodPopover: {
|
|
371
|
+
width: cx(210),
|
|
372
|
+
height: cx(90.5),
|
|
373
|
+
marginStart: cx(115),
|
|
374
|
+
marginTop: cx(100),
|
|
375
|
+
backgroundColor: '#fff',
|
|
376
|
+
},
|
|
377
|
+
popoverItem: {
|
|
378
|
+
width: cx(210),
|
|
379
|
+
height: cx(45),
|
|
380
|
+
alignItems: 'flex-start',
|
|
381
|
+
},
|
|
382
|
+
emptyListCon: {
|
|
383
|
+
flex: 1,
|
|
384
|
+
alignItems: 'center',
|
|
385
|
+
// marginTop: cx(30),
|
|
386
|
+
},
|
|
387
|
+
emptyImage: {
|
|
388
|
+
width: cx(225),
|
|
389
|
+
height: cx(198),
|
|
390
|
+
},
|
|
391
|
+
emptyText: {
|
|
392
|
+
flexDirection: 'row',
|
|
393
|
+
alignItems: 'center'
|
|
394
|
+
},
|
|
395
|
+
emptyNoTime: {
|
|
396
|
+
fontSize: cx(14),
|
|
397
|
+
lineHeight: cx(20),
|
|
398
|
+
textAlign: 'center',
|
|
399
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
400
|
+
color: '#000'
|
|
401
|
+
},
|
|
402
|
+
emptyBtnView: {
|
|
403
|
+
alignItems: 'center'
|
|
404
|
+
},
|
|
405
|
+
emptyBtn: {
|
|
406
|
+
backgroundColor: '#f60',
|
|
407
|
+
borderRadius: cx(5),
|
|
408
|
+
paddingHorizontal: cx(15),
|
|
409
|
+
paddingVertical: cx(10)
|
|
410
|
+
},
|
|
411
|
+
addTimer: {
|
|
412
|
+
justifyContent: 'center',
|
|
413
|
+
alignItems: 'center',
|
|
414
|
+
// width,
|
|
415
|
+
marginVertical: cx(20),
|
|
416
|
+
},
|
|
417
|
+
disableItemText: {
|
|
418
|
+
color: '#CBCBCB',
|
|
419
|
+
fontSize: cx(16),
|
|
420
|
+
},
|
|
409
421
|
})
|
|
410
422
|
|
|
411
423
|
export default SleepWakeUpPage
|