@ledvance/ui-biz-bundle 1.0.88 → 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
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.88",
7
+ "version": "1.0.90",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -173,6 +173,7 @@ const DynamicMoodEditorPage = () => {
173
173
  onChangeText={text => {
174
174
  state.mood.name = text
175
175
  }}
176
+ maxLength={33}
176
177
  showError={state.mood.name.length > 32 || nameRepeat}
177
178
  tipColor={nameRepeat ? '#f00' : undefined}
178
179
  tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
@@ -175,6 +175,7 @@ const StaticMoodEditorPage = () => {
175
175
  onChangeText={text => {
176
176
  state.mood.name = text
177
177
  }}
178
+ maxLength={33}
178
179
  showError={state.mood.name.length > 32 || nameRepeat}
179
180
  tipColor={nameRepeat ? '#f00' : undefined}
180
181
  tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
@@ -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
- label: string
28
- value: string
29
- dpId: string
27
+ label: string
28
+ value: string
29
+ dpId: string
30
30
  }
31
31
 
32
32
  export interface SleepWakeUpPageRouteParams extends JudgeTimeScheduleProps {
33
- dps: dpItem[]
34
- dpCodes: Record<string, string>
35
- getDpValue?: (v: any) => any
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
- 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)
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
- 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()
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
- const isMaxNum = useMemo(() =>{
59
- return state.sleepScheduleList.length >= MAX_SCHEDULE && state.wakeUpScheduleList >= MAX_SCHEDULE
60
- }, [state.sleepScheduleList, state.wakeUpScheduleList])
81
+ useUpdateEffect(() => {
82
+ state.sleepScheduleList = sleepPlan
83
+ }, [sleepPlan])
61
84
 
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
77
- })
78
- state.showAddSchedulePopover = false
79
- }, [state.filteredScheduleList])
85
+ useUpdateEffect(() => {
86
+ state.wakeUpScheduleList = wakeUpPlan
87
+ }, [wakeUpPlan])
80
88
 
81
- useUpdateEffect(() => {
82
- state.sleepScheduleList = sleepPlan
83
- }, [sleepPlan])
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
- useUpdateEffect(() => {
86
- state.wakeUpScheduleList = wakeUpPlan
87
- }, [wakeUpPlan])
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
- 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])
105
+ const hasScheduleList = useCallback(() => {
106
+ return !!(state.sleepScheduleList.length && state.wakeUpScheduleList.length)
107
+ }, [state.sleepScheduleList, state.wakeUpScheduleList])
98
108
 
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])
109
+ const navigateToEdit = (params) => {
110
+ navigation.navigate(ui_biz_routerKey.ui_biz_sleep_wakeUp_edit, params)
111
+ }
104
112
 
105
- const hasScheduleList = useCallback(() => {
106
- return !!(state.sleepScheduleList.length && state.wakeUpScheduleList.length)
107
- }, [state.sleepScheduleList, state.wakeUpScheduleList])
113
+ const isSleepMax = useMemo(() => {
114
+ return state.sleepScheduleList.length >= MAX_SCHEDULE
115
+ }, [state.sleepScheduleList])
108
116
 
109
- const navigateToEdit = (params) => {
110
- navigation.navigate(ui_biz_routerKey.ui_biz_sleep_wakeUp_edit, params)
111
- }
117
+ const isWakeUpMax = useMemo(() => {
118
+ return state.wakeUpScheduleList.length >= MAX_SCHEDULE
119
+ }, [state.wakeUpScheduleList])
112
120
 
113
- const onDelete = async (item) => {
114
- if (item.isSleep) {
115
- /// 删除
116
- const newList = cloneDeep(state.sleepScheduleList)
117
- const idx = state.sleepScheduleList.findIndex(sleep => sleep.index === item.index)
118
- newList.splice(idx, 1)
119
- await setSleepPlan(newList)
120
- } else {
121
- const newList = cloneDeep(state.wakeUpScheduleList)
122
- const idx = state.wakeUpScheduleList.findIndex(wakeup => wakeup.index === item.index)
123
- newList.splice(idx, 1)
124
- console.log(newList, '< --- newLIst')
125
- await setWakeUpPlan(newList)
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
- const deleteDialog = (item) => {
130
- return new Promise(resolve => {
131
- showDialog({
132
- method: 'confirm',
133
- title: I18n.getLang('cancel_dialog_delete_item_timeschedule_titel'),
134
- subTitle: I18n.getLang('cancel_dialog_delete_item_timeschedule_description'),
135
- onConfirm: async (_, { close }) => {
136
- await onDelete(item)
137
- close()
138
- resolve(true)
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
- const renderItem = useCallback(({ item }) => {
145
- return (
146
- <LdvScheduleItem
147
- item={item}
148
- onEnableChange={itemOnValueChange}
149
- onPress={(item) => onAddScheduleDialogItemClick(item.isSleep, 'edit', item)}
150
- onLongPress={(item) => {
151
- deleteDialog(item).then()
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
- const updateList = (list, conflictList) => {
158
- conflictList.forEach((conflict) => {
159
- const item = list.find((i) => i.index === conflict.index)
160
- if (item) {
161
- item.enable = 0
162
- }
163
- })
164
- return list
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
- const editTimePlanStatus = (sleepConflict, wakeupConflict, newList, fixItem) => {
168
- const { isSleep } = fixItem
169
- if (sleepConflict.length) {
170
- const listSleep = isSleep ? [...newList] : [...state.sleepScheduleList]
171
- const updateSleepList = updateList(listSleep, sleepConflict)
172
- if (!isSleep) {
173
- setSleepPlan(updateSleepList)
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
- const conflictFn = (item, editList, goback: boolean = false) => {
192
- const sleepTimeList = item.isSleep ? state.sleepScheduleList.filter(sleep => sleep.index !== item.index) : cloneDeep(state.sleepScheduleList)
193
- const wakeupTimeList = item.isSleep ? cloneDeep(state.wakeUpScheduleList) : state.wakeUpScheduleList.filter(wakeup => wakeup.index !== item.index)
194
- // 相关冲突校验
195
- const sleepConflict = findConflicts(sleepTimeList, item)
196
- const wakeupConflict = findConflicts(wakeupTimeList, item)
197
- const conflict = [...sleepConflict, ...wakeupConflict]
198
- // return
199
- // 存在冲突 || 生物节律为启用状态
200
- if (conflict.length || biorhythmState.enable) {
201
- return showDialog({
202
- method: 'confirm',
203
- title: I18n.getLang(item.isSleep ? 'conflict_dialog_save_item_sleepschedule_titel' : 'conflict_dialog_save_item_wakeupschedule_titel'),
204
- subTitle: I18n.getLang(item.isSleep ? 'conflict_dialog_save_item_sleepschedule_description' : 'conflict_dialog_save_item_wakeupschedule_description'),
205
- onConfirm: (_, { close }) => {
206
- editTimePlanStatus(sleepConflict, wakeupConflict, editList, item)
207
- if (biorhythmState.enable) setBiorhythm(deviceInfo.devId, {
208
- ...biorhythmState,
209
- enable: false,
210
- })
211
- close()
212
- if (goback) navigation.goBack()
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
- if (item.isSleep) {
217
- setSleepPlan(editList)
218
- } else {
219
- setWakeUpPlan(editList)
220
- }
221
- if (goback) navigation.goBack()
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
- const itemOnValueChange = async (item) => {
232
+ const itemOnValueChange = async (item) => {
225
233
 
226
- const editList = (item.isSleep ? state.sleepScheduleList : state.wakeUpScheduleList).map(schedule => {
227
- if (schedule.index === item.index) {
228
- return { ...schedule, enable: item.enable === 1 ? 0 : 1 }
229
- }
230
- return schedule
231
- })
232
- // 冲突检查
233
- if (!item.enable) {
234
- return conflictFn(item, editList)
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
- if (item.isSleep) {
238
- setSleepPlan(editList)
239
- } else {
240
- setWakeUpPlan(editList)
241
- }
245
+ if (item.isSleep) {
246
+ setSleepPlan(editList)
247
+ } else {
248
+ setWakeUpPlan(editList)
242
249
  }
243
- return (
244
- <>
245
- <Page
246
- backText={deviceInfo.name}
247
- onBackClick={navigation.goBack}
248
- headlineText={I18n.getLang('add_sleepschedule_one_source_system_back_text')}
249
- headlineIcon={isMaxNum ? undefined : res.device_panel_schedule_add}
250
- onHeadlineIconClick={() => {
251
- state.showAddSchedulePopover = !state.showAddSchedulePopover
252
- }}
253
- >
254
- <View style={{ marginHorizontal: cx(24) }}>
255
- <Text style={{ color: '#000', fontSize: 14 }}>
256
- {I18n.getLang('timeschedule_overview_description_text')}
257
- </Text>
258
- </View>
259
- <Spacer />
260
- {!!getTipText() && <View style={{ marginHorizontal: cx(24), marginVertical: cx(10), flexDirection: 'row', alignItems: 'center' }}>
261
- <Image style={{ width: cx(16), height: cx(16), tintColor: '#ff9500' }} source={res.ic_warning_amber} />
262
- {getTipText() === "sleep" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_sleep_text')}</Text>}
263
- {getTipText() === "wakeup" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_wakeup_text')}</Text>}
264
- {getTipText() === "both" && <Text>{I18n.getLang('sleepwakeschedule_warning_max_number_both_text')}</Text>}
265
- <Spacer />
266
- </View>}
267
- {hasScheduleList() && <View style={styles.tagLine}>
268
- <Tag
269
- checked={state.sleepTagChecked}
270
- text={I18n.getLang('sleepwakeschedule_field_3_Times_chips2_text')}
271
- onCheckedChange={checked => {
272
- state.sleepTagChecked = checked
273
- }} />
274
- <Spacer width={cx(8)} height={0} />
275
- <Tag
276
- checked={state.wakeUpTagChecked}
277
- text={I18n.getLang('sleepwakeschedule_field_3_Times_chips_text')}
278
- onCheckedChange={checked => {
279
- state.wakeUpTagChecked = checked
280
- }} />
281
- </View>}
282
- {state.filteredScheduleList.length ?
283
- <FlatList
284
- data={state.filteredScheduleList}
285
- renderItem={renderItem}
286
- ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
287
- ItemSeparatorComponent={() => (<Spacer />)}
288
- ListFooterComponent={() => (<Spacer />)}
289
- keyExtractor={item => `${item.isSleep ? 'sleep' : 'wakeUp'}_${item.index}`}
290
- /> :
291
- <View style={styles.emptyListCon}>
292
- <Spacer height={cx(70)} />
293
- <Image
294
- style={styles.emptyImage}
295
- source={res.scheduleEmpty}
296
- resizeMode="contain" />
297
- <Spacer height={cx(20)} />
298
- <View style={styles.emptyText}>
299
- <Image
300
- source={{ uri: res.device_panel_schedule_alert }}
301
- style={{ width: cx(16), height: cx(16) }}
302
- />
303
- <Text style={styles.emptyNoTime}>
304
- {
305
- !hasScheduleList() ?
306
- I18n.getLang('sleepwakeschedule_empty_information_text') :
307
- I18n.getLang('sleepwakeschedule_empty_filtering_information_text')
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
- </Page>
331
- <CustomListDialog
332
- show={state.showAddSchedulePopover}
333
- style={styles.addMoodPopover}
334
- itemStyle={styles.popoverItem}
335
- onDismiss={() => {
336
- state.showAddSchedulePopover = false
337
- }}
338
- data={[
339
- {
340
- text: I18n.getLang('sleepwakeschedule_add_button_text1'),
341
- value: true,
342
- },
343
- {
344
- text: I18n.getLang('sleepwakeschedule_add_button_text2'),
345
- value: false,
346
- },
347
- ]}
348
- onItemPress={(isSleep) => onAddScheduleDialogItemClick(isSleep, 'add')}
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
- tagLine: {
356
- flexDirection: 'row',
357
- marginHorizontal: cx(24),
358
- },
359
- infoLine: {
360
- marginHorizontal: cx(24),
361
- },
362
- addMoodPopover: {
363
- width: cx(210),
364
- height: cx(90.5),
365
- marginStart: cx(115),
366
- marginTop: cx(100),
367
- backgroundColor: '#fff',
368
- },
369
- popoverItem: {
370
- width: cx(210),
371
- height: cx(45),
372
- alignItems: 'flex-start',
373
- },
374
- emptyListCon: {
375
- flex: 1,
376
- alignItems: 'center',
377
- // marginTop: cx(30),
378
- },
379
- emptyImage: {
380
- width: cx(225),
381
- height: cx(198),
382
- },
383
- emptyText: {
384
- flexDirection: 'row',
385
- alignItems: 'center'
386
- },
387
- emptyNoTime: {
388
- fontSize: cx(14),
389
- lineHeight: cx(20),
390
- textAlign: 'center',
391
- fontFamily: 'helvetica_neue_lt_std_roman',
392
- color: '#000'
393
- },
394
- emptyBtnView: {
395
- alignItems: 'center'
396
- },
397
- emptyBtn: {
398
- backgroundColor: '#f60',
399
- borderRadius: cx(5),
400
- paddingHorizontal: cx(15),
401
- paddingVertical: cx(10)
402
- },
403
- addTimer: {
404
- justifyContent: 'center',
405
- alignItems: 'center',
406
- // width,
407
- marginVertical: cx(20),
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