@ledvance/ui-biz-bundle 1.1.69 → 1.1.70

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 (226) 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/AddMoodPage.tsx +194 -194
  181. package/src/newModules/mood/DynamicMoodEditorPage.tsx +650 -650
  182. package/src/newModules/mood/Interface.ts +220 -220
  183. package/src/newModules/mood/MixDynamicMoodEditor.tsx +786 -786
  184. package/src/newModules/mood/MoodActions.ts +232 -232
  185. package/src/newModules/mood/MoodInfo.ts +2151 -2151
  186. package/src/newModules/mood/MoodItem.tsx +160 -160
  187. package/src/newModules/mood/MoodPage.tsx +386 -386
  188. package/src/newModules/mood/MoodParse.ts +443 -443
  189. package/src/newModules/mood/RecommendMoodItem.tsx +81 -81
  190. package/src/newModules/mood/Router.ts +43 -43
  191. package/src/newModules/mood/StaticMoodEditorPage.tsx +290 -290
  192. package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -96
  193. package/src/newModules/overchargeSwitch/Router.ts +16 -16
  194. package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -266
  195. package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -173
  196. package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -106
  197. package/src/newModules/powerOnBehavior/Router.ts +27 -27
  198. package/src/newModules/randomTime/RandomTimeActions.ts +238 -238
  199. package/src/newModules/randomTime/RandomTimeDetailPage.tsx +325 -325
  200. package/src/newModules/randomTime/RandomTimePage.tsx +299 -299
  201. package/src/newModules/randomTime/Router.ts +25 -25
  202. package/src/newModules/randomTime/Summary.tsx +116 -116
  203. package/src/newModules/remoteControl/RemoteControlActions.ts +5 -5
  204. package/src/newModules/remoteControl/RemoteControlPage.tsx +51 -51
  205. package/src/newModules/remoteControl/Router.ts +15 -15
  206. package/src/newModules/select/Route.ts +16 -16
  207. package/src/newModules/select/SelectPage.d.ts +12 -12
  208. package/src/newModules/select/SelectPage.tsx +137 -137
  209. package/src/newModules/sleepWakeUp/Interface.ts +69 -69
  210. package/src/newModules/sleepWakeUp/Router.ts +24 -24
  211. package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +317 -317
  212. package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +661 -661
  213. package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +455 -455
  214. package/src/newModules/sleepWakeUp/utils.ts +253 -253
  215. package/src/newModules/swithInching/Router.ts +16 -16
  216. package/src/newModules/swithInching/SwithInching.tsx +231 -231
  217. package/src/newModules/swithInching/SwithInchingAction.ts +55 -55
  218. package/src/newModules/swithInching/pickerView.tsx +91 -91
  219. package/src/newModules/timeSchedule/Interface.ts +142 -142
  220. package/src/newModules/timeSchedule/Router.ts +25 -25
  221. package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -53
  222. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +648 -648
  223. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +253 -253
  224. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +460 -460
  225. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +125 -125
  226. package/tsconfig.json +50 -50
@@ -1,796 +1,796 @@
1
- import React, { useCallback, useEffect, useMemo } from 'react'
2
- import { FlatList, Image, Linking, Platform, ScrollView, Switch, Text, TouchableOpacity, View } from 'react-native'
3
- import { useNavigation } from '@react-navigation/native'
4
- import TimeCircular from './circular/TimeCircular'
5
- import { useDebounceFn, useReactive, useUpdateEffect } from 'ahooks'
6
- import {
7
- BiorhythmBean,
8
- BiorhythmGradientType,
9
- colorTemperatureValue,
10
- getDefBiorhythmUIState,
11
- Plan,
12
- } from './BiorhythmBean'
13
- import { Dialog, Modal, Utils, Toast } from 'tuya-panel-kit'
14
- import _ from 'lodash'
15
- import dayjs from 'dayjs'
16
- import iconList from './iconListData'
17
- import pIdList from './pIdList'
18
- import {
19
- useDeviceId,
20
- useDeviceInfo,
21
- useTimeSchedule
22
- } from '@ledvance/base/src/models/modules/NativePropsSlice'
23
- import I18n from '@ledvance/base/src/i18n'
24
- import LDVTopBar from '@ledvance/base/src/components/ldvTopBar'
25
- import res from '@ledvance/base/src/res'
26
- import { ui_biz_routerKey } from '../../navigation/Routers'
27
- import BiologicalRes from './res/BiologicalRes'
28
- import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
29
- import { NativeApi } from '@ledvance/base/src/api/native'
30
- import { setDataSource } from '@ledvance/base/src/components/weekSelect'
31
- import { useRoute } from '@react-navigation/core'
32
- import { BiorhythmEditPageParams } from './BiorhythmEditPage'
33
- import { useBiorhythm, userOperation } from './BiorhythmActions'
34
- import { useSleepPlan, useWakeUpPlan } from '../sleepWakeup/SleepWakeUpActions'
35
- import { showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
36
-
37
- const cx = Utils.RatioUtils.convertX
38
- const width = Utils.RatioUtils.width
39
-
40
- const weekSign = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
41
-
42
- interface UIState extends BiorhythmBean {
43
- showGradientTypeSelectModal: boolean;
44
- showMaskModal: boolean;
45
- flag: symbol;
46
- weekString: string,
47
- timeSchedule: any[]
48
- loading: boolean
49
- }
50
-
51
- export interface BiorhythmPageParams {
52
- biorhythmDp: string
53
- sleepPlanDp: string
54
- wakeUpPlanDp: string
55
- isSupportTemperature: boolean
56
- isSupportBrightness: boolean
57
- isMixRGBWLamp: boolean
58
- }
59
-
60
- const BiorhythmPage = () => {
61
- const navigation = useNavigation()
62
- const params = useRoute<any>().params as BiorhythmPageParams
63
- const [biorhythm, setBiorhythm] = useBiorhythm(params.biorhythmDp)
64
- const deviceId = useDeviceId()
65
- const deviceInfo = useDeviceInfo()
66
- const { productId } = deviceInfo
67
- const devicesJudge = pIdList.some(val => val === productId)
68
- const [, setTimeSchedule] = useTimeSchedule()
69
- const [sleepList, setSleepList] = useSleepPlan({ sleep_mode: params.sleepPlanDp })
70
- const [wakeUpList, setWakeUpList] = useWakeUpPlan({ wakeup_mode: params.wakeUpPlanDp })
71
- const sleepWakeUpStatus = [...sleepList, ...wakeUpList].some(ele => ele.enable)
72
- const state = useReactive<UIState>({
73
- ...biorhythm,
74
- showGradientTypeSelectModal: false,
75
- showMaskModal: false,
76
- flag: Symbol(),
77
- weekString: '',
78
- timeSchedule: [],
79
- loading: false
80
- })
81
-
82
- const checkWeekConflict = (weeksStr: string) => {
83
- const dayjsDate = dayjs()
84
- const todayWeek = dayjsDate.format('ddd')
85
- const weekIndex = weekSign.indexOf(todayWeek)
86
- const externalWeeks = weeksStr.split('').map(val => !!Number(val))
87
- const biorhythmWeeks = state.repeatPeriod.map(val => val?.enabled)
88
-
89
- for (let i = 0; i < biorhythmWeeks.length; i++) {
90
- if (biorhythmWeeks[i] && externalWeeks[i]) {
91
- return true
92
- }
93
- }
94
- return (externalWeeks.every(val => !val) && (biorhythmWeeks[weekIndex] || biorhythmWeeks.every(val => !val)));
95
- }
96
-
97
- const enableTimeScheduleStatus = state.timeSchedule?.some(val => !!val.mStatus && checkWeekConflict(val.mLoops))
98
- const showGradientTypeSelectModal = useCallback((show: boolean) => {
99
- state.showGradientTypeSelectModal = show
100
- }, [])
101
-
102
- const onPlanEdited = useCallback((isAdd: boolean, newPlan: Plan) => {
103
- if (isAdd) {
104
- state.planList.push(newPlan)
105
- state.planList = _.sortBy(state.planList, p => p.startTime)
106
- } else {
107
- state.planList = state.planList.map(plan => (plan.id === newPlan.id ? newPlan : plan))
108
- }
109
- state.flag = Symbol()
110
- }, [])
111
-
112
- const onPlanDelete = useCallback((id: number) => {
113
- state.planList = state.planList.filter(plan => plan.id !== id)
114
- state.flag = Symbol()
115
- }, [])
116
- const requestSetBiorhythm: () => void = useCallback(async () => {
117
- const planList = state.planList?.map(item => { return { ...item, icon: `${item.icon}` } })
118
- .sort((a, b) => {
119
- const timeA = a.startTime.split(":");
120
- const timeB = b.startTime.split(":");
121
- // 比较小时
122
- if (parseInt(timeA[0]) !== parseInt(timeB[0])) {
123
- return parseInt(timeA[0]) - parseInt(timeB[0]);
124
- }
125
- // 如果小时相等,比较分钟
126
- return parseInt(timeA[1]) - parseInt(timeB[1]);
127
- });
128
- console.log('设置生物节律数据', state)
129
- await userOperation(deviceId, false)
130
- const res = await setBiorhythm(deviceId, { ...state, planList })
131
- state.loading = false
132
- console.log('设置生物节律res', res)
133
- if (res.success) {
134
- console.log('设置生物节律 OK')
135
- }
136
- }, [])
137
-
138
- useUpdateEffect(() => {
139
- if (state.planList?.length === 0) {
140
- const data = getDefBiorhythmUIState()
141
- data.planList = data.planList?.map(item => {
142
- return { ...item, icon: `${item.icon}` }
143
- })
144
- setBiorhythm(deviceId, data).then()
145
- }
146
- }, [state.planList])
147
-
148
- const setTimer = value => {
149
- switch (value) {
150
- case 'Sunrise':
151
- return I18n.getLang('bio_ryhthm_default_field_text')
152
- case 'Wake Up':
153
- return I18n.getLang('bio_ryhthm_default_field_text2')
154
- case 'Sunlight':
155
- return I18n.getLang('bio_ryhthm_default_field_text3')
156
- case 'Comfortable':
157
- return I18n.getLang('bio_ryhthm_default_field_text4')
158
- case 'Night light':
159
- return I18n.getLang('bio_ryhthm_default_field_text5')
160
- default:
161
- return value
162
- }
163
- }
164
-
165
- const showDialog = useCallback(enable => {
166
- Dialog.confirm({
167
- title: I18n.getLang('conflict_dialog_save_item_bio_rhythm_titel'),
168
- subTitle: I18n.getLang('conflict_dialog_save_item_bio_rhythm_description'),
169
- cancelText: I18n.getLang('conflict_dialog_save_item_bio_rhythm_answer_no_text'),
170
- confirmText: I18n.getLang('conflict_dialog_save_item_bio_rhythm_answer_yes_text'),
171
- onConfirm: (_, { close }) => {
172
- const timeSchedule = state.timeSchedule
173
- const enableSleep = sleepList.some(item => item.enable)
174
- const enableWakeUp = wakeUpList.some(item => item.enable)
175
- const enableTimeSchedule = timeSchedule?.some(val => !!val?.mStatus)
176
- if (enableSleep) {
177
- sleepList.forEach(item => item.enable = 0)
178
- setSleepList(sleepList).then()
179
- }
180
- if (enableWakeUp) {
181
- wakeUpList.forEach(item => item.enable = 0)
182
- setWakeUpList(wakeUpList).then()
183
- }
184
- if (enableTimeSchedule) {
185
- timeSchedule?.forEach(item => {
186
- if (checkWeekConflict(item?.mLoops) && !!item?.mStatus) {
187
- const data = {
188
- time: item?.mTime,
189
- status: Platform.OS === 'ios' ? false : 0,
190
- loops: item?.mLoops,
191
- id: item?.mDpId,
192
- dps: item?.mValue && JSON.parse(item?.mValue),
193
- data: item?.mDate,
194
- timerId: item?.mTimerId,
195
- aliasName: item?.aliasName || item?.remark,
196
- value: item?.mValue,
197
- mStatus: Platform.OS === 'ios' ? false : 0,
198
- }
199
- NativeApi.editTimer(deviceId, data, () => {
200
- setTimeSchedule(false)
201
- })
202
- }
203
- })
204
- }
205
-
206
- state.enable = enable
207
- state.showMaskModal = !enable
208
- state.flag = Symbol()
209
- close()
210
- },
211
- motionConfig: {
212
- hideDuration: 0,
213
- showDuration: 100
214
- }
215
- })
216
- }, [sleepList, wakeUpList])
217
-
218
- const minimumEnable = (plan: Plan) => {
219
- const [h, m] = plan.startTime.split(':').map(str => parseInt(str, 10))
220
- const min = h * 60 + m
221
- const minutes = state.planList
222
- .filter(item => item.id !== plan.id && item.enable)
223
- .map(item => {
224
- const [hour, minute] = item.startTime.split(':').map(str => parseInt(str, 10))
225
- return hour * 60 + minute
226
- })
227
- let enable = false
228
- minutes.forEach(item => {
229
- const diff = Math.abs(min - item)
230
- if (diff < 15) enable = true
231
- })
232
- return enable
233
- }
234
-
235
- const showDeleteBtn = useMemo(() => {
236
- return state.planList?.length > 1
237
- }, [state.planList?.length])
238
-
239
- const { run } = useDebounceFn(requestSetBiorhythm, { wait: 500 })
240
-
241
- useUpdateEffect(() => {
242
- run()
243
- }, [state.flag])
244
-
245
- const replaceImg = (img) => {
246
- const item = iconList?.find(val => val.id === Number(img))
247
- switch (img) {
248
- case 'rhythm_icon1':
249
- case '31':
250
- return { icon: BiologicalRes.biorhythom_Icon1, iconId: 1 }
251
- case 'rhythm_icon2':
252
- case '33':
253
- return { icon: BiologicalRes.biorhythom_Icon5, iconId: 5 }
254
- case 'rhythm_icon3':
255
- case '35':
256
- return { icon: BiologicalRes.biorhythom_Icon2, iconId: 2 }
257
- case 'rhythm_icon4':
258
- case '32':
259
- return { icon: BiologicalRes.biorhythom_Icon9, iconId: 9 }
260
- case 'rhythm_icon12':
261
- case '39':
262
- return { icon: BiologicalRes.biorhythom_Icon3, iconId: 3 }
263
- default:
264
- return { icon: item?.icon, iconId: item?.id }
265
- }
266
- }
267
-
268
- useUpdateEffect(() => {
269
- console.log('Redux 生物节律数据更新', biorhythm)
270
- const planList = biorhythm.planList?.map(item => {
271
- return {
272
- ...item,
273
- icon: replaceImg(item?.iconId || item?.icon)?.icon,
274
- iconId: replaceImg(item?.iconId || item?.icon)?.iconId,
275
- }
276
- })
277
- state.enable = biorhythm.enable
278
- state.gradient = biorhythm.gradient
279
- state.repeatPeriod = biorhythm.repeatPeriod
280
- state.planList = planList
281
- state.showMaskModal = !biorhythm.enable
282
- const weeks: string[] = setDataSource(
283
- biorhythm.repeatPeriod.map(item => {
284
- return item?.enabled ? 1 : 0
285
- })).filter(item => item.enabled)
286
- .map(item => item.title)
287
-
288
- if (weeks.length > 0) {
289
- // / more than one
290
- if (weeks.length === 7) {
291
- // / seven
292
- state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text4')
293
- } else {
294
- state.weekString = I18n.formatValue('timeschedule_add_schedule_text', weeks.join(', '))
295
- }
296
- } else {
297
- // / zero
298
- state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text2')
299
- }
300
- }, [JSON.stringify(biorhythm)])
301
-
302
-
303
- const setImg = (id) => {
304
- const imgIcon = iconList?.find(val => val?.id === Number(id))?.icon
305
- return imgIcon || ''
306
- }
307
-
308
- const openLink = () => {
309
- const url = I18n.getLang('biorhythm_product_link') // 需要打开的链接
310
- Linking.openURL(url).catch((error) => console.error('无法打开链接:', error))
311
- }
312
-
313
- const sunHomeText = string => {
314
- const text = string.split('SUN@HOME')
315
- return text?.length === 1 && <Text style={{ fontSize: cx(14) }}>{text[0]}</Text> ||
316
- <Text style={{
317
- fontSize: cx(14),
318
- flexDirection: 'row',
319
- }}>
320
- <Text>{text[0]}</Text>
321
- <Text onPress={openLink}
322
- style={{
323
- fontFamily: 'helvetica_neue_lt_std_roman',
324
- color: '#ff6600',
325
- textDecorationLine: 'underline',
326
- flexWrap: 'wrap',
327
- }}>SUN@HOME</Text>
328
- <Text>{text[1]}</Text>
329
- </Text>
330
- }
331
-
332
- const randomIcon = () => {
333
- const iconIdList = state.planList?.map(item => {
334
- return item.iconId
335
- })
336
- const allIcon = iconList?.map(item => {
337
- return item.id
338
- })
339
- const availableChart = allIcon.filter((element) => !iconIdList.includes(element))
340
- const randomIndex = Math.floor(Math.random() * availableChart.length)
341
- return availableChart[randomIndex]
342
- }
343
-
344
- const reloadData = async () => {
345
- const res: any = await NativeApi.getAllTaskTimer(deviceId)
346
- console.log('reload data', res)
347
- if (res.success && res.data) {
348
- // 原生传过来的dps是json字符串。
349
- if (Array.isArray(res.data) && res.data.length) {
350
- state.timeSchedule = res.data
351
- }
352
- }
353
- }
354
-
355
- useEffect(() => {
356
- reloadData().then()
357
- }, [])
358
-
359
- return (
360
- <>
361
- <View style={{ flex: 1, flexDirection: 'column' }}>
362
- <LDVTopBar
363
- title={deviceInfo.name}
364
- onBackPress={() => {
365
- navigation.goBack()
366
- }}
367
- />
368
- <ScrollView nestedScrollEnabled={true} style={{ position: 'relative' }}>
369
- <View
370
- style={{
371
- height: cx(60),
372
- flexDirection: 'row',
373
- justifyContent: 'space-between',
374
- alignItems: 'center',
375
- marginHorizontal: cx(24),
376
- }}
377
- >
378
- <Text
379
- style={{
380
- color: '#FF6600',
381
- fontSize: cx(24),
382
- fontFamily: 'helvetica_neue_lt_std_roman',
383
- }}
384
- >
385
- {I18n.getLang('add_new_trigger_time_system_back_text')}
386
- </Text>
387
- <Switch
388
- value={state.enable}
389
- thumbColor={'#f60'}
390
- trackColor={{ false: '#00000026', true: '#ff660036' }}
391
- onValueChange={async enable => {
392
- if (enable && (sleepWakeUpStatus || enableTimeScheduleStatus)) return showDialog(enable)
393
- state.loading = true
394
- state.enable = enable
395
- state.flag = Symbol()
396
- }}
397
- />
398
- </View>
399
- <View style={{ marginHorizontal: cx(24) }}>
400
- {sunHomeText(I18n.getLang(devicesJudge ? 'bio_ryhthm_default_description_text' : 'bio_ryhthm_non_sun_home_products_description_text'))}
401
- </View>
402
- <View style={{ height: cx(10) }} />
403
- <View
404
- style={{
405
- flexDirection: 'row',
406
- justifyContent: 'space-between',
407
- marginHorizontal: cx(24),
408
- }}
409
- >
410
- {state.repeatPeriod.map(period => {
411
- return (
412
- <TouchableOpacity
413
- key={period.title}
414
- onPress={() => {
415
- const periodNum = state.repeatPeriod.filter(p => p.enabled)?.length
416
- if (periodNum === 1 && period.enabled) return
417
- period.enabled = !period.enabled
418
- state.flag = Symbol()
419
- }}
420
- >
421
- <View
422
- style={{
423
- width: cx(40),
424
- height: cx(40),
425
- justifyContent: 'center',
426
- alignItems: 'center',
427
- borderRadius: cx(20),
428
- backgroundColor: period.enabled ? '#ffe0d4' : '#fff',
429
- borderWidth: cx(1),
430
- borderColor: '#f60',
431
- }}
432
- >
433
- <Text
434
- style={{
435
- color: '#FF6600',
436
- textAlign: 'center',
437
- }}
438
- >
439
- {period.title}
440
- </Text>
441
- </View>
442
- </TouchableOpacity>
443
- )
444
- })}
445
- </View>
446
- <View style={{ marginHorizontal: cx(24), marginTop: cx(20) }}>
447
- <Text>{state.weekString}</Text>
448
- </View>
449
- <View style={{ marginHorizontal: cx(24), marginTop: cx(16) }}>
450
- <Text>
451
- {I18n.getLang('bio_ryhthm_default_selectionfield_topic_text')}
452
- </Text>
453
- <TouchableOpacity
454
- onPress={() => {
455
- showGradientTypeSelectModal(true)
456
- }}
457
- >
458
- <View
459
- style={{
460
- flexDirection: 'row',
461
- borderRadius: cx(4),
462
- backgroundColor: '#f6f6f6',
463
- alignItems: 'center',
464
- flex: 1,
465
- height: cx(44),
466
- borderBottomWidth: cx(1),
467
- borderBottomColor: '#cbcbcb',
468
- }}
469
- >
470
- <Text style={{
471
- fontSize: cx(16),
472
- color: '#000',
473
- fontFamily: 'helvetica_neue_lt_std_roman',
474
- paddingLeft: cx(16),
475
- }}>
476
- {
477
- I18n.getLang(
478
- state.gradient === BiorhythmGradientType.DirectGradient
479
- ? 'add_new_dynamic_mood_color_changing_mode_value2'
480
- : 'add_new_dynamic_mood_color_changing_mode_value',
481
- )
482
- }
483
-
484
- </Text>
485
- </View>
486
- </TouchableOpacity>
487
- </View>
488
- <View style={{ height: cx(20) }} />
489
- <TimeCircular
490
- planEdit={true}
491
- planList={state.planList}
492
- onPanMoved={(id, time) => {
493
- state.planList = state.planList.map(plan => {
494
- return {
495
- ...plan,
496
- startTime: plan.id === id ? time : plan.startTime,
497
- }
498
- })
499
- state.flag = Symbol()
500
- }}
501
- replaceStatus={devicesJudge}
502
- gradient={state.gradient === BiorhythmGradientType.DirectGradient}
503
- isSupportTemperature={!params.isSupportTemperature} />
504
- <View
505
- style={{
506
- flexDirection: 'row',
507
- justifyContent: 'space-between',
508
- marginHorizontal: cx(24),
509
- marginBottom: cx(-8),
510
- marginTop: cx(26),
511
- }}>
512
- {state.planList.length === 8 && <View
513
- style={{ marginVertical: cx(10), flexDirection: 'row', alignItems: 'center', width: width - cx(48) }}>
514
- <Image style={{ width: cx(16), height: cx(16), tintColor: '#ff9500' }} source={res.ic_warning_amber} />
515
- <Text
516
- style={{
517
- flexWrap: 'wrap',
518
- fontSize: cx(12),
519
- }}>{I18n.getLang('add_new_trigger_time_warning_max_number_text')}</Text>
520
- </View>}
521
- {state.planList.length < 8 &&
522
- <>
523
- <Text
524
- style={{
525
- fontSize: cx(16),
526
- fontWeight: 'bold',
527
- color: 'rgb(0,0,0)',
528
- }}>{I18n.getLang('bio_ryhthm_default_subheadline_text')}</Text>
529
- <TouchableOpacity
530
- onPress={() => {
531
- const ids: number[] = state.planList.map(p => p.id)
532
- const newPlan: Plan = {
533
- id: Math.max(...ids) + 1,
534
- icon: res.rhythm_icon1,
535
- startTime: '00:00',
536
- name: '',
537
- colorTemperature: 0,
538
- brightness: 100,
539
- action: [
540
- {
541
- uri: 'model/attribute/set/LightCtrl/ColorTemperature',
542
- startValue: `${colorTemperatureValue(0)}`,
543
- },
544
- {
545
- uri: 'model/attribute/set/LightCtrl/Brightness',
546
- startValue: '100',
547
- },
548
- ],
549
- enable: true,
550
- iconId: randomIcon(),
551
- }
552
- const editPageParams: BiorhythmEditPageParams = {
553
- planData: newPlan,
554
- isAdd: true,
555
- onPlanEdited,
556
- onPlanDelete,
557
- minimumEnable,
558
- iconIdList: state.planList?.map(item => {
559
- return item.iconId
560
- }),
561
- isMixRGBWLamp: params.isMixRGBWLamp,
562
- isSupportTemperature: params.isSupportTemperature,
563
- isSupportBrightness: params.isSupportBrightness,
564
- showDeleteBtn
565
- }
566
- navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
567
- }}>
568
- <Image source={BiologicalRes.biorhythom_add} style={{ height: cx(24), width: cx(24) }} />
569
- </TouchableOpacity>
570
- </>
571
- }
572
- </View>
573
- <FlatList
574
- data={state.planList}
575
- style={{
576
- flex: 1,
577
- marginTop: cx(12),
578
- }}
579
- nestedScrollEnabled={true}
580
- renderItem={({ item }) => {
581
- const type = typeof item?.icon === 'string'
582
- const bgColor = item?.brightness === 0 ? '#000' : !params.isSupportTemperature && cctToColor(1) || cctToColor(item.colorTemperature.toFixed(), item?.brightness)
583
- return (
584
- <View
585
- style={{
586
- height: cx(118),
587
- backgroundColor: 'white',
588
- elevation: cx(7),
589
- shadowColor: '#000000',
590
- shadowOpacity: 0.2,
591
- shadowRadius: cx(7),
592
- shadowOffset: {
593
- width: 0,
594
- height: cx(4),
595
- },
596
- borderRadius: cx(10),
597
- marginHorizontal: cx(24),
598
- marginVertical: cx(8),
599
- }}
600
- >
601
- <TouchableOpacity
602
- style={{ flex: 1 }}
603
- onPress={() => {
604
- const editPageParams: BiorhythmEditPageParams = {
605
- planData: {
606
- ...item,
607
- name: setTimer(item?.name)
608
- },
609
- isAdd: false,
610
- onPlanEdited,
611
- onPlanDelete,
612
- minimumEnable,
613
- iconIdList: state.planList?.map(item => {
614
- return item.iconId
615
- }),
616
- isMixRGBWLamp: params.isMixRGBWLamp,
617
- isSupportTemperature: params.isSupportTemperature,
618
- isSupportBrightness: params.isSupportBrightness,
619
- showDeleteBtn
620
- }
621
- navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
622
- }}
623
- >
624
- <View
625
- style={{
626
- flex: 1,
627
- flexDirection: 'column',
628
- }}
629
- >
630
- <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', marginTop: cx(16) }}>
631
- <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
632
- <Image
633
- source={setImg(item?.iconId) || type && { uri: item?.icon } || item?.icon}
634
- style={{
635
- width: cx(24),
636
- height: cx(24),
637
- marginStart: cx(10),
638
- marginRight: cx(6),
639
- tintColor: '#474e5d',
640
- }}
641
- />
642
- <Text
643
- style={{
644
- fontSize: cx(16),
645
- color: '#000',
646
- fontFamily: 'helvetica_neue_lt_std_roman',
647
- }}
648
- >
649
- {item.startTime}
650
- </Text>
651
- </View>
652
- <Switch
653
- value={item.enable}
654
- thumbColor={'#f60'}
655
- trackColor={{ false: '#00000026', true: '#ff660036' }}
656
- onValueChange={e => {
657
- item.enable = e
658
- state.flag = Symbol()
659
- }}
660
- style={{ marginRight: cx(10) }}
661
- />
662
- </View>
663
- <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between' }}>
664
- <Text
665
- style={{
666
- fontSize: cx(12),
667
- color: '#666',
668
- fontFamily: 'helvetica_neue_lt_std_roman',
669
- paddingLeft: cx(20),
670
- }}
671
- >
672
- {setTimer(item?.name)}
673
- </Text>
674
- </View>
675
- <View
676
- style={{
677
- width: cx(295),
678
- height: cx(24),
679
- backgroundColor: bgColor,
680
- marginLeft: cx(20),
681
- marginTop: cx(-5),
682
- marginBottom: cx(24),
683
- borderRadius: cx(8),
684
- }} />
685
- </View>
686
- </TouchableOpacity>
687
- </View>
688
- )
689
- }}
690
- keyExtractor={item => `${item.id}`}
691
- ListFooterComponent={() => {
692
- return (
693
- <View>
694
- <View
695
- style={{
696
- height: cx(50),
697
- backgroundColor: '#666',
698
- elevation: cx(7),
699
- shadowColor: '#000000',
700
- shadowOpacity: 0.2,
701
- shadowRadius: cx(7),
702
- shadowOffset: {
703
- width: 0,
704
- height: cx(4),
705
- },
706
- borderRadius: cx(10),
707
- marginHorizontal: cx(24),
708
- marginTop: cx(16),
709
- }}>
710
- <TouchableOpacity
711
- style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
712
- onPress={() => {
713
- showCommonDialog({
714
- method: 'confirm',
715
- title: I18n.getLang('bio_ryhthm_reset_description_text'),
716
- onConfirm: (_, { close }) => {
717
- const defBiorhythmUIState = getDefBiorhythmUIState()
718
- state.enable = defBiorhythmUIState.enable
719
- state.gradient = defBiorhythmUIState.gradient
720
- state.repeatPeriod = defBiorhythmUIState.repeatPeriod
721
- state.planList = defBiorhythmUIState.planList
722
- state.flag = Symbol()
723
- close()
724
- }
725
- })
726
- }}>
727
- <Text
728
- style={{
729
- fontSize: cx(16),
730
- color: '#fff',
731
- fontFamily: 'helvetica_neue_lt_std_roman',
732
- }}>{I18n.getLang('bio_ryhthm_default_button_reset_text')}</Text>
733
- </TouchableOpacity>
734
- </View>
735
- <View style={{ height: cx(20) }} />
736
- </View>
737
- ) || <></>
738
- }}
739
- />
740
- {state.showMaskModal && (
741
- <View
742
- style={{
743
- backgroundColor: 'rgba(0,0,0,.5)',
744
- width: '100%',
745
- height: '100%',
746
- position: 'absolute',
747
- top: cx(45),
748
- zIndex: 999,
749
- }}
750
- />
751
- )}
752
- </ScrollView>
753
- </View>
754
- <Modal.List
755
- type={'radio'}
756
- visible={state.showGradientTypeSelectModal}
757
- value={state.gradient}
758
- dataSource={[
759
- {
760
- title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value'),
761
- key: BiorhythmGradientType.EntireGradient,
762
- value: BiorhythmGradientType.EntireGradient,
763
- },
764
- {
765
- title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value2'),
766
- key: BiorhythmGradientType.DirectGradient,
767
- value: BiorhythmGradientType.DirectGradient,
768
- },
769
- ]}
770
- title={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
771
- onMaskPress={() => {
772
- showGradientTypeSelectModal(false)
773
- }}
774
- onCancel={() => {
775
- showGradientTypeSelectModal(false)
776
- }}
777
- cancelText={I18n.getLang('auto_scan_system_cancel')}
778
- confirmText={I18n.getLang('auto_scan_system_wifi_confirm')}
779
- onConfirm={(item: BiorhythmGradientType) => {
780
- state.gradient = item
781
- state.flag = Symbol()
782
- showGradientTypeSelectModal(false)
783
- }}
784
- />
785
- <Toast.Loading
786
- show={!!state.loading}
787
- onFinish={() => {
788
-
789
- }} />
790
- </>
791
- )
792
- }
793
-
794
- export default BiorhythmPage
795
-
796
-
1
+ import React, { useCallback, useEffect, useMemo } from 'react'
2
+ import { FlatList, Image, Linking, Platform, ScrollView, Switch, Text, TouchableOpacity, View } from 'react-native'
3
+ import { useNavigation } from '@react-navigation/native'
4
+ import TimeCircular from './circular/TimeCircular'
5
+ import { useDebounceFn, useReactive, useUpdateEffect } from 'ahooks'
6
+ import {
7
+ BiorhythmBean,
8
+ BiorhythmGradientType,
9
+ colorTemperatureValue,
10
+ getDefBiorhythmUIState,
11
+ Plan,
12
+ } from './BiorhythmBean'
13
+ import { Dialog, Modal, Utils, Toast } from 'tuya-panel-kit'
14
+ import _ from 'lodash'
15
+ import dayjs from 'dayjs'
16
+ import iconList from './iconListData'
17
+ import pIdList from './pIdList'
18
+ import {
19
+ useDeviceId,
20
+ useDeviceInfo,
21
+ useTimeSchedule
22
+ } from '@ledvance/base/src/models/modules/NativePropsSlice'
23
+ import I18n from '@ledvance/base/src/i18n'
24
+ import LDVTopBar from '@ledvance/base/src/components/ldvTopBar'
25
+ import res from '@ledvance/base/src/res'
26
+ import { ui_biz_routerKey } from '../../navigation/Routers'
27
+ import BiologicalRes from './res/BiologicalRes'
28
+ import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
29
+ import { NativeApi } from '@ledvance/base/src/api/native'
30
+ import { setDataSource } from '@ledvance/base/src/components/weekSelect'
31
+ import { useRoute } from '@react-navigation/core'
32
+ import { BiorhythmEditPageParams } from './BiorhythmEditPage'
33
+ import { useBiorhythm, userOperation } from './BiorhythmActions'
34
+ import { useSleepPlan, useWakeUpPlan } from '../sleepWakeup/SleepWakeUpActions'
35
+ import { showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
36
+
37
+ const cx = Utils.RatioUtils.convertX
38
+ const width = Utils.RatioUtils.width
39
+
40
+ const weekSign = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
41
+
42
+ interface UIState extends BiorhythmBean {
43
+ showGradientTypeSelectModal: boolean;
44
+ showMaskModal: boolean;
45
+ flag: symbol;
46
+ weekString: string,
47
+ timeSchedule: any[]
48
+ loading: boolean
49
+ }
50
+
51
+ export interface BiorhythmPageParams {
52
+ biorhythmDp: string
53
+ sleepPlanDp: string
54
+ wakeUpPlanDp: string
55
+ isSupportTemperature: boolean
56
+ isSupportBrightness: boolean
57
+ isMixRGBWLamp: boolean
58
+ }
59
+
60
+ const BiorhythmPage = () => {
61
+ const navigation = useNavigation()
62
+ const params = useRoute<any>().params as BiorhythmPageParams
63
+ const [biorhythm, setBiorhythm] = useBiorhythm(params.biorhythmDp)
64
+ const deviceId = useDeviceId()
65
+ const deviceInfo = useDeviceInfo()
66
+ const { productId } = deviceInfo
67
+ const devicesJudge = pIdList.some(val => val === productId)
68
+ const [, setTimeSchedule] = useTimeSchedule()
69
+ const [sleepList, setSleepList] = useSleepPlan({ sleep_mode: params.sleepPlanDp })
70
+ const [wakeUpList, setWakeUpList] = useWakeUpPlan({ wakeup_mode: params.wakeUpPlanDp })
71
+ const sleepWakeUpStatus = [...sleepList, ...wakeUpList].some(ele => ele.enable)
72
+ const state = useReactive<UIState>({
73
+ ...biorhythm,
74
+ showGradientTypeSelectModal: false,
75
+ showMaskModal: false,
76
+ flag: Symbol(),
77
+ weekString: '',
78
+ timeSchedule: [],
79
+ loading: false
80
+ })
81
+
82
+ const checkWeekConflict = (weeksStr: string) => {
83
+ const dayjsDate = dayjs()
84
+ const todayWeek = dayjsDate.format('ddd')
85
+ const weekIndex = weekSign.indexOf(todayWeek)
86
+ const externalWeeks = weeksStr.split('').map(val => !!Number(val))
87
+ const biorhythmWeeks = state.repeatPeriod.map(val => val?.enabled)
88
+
89
+ for (let i = 0; i < biorhythmWeeks.length; i++) {
90
+ if (biorhythmWeeks[i] && externalWeeks[i]) {
91
+ return true
92
+ }
93
+ }
94
+ return (externalWeeks.every(val => !val) && (biorhythmWeeks[weekIndex] || biorhythmWeeks.every(val => !val)));
95
+ }
96
+
97
+ const enableTimeScheduleStatus = state.timeSchedule?.some(val => !!val.mStatus && checkWeekConflict(val.mLoops))
98
+ const showGradientTypeSelectModal = useCallback((show: boolean) => {
99
+ state.showGradientTypeSelectModal = show
100
+ }, [])
101
+
102
+ const onPlanEdited = useCallback((isAdd: boolean, newPlan: Plan) => {
103
+ if (isAdd) {
104
+ state.planList.push(newPlan)
105
+ state.planList = _.sortBy(state.planList, p => p.startTime)
106
+ } else {
107
+ state.planList = state.planList.map(plan => (plan.id === newPlan.id ? newPlan : plan))
108
+ }
109
+ state.flag = Symbol()
110
+ }, [])
111
+
112
+ const onPlanDelete = useCallback((id: number) => {
113
+ state.planList = state.planList.filter(plan => plan.id !== id)
114
+ state.flag = Symbol()
115
+ }, [])
116
+ const requestSetBiorhythm: () => void = useCallback(async () => {
117
+ const planList = state.planList?.map(item => { return { ...item, icon: `${item.icon}` } })
118
+ .sort((a, b) => {
119
+ const timeA = a.startTime.split(":");
120
+ const timeB = b.startTime.split(":");
121
+ // 比较小时
122
+ if (parseInt(timeA[0]) !== parseInt(timeB[0])) {
123
+ return parseInt(timeA[0]) - parseInt(timeB[0]);
124
+ }
125
+ // 如果小时相等,比较分钟
126
+ return parseInt(timeA[1]) - parseInt(timeB[1]);
127
+ });
128
+ console.log('设置生物节律数据', state)
129
+ await userOperation(deviceId, false)
130
+ const res = await setBiorhythm(deviceId, { ...state, planList })
131
+ state.loading = false
132
+ console.log('设置生物节律res', res)
133
+ if (res.success) {
134
+ console.log('设置生物节律 OK')
135
+ }
136
+ }, [])
137
+
138
+ useUpdateEffect(() => {
139
+ if (state.planList?.length === 0) {
140
+ const data = getDefBiorhythmUIState()
141
+ data.planList = data.planList?.map(item => {
142
+ return { ...item, icon: `${item.icon}` }
143
+ })
144
+ setBiorhythm(deviceId, data).then()
145
+ }
146
+ }, [state.planList])
147
+
148
+ const setTimer = value => {
149
+ switch (value) {
150
+ case 'Sunrise':
151
+ return I18n.getLang('bio_ryhthm_default_field_text')
152
+ case 'Wake Up':
153
+ return I18n.getLang('bio_ryhthm_default_field_text2')
154
+ case 'Sunlight':
155
+ return I18n.getLang('bio_ryhthm_default_field_text3')
156
+ case 'Comfortable':
157
+ return I18n.getLang('bio_ryhthm_default_field_text4')
158
+ case 'Night light':
159
+ return I18n.getLang('bio_ryhthm_default_field_text5')
160
+ default:
161
+ return value
162
+ }
163
+ }
164
+
165
+ const showDialog = useCallback(enable => {
166
+ Dialog.confirm({
167
+ title: I18n.getLang('conflict_dialog_save_item_bio_rhythm_titel'),
168
+ subTitle: I18n.getLang('conflict_dialog_save_item_bio_rhythm_description'),
169
+ cancelText: I18n.getLang('conflict_dialog_save_item_bio_rhythm_answer_no_text'),
170
+ confirmText: I18n.getLang('conflict_dialog_save_item_bio_rhythm_answer_yes_text'),
171
+ onConfirm: (_, { close }) => {
172
+ const timeSchedule = state.timeSchedule
173
+ const enableSleep = sleepList.some(item => item.enable)
174
+ const enableWakeUp = wakeUpList.some(item => item.enable)
175
+ const enableTimeSchedule = timeSchedule?.some(val => !!val?.mStatus)
176
+ if (enableSleep) {
177
+ sleepList.forEach(item => item.enable = 0)
178
+ setSleepList(sleepList).then()
179
+ }
180
+ if (enableWakeUp) {
181
+ wakeUpList.forEach(item => item.enable = 0)
182
+ setWakeUpList(wakeUpList).then()
183
+ }
184
+ if (enableTimeSchedule) {
185
+ timeSchedule?.forEach(item => {
186
+ if (checkWeekConflict(item?.mLoops) && !!item?.mStatus) {
187
+ const data = {
188
+ time: item?.mTime,
189
+ status: Platform.OS === 'ios' ? false : 0,
190
+ loops: item?.mLoops,
191
+ id: item?.mDpId,
192
+ dps: item?.mValue && JSON.parse(item?.mValue),
193
+ data: item?.mDate,
194
+ timerId: item?.mTimerId,
195
+ aliasName: item?.aliasName || item?.remark,
196
+ value: item?.mValue,
197
+ mStatus: Platform.OS === 'ios' ? false : 0,
198
+ }
199
+ NativeApi.editTimer(deviceId, data, () => {
200
+ setTimeSchedule(false)
201
+ })
202
+ }
203
+ })
204
+ }
205
+
206
+ state.enable = enable
207
+ state.showMaskModal = !enable
208
+ state.flag = Symbol()
209
+ close()
210
+ },
211
+ motionConfig: {
212
+ hideDuration: 0,
213
+ showDuration: 100
214
+ }
215
+ })
216
+ }, [sleepList, wakeUpList])
217
+
218
+ const minimumEnable = (plan: Plan) => {
219
+ const [h, m] = plan.startTime.split(':').map(str => parseInt(str, 10))
220
+ const min = h * 60 + m
221
+ const minutes = state.planList
222
+ .filter(item => item.id !== plan.id && item.enable)
223
+ .map(item => {
224
+ const [hour, minute] = item.startTime.split(':').map(str => parseInt(str, 10))
225
+ return hour * 60 + minute
226
+ })
227
+ let enable = false
228
+ minutes.forEach(item => {
229
+ const diff = Math.abs(min - item)
230
+ if (diff < 15) enable = true
231
+ })
232
+ return enable
233
+ }
234
+
235
+ const showDeleteBtn = useMemo(() => {
236
+ return state.planList?.length > 1
237
+ }, [state.planList?.length])
238
+
239
+ const { run } = useDebounceFn(requestSetBiorhythm, { wait: 500 })
240
+
241
+ useUpdateEffect(() => {
242
+ run()
243
+ }, [state.flag])
244
+
245
+ const replaceImg = (img) => {
246
+ const item = iconList?.find(val => val.id === Number(img))
247
+ switch (img) {
248
+ case 'rhythm_icon1':
249
+ case '31':
250
+ return { icon: BiologicalRes.biorhythom_Icon1, iconId: 1 }
251
+ case 'rhythm_icon2':
252
+ case '33':
253
+ return { icon: BiologicalRes.biorhythom_Icon5, iconId: 5 }
254
+ case 'rhythm_icon3':
255
+ case '35':
256
+ return { icon: BiologicalRes.biorhythom_Icon2, iconId: 2 }
257
+ case 'rhythm_icon4':
258
+ case '32':
259
+ return { icon: BiologicalRes.biorhythom_Icon9, iconId: 9 }
260
+ case 'rhythm_icon12':
261
+ case '39':
262
+ return { icon: BiologicalRes.biorhythom_Icon3, iconId: 3 }
263
+ default:
264
+ return { icon: item?.icon, iconId: item?.id }
265
+ }
266
+ }
267
+
268
+ useUpdateEffect(() => {
269
+ console.log('Redux 生物节律数据更新', biorhythm)
270
+ const planList = biorhythm.planList?.map(item => {
271
+ return {
272
+ ...item,
273
+ icon: replaceImg(item?.iconId || item?.icon)?.icon,
274
+ iconId: replaceImg(item?.iconId || item?.icon)?.iconId,
275
+ }
276
+ })
277
+ state.enable = biorhythm.enable
278
+ state.gradient = biorhythm.gradient
279
+ state.repeatPeriod = biorhythm.repeatPeriod
280
+ state.planList = planList
281
+ state.showMaskModal = !biorhythm.enable
282
+ const weeks: string[] = setDataSource(
283
+ biorhythm.repeatPeriod.map(item => {
284
+ return item?.enabled ? 1 : 0
285
+ })).filter(item => item.enabled)
286
+ .map(item => item.title)
287
+
288
+ if (weeks.length > 0) {
289
+ // / more than one
290
+ if (weeks.length === 7) {
291
+ // / seven
292
+ state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text4')
293
+ } else {
294
+ state.weekString = I18n.formatValue('timeschedule_add_schedule_text', weeks.join(', '))
295
+ }
296
+ } else {
297
+ // / zero
298
+ state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text2')
299
+ }
300
+ }, [JSON.stringify(biorhythm)])
301
+
302
+
303
+ const setImg = (id) => {
304
+ const imgIcon = iconList?.find(val => val?.id === Number(id))?.icon
305
+ return imgIcon || ''
306
+ }
307
+
308
+ const openLink = () => {
309
+ const url = I18n.getLang('biorhythm_product_link') // 需要打开的链接
310
+ Linking.openURL(url).catch((error) => console.error('无法打开链接:', error))
311
+ }
312
+
313
+ const sunHomeText = string => {
314
+ const text = string.split('SUN@HOME')
315
+ return text?.length === 1 && <Text style={{ fontSize: cx(14) }}>{text[0]}</Text> ||
316
+ <Text style={{
317
+ fontSize: cx(14),
318
+ flexDirection: 'row',
319
+ }}>
320
+ <Text>{text[0]}</Text>
321
+ <Text onPress={openLink}
322
+ style={{
323
+ fontFamily: 'helvetica_neue_lt_std_roman',
324
+ color: '#ff6600',
325
+ textDecorationLine: 'underline',
326
+ flexWrap: 'wrap',
327
+ }}>SUN@HOME</Text>
328
+ <Text>{text[1]}</Text>
329
+ </Text>
330
+ }
331
+
332
+ const randomIcon = () => {
333
+ const iconIdList = state.planList?.map(item => {
334
+ return item.iconId
335
+ })
336
+ const allIcon = iconList?.map(item => {
337
+ return item.id
338
+ })
339
+ const availableChart = allIcon.filter((element) => !iconIdList.includes(element))
340
+ const randomIndex = Math.floor(Math.random() * availableChart.length)
341
+ return availableChart[randomIndex]
342
+ }
343
+
344
+ const reloadData = async () => {
345
+ const res: any = await NativeApi.getAllTaskTimer(deviceId)
346
+ console.log('reload data', res)
347
+ if (res.success && res.data) {
348
+ // 原生传过来的dps是json字符串。
349
+ if (Array.isArray(res.data) && res.data.length) {
350
+ state.timeSchedule = res.data
351
+ }
352
+ }
353
+ }
354
+
355
+ useEffect(() => {
356
+ reloadData().then()
357
+ }, [])
358
+
359
+ return (
360
+ <>
361
+ <View style={{ flex: 1, flexDirection: 'column' }}>
362
+ <LDVTopBar
363
+ title={deviceInfo.name}
364
+ onBackPress={() => {
365
+ navigation.goBack()
366
+ }}
367
+ />
368
+ <ScrollView nestedScrollEnabled={true} style={{ position: 'relative' }}>
369
+ <View
370
+ style={{
371
+ height: cx(60),
372
+ flexDirection: 'row',
373
+ justifyContent: 'space-between',
374
+ alignItems: 'center',
375
+ marginHorizontal: cx(24),
376
+ }}
377
+ >
378
+ <Text
379
+ style={{
380
+ color: '#FF6600',
381
+ fontSize: cx(24),
382
+ fontFamily: 'helvetica_neue_lt_std_roman',
383
+ }}
384
+ >
385
+ {I18n.getLang('add_new_trigger_time_system_back_text')}
386
+ </Text>
387
+ <Switch
388
+ value={state.enable}
389
+ thumbColor={'#f60'}
390
+ trackColor={{ false: '#00000026', true: '#ff660036' }}
391
+ onValueChange={async enable => {
392
+ if (enable && (sleepWakeUpStatus || enableTimeScheduleStatus)) return showDialog(enable)
393
+ state.loading = true
394
+ state.enable = enable
395
+ state.flag = Symbol()
396
+ }}
397
+ />
398
+ </View>
399
+ <View style={{ marginHorizontal: cx(24) }}>
400
+ {sunHomeText(I18n.getLang(devicesJudge ? 'bio_ryhthm_default_description_text' : 'bio_ryhthm_non_sun_home_products_description_text'))}
401
+ </View>
402
+ <View style={{ height: cx(10) }} />
403
+ <View
404
+ style={{
405
+ flexDirection: 'row',
406
+ justifyContent: 'space-between',
407
+ marginHorizontal: cx(24),
408
+ }}
409
+ >
410
+ {state.repeatPeriod.map(period => {
411
+ return (
412
+ <TouchableOpacity
413
+ key={period.title}
414
+ onPress={() => {
415
+ const periodNum = state.repeatPeriod.filter(p => p.enabled)?.length
416
+ if (periodNum === 1 && period.enabled) return
417
+ period.enabled = !period.enabled
418
+ state.flag = Symbol()
419
+ }}
420
+ >
421
+ <View
422
+ style={{
423
+ width: cx(40),
424
+ height: cx(40),
425
+ justifyContent: 'center',
426
+ alignItems: 'center',
427
+ borderRadius: cx(20),
428
+ backgroundColor: period.enabled ? '#ffe0d4' : '#fff',
429
+ borderWidth: cx(1),
430
+ borderColor: '#f60',
431
+ }}
432
+ >
433
+ <Text
434
+ style={{
435
+ color: '#FF6600',
436
+ textAlign: 'center',
437
+ }}
438
+ >
439
+ {period.title}
440
+ </Text>
441
+ </View>
442
+ </TouchableOpacity>
443
+ )
444
+ })}
445
+ </View>
446
+ <View style={{ marginHorizontal: cx(24), marginTop: cx(20) }}>
447
+ <Text>{state.weekString}</Text>
448
+ </View>
449
+ <View style={{ marginHorizontal: cx(24), marginTop: cx(16) }}>
450
+ <Text>
451
+ {I18n.getLang('bio_ryhthm_default_selectionfield_topic_text')}
452
+ </Text>
453
+ <TouchableOpacity
454
+ onPress={() => {
455
+ showGradientTypeSelectModal(true)
456
+ }}
457
+ >
458
+ <View
459
+ style={{
460
+ flexDirection: 'row',
461
+ borderRadius: cx(4),
462
+ backgroundColor: '#f6f6f6',
463
+ alignItems: 'center',
464
+ flex: 1,
465
+ height: cx(44),
466
+ borderBottomWidth: cx(1),
467
+ borderBottomColor: '#cbcbcb',
468
+ }}
469
+ >
470
+ <Text style={{
471
+ fontSize: cx(16),
472
+ color: '#000',
473
+ fontFamily: 'helvetica_neue_lt_std_roman',
474
+ paddingLeft: cx(16),
475
+ }}>
476
+ {
477
+ I18n.getLang(
478
+ state.gradient === BiorhythmGradientType.DirectGradient
479
+ ? 'add_new_dynamic_mood_color_changing_mode_value2'
480
+ : 'add_new_dynamic_mood_color_changing_mode_value',
481
+ )
482
+ }
483
+
484
+ </Text>
485
+ </View>
486
+ </TouchableOpacity>
487
+ </View>
488
+ <View style={{ height: cx(20) }} />
489
+ <TimeCircular
490
+ planEdit={true}
491
+ planList={state.planList}
492
+ onPanMoved={(id, time) => {
493
+ state.planList = state.planList.map(plan => {
494
+ return {
495
+ ...plan,
496
+ startTime: plan.id === id ? time : plan.startTime,
497
+ }
498
+ })
499
+ state.flag = Symbol()
500
+ }}
501
+ replaceStatus={devicesJudge}
502
+ gradient={state.gradient === BiorhythmGradientType.DirectGradient}
503
+ isSupportTemperature={!params.isSupportTemperature} />
504
+ <View
505
+ style={{
506
+ flexDirection: 'row',
507
+ justifyContent: 'space-between',
508
+ marginHorizontal: cx(24),
509
+ marginBottom: cx(-8),
510
+ marginTop: cx(26),
511
+ }}>
512
+ {state.planList.length === 8 && <View
513
+ style={{ marginVertical: cx(10), flexDirection: 'row', alignItems: 'center', width: width - cx(48) }}>
514
+ <Image style={{ width: cx(16), height: cx(16), tintColor: '#ff9500' }} source={res.ic_warning_amber} />
515
+ <Text
516
+ style={{
517
+ flexWrap: 'wrap',
518
+ fontSize: cx(12),
519
+ }}>{I18n.getLang('add_new_trigger_time_warning_max_number_text')}</Text>
520
+ </View>}
521
+ {state.planList.length < 8 &&
522
+ <>
523
+ <Text
524
+ style={{
525
+ fontSize: cx(16),
526
+ fontWeight: 'bold',
527
+ color: 'rgb(0,0,0)',
528
+ }}>{I18n.getLang('bio_ryhthm_default_subheadline_text')}</Text>
529
+ <TouchableOpacity
530
+ onPress={() => {
531
+ const ids: number[] = state.planList.map(p => p.id)
532
+ const newPlan: Plan = {
533
+ id: Math.max(...ids) + 1,
534
+ icon: res.rhythm_icon1,
535
+ startTime: '00:00',
536
+ name: '',
537
+ colorTemperature: 0,
538
+ brightness: 100,
539
+ action: [
540
+ {
541
+ uri: 'model/attribute/set/LightCtrl/ColorTemperature',
542
+ startValue: `${colorTemperatureValue(0)}`,
543
+ },
544
+ {
545
+ uri: 'model/attribute/set/LightCtrl/Brightness',
546
+ startValue: '100',
547
+ },
548
+ ],
549
+ enable: true,
550
+ iconId: randomIcon(),
551
+ }
552
+ const editPageParams: BiorhythmEditPageParams = {
553
+ planData: newPlan,
554
+ isAdd: true,
555
+ onPlanEdited,
556
+ onPlanDelete,
557
+ minimumEnable,
558
+ iconIdList: state.planList?.map(item => {
559
+ return item.iconId
560
+ }),
561
+ isMixRGBWLamp: params.isMixRGBWLamp,
562
+ isSupportTemperature: params.isSupportTemperature,
563
+ isSupportBrightness: params.isSupportBrightness,
564
+ showDeleteBtn
565
+ }
566
+ navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
567
+ }}>
568
+ <Image source={BiologicalRes.biorhythom_add} style={{ height: cx(24), width: cx(24) }} />
569
+ </TouchableOpacity>
570
+ </>
571
+ }
572
+ </View>
573
+ <FlatList
574
+ data={state.planList}
575
+ style={{
576
+ flex: 1,
577
+ marginTop: cx(12),
578
+ }}
579
+ nestedScrollEnabled={true}
580
+ renderItem={({ item }) => {
581
+ const type = typeof item?.icon === 'string'
582
+ const bgColor = item?.brightness === 0 ? '#000' : !params.isSupportTemperature && cctToColor(1) || cctToColor(item.colorTemperature.toFixed(), item?.brightness)
583
+ return (
584
+ <View
585
+ style={{
586
+ height: cx(118),
587
+ backgroundColor: 'white',
588
+ elevation: cx(7),
589
+ shadowColor: '#000000',
590
+ shadowOpacity: 0.2,
591
+ shadowRadius: cx(7),
592
+ shadowOffset: {
593
+ width: 0,
594
+ height: cx(4),
595
+ },
596
+ borderRadius: cx(10),
597
+ marginHorizontal: cx(24),
598
+ marginVertical: cx(8),
599
+ }}
600
+ >
601
+ <TouchableOpacity
602
+ style={{ flex: 1 }}
603
+ onPress={() => {
604
+ const editPageParams: BiorhythmEditPageParams = {
605
+ planData: {
606
+ ...item,
607
+ name: setTimer(item?.name)
608
+ },
609
+ isAdd: false,
610
+ onPlanEdited,
611
+ onPlanDelete,
612
+ minimumEnable,
613
+ iconIdList: state.planList?.map(item => {
614
+ return item.iconId
615
+ }),
616
+ isMixRGBWLamp: params.isMixRGBWLamp,
617
+ isSupportTemperature: params.isSupportTemperature,
618
+ isSupportBrightness: params.isSupportBrightness,
619
+ showDeleteBtn
620
+ }
621
+ navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
622
+ }}
623
+ >
624
+ <View
625
+ style={{
626
+ flex: 1,
627
+ flexDirection: 'column',
628
+ }}
629
+ >
630
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', marginTop: cx(16) }}>
631
+ <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
632
+ <Image
633
+ source={setImg(item?.iconId) || type && { uri: item?.icon } || item?.icon}
634
+ style={{
635
+ width: cx(24),
636
+ height: cx(24),
637
+ marginStart: cx(10),
638
+ marginRight: cx(6),
639
+ tintColor: '#474e5d',
640
+ }}
641
+ />
642
+ <Text
643
+ style={{
644
+ fontSize: cx(16),
645
+ color: '#000',
646
+ fontFamily: 'helvetica_neue_lt_std_roman',
647
+ }}
648
+ >
649
+ {item.startTime}
650
+ </Text>
651
+ </View>
652
+ <Switch
653
+ value={item.enable}
654
+ thumbColor={'#f60'}
655
+ trackColor={{ false: '#00000026', true: '#ff660036' }}
656
+ onValueChange={e => {
657
+ item.enable = e
658
+ state.flag = Symbol()
659
+ }}
660
+ style={{ marginRight: cx(10) }}
661
+ />
662
+ </View>
663
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between' }}>
664
+ <Text
665
+ style={{
666
+ fontSize: cx(12),
667
+ color: '#666',
668
+ fontFamily: 'helvetica_neue_lt_std_roman',
669
+ paddingLeft: cx(20),
670
+ }}
671
+ >
672
+ {setTimer(item?.name)}
673
+ </Text>
674
+ </View>
675
+ <View
676
+ style={{
677
+ width: cx(295),
678
+ height: cx(24),
679
+ backgroundColor: bgColor,
680
+ marginLeft: cx(20),
681
+ marginTop: cx(-5),
682
+ marginBottom: cx(24),
683
+ borderRadius: cx(8),
684
+ }} />
685
+ </View>
686
+ </TouchableOpacity>
687
+ </View>
688
+ )
689
+ }}
690
+ keyExtractor={item => `${item.id}`}
691
+ ListFooterComponent={() => {
692
+ return (
693
+ <View>
694
+ <View
695
+ style={{
696
+ height: cx(50),
697
+ backgroundColor: '#666',
698
+ elevation: cx(7),
699
+ shadowColor: '#000000',
700
+ shadowOpacity: 0.2,
701
+ shadowRadius: cx(7),
702
+ shadowOffset: {
703
+ width: 0,
704
+ height: cx(4),
705
+ },
706
+ borderRadius: cx(10),
707
+ marginHorizontal: cx(24),
708
+ marginTop: cx(16),
709
+ }}>
710
+ <TouchableOpacity
711
+ style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
712
+ onPress={() => {
713
+ showCommonDialog({
714
+ method: 'confirm',
715
+ title: I18n.getLang('bio_ryhthm_reset_description_text'),
716
+ onConfirm: (_, { close }) => {
717
+ const defBiorhythmUIState = getDefBiorhythmUIState()
718
+ state.enable = defBiorhythmUIState.enable
719
+ state.gradient = defBiorhythmUIState.gradient
720
+ state.repeatPeriod = defBiorhythmUIState.repeatPeriod
721
+ state.planList = defBiorhythmUIState.planList
722
+ state.flag = Symbol()
723
+ close()
724
+ }
725
+ })
726
+ }}>
727
+ <Text
728
+ style={{
729
+ fontSize: cx(16),
730
+ color: '#fff',
731
+ fontFamily: 'helvetica_neue_lt_std_roman',
732
+ }}>{I18n.getLang('bio_ryhthm_default_button_reset_text')}</Text>
733
+ </TouchableOpacity>
734
+ </View>
735
+ <View style={{ height: cx(20) }} />
736
+ </View>
737
+ ) || <></>
738
+ }}
739
+ />
740
+ {state.showMaskModal && (
741
+ <View
742
+ style={{
743
+ backgroundColor: 'rgba(0,0,0,.5)',
744
+ width: '100%',
745
+ height: '100%',
746
+ position: 'absolute',
747
+ top: cx(45),
748
+ zIndex: 999,
749
+ }}
750
+ />
751
+ )}
752
+ </ScrollView>
753
+ </View>
754
+ <Modal.List
755
+ type={'radio'}
756
+ visible={state.showGradientTypeSelectModal}
757
+ value={state.gradient}
758
+ dataSource={[
759
+ {
760
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value'),
761
+ key: BiorhythmGradientType.EntireGradient,
762
+ value: BiorhythmGradientType.EntireGradient,
763
+ },
764
+ {
765
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value2'),
766
+ key: BiorhythmGradientType.DirectGradient,
767
+ value: BiorhythmGradientType.DirectGradient,
768
+ },
769
+ ]}
770
+ title={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
771
+ onMaskPress={() => {
772
+ showGradientTypeSelectModal(false)
773
+ }}
774
+ onCancel={() => {
775
+ showGradientTypeSelectModal(false)
776
+ }}
777
+ cancelText={I18n.getLang('auto_scan_system_cancel')}
778
+ confirmText={I18n.getLang('auto_scan_system_wifi_confirm')}
779
+ onConfirm={(item: BiorhythmGradientType) => {
780
+ state.gradient = item
781
+ state.flag = Symbol()
782
+ showGradientTypeSelectModal(false)
783
+ }}
784
+ />
785
+ <Toast.Loading
786
+ show={!!state.loading}
787
+ onFinish={() => {
788
+
789
+ }} />
790
+ </>
791
+ )
792
+ }
793
+
794
+ export default BiorhythmPage
795
+
796
+