@ledvance/ui-biz-bundle 1.1.59 → 1.1.61

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 (120) hide show
  1. package/package.json +1 -1
  2. package/src/modules/flags/FlagEditPage.tsx +22 -14
  3. package/src/modules/flags/FlagPage.tsx +7 -18
  4. package/src/modules/mood/DynamicMoodEditorPage.tsx +12 -14
  5. package/src/modules/mood/FantasyMoodEditPage.tsx +12 -14
  6. package/src/modules/mood/StaticMoodEditorPage.tsx +12 -13
  7. package/src/modules/timer/TimerPage.tsx +58 -56
  8. package/src/newModules/biorhythm/BiorhythmActions.ts +374 -0
  9. package/src/newModules/biorhythm/BiorhythmBean.ts +230 -0
  10. package/src/newModules/biorhythm/BiorhythmEditPage.tsx +267 -0
  11. package/src/newModules/biorhythm/BiorhythmPage.tsx +638 -0
  12. package/src/newModules/biorhythm/IconSelect.tsx +85 -0
  13. package/src/newModules/biorhythm/Router.ts +34 -0
  14. package/src/newModules/biorhythm/circular/ItemIcon.d.ts +22 -0
  15. package/src/newModules/biorhythm/circular/ItemIcon.tsx +173 -0
  16. package/src/newModules/biorhythm/circular/Progress.d.ts +24 -0
  17. package/src/newModules/biorhythm/circular/Progress.tsx +372 -0
  18. package/src/newModules/biorhythm/circular/TimeCircular.d.ts +11 -0
  19. package/src/newModules/biorhythm/circular/TimeCircular.tsx +64 -0
  20. package/src/newModules/biorhythm/circular/biorhythm_plantimer.png +0 -0
  21. package/src/newModules/biorhythm/circular/rhythm_icon.png +0 -0
  22. package/src/newModules/biorhythm/iconListData.ts +30 -0
  23. package/src/newModules/biorhythm/pIdList.ts +36 -0
  24. package/src/newModules/biorhythm/res/BiologicalRes.d.ts +43 -0
  25. package/src/newModules/biorhythm/res/BiologicalRes.ts +42 -0
  26. package/src/newModules/biorhythm/res/Biological_Rhythm.png +0 -0
  27. package/src/newModules/biorhythm/res/Biological_Rhythm_12.png +0 -0
  28. package/src/newModules/biorhythm/res/Biological_Rhythm_new.png +0 -0
  29. package/src/newModules/biorhythm/res/Biological_Rhythm_new_12.png +0 -0
  30. package/src/newModules/biorhythm/res/iconsMaterialOutlinedAccountGroups.png +0 -0
  31. package/src/newModules/biorhythm/res/iconsMaterialOutlinedAccountGroups@2x.png +0 -0
  32. package/src/newModules/biorhythm/res/iconsMaterialOutlinedAccountGroups@3x.png +0 -0
  33. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd.png +0 -0
  34. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd@2x.png +0 -0
  35. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd@3x.png +0 -0
  36. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos.png +0 -0
  37. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos@2x.png +0 -0
  38. package/src/newModules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos@3x.png +0 -0
  39. package/src/newModules/biorhythm/res/iconsMaterialOutlinedBuildingsHome.png +0 -0
  40. package/src/newModules/biorhythm/res/iconsMaterialOutlinedBuildingsHome@2x.png +0 -0
  41. package/src/newModules/biorhythm/res/iconsMaterialOutlinedBuildingsHome@3x.png +0 -0
  42. package/src/newModules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder.png +0 -0
  43. package/src/newModules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder@2x.png +0 -0
  44. package/src/newModules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder@3x.png +0 -0
  45. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBed.png +0 -0
  46. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBed@2x.png +0 -0
  47. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBed@3x.png +0 -0
  48. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter.png +0 -0
  49. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter@2x.png +0 -0
  50. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter@3x.png +0 -0
  51. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherChair.png +0 -0
  52. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherChair@2x.png +0 -0
  53. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherChair@3x.png +0 -0
  54. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherCoffee.png +0 -0
  55. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherCoffee@2x.png +0 -0
  56. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherCoffee@3x.png +0 -0
  57. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar.png +0 -0
  58. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar@2x.png +0 -0
  59. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar@3x.png +0 -0
  60. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter.png +0 -0
  61. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter@2x.png +0 -0
  62. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter@3x.png +0 -0
  63. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones.png +0 -0
  64. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones@2x.png +0 -0
  65. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones@3x.png +0 -0
  66. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook.png +0 -0
  67. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook@2x.png +0 -0
  68. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook@3x.png +0 -0
  69. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote.png +0 -0
  70. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote@2x.png +0 -0
  71. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote@3x.png +0 -0
  72. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone.png +0 -0
  73. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone@2x.png +0 -0
  74. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone@3x.png +0 -0
  75. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant.png +0 -0
  76. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant@2x.png +0 -0
  77. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant@3x.png +0 -0
  78. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant.png +0 -0
  79. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant@2x.png +0 -0
  80. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant@3x.png +0 -0
  81. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied.png +0 -0
  82. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied@2x.png +0 -0
  83. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied@3x.png +0 -0
  84. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports.png +0 -0
  85. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports@2x.png +0 -0
  86. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports@3x.png +0 -0
  87. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherTv.png +0 -0
  88. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherTv@2x.png +0 -0
  89. package/src/newModules/biorhythm/res/iconsMaterialOutlinedOtherTv@3x.png +0 -0
  90. package/src/newModules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm.png +0 -0
  91. package/src/newModules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm@2x.png +0 -0
  92. package/src/newModules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm@3x.png +0 -0
  93. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime.png +0 -0
  94. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime@2x.png +0 -0
  95. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime@3x.png +0 -0
  96. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay.png +0 -0
  97. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay@2x.png +0 -0
  98. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay@3x.png +0 -0
  99. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline.png +0 -0
  100. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline@2x.png +0 -0
  101. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline@3x.png +0 -0
  102. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny.png +0 -0
  103. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny@2x.png +0 -0
  104. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny@3x.png +0 -0
  105. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight.png +0 -0
  106. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight@2x.png +0 -0
  107. package/src/newModules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight@3x.png +0 -0
  108. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +84 -83
  109. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +133 -132
  110. package/src/newModules/energyConsumption/component/EnergyModal.tsx +119 -117
  111. package/src/newModules/energyConsumption/component/Overview.tsx +38 -36
  112. package/src/newModules/mood/AddMoodPage.tsx +37 -21
  113. package/src/newModules/mood/DynamicMoodEditorPage.tsx +7 -2
  114. package/src/newModules/mood/MixDynamicMoodEditor.tsx +8 -2
  115. package/src/newModules/mood/StaticMoodEditorPage.tsx +9 -2
  116. package/src/newModules/timeSchedule/Interface.ts +1 -0
  117. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +203 -202
  118. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +35 -34
  119. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +11 -10
  120. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +63 -60
@@ -0,0 +1,638 @@
1
+ import React, { useCallback, useEffect, useMemo } from 'react'
2
+ import { FlatList, Image, Linking, ScrollView, Switch, Text, TouchableOpacity, View } from 'react-native'
3
+ import { useNavigation } from '@react-navigation/native'
4
+ import { useDebounceFn, useReactive, useUpdateEffect } from 'ahooks'
5
+ import {
6
+ BiorhythmBean,
7
+ BiorhythmGradientType,
8
+ colorTemperatureValue,
9
+ getDefBiorhythmUIState,
10
+ Plan,
11
+ } from './BiorhythmBean'
12
+ import { Modal, Utils } from 'tuya-panel-kit'
13
+ import { cloneDeep, sortBy } from 'lodash'
14
+ import iconList from './iconListData'
15
+ import pIdList from './pIdList'
16
+ import {
17
+ useDeviceId,
18
+ useDeviceInfo,
19
+ useSystemTimeFormate,
20
+ } from '@ledvance/base/src/models/modules/NativePropsSlice'
21
+ import I18n from '@ledvance/base/src/i18n'
22
+ import res from '@ledvance/base/src/res'
23
+ import { ui_biz_routerKey } from "../../navigation/Routers";
24
+ import BiologicalRes from './res/BiologicalRes'
25
+ import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
26
+ import { setDataSource } from '@ledvance/base/src/components/weekSelect'
27
+ import { BiorhythmEditPageParams } from './BiorhythmEditPage'
28
+ import { useBiorhythm, userOperation } from './BiorhythmActions'
29
+ import { convertMinutesTo12HourFormat, showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
30
+ import TimeCircular from './circular/TimeCircular'
31
+ import Page from '@ledvance/base/src/components/Page'
32
+ import Card from '@ledvance/base/src/components/Card'
33
+ import Spacer from '@ledvance/base/src/components/Spacer'
34
+ import DeleteButton from '@ledvance/base/src/components/DeleteButton'
35
+ import { useParams } from '@ledvance/base/src/hooks/Hooks'
36
+
37
+ const cx = Utils.RatioUtils.convertX
38
+ const width = Utils.RatioUtils.width
39
+
40
+ interface UIState extends BiorhythmBean {
41
+ showGradientTypeSelectModal: boolean;
42
+ flag: symbol;
43
+ weekString: string,
44
+ timeSchedule: any[]
45
+ loading: boolean
46
+ }
47
+
48
+ export interface BiorhythmPageParams {
49
+ biorhythmDp: string
50
+ sleepPlanDp: string
51
+ wakeUpPlanDp: string
52
+ isSupportTemperature: boolean
53
+ isSupportBrightness: boolean
54
+ isMixRGBWLamp: boolean
55
+ }
56
+
57
+ const BiorhythmPage = () => {
58
+ const params = useParams<BiorhythmPageParams>()
59
+ const navigation = useNavigation()
60
+ const [biorhythm, setBiorhythm] = useBiorhythm(params.biorhythmDp)
61
+ const deviceId = useDeviceId()
62
+ const deviceInfo = useDeviceInfo()
63
+ const { productId } = deviceInfo
64
+ const is24Hour = useSystemTimeFormate()
65
+ const devicesJudge = pIdList.some(val => val === productId)
66
+ // const [sleepList, setSleepList] = useSleepPlan({ sleep_mode: params.sleepPlanDp })
67
+ // const [wakeUpList, setWakeUpList] = useWakeUpPlan({ wakeup_mode: params.wakeUpPlanDp })
68
+ // const sleepWakeUpStatus = [...sleepList, ...wakeUpList].some(ele => ele.enable)
69
+ const state = useReactive<UIState>({
70
+ ...biorhythm,
71
+ showGradientTypeSelectModal: false,
72
+ flag: Symbol(),
73
+ weekString: '',
74
+ timeSchedule: [],
75
+ loading: false
76
+ })
77
+
78
+ const showGradientTypeSelectModal = useCallback((show: boolean) => {
79
+ state.showGradientTypeSelectModal = show
80
+ }, [])
81
+
82
+ const onPlanEdited = useCallback((isAdd: boolean, newPlan: Plan) => {
83
+ if (isAdd) {
84
+ state.planList.push(newPlan)
85
+ state.planList = sortBy(state.planList, p => p.time)
86
+ } else {
87
+ state.planList = state.planList.map(plan => (plan.index === newPlan.index ? newPlan : plan))
88
+ }
89
+ state.flag = Symbol()
90
+ }, [])
91
+
92
+ const onPlanDelete = useCallback((id: number) => {
93
+ state.planList = state.planList.filter(plan => plan.index !== id)
94
+ state.flag = Symbol()
95
+ }, [])
96
+
97
+ const requestSetBiorhythm = useCallback(async (pushFeature: boolean = true) => {
98
+ state.loading = true
99
+ const planList = state.planList?.map(item => { return { ...item, icon: `${item.icon}` } })
100
+ .sort((a, b) => a.time - b.time);
101
+ await userOperation(deviceId, false)
102
+ const res = await setBiorhythm(cloneDeep({ ...state, planList }), pushFeature)
103
+ state.loading = false
104
+ if (res.success) {
105
+ console.log('设置生物节律 OK')
106
+ }
107
+ }, [])
108
+
109
+ useUpdateEffect(() => {
110
+ if (state.planList?.length === 0) {
111
+ const data = getDefBiorhythmUIState()
112
+ data.planList = data.planList?.map(item => {
113
+ return { ...item, icon: `${item.icon}` }
114
+ })
115
+ setBiorhythm(cloneDeep(data)).then()
116
+ }
117
+ }, [state.planList])
118
+
119
+ const setTimer = value => {
120
+ switch (value) {
121
+ case 'Sunrise':
122
+ return I18n.getLang('bio_ryhthm_default_field_text')
123
+ case 'Wake Up':
124
+ return I18n.getLang('bio_ryhthm_default_field_text2')
125
+ case 'Sunlight':
126
+ return I18n.getLang('bio_ryhthm_default_field_text3')
127
+ case 'Comfortable':
128
+ return I18n.getLang('bio_ryhthm_default_field_text4')
129
+ case 'Night light':
130
+ return I18n.getLang('bio_ryhthm_default_field_text5')
131
+ default:
132
+ return value
133
+ }
134
+ }
135
+
136
+ const minimumEnable = useCallback((plan: Plan) => {
137
+ let enable = false
138
+ state.planList.filter(p => p.index !== plan.index).forEach(item => {
139
+ const diff = Math.abs(plan.time - item.time)
140
+ if (diff < 15) enable = true
141
+ })
142
+ return enable
143
+ }, [state.planList])
144
+
145
+ const nameRepeat = useCallback((plan: Plan) => {
146
+ return !!state.planList.filter(p => p.index !== plan.index).find(p => p.name === plan.name)
147
+ }, [state.planList])
148
+
149
+ const showDeleteBtn = useMemo(() => {
150
+ return state.planList?.length > 1
151
+ }, [state.planList?.length])
152
+
153
+ const { run } = useDebounceFn(requestSetBiorhythm, { wait: 300 })
154
+
155
+ useUpdateEffect(() => {
156
+ run()
157
+ }, [state.flag])
158
+
159
+ const replaceImg = (img) => {
160
+ const item = iconList?.find(val => val.id === Number(img))
161
+ switch (img) {
162
+ case 'rhythm_icon1':
163
+ case '31':
164
+ return { icon: BiologicalRes.biorhythom_Icon1, iconId: 1 }
165
+ case 'rhythm_icon2':
166
+ case '33':
167
+ return { icon: BiologicalRes.biorhythom_Icon5, iconId: 5 }
168
+ case 'rhythm_icon3':
169
+ case '35':
170
+ return { icon: BiologicalRes.biorhythom_Icon2, iconId: 2 }
171
+ case 'rhythm_icon4':
172
+ case '32':
173
+ return { icon: BiologicalRes.biorhythom_Icon9, iconId: 9 }
174
+ case 'rhythm_icon12':
175
+ case '39':
176
+ return { icon: BiologicalRes.biorhythom_Icon3, iconId: 3 }
177
+ default:
178
+ return { icon: item?.icon, iconId: item?.id }
179
+ }
180
+ }
181
+
182
+ useEffect(() =>{
183
+ const weeks: string[] = setDataSource(
184
+ biorhythm.repeatPeriod.map(item => {
185
+ return item?.enabled ? 1 : 0
186
+ })).filter(item => item.enabled)
187
+ .map(item => item.title)
188
+
189
+ if (weeks.length > 0) {
190
+ if (weeks.length === 7) {
191
+ state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text4')
192
+ } else {
193
+ state.weekString = I18n.formatValue('timeschedule_add_schedule_text', weeks.join(', '))
194
+ }
195
+ } else {
196
+ state.weekString = I18n.getLang('motion_detection_time_schedule_notifications_field_weekdays_text2')
197
+ }
198
+ }, [JSON.stringify(biorhythm.repeatPeriod)])
199
+
200
+ useUpdateEffect(() => {
201
+ console.log('Redux 生物节律数据更新', biorhythm)
202
+ const planList = biorhythm.planList?.map(item => {
203
+ return {
204
+ ...item,
205
+ icon: replaceImg(item?.iconId || item?.icon)?.icon,
206
+ iconId: replaceImg(item?.iconId || item?.icon)?.iconId,
207
+ }
208
+ })
209
+ state.enable = biorhythm.enable
210
+ state.gradient = biorhythm.gradient
211
+ state.repeatPeriod = biorhythm.repeatPeriod
212
+ state.planList = planList
213
+
214
+ }, [JSON.stringify(biorhythm)])
215
+
216
+
217
+ const setImg = (id) => {
218
+ const imgIcon = iconList?.find(val => val?.id === Number(id))?.icon
219
+ return imgIcon || ''
220
+ }
221
+
222
+ const openLink = () => {
223
+ const url = I18n.getLang('biorhythm_product_link') // 需要打开的链接
224
+ Linking.openURL(url).catch((error) => console.error('无法打开链接:', error))
225
+ }
226
+
227
+ const sunHomeText = string => {
228
+ const text = string.split('SUN@HOME')
229
+ return text?.length === 1 && <Text style={{ fontSize: cx(14) }}>{text[0]}</Text> ||
230
+ <Text style={{
231
+ fontSize: cx(14),
232
+ flexDirection: 'row',
233
+ }}>
234
+ <Text>{text[0]}</Text>
235
+ <Text onPress={openLink}
236
+ style={{
237
+ fontFamily: 'helvetica_neue_lt_std_roman',
238
+ color: '#ff6600',
239
+ textDecorationLine: 'underline',
240
+ flexWrap: 'wrap',
241
+ }}>SUN@HOME</Text>
242
+ <Text>{text[1]}</Text>
243
+ </Text>
244
+ }
245
+
246
+ const randomIcon = () => {
247
+ const iconIdList = state.planList?.map(item => {
248
+ return item.iconId
249
+ })
250
+ const allIcon = iconList?.map(item => {
251
+ return item.id
252
+ })
253
+ const availableChart = allIcon.filter((element) => !iconIdList.includes(element))
254
+ const randomIndex = Math.floor(Math.random() * availableChart.length)
255
+ return availableChart[randomIndex]
256
+ }
257
+
258
+ return (
259
+ <>
260
+ <Page
261
+ backText={deviceInfo.name}
262
+ onBackClick={navigation.goBack}
263
+ headlineText={I18n.getLang('add_new_trigger_time_system_back_text')}
264
+ headlineContent={<Switch
265
+ value={state.enable}
266
+ thumbColor={'#f60'}
267
+ trackColor={{ false: '#00000026', true: '#ff660036' }}
268
+ onValueChange={async enable => {
269
+ state.loading = true
270
+ state.enable = enable
271
+ requestSetBiorhythm(false)
272
+ }}
273
+ />}
274
+ loading={state.loading}
275
+ >
276
+ <ScrollView nestedScrollEnabled={true} style={{ position: 'relative' }}>
277
+ <View style={{ marginHorizontal: cx(24) }}>
278
+ {sunHomeText(I18n.getLang(devicesJudge ? 'bio_ryhthm_default_description_text' : 'bio_ryhthm_non_sun_home_products_description_text'))}
279
+ </View>
280
+ <View style={{ height: cx(10) }} />
281
+ <View
282
+ style={{
283
+ flexDirection: 'row',
284
+ justifyContent: 'space-between',
285
+ marginHorizontal: cx(24),
286
+ }}
287
+ >
288
+ {state.repeatPeriod.map(period => {
289
+ return (
290
+ <TouchableOpacity
291
+ key={period.title}
292
+ onPress={() => {
293
+ const periodNum = state.repeatPeriod.filter(p => p.enabled)?.length
294
+ if (periodNum === 1 && period.enabled) return
295
+ period.enabled = !period.enabled
296
+ requestSetBiorhythm(false)
297
+ }}
298
+ >
299
+ <View
300
+ style={{
301
+ width: cx(40),
302
+ height: cx(40),
303
+ justifyContent: 'center',
304
+ alignItems: 'center',
305
+ borderRadius: cx(20),
306
+ backgroundColor: period.enabled ? '#ffe0d4' : '#fff',
307
+ borderWidth: cx(1),
308
+ borderColor: '#f60',
309
+ }}
310
+ >
311
+ <Text
312
+ style={{
313
+ color: '#FF6600',
314
+ textAlign: 'center',
315
+ }}
316
+ >
317
+ {period.title}
318
+ </Text>
319
+ </View>
320
+ </TouchableOpacity>
321
+ )
322
+ })}
323
+ </View>
324
+ <View style={{ marginHorizontal: cx(24), marginTop: cx(20) }}>
325
+ <Text>{state.weekString}</Text>
326
+ </View>
327
+ <View style={{ marginHorizontal: cx(24), marginTop: cx(16) }}>
328
+ <Text>
329
+ {I18n.getLang('bio_ryhthm_default_selectionfield_topic_text')}
330
+ </Text>
331
+ <TouchableOpacity
332
+ onPress={() => {
333
+ showGradientTypeSelectModal(true)
334
+ }}
335
+ >
336
+ <View
337
+ style={{
338
+ flexDirection: 'row',
339
+ borderRadius: cx(4),
340
+ backgroundColor: '#f6f6f6',
341
+ alignItems: 'center',
342
+ flex: 1,
343
+ height: cx(44),
344
+ borderBottomWidth: cx(1),
345
+ borderBottomColor: '#cbcbcb',
346
+ }}
347
+ >
348
+ <Text style={{
349
+ fontSize: cx(16),
350
+ color: '#000',
351
+ fontFamily: 'helvetica_neue_lt_std_roman',
352
+ paddingLeft: cx(16),
353
+ }}>
354
+ {
355
+ I18n.getLang(
356
+ state.gradient === BiorhythmGradientType.DirectGradient
357
+ ? 'add_new_dynamic_mood_color_changing_mode_value2'
358
+ : 'add_new_dynamic_mood_color_changing_mode_value',
359
+ )
360
+ }
361
+
362
+ </Text>
363
+ </View>
364
+ </TouchableOpacity>
365
+ </View>
366
+ <View style={{ height: cx(20) }} />
367
+ <TimeCircular
368
+ planEdit={true}
369
+ planList={state.planList}
370
+ onPanMoved={(id, time) => {
371
+ state.planList = state.planList.map(plan => {
372
+ return {
373
+ ...plan,
374
+ time: plan.index === id ? time : plan.time,
375
+ }
376
+ })
377
+ state.flag = Symbol()
378
+ }}
379
+ replaceStatus={devicesJudge}
380
+ gradient={state.gradient === BiorhythmGradientType.DirectGradient}
381
+ isSupportTemperature={!params.isSupportTemperature} />
382
+ <View
383
+ style={{
384
+ flexDirection: 'row',
385
+ justifyContent: 'space-between',
386
+ marginHorizontal: cx(24),
387
+ marginBottom: cx(-8),
388
+ marginTop: cx(26),
389
+ }}>
390
+ {state.planList.length === 8 && <View
391
+ style={{ marginVertical: cx(10), flexDirection: 'row', alignItems: 'center', width: width - cx(48) }}>
392
+ <Image style={{ width: cx(16), height: cx(16), tintColor: '#ff9500' }} source={res.ic_warning_amber} />
393
+ <Text
394
+ style={{
395
+ flexWrap: 'wrap',
396
+ fontSize: cx(12),
397
+ }}>{I18n.getLang('add_new_trigger_time_warning_max_number_text')}</Text>
398
+ </View>}
399
+ {state.planList.length < 8 &&
400
+ <>
401
+ <Text
402
+ style={{
403
+ fontSize: cx(16),
404
+ fontWeight: 'bold',
405
+ color: 'rgb(0,0,0)',
406
+ }}>{I18n.getLang('bio_ryhthm_default_subheadline_text')}</Text>
407
+ <TouchableOpacity
408
+ onPress={() => {
409
+ const ids: number[] = state.planList.map(p => p.index)
410
+ const newPlan: Plan = {
411
+ index: Math.max(...ids) + 1,
412
+ icon: res.rhythm_icon1,
413
+ time: 0,
414
+ name: '',
415
+ colorTemperature: 0,
416
+ brightness: 100,
417
+ action: [
418
+ {
419
+ uri: 'model/attribute/set/LightCtrl/ColorTemperature',
420
+ startValue: `${colorTemperatureValue(0)}`,
421
+ },
422
+ {
423
+ uri: 'model/attribute/set/LightCtrl/Brightness',
424
+ startValue: '100',
425
+ },
426
+ ],
427
+ enable: true,
428
+ iconId: randomIcon(),
429
+ }
430
+ const editPageParams: BiorhythmEditPageParams = {
431
+ planData: newPlan,
432
+ isAdd: true,
433
+ onPlanEdited,
434
+ onPlanDelete,
435
+ minimumEnable,
436
+ nameRepeat,
437
+ iconIdList: state.planList?.map(item => {
438
+ return item.iconId
439
+ }),
440
+ isMixRGBWLamp: params.isMixRGBWLamp,
441
+ isSupportTemperature: params.isSupportTemperature,
442
+ isSupportBrightness: params.isSupportBrightness,
443
+ showDeleteBtn
444
+ }
445
+ navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
446
+ }}>
447
+ <Image source={BiologicalRes.biorhythom_add} style={{ height: cx(24), width: cx(24) }} />
448
+ </TouchableOpacity>
449
+ </>
450
+ }
451
+ </View>
452
+ <FlatList
453
+ data={state.planList}
454
+ style={{
455
+ flex: 1,
456
+ marginTop: cx(12),
457
+ }}
458
+ nestedScrollEnabled={true}
459
+ ListHeaderComponent={() => (<Spacer height={cx(16)} />)}
460
+ ItemSeparatorComponent={() => (<Spacer height={cx(16)} />)}
461
+ renderItem={({ item }) => {
462
+ const type = typeof item?.icon === 'string'
463
+ const bgColor = item?.brightness === 0 ? '#000' : !params.isSupportTemperature && cctToColor(1) || cctToColor(item.colorTemperature.toFixed(), item?.brightness)
464
+ return (
465
+ <Card
466
+ style={{ marginHorizontal: cx(24) }}
467
+ onPress={() => {
468
+ const editPageParams: BiorhythmEditPageParams = {
469
+ planData: {
470
+ ...item,
471
+ name: setTimer(item?.name)
472
+ },
473
+ isAdd: false,
474
+ onPlanEdited,
475
+ onPlanDelete,
476
+ minimumEnable,
477
+ nameRepeat,
478
+ iconIdList: state.planList?.map(item => {
479
+ return item.iconId
480
+ }),
481
+ isMixRGBWLamp: params.isMixRGBWLamp,
482
+ isSupportTemperature: params.isSupportTemperature,
483
+ isSupportBrightness: params.isSupportBrightness,
484
+ showDeleteBtn
485
+ }
486
+ navigation.navigate(ui_biz_routerKey.bi_biz_biological_edit, editPageParams)
487
+ }}
488
+ >
489
+ <View
490
+ style={{
491
+ flex: 1,
492
+ flexDirection: 'column',
493
+ }}
494
+ >
495
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', marginTop: cx(16) }}>
496
+ <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
497
+ <Image
498
+ source={setImg(item?.iconId) || type && { uri: item?.icon } || item?.icon}
499
+ style={{
500
+ width: cx(24),
501
+ height: cx(24),
502
+ marginStart: cx(10),
503
+ marginRight: cx(6),
504
+ tintColor: '#474e5d',
505
+ }}
506
+ />
507
+ <Text
508
+ style={{
509
+ fontSize: cx(16),
510
+ color: '#000',
511
+ fontFamily: 'helvetica_neue_lt_std_roman',
512
+ }}
513
+ >
514
+ {convertMinutesTo12HourFormat(item.time, is24Hour)}
515
+ </Text>
516
+ </View>
517
+ <Switch
518
+ value={item.enable}
519
+ thumbColor={'#f60'}
520
+ trackColor={{ false: '#00000026', true: '#ff660036' }}
521
+ onValueChange={e => {
522
+ item.enable = e
523
+ requestSetBiorhythm()
524
+ }}
525
+ style={{ marginRight: cx(10) }}
526
+ />
527
+ </View>
528
+ <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between' }}>
529
+ <Text
530
+ style={{
531
+ fontSize: cx(12),
532
+ color: '#666',
533
+ fontFamily: 'helvetica_neue_lt_std_roman',
534
+ paddingLeft: cx(20),
535
+ }}
536
+ >
537
+ {setTimer(item?.name)}
538
+ </Text>
539
+ </View>
540
+ <View
541
+ style={{
542
+ width: cx(295),
543
+ height: cx(24),
544
+ backgroundColor: bgColor,
545
+ marginLeft: cx(20),
546
+ marginTop: cx(5),
547
+ marginBottom: cx(24),
548
+ borderRadius: cx(8),
549
+ }} />
550
+ </View>
551
+ </Card>
552
+ )
553
+ }}
554
+ keyExtractor={item => `${item.index}`}
555
+ ListFooterComponent={() => {
556
+ return (
557
+ <View style={{ marginHorizontal: cx(24) }}>
558
+ <Spacer />
559
+ <DeleteButton
560
+ text={I18n.getLang('bio_ryhthm_default_button_reset_text')}
561
+ textStyle={{
562
+ fontSize: cx(16),
563
+ color: '#fff',
564
+ fontFamily: 'helvetica_neue_lt_std_roman',
565
+ }}
566
+ onPress={() => {
567
+ showCommonDialog({
568
+ method: 'confirm',
569
+ title: I18n.getLang('bio_ryhthm_reset_description_text'),
570
+ onConfirm: (_, { close }) => {
571
+ const defBiorhythmUIState = getDefBiorhythmUIState()
572
+ state.enable = defBiorhythmUIState.enable
573
+ state.gradient = defBiorhythmUIState.gradient
574
+ state.repeatPeriod = defBiorhythmUIState.repeatPeriod
575
+ state.planList = defBiorhythmUIState.planList
576
+ requestSetBiorhythm()
577
+ close()
578
+ }
579
+ })
580
+ }}
581
+ />
582
+ <Spacer />
583
+ </View>
584
+ )
585
+ }}
586
+ />
587
+ {!state.enable && (
588
+ <View
589
+ style={{
590
+ backgroundColor: 'rgba(0,0,0,.5)',
591
+ width: '100%',
592
+ height: '100%',
593
+ position: 'absolute',
594
+ top: 0,
595
+ zIndex: 999,
596
+ }}
597
+ />
598
+ )}
599
+ </ScrollView>
600
+ </Page>
601
+ <Modal.List
602
+ type={'radio'}
603
+ visible={state.showGradientTypeSelectModal}
604
+ value={state.gradient}
605
+ dataSource={[
606
+ {
607
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value'),
608
+ key: BiorhythmGradientType.EntireGradient.toString(),
609
+ value: BiorhythmGradientType.EntireGradient,
610
+ },
611
+ {
612
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_value2'),
613
+ key: BiorhythmGradientType.DirectGradient.toString(),
614
+ value: BiorhythmGradientType.DirectGradient,
615
+ },
616
+ ]}
617
+ title={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
618
+ onMaskPress={() => {
619
+ showGradientTypeSelectModal(false)
620
+ }}
621
+ onCancel={() => {
622
+ showGradientTypeSelectModal(false)
623
+ }}
624
+ cancelText={I18n.getLang('auto_scan_system_cancel')}
625
+ confirmText={I18n.getLang('auto_scan_system_wifi_confirm')}
626
+ onConfirm={(item: BiorhythmGradientType) => {
627
+ state.gradient = item
628
+ requestSetBiorhythm()
629
+ showGradientTypeSelectModal(false)
630
+ }}
631
+ />
632
+ </>
633
+ )
634
+ }
635
+
636
+ export default BiorhythmPage
637
+
638
+