@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,326 +1,326 @@
1
- import React, { useEffect, useMemo } from "react";
2
- import { ScrollView, StyleSheet, View, Text, Image, TouchableOpacity } from "react-native";
3
- import { useReactive } from "ahooks";
4
- import Page from "@ledvance/base/src/components/Page";
5
- import { useNavigation, useRoute } from '@react-navigation/core'
6
- import I18n from "@ledvance/base/src/i18n";
7
- import res from "@ledvance/base/src/res";
8
- import TextField from "@ledvance/base/src/components/TextField";
9
- import LdvWeekView from '@ledvance/base/src/components/weekSelect'
10
- import { TimerPicker, Utils } from "tuya-panel-kit";
11
- import DeleteButton from "@ledvance/base/src/components/DeleteButton";
12
- import Spacer from "@ledvance/base/src/components/Spacer";
13
- import { convertMinutesTo12HourFormat, loopText, showDialog } from "@ledvance/base/src/utils/common";
14
- import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
15
- import Card from "@ledvance/base/src/components/Card";
16
- import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
17
- import { RandomTimerUiItem } from "./RandomTimeActions";
18
- import { cloneDeep, isEqual } from "lodash";
19
- import Summary from "./Summary";
20
- import { RandomTimePageParams } from "./RandomTimePage";
21
- import { Result } from "@ledvance/base/src/models/modules/Result";
22
- import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
23
-
24
- const { convertX: cx } = Utils.RatioUtils;
25
-
26
- export interface RandomTimeDetailPageParams extends RandomTimePageParams {
27
- mode: 'add' | 'edit'
28
- scheduleItem: RandomTimerUiItem
29
- onPost: (mode: 'add' | 'edit' | 'del', randomTime: RandomTimerUiItem) => Promise<Result<any>>
30
- }
31
- const minTimeGap = 30
32
- const RandomTimeDetailPage = () => {
33
- const navigation = useNavigation()
34
- const params = useRoute().params as RandomTimeDetailPageParams
35
- const is24Hour = useSystemTimeFormate()
36
- const state = useReactive({
37
- loading: false,
38
- isColorMode: false,
39
- randomTime: cloneDeep(params.scheduleItem)
40
- })
41
-
42
- useEffect(() => {
43
- if (!params.isPlug && state.randomTime.color) {
44
- const { brightness, temperature, h, s, v } = state.randomTime.color
45
- const isColor = brightness === 0 && temperature === 0 && (h !== 0 || s !== 0 || v !== 0)
46
- state.isColorMode = isColor
47
- }
48
- }, [])
49
-
50
- const checkItemChanged = useMemo(() =>{
51
- return isEqual(state.randomTime, params.scheduleItem)
52
- }, [params.scheduleItem, JSON.stringify(state.randomTime)])
53
-
54
- const canSubmit = useMemo(() => {
55
- return state.randomTime.name?.length > 0 && state.randomTime.name?.length < 33 && !checkItemChanged && state.randomTime.channel !== undefined
56
- }, [JSON.stringify(state.randomTime), checkItemChanged])
57
-
58
- return (
59
- <Page
60
- backText={I18n.getLang('randomtimecycle_sockets_headline_text')}
61
- rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
62
- loading={state.loading}
63
- showBackDialog={!checkItemChanged}
64
- backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
65
- backDialogContent={I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description')}
66
- headlineText={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')}
67
- rightButtonIconClick={async () => {
68
- if (!canSubmit || state.loading) return
69
- const { startTime, endTime} = state.randomTime
70
- if(startTime < endTime && (endTime - startTime) < minTimeGap){
71
- return showDialog({
72
- method: 'alert',
73
- title: I18n.getLang('conflict_dialog_save_item_randomtimecycle_tips'),
74
- subTitle: I18n.getLang('conflict_dialog_save_item_randomtimecycle_interval_description'),
75
- confirmText: I18n.getLang('conflict_dialog_save_item_randomtimecycle_answer_confirm_text'),
76
- onConfirm: (_, { close}) =>{
77
- close()
78
- }
79
- })
80
- }
81
- state.loading = true
82
- const editRandomTime = {
83
- ...state.randomTime,
84
- enable: true
85
- }
86
- if (!params.isPlug && state.randomTime.color) {
87
- editRandomTime.color = {
88
- h: state.isColorMode ? state.randomTime.color?.h : 0,
89
- s: state.isColorMode ? state.randomTime.color?.s : 0,
90
- v: state.isColorMode ? state.randomTime.color?.v : 0,
91
- temperature: state.isColorMode ? 0 : state.randomTime.color?.temperature,
92
- brightness: state.isColorMode ? 0 : state.randomTime.color?.brightness
93
- }
94
- }
95
- const res = await params.onPost(params.mode, editRandomTime)
96
- state.loading = false
97
- if (res.success) {
98
- navigation.goBack()
99
- }
100
- }}
101
- >
102
- <ScrollView nestedScrollEnabled={true}>
103
- <TextField
104
- style={styles.cardContainer}
105
- value={state.randomTime.name}
106
- showError={state.randomTime.name?.length > 32}
107
- maxLength={33}
108
- errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
109
- placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
110
- onChangeText={(t: string) => {
111
- state.randomTime.name = t;
112
- }}
113
- />
114
- {/* pick */}
115
- <TimerPicker
116
- itemTextColor='#aeadb5'
117
- style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
118
- is12Hours={!is24Hour}
119
- startTime={state.randomTime.startTime}
120
- endTime={state.randomTime.endTime}
121
- onTimerChange={(startTime, endTime) => {
122
- state.randomTime.startTime = startTime
123
- state.randomTime.endTime = endTime
124
- }} />
125
- <LdvWeekView
126
- value={state.randomTime.weeks}
127
- style={styles.cardContainer}
128
- onSelect={(index: number) => {
129
- const rawIndex = index - 1
130
- state.randomTime.weeks[rawIndex] = state.randomTime.weeks[rawIndex] === 1 ? 0 : 1
131
- }} />
132
- <Spacer />
133
- <Text style={styles.cardContainer}>{loopText(state.randomTime.weeks)}</Text>
134
- <Spacer />
135
- {/* Apply for */}
136
- <View style={styles.cardContainer}>
137
- <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
138
- <Spacer height={cx(10)} />
139
- <View style={[styles.applyContent, { paddingTop: state.randomTime.channel === undefined ? 0 : cx(10) }]}>
140
- {state.randomTime.channel === undefined ?
141
- <Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
142
- <View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}>
143
- <Text style={{ color: '#000', fontSize: cx(12) }}>{params.applyForList[state.randomTime.channel]?.key}</Text>
144
- {params.applyForList.length > 1 && <TouchableOpacity
145
- onPress={() => {
146
- state.randomTime.channel = undefined
147
- }}
148
- style={{ paddingHorizontal: cx(5) }}>
149
- <Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
150
- </TouchableOpacity>}
151
- </View>
152
- }
153
- </View>
154
- {params.applyForList.map((item, index) => {
155
- if (state.randomTime.channel === index) return null
156
- return (
157
- <TouchableOpacity
158
- style={styles.applyItem}
159
- key={item.key}
160
- onPress={() => {
161
- state.randomTime.channel = index
162
- }}>
163
- <Text style={{ color: '#000', fontSize: cx(12) }}>{item.key}</Text>
164
- <Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
165
- </TouchableOpacity>
166
- )
167
- })}
168
- </View>
169
- <Spacer />
170
- {/* Devices */}
171
- {!!state.randomTime.color && !params.isPlug && <View style={styles.cardContainer}>
172
- <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
173
- <Spacer height={cx(10)} />
174
- <Card>
175
- <LdvSwitch
176
- title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
177
- color={'#fff'}
178
- colorAlpha={1}
179
- enable={true}
180
- setEnable={() => { }}
181
- showSwitch={false}
182
- />
183
- <LampAdjustView
184
- isSupportColor={!!params.isSupportColor}
185
- isSupportBrightness={!!params.isSupportBrightness}
186
- isSupportTemperature={!!params.isSupportTemperature}
187
- isColorMode={state.isColorMode}
188
- reserveSV={true}
189
- setIsColorMode={(v) => state.isColorMode = v}
190
- h={state.randomTime.color.h}
191
- s={state.randomTime.color.s}
192
- v={state.randomTime.color.v}
193
- colorTemp={state.randomTime.color.temperature}
194
- brightness={state.randomTime.color.brightness}
195
- onHSVChangeComplete={(h, s, v) => {
196
- state.randomTime.color = {
197
- ...state.randomTime.color,
198
- h,
199
- s,
200
- v
201
- }
202
- }}
203
- onCCTChangeComplete={(v) => {
204
- state.randomTime.color = {
205
- ...state.randomTime.color,
206
- temperature: v
207
- }
208
- }}
209
- onBrightnessChangeComplete={(v) => {
210
- state.randomTime.color = {
211
- ...state.randomTime.color,
212
- brightness: v
213
- }
214
- }}
215
- />
216
- </Card>
217
- <Spacer />
218
- </View>}
219
- {/* summary */}
220
- <Summary
221
- frequency={loopText(state.randomTime.weeks)}
222
- time={`${convertMinutesTo12HourFormat(state.randomTime.startTime, is24Hour)} - ${convertMinutesTo12HourFormat(state.randomTime.endTime, is24Hour)}`}
223
- hideActions={true}
224
- />
225
- <Spacer />
226
- {params.mode === 'edit' &&
227
- <View style={{ marginHorizontal: cx(24) }}>
228
- <DeleteButton
229
- text={I18n.getLang('edit_fixedtimecycle_bttn_text')}
230
- onPress={() => {
231
- showDialog({
232
- method: 'confirm',
233
- title: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_titel'),
234
- subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
235
- onConfirm: async (_, { close }) => {
236
- close()
237
- state.loading = true
238
- const res = await params.onPost('del', state.randomTime)
239
- state.loading = false
240
- if (res.success) {
241
- navigation.goBack()
242
- }
243
- }
244
- })
245
- }} />
246
- </View>
247
- }
248
- <Spacer />
249
- </ScrollView>
250
- </Page>
251
- )
252
- }
253
-
254
-
255
- const styles = StyleSheet.create({
256
- cardContainer: {
257
- marginHorizontal: cx(24)
258
- },
259
- itemTitle: {
260
- color: '#000',
261
- fontSize: cx(16),
262
- fontWeight: 'bold',
263
- fontFamily: 'helvetica_neue_lt_std_bd',
264
- },
265
- applyContent: {
266
- backgroundColor: '#f6f6f6',
267
- borderRadius: 4,
268
- minHeight: cx(55),
269
- flex: 1,
270
- justifyContent: 'center',
271
- paddingHorizontal: cx(10),
272
- paddingTop: cx(10)
273
- },
274
- applyItem: {
275
- paddingLeft: cx(5),
276
- flexDirection: 'row',
277
- justifyContent: 'space-between',
278
- alignItems: 'center',
279
- backgroundColor: '#fff',
280
- height: cx(35),
281
- },
282
- summaryContainer: {
283
- flexDirection: 'row',
284
- justifyContent: 'flex-start',
285
- marginBottom: cx(10)
286
- },
287
- summaryLeft: {
288
- flexDirection: 'row',
289
- justifyContent: 'flex-start',
290
- alignItems: 'center',
291
- },
292
- summaryImg: {
293
- width: cx(12),
294
- height: cx(12),
295
- marginRight: cx(6)
296
- },
297
- leftTitle: {
298
- fontSize: cx(14),
299
- color: '#000'
300
- },
301
- summaryRight: {
302
- flexDirection: 'column',
303
- marginLeft: cx(21),
304
- borderRadius: cx(16),
305
- backgroundColor: '#cbcbcb',
306
- },
307
- rightItem: {
308
- paddingHorizontal: cx(12),
309
- color: '#000',
310
- },
311
- rightTitle: {
312
- paddingLeft: cx(12),
313
- paddingRight: cx(12),
314
- fontSize: cx(10),
315
- textAlign: 'center',
316
- alignSelf: 'flex-start'
317
- },
318
- filletCorner: {
319
- flexDirection: 'row',
320
- backgroundColor: '#cbcbcb',
321
- borderRadius: cx(16),
322
- alignSelf: 'flex-start'
323
- }
324
- })
325
-
1
+ import React, { useEffect, useMemo } from "react";
2
+ import { ScrollView, StyleSheet, View, Text, Image, TouchableOpacity } from "react-native";
3
+ import { useReactive } from "ahooks";
4
+ import Page from "@ledvance/base/src/components/Page";
5
+ import { useNavigation, useRoute } from '@react-navigation/core'
6
+ import I18n from "@ledvance/base/src/i18n";
7
+ import res from "@ledvance/base/src/res";
8
+ import TextField from "@ledvance/base/src/components/TextField";
9
+ import LdvWeekView from '@ledvance/base/src/components/weekSelect'
10
+ import { TimerPicker, Utils } from "tuya-panel-kit";
11
+ import DeleteButton from "@ledvance/base/src/components/DeleteButton";
12
+ import Spacer from "@ledvance/base/src/components/Spacer";
13
+ import { convertMinutesTo12HourFormat, loopText, showDialog } from "@ledvance/base/src/utils/common";
14
+ import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
15
+ import Card from "@ledvance/base/src/components/Card";
16
+ import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
17
+ import { RandomTimerUiItem } from "./RandomTimeActions";
18
+ import { cloneDeep, isEqual } from "lodash";
19
+ import Summary from "./Summary";
20
+ import { RandomTimePageParams } from "./RandomTimePage";
21
+ import { Result } from "@ledvance/base/src/models/modules/Result";
22
+ import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
23
+
24
+ const { convertX: cx } = Utils.RatioUtils;
25
+
26
+ export interface RandomTimeDetailPageParams extends RandomTimePageParams {
27
+ mode: 'add' | 'edit'
28
+ scheduleItem: RandomTimerUiItem
29
+ onPost: (mode: 'add' | 'edit' | 'del', randomTime: RandomTimerUiItem) => Promise<Result<any>>
30
+ }
31
+ const minTimeGap = 30
32
+ const RandomTimeDetailPage = () => {
33
+ const navigation = useNavigation()
34
+ const params = useRoute().params as RandomTimeDetailPageParams
35
+ const is24Hour = useSystemTimeFormate()
36
+ const state = useReactive({
37
+ loading: false,
38
+ isColorMode: false,
39
+ randomTime: cloneDeep(params.scheduleItem)
40
+ })
41
+
42
+ useEffect(() => {
43
+ if (!params.isPlug && state.randomTime.color) {
44
+ const { brightness, temperature, h, s, v } = state.randomTime.color
45
+ const isColor = brightness === 0 && temperature === 0 && (h !== 0 || s !== 0 || v !== 0)
46
+ state.isColorMode = isColor
47
+ }
48
+ }, [])
49
+
50
+ const checkItemChanged = useMemo(() =>{
51
+ return isEqual(state.randomTime, params.scheduleItem)
52
+ }, [params.scheduleItem, JSON.stringify(state.randomTime)])
53
+
54
+ const canSubmit = useMemo(() => {
55
+ return state.randomTime.name?.length > 0 && state.randomTime.name?.length < 33 && !checkItemChanged && state.randomTime.channel !== undefined
56
+ }, [JSON.stringify(state.randomTime), checkItemChanged])
57
+
58
+ return (
59
+ <Page
60
+ backText={I18n.getLang('randomtimecycle_sockets_headline_text')}
61
+ rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
62
+ loading={state.loading}
63
+ showBackDialog={!checkItemChanged}
64
+ backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
65
+ backDialogContent={I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description')}
66
+ headlineText={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')}
67
+ rightButtonIconClick={async () => {
68
+ if (!canSubmit || state.loading) return
69
+ const { startTime, endTime} = state.randomTime
70
+ if(startTime < endTime && (endTime - startTime) < minTimeGap){
71
+ return showDialog({
72
+ method: 'alert',
73
+ title: I18n.getLang('conflict_dialog_save_item_randomtimecycle_tips'),
74
+ subTitle: I18n.getLang('conflict_dialog_save_item_randomtimecycle_interval_description'),
75
+ confirmText: I18n.getLang('conflict_dialog_save_item_randomtimecycle_answer_confirm_text'),
76
+ onConfirm: (_, { close}) =>{
77
+ close()
78
+ }
79
+ })
80
+ }
81
+ state.loading = true
82
+ const editRandomTime = {
83
+ ...state.randomTime,
84
+ enable: true
85
+ }
86
+ if (!params.isPlug && state.randomTime.color) {
87
+ editRandomTime.color = {
88
+ h: state.isColorMode ? state.randomTime.color?.h : 0,
89
+ s: state.isColorMode ? state.randomTime.color?.s : 0,
90
+ v: state.isColorMode ? state.randomTime.color?.v : 0,
91
+ temperature: state.isColorMode ? 0 : state.randomTime.color?.temperature,
92
+ brightness: state.isColorMode ? 0 : state.randomTime.color?.brightness
93
+ }
94
+ }
95
+ const res = await params.onPost(params.mode, editRandomTime)
96
+ state.loading = false
97
+ if (res.success) {
98
+ navigation.goBack()
99
+ }
100
+ }}
101
+ >
102
+ <ScrollView nestedScrollEnabled={true}>
103
+ <TextField
104
+ style={styles.cardContainer}
105
+ value={state.randomTime.name}
106
+ showError={state.randomTime.name?.length > 32}
107
+ maxLength={33}
108
+ errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
109
+ placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
110
+ onChangeText={(t: string) => {
111
+ state.randomTime.name = t;
112
+ }}
113
+ />
114
+ {/* pick */}
115
+ <TimerPicker
116
+ itemTextColor='#aeadb5'
117
+ style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
118
+ is12Hours={!is24Hour}
119
+ startTime={state.randomTime.startTime}
120
+ endTime={state.randomTime.endTime}
121
+ onTimerChange={(startTime, endTime) => {
122
+ state.randomTime.startTime = startTime
123
+ state.randomTime.endTime = endTime
124
+ }} />
125
+ <LdvWeekView
126
+ value={state.randomTime.weeks}
127
+ style={styles.cardContainer}
128
+ onSelect={(index: number) => {
129
+ const rawIndex = index - 1
130
+ state.randomTime.weeks[rawIndex] = state.randomTime.weeks[rawIndex] === 1 ? 0 : 1
131
+ }} />
132
+ <Spacer />
133
+ <Text style={styles.cardContainer}>{loopText(state.randomTime.weeks)}</Text>
134
+ <Spacer />
135
+ {/* Apply for */}
136
+ <View style={styles.cardContainer}>
137
+ <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
138
+ <Spacer height={cx(10)} />
139
+ <View style={[styles.applyContent, { paddingTop: state.randomTime.channel === undefined ? 0 : cx(10) }]}>
140
+ {state.randomTime.channel === undefined ?
141
+ <Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
142
+ <View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}>
143
+ <Text style={{ color: '#000', fontSize: cx(12) }}>{params.applyForList[state.randomTime.channel]?.key}</Text>
144
+ {params.applyForList.length > 1 && <TouchableOpacity
145
+ onPress={() => {
146
+ state.randomTime.channel = undefined
147
+ }}
148
+ style={{ paddingHorizontal: cx(5) }}>
149
+ <Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
150
+ </TouchableOpacity>}
151
+ </View>
152
+ }
153
+ </View>
154
+ {params.applyForList.map((item, index) => {
155
+ if (state.randomTime.channel === index) return null
156
+ return (
157
+ <TouchableOpacity
158
+ style={styles.applyItem}
159
+ key={item.key}
160
+ onPress={() => {
161
+ state.randomTime.channel = index
162
+ }}>
163
+ <Text style={{ color: '#000', fontSize: cx(12) }}>{item.key}</Text>
164
+ <Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
165
+ </TouchableOpacity>
166
+ )
167
+ })}
168
+ </View>
169
+ <Spacer />
170
+ {/* Devices */}
171
+ {!!state.randomTime.color && !params.isPlug && <View style={styles.cardContainer}>
172
+ <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
173
+ <Spacer height={cx(10)} />
174
+ <Card>
175
+ <LdvSwitch
176
+ title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
177
+ color={'#fff'}
178
+ colorAlpha={1}
179
+ enable={true}
180
+ setEnable={() => { }}
181
+ showSwitch={false}
182
+ />
183
+ <LampAdjustView
184
+ isSupportColor={!!params.isSupportColor}
185
+ isSupportBrightness={!!params.isSupportBrightness}
186
+ isSupportTemperature={!!params.isSupportTemperature}
187
+ isColorMode={state.isColorMode}
188
+ reserveSV={true}
189
+ setIsColorMode={(v) => state.isColorMode = v}
190
+ h={state.randomTime.color.h}
191
+ s={state.randomTime.color.s}
192
+ v={state.randomTime.color.v}
193
+ colorTemp={state.randomTime.color.temperature}
194
+ brightness={state.randomTime.color.brightness}
195
+ onHSVChangeComplete={(h, s, v) => {
196
+ state.randomTime.color = {
197
+ ...state.randomTime.color,
198
+ h,
199
+ s,
200
+ v
201
+ }
202
+ }}
203
+ onCCTChangeComplete={(v) => {
204
+ state.randomTime.color = {
205
+ ...state.randomTime.color,
206
+ temperature: v
207
+ }
208
+ }}
209
+ onBrightnessChangeComplete={(v) => {
210
+ state.randomTime.color = {
211
+ ...state.randomTime.color,
212
+ brightness: v
213
+ }
214
+ }}
215
+ />
216
+ </Card>
217
+ <Spacer />
218
+ </View>}
219
+ {/* summary */}
220
+ <Summary
221
+ frequency={loopText(state.randomTime.weeks)}
222
+ time={`${convertMinutesTo12HourFormat(state.randomTime.startTime, is24Hour)} - ${convertMinutesTo12HourFormat(state.randomTime.endTime, is24Hour)}`}
223
+ hideActions={true}
224
+ />
225
+ <Spacer />
226
+ {params.mode === 'edit' &&
227
+ <View style={{ marginHorizontal: cx(24) }}>
228
+ <DeleteButton
229
+ text={I18n.getLang('edit_fixedtimecycle_bttn_text')}
230
+ onPress={() => {
231
+ showDialog({
232
+ method: 'confirm',
233
+ title: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_titel'),
234
+ subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
235
+ onConfirm: async (_, { close }) => {
236
+ close()
237
+ state.loading = true
238
+ const res = await params.onPost('del', state.randomTime)
239
+ state.loading = false
240
+ if (res.success) {
241
+ navigation.goBack()
242
+ }
243
+ }
244
+ })
245
+ }} />
246
+ </View>
247
+ }
248
+ <Spacer />
249
+ </ScrollView>
250
+ </Page>
251
+ )
252
+ }
253
+
254
+
255
+ const styles = StyleSheet.create({
256
+ cardContainer: {
257
+ marginHorizontal: cx(24)
258
+ },
259
+ itemTitle: {
260
+ color: '#000',
261
+ fontSize: cx(16),
262
+ fontWeight: 'bold',
263
+ fontFamily: 'helvetica_neue_lt_std_bd',
264
+ },
265
+ applyContent: {
266
+ backgroundColor: '#f6f6f6',
267
+ borderRadius: 4,
268
+ minHeight: cx(55),
269
+ flex: 1,
270
+ justifyContent: 'center',
271
+ paddingHorizontal: cx(10),
272
+ paddingTop: cx(10)
273
+ },
274
+ applyItem: {
275
+ paddingLeft: cx(5),
276
+ flexDirection: 'row',
277
+ justifyContent: 'space-between',
278
+ alignItems: 'center',
279
+ backgroundColor: '#fff',
280
+ height: cx(35),
281
+ },
282
+ summaryContainer: {
283
+ flexDirection: 'row',
284
+ justifyContent: 'flex-start',
285
+ marginBottom: cx(10)
286
+ },
287
+ summaryLeft: {
288
+ flexDirection: 'row',
289
+ justifyContent: 'flex-start',
290
+ alignItems: 'center',
291
+ },
292
+ summaryImg: {
293
+ width: cx(12),
294
+ height: cx(12),
295
+ marginRight: cx(6)
296
+ },
297
+ leftTitle: {
298
+ fontSize: cx(14),
299
+ color: '#000'
300
+ },
301
+ summaryRight: {
302
+ flexDirection: 'column',
303
+ marginLeft: cx(21),
304
+ borderRadius: cx(16),
305
+ backgroundColor: '#cbcbcb',
306
+ },
307
+ rightItem: {
308
+ paddingHorizontal: cx(12),
309
+ color: '#000',
310
+ },
311
+ rightTitle: {
312
+ paddingLeft: cx(12),
313
+ paddingRight: cx(12),
314
+ fontSize: cx(10),
315
+ textAlign: 'center',
316
+ alignSelf: 'flex-start'
317
+ },
318
+ filletCorner: {
319
+ flexDirection: 'row',
320
+ backgroundColor: '#cbcbcb',
321
+ borderRadius: cx(16),
322
+ alignSelf: 'flex-start'
323
+ }
324
+ })
325
+
326
326
  export default RandomTimeDetailPage