@ledvance/ui-biz-bundle 1.1.69 → 1.1.71

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.
Files changed (222) hide show
  1. package/.babelrc +31 -31
  2. package/.eslintignore +5 -5
  3. package/.eslintrc.js +27 -27
  4. package/.prettierrc.js +1 -1
  5. package/.versionrc +5 -5
  6. package/package.json +74 -74
  7. package/rn-cli.config.js +8 -8
  8. package/src/hooks/DeviceDpStateHooks.d.ts +14 -14
  9. package/src/hooks/DeviceDpStateHooks.ts +50 -50
  10. package/src/modules/biorhythm/BiorhythmActions.d.ts +8 -8
  11. package/src/modules/biorhythm/BiorhythmActions.ts +324 -324
  12. package/src/modules/biorhythm/BiorhythmBean.d.ts +58 -58
  13. package/src/modules/biorhythm/BiorhythmBean.ts +230 -230
  14. package/src/modules/biorhythm/BiorhythmEditPage.d.ts +14 -14
  15. package/src/modules/biorhythm/BiorhythmEditPage.tsx +324 -324
  16. package/src/modules/biorhythm/BiorhythmPage.d.ts +10 -10
  17. package/src/modules/biorhythm/BiorhythmPage.tsx +796 -796
  18. package/src/modules/biorhythm/IconSelect.d.ts +2 -2
  19. package/src/modules/biorhythm/IconSelect.tsx +81 -81
  20. package/src/modules/biorhythm/Router.ts +34 -34
  21. package/src/modules/biorhythm/circular/ItemIcon.d.ts +22 -22
  22. package/src/modules/biorhythm/circular/ItemIcon.tsx +172 -172
  23. package/src/modules/biorhythm/circular/Progress.d.ts +24 -24
  24. package/src/modules/biorhythm/circular/Progress.tsx +411 -411
  25. package/src/modules/biorhythm/circular/TimeCircular.d.ts +11 -11
  26. package/src/modules/biorhythm/circular/TimeCircular.tsx +70 -70
  27. package/src/modules/biorhythm/iconListData.d.ts +7 -7
  28. package/src/modules/biorhythm/iconListData.ts +29 -29
  29. package/src/modules/biorhythm/pIdList.d.ts +2 -2
  30. package/src/modules/biorhythm/pIdList.ts +35 -35
  31. package/src/modules/biorhythm/res/BiologicalRes.d.ts +43 -43
  32. package/src/modules/biorhythm/res/BiologicalRes.ts +41 -41
  33. package/src/modules/config/ldvConfig.d.ts +2 -2
  34. package/src/modules/config/ldvConfig.tsx +18 -18
  35. package/src/modules/fixedTime/FixedTimeActions.ts +173 -173
  36. package/src/modules/fixedTime/FixedTimeDetailPage.tsx +372 -372
  37. package/src/modules/fixedTime/FixedTimePage.tsx +213 -213
  38. package/src/modules/fixedTime/Router.ts +26 -26
  39. package/src/modules/flags/FlagActions.ts +267 -267
  40. package/src/modules/flags/FlagEditPage.tsx +441 -441
  41. package/src/modules/flags/FlagInfo.tsx +563 -563
  42. package/src/modules/flags/FlagItem.tsx +90 -90
  43. package/src/modules/flags/FlagPage.tsx +277 -277
  44. package/src/modules/flags/Router.ts +25 -25
  45. package/src/modules/history/HistoryPage.d.ts +2 -2
  46. package/src/modules/history/HistoryPage.tsx +261 -261
  47. package/src/modules/history/Router.ts +16 -16
  48. package/src/modules/history/SwitchHistoryPageActions.d.ts +14 -14
  49. package/src/modules/history/SwitchHistoryPageActions.ts +76 -76
  50. package/src/modules/mood/AddMoodPage.d.ts +10 -10
  51. package/src/modules/mood/AddMoodPage.tsx +792 -792
  52. package/src/modules/mood/DynamicMoodEditorPage.d.ts +6 -6
  53. package/src/modules/mood/DynamicMoodEditorPage.tsx +561 -561
  54. package/src/modules/mood/FantasyMood.tsx +176 -176
  55. package/src/modules/mood/FantasyMoodEditPage.tsx +582 -582
  56. package/src/modules/mood/FantasyMoodItem.tsx +104 -104
  57. package/src/modules/mood/FantasyRouter.ts +35 -35
  58. package/src/modules/mood/MixMood/AddMixMoodPage.tsx +247 -247
  59. package/src/modules/mood/MixMood/MixMoodActions.ts +128 -128
  60. package/src/modules/mood/MixMood/MixMoodEditPage.tsx +721 -721
  61. package/src/modules/mood/MixMood/MixMoodItem.tsx +134 -134
  62. package/src/modules/mood/MixMood/MixMoodPage.tsx +326 -326
  63. package/src/modules/mood/MixMood/MixSceneBeans.ts +364 -364
  64. package/src/modules/mood/MixMood/RecommendMixMoodItem.tsx +69 -69
  65. package/src/modules/mood/MixMood/Router.ts +44 -44
  66. package/src/modules/mood/MoodItem.d.ts +11 -11
  67. package/src/modules/mood/MoodItem.tsx +114 -114
  68. package/src/modules/mood/MoodPage.d.ts +16 -16
  69. package/src/modules/mood/MoodPage.tsx +296 -296
  70. package/src/modules/mood/RecommendMoodItem.d.ts +13 -13
  71. package/src/modules/mood/RecommendMoodItem.tsx +74 -74
  72. package/src/modules/mood/Router.ts +53 -53
  73. package/src/modules/mood/StaticMoodEditorPage.d.ts +16 -16
  74. package/src/modules/mood/StaticMoodEditorPage.tsx +320 -320
  75. package/src/modules/mood/tools.d.ts +3 -3
  76. package/src/modules/mood/tools.ts +11 -11
  77. package/src/modules/music/MusicDataBean.d.ts +47 -47
  78. package/src/modules/music/MusicDataBean.ts +167 -167
  79. package/src/modules/music/MusicManager.d.ts +27 -27
  80. package/src/modules/music/MusicManager.ts +207 -207
  81. package/src/modules/music/MusicPage.d.ts +10 -10
  82. package/src/modules/music/MusicPage.tsx +347 -347
  83. package/src/modules/music/MusicPageActions.d.ts +35 -35
  84. package/src/modules/music/MusicPageActions.ts +317 -317
  85. package/src/modules/music/Router.ts +16 -16
  86. package/src/modules/music/SelecetGenre.d.ts +7 -7
  87. package/src/modules/music/SelecetGenre.tsx +63 -63
  88. package/src/modules/music/color.d.ts +2 -2
  89. package/src/modules/music/color.ts +73 -73
  90. package/src/modules/music/res/index.d.ts +10 -10
  91. package/src/modules/music/res/index.ts +9 -9
  92. package/src/modules/powerOnBehavior/PowerOnBehaviorActions.ts +11 -11
  93. package/src/modules/powerOnBehavior/PowerOnBehaviorPage.tsx +173 -173
  94. package/src/modules/powerOnBehavior/Router.ts +16 -16
  95. package/src/modules/randomTime/RandomTimeActions.ts +160 -160
  96. package/src/modules/randomTime/RandomTimeDetailPage.tsx +337 -337
  97. package/src/modules/randomTime/RandomTimePage.tsx +214 -214
  98. package/src/modules/randomTime/Router.ts +25 -25
  99. package/src/modules/randomTime/Summary.tsx +122 -122
  100. package/src/modules/scene/SceneAction.d.ts +13 -13
  101. package/src/modules/scene/SceneAction.ts +473 -473
  102. package/src/modules/scene/SceneDetailPage.d.ts +1 -1
  103. package/src/modules/scene/SceneDetailPage.tsx +421 -421
  104. package/src/modules/scene/SceneInfo.d.ts +72 -72
  105. package/src/modules/scene/SceneInfo.ts +1059 -1059
  106. package/src/modules/scene/ScenePage.d.ts +7 -7
  107. package/src/modules/scene/ScenePage.tsx +147 -147
  108. package/src/modules/select/SelectPage.d.ts +12 -12
  109. package/src/modules/select/SelectPage.tsx +137 -137
  110. package/src/modules/sleepWakeup/DeviceState.d.ts +9 -9
  111. package/src/modules/sleepWakeup/DeviceState.tsx +99 -99
  112. package/src/modules/sleepWakeup/LdvScheduleItem.d.ts +15 -15
  113. package/src/modules/sleepWakeup/LdvScheduleItem.tsx +176 -176
  114. package/src/modules/sleepWakeup/Router.ts +25 -25
  115. package/src/modules/sleepWakeup/SleepWakeUpActions.d.ts +2 -2
  116. package/src/modules/sleepWakeup/SleepWakeUpActions.ts +180 -180
  117. package/src/modules/sleepWakeup/SleepWakeUpDetailPage.d.ts +2 -2
  118. package/src/modules/sleepWakeup/SleepWakeUpDetailPage.tsx +616 -616
  119. package/src/modules/sleepWakeup/SleepWakeUpPage.d.ts +13 -13
  120. package/src/modules/sleepWakeup/SleepWakeUpPage.tsx +424 -424
  121. package/src/modules/sleepWakeup/utils.d.ts +44 -44
  122. package/src/modules/sleepWakeup/utils.ts +253 -253
  123. package/src/modules/timeSchedule/DeviceState.d.ts +17 -17
  124. package/src/modules/timeSchedule/DeviceState.tsx +94 -94
  125. package/src/modules/timeSchedule/LdvScheduleItem.d.ts +15 -15
  126. package/src/modules/timeSchedule/LdvScheduleItem.tsx +130 -130
  127. package/src/modules/timeSchedule/ManualSetting.d.ts +14 -14
  128. package/src/modules/timeSchedule/ManualSetting.tsx +219 -219
  129. package/src/modules/timeSchedule/MoodSetting.d.ts +11 -11
  130. package/src/modules/timeSchedule/MoodSetting.tsx +228 -228
  131. package/src/modules/timeSchedule/Router.ts +25 -25
  132. package/src/modules/timeSchedule/ScheduleScene.d.ts +6 -6
  133. package/src/modules/timeSchedule/ScheduleScene.tsx +144 -144
  134. package/src/modules/timeSchedule/SingleLightView.d.ts +12 -12
  135. package/src/modules/timeSchedule/SingleLightView.tsx +175 -175
  136. package/src/modules/timeSchedule/TimeScheduleBean.d.ts +14 -14
  137. package/src/modules/timeSchedule/TimeScheduleBean.ts +18 -18
  138. package/src/modules/timeSchedule/TimeScheduleEditpage.d.ts +6 -6
  139. package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +765 -765
  140. package/src/modules/timeSchedule/TimeSchedulePage.d.ts +13 -13
  141. package/src/modules/timeSchedule/TimeSchedulePage.tsx +358 -358
  142. package/src/modules/timeSchedule/components/ColorList.ts +23 -23
  143. package/src/modules/timeSchedule/components/LampSwitchCard.tsx +106 -106
  144. package/src/modules/timeSchedule/mix/MixLightActions.d.ts +3 -3
  145. package/src/modules/timeSchedule/mix/MixLightActions.ts +49 -49
  146. package/src/modules/timeSchedule/mix/MixLightBean.d.ts +10 -10
  147. package/src/modules/timeSchedule/mix/MixLightBean.ts +9 -9
  148. package/src/modules/timeSchedule/mix/MixLightView.d.ts +7 -7
  149. package/src/modules/timeSchedule/mix/MixLightView.tsx +197 -197
  150. package/src/modules/timeSchedule/utils.d.ts +1 -1
  151. package/src/modules/timeSchedule/utils.ts +6 -6
  152. package/src/modules/timer/Router.ts +16 -16
  153. package/src/modules/timer/TimerPage.d.ts +11 -11
  154. package/src/modules/timer/TimerPage.tsx +384 -384
  155. package/src/modules/timer/TimerPageAction.d.ts +22 -22
  156. package/src/modules/timer/TimerPageAction.ts +131 -131
  157. package/src/navigation/Routers.d.ts +15 -15
  158. package/src/navigation/Routers.ts +46 -46
  159. package/src/navigation/tools.d.ts +9 -9
  160. package/src/navigation/tools.ts +21 -21
  161. package/src/newModules/biorhythm/BiorhythmActions.ts +62 -11
  162. package/src/newModules/biorhythm/BiorhythmPage.tsx +1 -4
  163. package/src/newModules/childLock/ChildLockPage.tsx +97 -97
  164. package/src/newModules/childLock/Router.ts +16 -16
  165. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -23
  166. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -84
  167. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +322 -322
  168. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +393 -393
  169. package/src/newModules/energyConsumption/Router.ts +34 -34
  170. package/src/newModules/energyConsumption/co2Data.ts +23655 -23655
  171. package/src/newModules/energyConsumption/component/BarChart.tsx +93 -93
  172. package/src/newModules/energyConsumption/component/EnergyModal.tsx +284 -284
  173. package/src/newModules/energyConsumption/component/Overview.tsx +118 -118
  174. package/src/newModules/fixedTime/FixedTimeActions.ts +241 -241
  175. package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +345 -345
  176. package/src/newModules/fixedTime/FixedTimePage.tsx +302 -302
  177. package/src/newModules/fixedTime/Router.ts +25 -25
  178. package/src/newModules/lightMode/LightModePage.tsx +204 -204
  179. package/src/newModules/lightMode/Router.ts +16 -16
  180. package/src/newModules/mood/Interface.ts +5 -0
  181. package/src/newModules/mood/MixDynamicMoodEditor.tsx +8 -5
  182. package/src/newModules/mood/MoodActions.ts +32 -20
  183. package/src/newModules/mood/MoodItem.tsx +3 -3
  184. package/src/newModules/mood/MoodPage.tsx +31 -15
  185. package/src/newModules/mood/MoodParse.ts +5 -6
  186. package/src/newModules/mood/RecommendMoodItem.tsx +3 -3
  187. package/src/newModules/mood/Router.ts +9 -0
  188. package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -96
  189. package/src/newModules/overchargeSwitch/Router.ts +16 -16
  190. package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -266
  191. package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -173
  192. package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -106
  193. package/src/newModules/powerOnBehavior/Router.ts +27 -27
  194. package/src/newModules/randomTime/RandomTimeActions.ts +238 -238
  195. package/src/newModules/randomTime/RandomTimeDetailPage.tsx +325 -325
  196. package/src/newModules/randomTime/RandomTimePage.tsx +299 -299
  197. package/src/newModules/randomTime/Router.ts +25 -25
  198. package/src/newModules/randomTime/Summary.tsx +116 -116
  199. package/src/newModules/remoteControl/RemoteControlActions.ts +5 -5
  200. package/src/newModules/remoteControl/RemoteControlPage.tsx +51 -51
  201. package/src/newModules/remoteControl/Router.ts +15 -15
  202. package/src/newModules/select/Route.ts +16 -16
  203. package/src/newModules/select/SelectPage.d.ts +12 -12
  204. package/src/newModules/select/SelectPage.tsx +137 -137
  205. package/src/newModules/sleepWakeUp/Interface.ts +69 -69
  206. package/src/newModules/sleepWakeUp/Router.ts +24 -24
  207. package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +317 -317
  208. package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +661 -661
  209. package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +455 -455
  210. package/src/newModules/sleepWakeUp/utils.ts +253 -253
  211. package/src/newModules/swithInching/Router.ts +16 -16
  212. package/src/newModules/swithInching/SwithInching.tsx +231 -231
  213. package/src/newModules/swithInching/SwithInchingAction.ts +55 -55
  214. package/src/newModules/swithInching/pickerView.tsx +91 -91
  215. package/src/newModules/timeSchedule/Interface.ts +142 -142
  216. package/src/newModules/timeSchedule/Router.ts +25 -25
  217. package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -53
  218. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +648 -648
  219. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +253 -253
  220. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +460 -460
  221. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +125 -125
  222. package/tsconfig.json +50 -50
@@ -1,425 +1,425 @@
1
- import React, { useCallback, useEffect, useMemo } from "react";
2
- import { StyleSheet, View, Text, Image, FlatList } from 'react-native'
3
- import { useRoute } from '@react-navigation/core'
4
- import Page from '@ledvance/base/src/components/Page'
5
- import Tag from '@ledvance/base/src/components/Tag'
6
- import Spacer from '@ledvance/base/src/components/Spacer'
7
- import { useNavigation } from '@react-navigation/native'
8
- import I18n from '@ledvance/base/src/i18n'
9
- import res from '@ledvance/base/src/res'
10
- import { useDeviceInfo } from "@ledvance/base/src/models/modules/NativePropsSlice";
11
- import { useReactive, useUpdateEffect } from "ahooks";
12
- import CustomListDialog from "@ledvance/base/src/components/CustomListDialog";
13
- import { Utils } from "tuya-panel-kit";
14
- import LdvScheduleItem from "./LdvScheduleItem";
15
- import { showDialog } from "@ledvance/base/src/utils/common";
16
- import TextButton from "@ledvance/base/src/components/TextButton";
17
- import { JudgeTimeScheduleProps } from "../timeSchedule/TimeScheduleBean";
18
- import { useSleepPlan, useWakeUpPlan } from "./SleepWakeUpActions";
19
- import { ui_biz_routerKey } from "../../navigation/Routers";
20
- import { findConflicts } from '@ledvance/base/src/utils/loopsCompare'
21
- import { useBiorhythm } from '@ledvance/ui-biz-bundle/src/modules/biorhythm/BiorhythmActions'
22
- import { cloneDeep } from "lodash";
23
-
24
- const cx = Utils.RatioUtils.convertX
25
-
26
- type dpItem = {
27
- label: string
28
- value: string
29
- dpId: string
30
- }
31
-
32
- export interface SleepWakeUpPageRouteParams extends JudgeTimeScheduleProps {
33
- dps: dpItem[]
34
- dpCodes: Record<string, string>
35
- getDpValue?: (v: any) => any
36
- }
37
-
38
- const MAX_SCHEDULE = 4
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)
46
-
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()
56
- })
57
-
58
- const isMaxNum = useMemo(() => {
59
- return state.sleepScheduleList.length >= MAX_SCHEDULE && state.wakeUpScheduleList.length >= 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
77
- })
78
- state.showAddSchedulePopover = false
79
- }, [state.filteredScheduleList])
80
-
81
- useUpdateEffect(() => {
82
- state.sleepScheduleList = sleepPlan
83
- }, [sleepPlan])
84
-
85
- useUpdateEffect(() => {
86
- state.wakeUpScheduleList = wakeUpPlan
87
- }, [wakeUpPlan])
88
-
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])
98
-
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])
104
-
105
- const hasScheduleList = useCallback(() => {
106
- return !!(state.sleepScheduleList.length && state.wakeUpScheduleList.length)
107
- }, [state.sleepScheduleList, state.wakeUpScheduleList])
108
-
109
- const navigateToEdit = (params) => {
110
- navigation.navigate(ui_biz_routerKey.ui_biz_sleep_wakeUp_edit, params)
111
- }
112
-
113
- const isSleepMax = useMemo(() => {
114
- return state.sleepScheduleList.length >= MAX_SCHEDULE
115
- }, [state.sleepScheduleList])
116
-
117
- const isWakeUpMax = useMemo(() => {
118
- return state.wakeUpScheduleList.length >= MAX_SCHEDULE
119
- }, [state.wakeUpScheduleList])
120
-
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)
134
- }
135
- }
136
-
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
- }
151
-
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
- }, [])
164
-
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
- }
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
- }
183
-
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
- }
198
-
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()
221
- }
222
- })
223
- }
224
- if (item.isSleep) {
225
- setSleepPlan(editList)
226
- } else {
227
- setWakeUpPlan(editList)
228
- }
229
- if (goback) navigation.goBack()
230
- }
231
-
232
- const itemOnValueChange = async (item) => {
233
-
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
- }
244
-
245
- if (item.isSleep) {
246
- setSleepPlan(editList)
247
- } else {
248
- setWakeUpPlan(editList)
249
- }
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')
316
- }
317
- </Text>
318
- </View>
319
- {!hasScheduleList() &&
320
- <View style={styles.emptyBtnView}>
321
- <Spacer />
322
- <TextButton
323
- style={styles.emptyBtn}
324
- textStyle={isSleepMax ? 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
- isMax: isSleepMax
351
- },
352
- {
353
- text: I18n.getLang('sleepwakeschedule_add_button_text2'),
354
- value: false,
355
- isMax: isWakeUpMax
356
- },
357
- ]}
358
- onItemPress={(isSleep) => onAddScheduleDialogItemClick(isSleep, 'add')}
359
- />
360
- </>
361
- )
362
- }
363
-
364
- const styles = StyleSheet.create({
365
- tagLine: {
366
- flexDirection: 'row',
367
- marginHorizontal: cx(24),
368
- },
369
- infoLine: {
370
- marginHorizontal: cx(24),
371
- },
372
- addMoodPopover: {
373
- width: cx(210),
374
- height: cx(90.5),
375
- marginStart: cx(115),
376
- marginTop: cx(100),
377
- backgroundColor: '#fff',
378
- },
379
- popoverItem: {
380
- width: cx(210),
381
- height: cx(45),
382
- alignItems: 'flex-start',
383
- },
384
- emptyListCon: {
385
- flex: 1,
386
- alignItems: 'center',
387
- // marginTop: cx(30),
388
- },
389
- emptyImage: {
390
- width: cx(225),
391
- height: cx(198),
392
- },
393
- emptyText: {
394
- flexDirection: 'row',
395
- alignItems: 'center'
396
- },
397
- emptyNoTime: {
398
- fontSize: cx(14),
399
- lineHeight: cx(20),
400
- textAlign: 'center',
401
- fontFamily: 'helvetica_neue_lt_std_roman',
402
- color: '#000'
403
- },
404
- emptyBtnView: {
405
- alignItems: 'center'
406
- },
407
- emptyBtn: {
408
- backgroundColor: '#f60',
409
- borderRadius: cx(5),
410
- paddingHorizontal: cx(15),
411
- paddingVertical: cx(10)
412
- },
413
- addTimer: {
414
- justifyContent: 'center',
415
- alignItems: 'center',
416
- // width,
417
- marginVertical: cx(20),
418
- },
419
- disableItemText: {
420
- color: '#CBCBCB',
421
- fontSize: cx(16),
422
- },
423
- })
424
-
1
+ import React, { useCallback, useEffect, useMemo } from "react";
2
+ import { StyleSheet, View, Text, Image, FlatList } from 'react-native'
3
+ import { useRoute } from '@react-navigation/core'
4
+ import Page from '@ledvance/base/src/components/Page'
5
+ import Tag from '@ledvance/base/src/components/Tag'
6
+ import Spacer from '@ledvance/base/src/components/Spacer'
7
+ import { useNavigation } from '@react-navigation/native'
8
+ import I18n from '@ledvance/base/src/i18n'
9
+ import res from '@ledvance/base/src/res'
10
+ import { useDeviceInfo } from "@ledvance/base/src/models/modules/NativePropsSlice";
11
+ import { useReactive, useUpdateEffect } from "ahooks";
12
+ import CustomListDialog from "@ledvance/base/src/components/CustomListDialog";
13
+ import { Utils } from "tuya-panel-kit";
14
+ import LdvScheduleItem from "./LdvScheduleItem";
15
+ import { showDialog } from "@ledvance/base/src/utils/common";
16
+ import TextButton from "@ledvance/base/src/components/TextButton";
17
+ import { JudgeTimeScheduleProps } from "../timeSchedule/TimeScheduleBean";
18
+ import { useSleepPlan, useWakeUpPlan } from "./SleepWakeUpActions";
19
+ import { ui_biz_routerKey } from "../../navigation/Routers";
20
+ import { findConflicts } from '@ledvance/base/src/utils/loopsCompare'
21
+ import { useBiorhythm } from '@ledvance/ui-biz-bundle/src/modules/biorhythm/BiorhythmActions'
22
+ import { cloneDeep } from "lodash";
23
+
24
+ const cx = Utils.RatioUtils.convertX
25
+
26
+ type dpItem = {
27
+ label: string
28
+ value: string
29
+ dpId: string
30
+ }
31
+
32
+ export interface SleepWakeUpPageRouteParams extends JudgeTimeScheduleProps {
33
+ dps: dpItem[]
34
+ dpCodes: Record<string, string>
35
+ getDpValue?: (v: any) => any
36
+ }
37
+
38
+ const MAX_SCHEDULE = 4
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)
46
+
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()
56
+ })
57
+
58
+ const isMaxNum = useMemo(() => {
59
+ return state.sleepScheduleList.length >= MAX_SCHEDULE && state.wakeUpScheduleList.length >= 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
77
+ })
78
+ state.showAddSchedulePopover = false
79
+ }, [state.filteredScheduleList])
80
+
81
+ useUpdateEffect(() => {
82
+ state.sleepScheduleList = sleepPlan
83
+ }, [sleepPlan])
84
+
85
+ useUpdateEffect(() => {
86
+ state.wakeUpScheduleList = wakeUpPlan
87
+ }, [wakeUpPlan])
88
+
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])
98
+
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])
104
+
105
+ const hasScheduleList = useCallback(() => {
106
+ return !!(state.sleepScheduleList.length && state.wakeUpScheduleList.length)
107
+ }, [state.sleepScheduleList, state.wakeUpScheduleList])
108
+
109
+ const navigateToEdit = (params) => {
110
+ navigation.navigate(ui_biz_routerKey.ui_biz_sleep_wakeUp_edit, params)
111
+ }
112
+
113
+ const isSleepMax = useMemo(() => {
114
+ return state.sleepScheduleList.length >= MAX_SCHEDULE
115
+ }, [state.sleepScheduleList])
116
+
117
+ const isWakeUpMax = useMemo(() => {
118
+ return state.wakeUpScheduleList.length >= MAX_SCHEDULE
119
+ }, [state.wakeUpScheduleList])
120
+
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)
134
+ }
135
+ }
136
+
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
+ }
151
+
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
+ }, [])
164
+
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
+ }
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
+ }
183
+
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
+ }
198
+
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()
221
+ }
222
+ })
223
+ }
224
+ if (item.isSleep) {
225
+ setSleepPlan(editList)
226
+ } else {
227
+ setWakeUpPlan(editList)
228
+ }
229
+ if (goback) navigation.goBack()
230
+ }
231
+
232
+ const itemOnValueChange = async (item) => {
233
+
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
+ }
244
+
245
+ if (item.isSleep) {
246
+ setSleepPlan(editList)
247
+ } else {
248
+ setWakeUpPlan(editList)
249
+ }
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')
316
+ }
317
+ </Text>
318
+ </View>
319
+ {!hasScheduleList() &&
320
+ <View style={styles.emptyBtnView}>
321
+ <Spacer />
322
+ <TextButton
323
+ style={styles.emptyBtn}
324
+ textStyle={isSleepMax ? 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
+ isMax: isSleepMax
351
+ },
352
+ {
353
+ text: I18n.getLang('sleepwakeschedule_add_button_text2'),
354
+ value: false,
355
+ isMax: isWakeUpMax
356
+ },
357
+ ]}
358
+ onItemPress={(isSleep) => onAddScheduleDialogItemClick(isSleep, 'add')}
359
+ />
360
+ </>
361
+ )
362
+ }
363
+
364
+ const styles = StyleSheet.create({
365
+ tagLine: {
366
+ flexDirection: 'row',
367
+ marginHorizontal: cx(24),
368
+ },
369
+ infoLine: {
370
+ marginHorizontal: cx(24),
371
+ },
372
+ addMoodPopover: {
373
+ width: cx(210),
374
+ height: cx(90.5),
375
+ marginStart: cx(115),
376
+ marginTop: cx(100),
377
+ backgroundColor: '#fff',
378
+ },
379
+ popoverItem: {
380
+ width: cx(210),
381
+ height: cx(45),
382
+ alignItems: 'flex-start',
383
+ },
384
+ emptyListCon: {
385
+ flex: 1,
386
+ alignItems: 'center',
387
+ // marginTop: cx(30),
388
+ },
389
+ emptyImage: {
390
+ width: cx(225),
391
+ height: cx(198),
392
+ },
393
+ emptyText: {
394
+ flexDirection: 'row',
395
+ alignItems: 'center'
396
+ },
397
+ emptyNoTime: {
398
+ fontSize: cx(14),
399
+ lineHeight: cx(20),
400
+ textAlign: 'center',
401
+ fontFamily: 'helvetica_neue_lt_std_roman',
402
+ color: '#000'
403
+ },
404
+ emptyBtnView: {
405
+ alignItems: 'center'
406
+ },
407
+ emptyBtn: {
408
+ backgroundColor: '#f60',
409
+ borderRadius: cx(5),
410
+ paddingHorizontal: cx(15),
411
+ paddingVertical: cx(10)
412
+ },
413
+ addTimer: {
414
+ justifyContent: 'center',
415
+ alignItems: 'center',
416
+ // width,
417
+ marginVertical: cx(20),
418
+ },
419
+ disableItemText: {
420
+ color: '#CBCBCB',
421
+ fontSize: cx(16),
422
+ },
423
+ })
424
+
425
425
  export default SleepWakeUpPage