@ledvance/ui-biz-bundle 1.1.55 → 1.1.57

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 (70) hide show
  1. package/package.json +2 -1
  2. package/src/modules/biorhythm/Router.ts +34 -0
  3. package/src/modules/fixedTime/Router.ts +26 -0
  4. package/src/modules/flags/FlagActions.ts +12 -4
  5. package/src/modules/flags/FlagPage.tsx +31 -11
  6. package/src/modules/flags/Router.ts +25 -0
  7. package/src/modules/history/Router.ts +16 -0
  8. package/src/modules/mood/FantasyRouter.ts +35 -0
  9. package/src/modules/mood/MixMood/Router.ts +44 -0
  10. package/src/modules/mood/Router.ts +53 -0
  11. package/src/modules/music/Router.ts +16 -0
  12. package/src/modules/powerOnBehavior/Router.ts +16 -0
  13. package/src/modules/randomTime/Router.ts +25 -0
  14. package/src/modules/sleepWakeup/Router.ts +25 -0
  15. package/src/modules/timeSchedule/Router.ts +25 -0
  16. package/src/modules/timer/Router.ts +16 -0
  17. package/src/navigation/Routers.d.ts +0 -7
  18. package/src/navigation/Routers.ts +15 -304
  19. package/src/newModules/childLock/ChildLockPage.tsx +97 -0
  20. package/src/newModules/childLock/Router.ts +16 -0
  21. package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
  22. package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
  23. package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
  24. package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
  25. package/src/newModules/energyConsumption/Router.ts +34 -0
  26. package/src/newModules/energyConsumption/co2Data.ts +23655 -0
  27. package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
  28. package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
  29. package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
  30. package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
  31. package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
  32. package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
  33. package/src/newModules/fixedTime/Router.ts +25 -0
  34. package/src/newModules/lightMode/LightModePage.tsx +204 -0
  35. package/src/newModules/lightMode/Router.ts +16 -0
  36. package/src/newModules/mood/AddMoodPage.tsx +178 -0
  37. package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
  38. package/src/newModules/mood/Interface.ts +219 -0
  39. package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
  40. package/src/newModules/mood/MoodActions.ts +235 -0
  41. package/src/newModules/mood/MoodInfo.ts +2151 -0
  42. package/src/newModules/mood/MoodItem.tsx +148 -0
  43. package/src/newModules/mood/MoodPage.tsx +385 -0
  44. package/src/newModules/mood/MoodParse.ts +442 -0
  45. package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
  46. package/src/newModules/mood/Router.ts +53 -0
  47. package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
  48. package/src/newModules/mood/tools.ts +12 -0
  49. package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
  50. package/src/newModules/overchargeSwitch/Router.ts +16 -0
  51. package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
  52. package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
  53. package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
  54. package/src/newModules/powerOnBehavior/Router.ts +16 -0
  55. package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
  56. package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
  57. package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
  58. package/src/newModules/randomTime/Router.ts +25 -0
  59. package/src/newModules/randomTime/Summary.tsx +116 -0
  60. package/src/newModules/swithInching/Router.ts +16 -0
  61. package/src/newModules/swithInching/SwithInching.tsx +231 -0
  62. package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
  63. package/src/newModules/swithInching/pickerView.tsx +91 -0
  64. package/src/newModules/timeSchedule/Interface.ts +111 -0
  65. package/src/newModules/timeSchedule/Router.ts +25 -0
  66. package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
  67. package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
  68. package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
  69. package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
  70. package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
@@ -0,0 +1,321 @@
1
+ import React, {useEffect} from "react";
2
+ import {Image, ScrollView, StyleSheet, Text, TouchableOpacity, View} from "react-native";
3
+ import {useNavigation, useRoute} from '@react-navigation/core'
4
+ import Page from "@ledvance/base/src/components/Page";
5
+ import res from "@ledvance/base/src/res";
6
+ import I18n from "@ledvance/base/src/i18n";
7
+ import {Utils} from "tuya-panel-kit";
8
+ import Spacer from "@ledvance/base/src/components/Spacer";
9
+ import Card from "@ledvance/base/src/components/Card";
10
+ import OverView from "./component/Overview";
11
+ import {useReactive, useUpdateEffect} from "ahooks";
12
+ import {getDataWithSpecified, getDpResultByHour} from "@ledvance/base/src/models/TuyaApi";
13
+ import {useDeviceId, useEngergyGeneration, useTimeZoneCity} from "@ledvance/base/src/models/modules/NativePropsSlice";
14
+ import {cloneDeep, isEmpty} from "lodash";
15
+ import {OverviewItem, PopupType} from "./EnergyConsumptionPage";
16
+ import {exchangeNumber, localeNumber, loopsText} from '@ledvance/base/src/utils/common'
17
+ import dayjs from "dayjs";
18
+ import {ui_biz_routerKey} from "../../navigation/Routers";
19
+ import {EnergyConsumptionChartProps} from "./EnergyConsumptionChart";
20
+ import {overDays} from "@ledvance/base/src/utils";
21
+ import EnergyPopup, {EnergyData} from "./component/EnergyModal";
22
+ import {carbonDioxideEmission, countryAndRegion} from "./co2Data";
23
+
24
+ const { convertX: cx } = Utils.RatioUtils
25
+
26
+ export interface EnergyConsumptionDetailProps {
27
+ addEleDpCode: string
28
+ curMonth: OverviewItem
29
+ price: string
30
+ unit: string
31
+ updateEnergyData: (data: EnergyData) => {}
32
+ }
33
+
34
+ const EnergyConsumptionDetail = () => {
35
+ const props = useRoute().params as EnergyConsumptionDetailProps
36
+ const devId = useDeviceId()
37
+ const isSolarPlug = useEngergyGeneration()
38
+ const navigation = useNavigation()
39
+ const timeZoneCity = useTimeZoneCity()
40
+ const state = useReactive({
41
+ todayElectricity: '0',
42
+ totalElectricity: '0',
43
+ co2Saved: '0',
44
+ price: '',
45
+ unit: '',
46
+ overviewList: [] as OverviewItem[],
47
+ loading: false,
48
+ over365Days: false,
49
+ over7Days: false,
50
+ showPopup: false,
51
+ popupType: '' as PopupType,
52
+ })
53
+
54
+ useEffect(() => {
55
+ state.price = props.price
56
+ state.unit = props.unit
57
+ getElectricity().then()
58
+ }, [])
59
+
60
+ useUpdateEffect(() =>{
61
+ if(Number(state.totalElectricity) > 0 && timeZoneCity){
62
+ const letOut = carbonDioxideEmission(timeZoneCity, countryAndRegion) || 0
63
+ state.co2Saved = localeNumber((letOut * Number(state.totalElectricity)) / 1000, 4)
64
+ }
65
+ }, [state.totalElectricity, timeZoneCity])
66
+
67
+ const getElectricity = async () => {
68
+ const startDay = props.curMonth.headlineText + '01'
69
+ const endDay = props.curMonth.headlineText + dayjs(props.curMonth.headlineText + '01').daysInMonth()
70
+ state.over365Days = overDays(startDay, 365)
71
+ if (state.over365Days) {
72
+ state.overviewList = []
73
+ return
74
+ }
75
+ const res = await getDataWithSpecified(devId, props.addEleDpCode, startDay, endDay, 'sum')
76
+ if (!isEmpty(res) && res.result) {
77
+ const dayList = res.result
78
+ const dayData = Object.keys(dayList).filter(v => Number(dayList[v]) > 0).map(time => {
79
+ // 提取年、月和日
80
+ const year = time.slice(0, 4);
81
+ const month = time.slice(4, 6);
82
+ const day = time.slice(6, 8);
83
+
84
+ // 格式化为 'YYYY/MM/DD' 格式
85
+ const formattedDate = `${year}/${month}/${day}`
86
+ const dateStr = `${day}/${month}/${year}`
87
+ const dateObj = dayjs(formattedDate, "YYYY/MM/DD");
88
+ const dayOfWeek = dateObj.day() % 7;
89
+ const key = `${dateStr} (${loopsText[dayOfWeek]})`
90
+ return {
91
+ key,
92
+ value: dayList[time],
93
+ headlineText: formattedDate,
94
+ chartTitle: `${Number(key?.split('/')[0])}\n${loopsText[dayOfWeek]}`
95
+ }
96
+ })
97
+
98
+ state.overviewList = cloneDeep(dayData).reverse()
99
+ }
100
+ }
101
+
102
+ const getHourList = async (item: OverviewItem) => {
103
+ const value = item?.key?.split(' ')[0]?.split('/')
104
+ const date = `${value[2]}${value[1]}${value[0]}`
105
+ state.over7Days = overDays(date, 7)
106
+ if (state.over7Days) {
107
+ return []
108
+ }
109
+ const res = await getDpResultByHour(devId, props.addEleDpCode, date, 'sum')
110
+ const list: Array<object> = []
111
+ const resData = Object.keys(res)?.map(val => {
112
+ return { key: Number(val?.slice(8, 10)), value: Number(res[val]) }
113
+ })
114
+ for (let i = 0; i <= 23; i++) {
115
+ const hourData = resData?.find(val => val?.key === i)
116
+ const hourKey = hourData?.key || i
117
+ const hourValue = Number(hourData?.value) || 0
118
+ list.push({
119
+ key: `${hourKey.toString().padStart(2, '0')}:00`, value: hourValue, chartTitle: `${hourKey}:00`
120
+ })
121
+ }
122
+ return list
123
+ }
124
+
125
+ return (
126
+ <Page
127
+ backText={I18n.getLang('consumption_data_annual_bar_chart_system_back_text')}
128
+ headlineText={props.curMonth.key}
129
+ headlineIcon={res.download_icon}
130
+ onHeadlineIconClick={() => { }}
131
+ showGreenery={false}
132
+ greeneryIcon={res.energy_consumption_greenery}
133
+ loading={state.loading}
134
+ >
135
+ <ScrollView nestedScrollEnabled={true}>
136
+ <View>
137
+ <Spacer height={cx(15)} />
138
+ {/* 365 day */}
139
+ <Card
140
+ style={styles.cardContainer}
141
+ >
142
+ <Text style={styles.cardTitle}>{props.curMonth.key}</Text>
143
+ <Spacer height={cx(15)} />
144
+ <View style={{ flexDirection: 'row', alignItems: 'flex-end' }}>
145
+ <Text style={[styles.consumptionNum, { fontSize: cx(38), marginRight: cx(8) }]}>{props.curMonth.value}</Text>
146
+ <Text style={[styles.consumptionNum, { fontSize: cx(22), marginBottom: cx(4) }]}>kWh</Text>
147
+ </View>
148
+ <Spacer />
149
+ {/* CO2 */}
150
+ {isSolarPlug && <>
151
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
152
+ <View style={styles.priceBg}>
153
+ <Image
154
+ source={res.energy_consumption_cash}
155
+ resizeMode="contain"
156
+ style={{ height: cx(20), width: cx(20), tintColor: '#FF6600' }}
157
+ />
158
+ </View>
159
+ <View style={styles.priceNum}>
160
+ <View style={{ flexDirection: 'row' }}>
161
+ <Text style={{ color: '#666', marginRight: cx(5) }}>{I18n.getLang('consumption_data_field3_co2_topic_text')}</Text>
162
+ <TouchableOpacity
163
+ onPress={() => {
164
+ state.showPopup = true
165
+ state.popupType = 'co2'
166
+ }}
167
+ >
168
+ <Image
169
+ source={res.co2Icon}
170
+ resizeMode="contain"
171
+ style={{ height: cx(20), width: cx(20), tintColor: '#FF6600' }}
172
+ />
173
+ </TouchableOpacity>
174
+ </View>
175
+ <Text style={{ color: '#000', fontWeight: 'bold' }}>{`${state.co2Saved} kg`}</Text>
176
+ </View>
177
+ </View>
178
+ <Spacer height={cx(10)} />
179
+ </>}
180
+ {/* money */}
181
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
182
+ <View style={styles.priceBg}>
183
+ <Image
184
+ source={res.energy_consumption_cash}
185
+ resizeMode="contain"
186
+ style={{ height: cx(20), width: cx(20), tintColor: '#FF6600' }}
187
+ />
188
+ </View>
189
+ <View>
190
+ <View style={styles.priceNum}>
191
+ <Text style={{ color: '#666' }}>{I18n.getLang('consumption_data_field3_value_text2')}</Text>
192
+ <Text style={{ color: '#000', fontWeight: 'bold' }}>{state.price ? `${localeNumber(Number(state.price ) * Number(props.curMonth.value), 2)} ${state.unit}` : '-'}</Text>
193
+ </View>
194
+ <TouchableOpacity onPress={() => {
195
+ state.showPopup = true
196
+ state.popupType = 'money'
197
+ }}>
198
+ <View style={styles.priceButton}>
199
+ <Text style={{ color: '#fff' }}>{I18n.getLang('consumption_data_field3_button_text')}</Text>
200
+ </View>
201
+ </TouchableOpacity>
202
+ </View>
203
+ </View>
204
+ </Card>
205
+ <Spacer height={cx(30)} />
206
+ {/* Annual overview */}
207
+ <OverView
208
+ style={{ marginHorizontal: cx(24) }}
209
+ headlineText={I18n.getLang('consumption_data_monthly_overview_field2_headline_text')}
210
+ headlineClick={() => {
211
+ navigation.navigate(ui_biz_routerKey.ui_biz_energy_consumption_chart, {
212
+ headlineText: props.curMonth.key,
213
+ chartData: state.overviewList,
214
+ over365Days: state.over365Days
215
+ } as EnergyConsumptionChartProps)
216
+ }}
217
+ overviewItemClick={async (item) =>{
218
+ state.loading = true
219
+ const res = await getHourList(item)
220
+ state.loading = false
221
+ navigation.navigate(ui_biz_routerKey.ui_biz_energy_consumption_chart, {
222
+ headlineText: item.key,
223
+ chartData: res,
224
+ over7Days: state.over7Days
225
+ } as EnergyConsumptionChartProps)
226
+ }}
227
+ overViewList={state.overviewList}
228
+ />
229
+ {/* modal */}
230
+ <EnergyPopup
231
+ visible={(!!state.popupType && state.showPopup)}
232
+ popupType={state.popupType || 'co2'}
233
+ title={state.popupType === 'co2' ? I18n.getLang('consumption_data_field3_co2_topic_text') : ''}
234
+ cancelText={state.popupType === 'co2' ? '' : I18n.getLang("auto_scan_system_cancel")}
235
+ confirmText={I18n.getLang(state.popupType === 'co2' ? 'home_screen_home_dialog_yes_con' : 'auto_scan_system_wifi_confirm')}
236
+ energyData={{ price: state.price, unit: state.unit }}
237
+ onConfirm={(energyData) => {
238
+ state.popupType = ''
239
+ state.showPopup = false
240
+ if(energyData){
241
+ props.updateEnergyData({
242
+ ...energyData,
243
+ price: exchangeNumber(energyData.price)
244
+ })
245
+ state.price = energyData.price
246
+ state.unit = energyData.unit
247
+ }
248
+ }}
249
+ onCancel={() => {
250
+ state.popupType = ''
251
+ state.showPopup = false
252
+ }}
253
+ />
254
+ </View>
255
+ </ScrollView>
256
+ </Page>
257
+ )
258
+ }
259
+
260
+ const styles = StyleSheet.create({
261
+ showTip: {
262
+ marginHorizontal: cx(24)
263
+ },
264
+ cardContainer: {
265
+ flex: 1,
266
+ marginHorizontal: cx(24),
267
+ padding: cx(16)
268
+ },
269
+ cardTitle: {
270
+ color: '#000',
271
+ fontSize: cx(16),
272
+ fontWeight: 'bold'
273
+ },
274
+ consumedEnergyContent: {
275
+ flex: 1,
276
+ flexDirection: 'row',
277
+ },
278
+ consumptionNum: {
279
+ color: '#FF8555',
280
+ fontFamily: 'helvetica_neue_lt_std_bd',
281
+ },
282
+ subContent: {
283
+ flex: 1,
284
+ alignItems: 'center',
285
+ marginBottom: cx(9)
286
+ },
287
+ valueText: {
288
+ fontSize: cx(24),
289
+ fontWeight: 'bold',
290
+ color: '#ff8555',
291
+ },
292
+ titleText: {
293
+ fontFamily: 'helvetica_neue_lt_std_roman',
294
+ fontSize: cx(14),
295
+ color: '#666666',
296
+ textAlign: 'center',
297
+ },
298
+ priceBg: {
299
+ height: cx(40),
300
+ width: cx(40),
301
+ borderRadius: cx(40),
302
+ backgroundColor: '#FFE0D4',
303
+ justifyContent: 'center',
304
+ alignItems: 'center',
305
+ marginRight: cx(10)
306
+ },
307
+ priceNum: {
308
+ marginRight: cx(10)
309
+ },
310
+ priceButton: {
311
+ borderRadius: cx(5),
312
+ paddingHorizontal: cx(10),
313
+ paddingVertical: cx(8),
314
+ marginTop: cx(8),
315
+ backgroundColor: '#FF6600',
316
+ alignItems: 'center',
317
+ justifyContent: 'center'
318
+ }
319
+ })
320
+
321
+ export default EnergyConsumptionDetail