@ledvance/group-ui-biz-bundle 1.0.37 → 1.0.39

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