@ledvance/group-ui-biz-bundle 1.0.140 → 1.0.142

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 (22) hide show
  1. package/package.json +1 -1
  2. package/src/modules/biorhythm/IconSelect.tsx +92 -29
  3. package/src/modules/energyConsumption/EnergyConsumptionActions.ts +42 -16
  4. package/src/modules/energyConsumption/EnergyConsumptionCard.tsx +3 -3
  5. package/src/modules/energyConsumption/EnergyConsumptionChart/ChartSection.tsx +103 -15
  6. package/src/modules/energyConsumption/EnergyConsumptionChart/LandscapeView.tsx +1 -0
  7. package/src/modules/energyConsumption/EnergyConsumptionChart/PortraitView.tsx +3 -27
  8. package/src/modules/energyConsumption/EnergyConsumptionChart/styles.ts +13 -4
  9. package/src/modules/energyConsumption/EnergyConsumptionChart/useEnergyData.ts +28 -12
  10. package/src/modules/energyConsumption/EnergyConsumptionChart.tsx +4 -0
  11. package/src/modules/energyConsumption/EnergyConsumptionDetail.tsx +41 -31
  12. package/src/modules/energyConsumption/EnergyConsumptionPage.tsx +52 -3
  13. package/src/modules/energyConsumption/component/DateSelectedItem.tsx +1 -1
  14. package/src/modules/energyConsumption/component/DateSwitch.tsx +10 -8
  15. package/src/modules/energyConsumption/component/DateTypeItem.tsx +1 -1
  16. package/src/modules/energyConsumption/component/EnergyModal.tsx +2 -2
  17. package/src/modules/energyConsumption/component/NewBarChart.tsx +221 -153
  18. package/src/modules/energyConsumption/component/Overview.tsx +1 -1
  19. package/src/modules/flags/FlagInfo.tsx +1204 -1054
  20. package/src/modules/flags/FlagItem.tsx +1 -2
  21. package/src/modules/flags/FlagPage.tsx +19 -15
  22. package/src/modules/mood_new/MoodItem.tsx +0 -1
@@ -22,7 +22,7 @@ import EnergyPopup, { EnergyData } from "./component/EnergyModal";
22
22
  import { carbonDioxideEmission, countryAndRegion } from "./co2Data";
23
23
  import ThemeType from '@ledvance/base/src/config/themeType'
24
24
  import { exportEnergyCsv } from "./EnergyConsumptionActions";
25
-
25
+ import { EnergyDisplayMode } from './EnergyConsumptionChart/useEnergyData'
26
26
  const { convertX: cx } = Utils.RatioUtils
27
27
  const { withTheme } = Utils.ThemeUtils
28
28
 
@@ -33,6 +33,9 @@ export interface EnergyConsumptionDetailProps {
33
33
  price: string
34
34
  unit: string
35
35
  deviceIdGroup: string[];
36
+ displayMode?: EnergyDisplayMode;
37
+ consumptionDeviceIds: string[];
38
+ generationDeviceIds: string[];
36
39
  isSolarMode: boolean
37
40
  updateEnergyData: (data: EnergyData) => {}
38
41
  }
@@ -171,7 +174,7 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
171
174
  },
172
175
  consumptionNum: {
173
176
  color: props.theme?.global.secondBrand,
174
- fontFamily: 'helvetica_neue_lt_std_bd',
177
+ // fontFamily: 'helvetica_neue_lt_std_bd',
175
178
  },
176
179
  subContent: {
177
180
  flex: 1,
@@ -184,7 +187,7 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
184
187
  color: props.theme?.global.secondBrand,
185
188
  },
186
189
  titleText: {
187
- fontFamily: 'helvetica_neue_lt_std_roman',
190
+ // fontFamily: 'helvetica_neue_lt_std_roman',
188
191
  fontSize: cx(14),
189
192
  color: props.theme?.global.secondFontColor,
190
193
  textAlign: 'center',
@@ -218,8 +221,9 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
218
221
  headlineText={params.curMonth.key}
219
222
  headlineIcon={state.overviewList.length ? res.download_icon : undefined}
220
223
  onHeadlineIconClick={() => {
224
+ const headers = [I18n.getLang('date'), `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`, `Price(${params.unit})`]
221
225
  const values = state.overviewList.map(item => [item.key, item.value, (Number(params.price) * Number(item.value)).toFixed(2)])
222
- exportEnergyCsv(values, params.unit)
226
+ exportEnergyCsv(headers, values)
223
227
  }}
224
228
  showGreenery={false}
225
229
  greeneryIcon={res.energy_consumption_greenery}
@@ -241,34 +245,34 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
241
245
  <Spacer />
242
246
  {/* CO2 */}
243
247
  {params.isSolarMode && <>
244
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
245
- <View style={styles.priceBg}>
246
- <Image
247
- source={{ uri: res.energy_consumption_cash}}
248
- resizeMode="contain"
249
- style={{ height: cx(20), width: cx(20), tintColor: props.theme?.button.primary }}
250
- />
248
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
249
+ <View style={styles.priceBg}>
250
+ <Image
251
+ source={{ uri: res.energy_consumption_cash}}
252
+ resizeMode="contain"
253
+ style={{ height: cx(20), width: cx(20), tintColor: props.theme?.button.primary }}
254
+ />
255
+ </View>
256
+ <View style={styles.priceNum}>
257
+ <View style={{ flexDirection: 'row' }}>
258
+ <Text style={{ color: props.theme?.global.secondFontColor, marginRight: cx(5) }}>{I18n.getLang('consumption_data_field3_co2_topic_text')}</Text>
259
+ <TouchableOpacity
260
+ onPress={() => {
261
+ state.showPopup = true
262
+ state.popupType = 'co2'
263
+ }}
264
+ >
265
+ <Image
266
+ source={{ uri: res.co2_icon}}
267
+ resizeMode="contain"
268
+ style={{ height: cx(20), width: cx(20), tintColor: props.theme?.button.primary }}
269
+ />
270
+ </TouchableOpacity>
271
+ </View>
272
+ <Text style={{ color: props.theme?.global.fontColor, fontWeight: 'bold' }}>{`${state.co2Saved} kg`}</Text>
273
+ </View>
251
274
  </View>
252
- <View style={styles.priceNum}>
253
- <View style={{ flexDirection: 'row' }}>
254
- <Text style={{ color: props.theme?.global.secondFontColor, marginRight: cx(5) }}>{I18n.getLang('consumption_data_field3_co2_topic_text')}</Text>
255
- <TouchableOpacity
256
- onPress={() => {
257
- state.showPopup = true
258
- state.popupType = 'co2'
259
- }}
260
- >
261
- <Image
262
- source={{ uri: res.co2_icon}}
263
- resizeMode="contain"
264
- style={{ height: cx(20), width: cx(20), tintColor: props.theme?.button.primary }}
265
- />
266
- </TouchableOpacity>
267
- </View>
268
- <Text style={{ color: props.theme?.global.fontColor, fontWeight: 'bold' }}>{`${state.co2Saved} kg`}</Text>
269
- </View>
270
- </View>
271
- <Spacer height={cx(10)} />
275
+ <Spacer height={cx(10)} />
272
276
  </>}
273
277
  {/* money */}
274
278
  <View style={{ flexDirection: 'row', alignItems: 'center' }}>
@@ -311,6 +315,9 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
311
315
  addEleDpCode: params.addEleDpCode,
312
316
  date: params.curMonth.headlineText,
313
317
  deviceIdGroup: params.deviceIdGroup,
318
+ displayMode: params.displayMode,
319
+ consumptionDeviceIds: params.consumptionDeviceIds,
320
+ generationDeviceIds: params.generationDeviceIds,
314
321
  } as EnergyConsumptionChartProps)
315
322
  }}
316
323
  overviewItemClick={async (item) => {
@@ -327,6 +334,9 @@ const EnergyConsumptionDetail = (props: { theme?: ThemeType }) => {
327
334
  unit: state.unit,
328
335
  date: item.headlineText,
329
336
  deviceIdGroup: params.deviceIdGroup,
337
+ displayMode: params.displayMode,
338
+ consumptionDeviceIds: params.consumptionDeviceIds,
339
+ generationDeviceIds: params.generationDeviceIds,
330
340
  } as EnergyConsumptionChartProps)
331
341
  }}
332
342
  overViewList={state.overviewList}
@@ -1,3 +1,10 @@
1
+ import {
2
+ ChartSection
3
+ } from '@ledvance/group-ui-biz-bundle/src/modules/energyConsumption/EnergyConsumptionChart/ChartSection'
4
+ import { getStyles } from '@ledvance/group-ui-biz-bundle/src/modules/energyConsumption/EnergyConsumptionChart/styles'
5
+ import {
6
+ useEnergyData
7
+ } from '@ledvance/group-ui-biz-bundle/src/modules/energyConsumption/EnergyConsumptionChart/useEnergyData'
1
8
  import React, { useEffect, useMemo } from 'react';
2
9
  import { ScrollView, StyleSheet, View, Text, Image, TouchableOpacity } from 'react-native';
3
10
  import { useNavigation } from '@react-navigation/core';
@@ -103,6 +110,25 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
103
110
  : '';
104
111
  }, [state.solarOverviewList, state.wifiOverviewList, state.isSolarMode]);
105
112
 
113
+ const chartParams = useMemo(() => {
114
+ return {
115
+ backTitle,
116
+ headlineText: chartHeadline,
117
+ chartData: [],
118
+ price: state.price,
119
+ unit: state.unit,
120
+ addEleDpCode: params.addEleDpCode,
121
+ date: (new Date()).getFullYear().toString(),
122
+ deviceIdGroup: [],
123
+ displayMode: state.isSolarMode ? 'generation' : 'consumption',
124
+ consumptionDeviceIds: params.wifiPlugGroup,
125
+ generationDeviceIds: params.solarPlugGroup,
126
+ }
127
+ }, [backTitle, chartHeadline, state.price, state.unit, params.addEleDpCode, state.isSolarMode, params.wifiPlugGroup, params.solarPlugGroup])
128
+
129
+ const { state: chartState, actions } = useEnergyData(chartParams);
130
+ const chartStyles = useMemo(() => getStyles(props.theme), [props.theme]);
131
+
106
132
  useEffect(() => {
107
133
  getElectricity().then();
108
134
  }, []);
@@ -203,6 +229,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
203
229
  setEnergyData(data).then()
204
230
  state.price = data.price;
205
231
  state.unit = data.unit;
232
+ actions.setPriceAndUnit(data.price, data.unit)
206
233
  };
207
234
 
208
235
  const backTitle = useMemo(() => {
@@ -229,7 +256,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
229
256
  },
230
257
  consumptionNum: {
231
258
  color: props.theme?.global.secondBrand,
232
- fontFamily: 'helvetica_neue_lt_std_bd',
259
+ // fontFamily: 'helvetica_neue_lt_std_bd',
233
260
  },
234
261
  subContent: {
235
262
  flex: 1,
@@ -242,7 +269,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
242
269
  color: props.theme?.global.secondBrand,
243
270
  },
244
271
  titleText: {
245
- fontFamily: 'helvetica_neue_lt_std_roman',
272
+ // fontFamily: 'helvetica_neue_lt_std_roman',
246
273
  fontSize: cx(14),
247
274
  color: props.theme?.global.secondFontColor,
248
275
  textAlign: 'center',
@@ -299,8 +326,9 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
299
326
  )}
300
327
  headlineIcon={(state.isSolarMode ? state.solarOverviewList : state.wifiOverviewList).length ? res.download_icon : undefined}
301
328
  onHeadlineIconClick={() => {
329
+ const headers = [I18n.getLang('date'), `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`, `Price(${state.unit})`]
302
330
  const values = (state.isSolarMode ? state.solarOverviewList : state.wifiOverviewList).map(item => [item.key, item.value, (Number(state.price) * Number(item.value)).toFixed(2)])
303
- exportEnergyCsv(values, state.unit)
331
+ exportEnergyCsv(headers, values)
304
332
  }}
305
333
  showGreenery={state.isSolarMode}
306
334
  greeneryIcon={res.energy_consumption_greenery}
@@ -314,6 +342,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
314
342
  tabStyle={{paddingHorizontal: cx(15)}}
315
343
  setIsFirst={(v) => {
316
344
  state.isSolarMode = !v
345
+ actions.setDisplayMode(!v ? 'generation' : 'consumption')
317
346
  }} />
318
347
  </View> : undefined
319
348
  }
@@ -345,6 +374,9 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
345
374
  addEleDpCode: params.addEleDpCode,
346
375
  date: (new Date()).getFullYear().toString(),
347
376
  deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
377
+ displayMode: (params.wifiPlugGroup.length && params.solarPlugGroup.length) ? 'both' : (params.wifiPlugGroup.length ? 'consumption' : 'generation'),
378
+ consumptionDeviceIds: params.wifiPlugGroup,
379
+ generationDeviceIds: params.solarPlugGroup,
348
380
  } as EnergyConsumptionChartProps)
349
381
  }}
350
382
  >
@@ -487,6 +519,17 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
487
519
  </View>
488
520
  </Card>
489
521
  <Spacer height={cx(30)} />
522
+ <View style={{ marginHorizontal: cx(24) }}>
523
+ <ChartSection
524
+ state={chartState}
525
+ actions={actions}
526
+ params={chartParams}
527
+ styles={chartStyles}
528
+ theme={props.theme}
529
+ chartHeight={cx(400)}
530
+ />
531
+ </View>
532
+ <Spacer height={cx(30)} />
490
533
  {/* Annual overview */}
491
534
  <OverView
492
535
  style={{marginHorizontal: cx(24)}}
@@ -501,6 +544,9 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
501
544
  addEleDpCode: params.addEleDpCode,
502
545
  date: (new Date()).getFullYear().toString(),
503
546
  deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
547
+ displayMode: (params.wifiPlugGroup.length && params.solarPlugGroup.length) ? 'both' : (params.wifiPlugGroup.length ? 'consumption' : 'generation'),
548
+ consumptionDeviceIds: params.wifiPlugGroup,
549
+ generationDeviceIds: params.solarPlugGroup,
504
550
  } as EnergyConsumptionChartProps)
505
551
  }}
506
552
  overviewItemClick={(item) => {
@@ -512,6 +558,9 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
512
558
  unit: state.unit,
513
559
  isSolarMode: state.isSolarMode,
514
560
  deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
561
+ displayMode: (params.wifiPlugGroup.length && params.solarPlugGroup.length) ? 'both' : (params.wifiPlugGroup.length ? 'consumption' : 'generation'),
562
+ consumptionDeviceIds: params.wifiPlugGroup,
563
+ generationDeviceIds: params.solarPlugGroup,
515
564
  updateEnergyData
516
565
  } as EnergyConsumptionDetailProps)
517
566
  }}
@@ -68,7 +68,7 @@ export default withTheme(function DateSelectedItem(props: DateSelectedItemProps)
68
68
  textAlign: 'center',
69
69
  flex: 1,
70
70
  color: props.theme?.textInput.fontColor,
71
- fontFamily: 'helvetica_neue_lt_std_roman',
71
+ // fontFamily: 'helvetica_neue_lt_std_roman',
72
72
  },
73
73
  modalRoot: {paddingTop: cx(20), backgroundColor: theme?.popup.cellBg},
74
74
  modalButtonParent: {flex: 1, height: cx(48)},
@@ -1,11 +1,12 @@
1
1
  import ThemeType from "@ledvance/base/src/config/themeType";
2
2
  import React, {PropsWithChildren, useCallback, useEffect} from "react";
3
- import {Image, Text, TouchableOpacity, View, ViewProps} from "react-native";
3
+ import {Image, TouchableOpacity, View, ViewProps} from "react-native";
4
4
  import {Utils} from "tuya-panel-kit";
5
5
  import {useReactive} from "ahooks";
6
6
  import res from "@ledvance/base/src/res";
7
7
  import dayjs from "dayjs";
8
8
  import {DateType} from "../co2Data";
9
+ import DateSelectedItem from './DateSelectedItem'
9
10
 
10
11
  const cx = Utils.RatioUtils.convertX;
11
12
  const {withTheme} = Utils.ThemeUtils
@@ -89,13 +90,14 @@ export default withTheme(function DateSwitch(props: DateSwitchProps) {
89
90
  height={cx(36)}
90
91
  width={cx(36)}/>
91
92
  </TouchableOpacity>
92
- <Text style={{
93
- fontSize: cx(24),
94
- minWidth: cx(200),
95
- textAlign: 'center',
96
- color: theme?.global.brand,
97
- fontFamily: 'helvetica_neue_lt_std_roman',
98
- }}>{state.headlineText}</Text>
93
+ <DateSelectedItem
94
+ style={{flex: 1}}
95
+ dateType={state.dateType}
96
+ date={state.date}
97
+ onDateChange={date => {
98
+ props.onDateChange(date)
99
+ }}
100
+ />
99
101
  <TouchableOpacity
100
102
  disabled={state.disableArrowRight}
101
103
  onPress={() => {
@@ -61,7 +61,7 @@ export default withTheme(function DateTypeItem(props: DateTypeItemProps) {
61
61
  textAlign: 'center',
62
62
  flex: 1,
63
63
  color: props.theme?.textInput.fontColor,
64
- fontFamily: 'helvetica_neue_lt_std_roman',
64
+ // fontFamily: 'helvetica_neue_lt_std_roman',
65
65
  }}>{state.dateTypeTitle}</Text>
66
66
  </View>
67
67
  </TouchableOpacity>
@@ -114,7 +114,7 @@ const EnergyModal = (props: EnergyModalProps) => {
114
114
  marginEnd: cx(6),
115
115
  fontSize: cx(16),
116
116
  color: props.theme?.textInput.fontColor,
117
- fontFamily: 'helvetica_neue_lt_std_roman',
117
+ // fontFamily: 'helvetica_neue_lt_std_roman',
118
118
  },
119
119
  textInputGroup: {
120
120
  flexDirection: 'row',
@@ -156,7 +156,7 @@ const EnergyModal = (props: EnergyModalProps) => {
156
156
  <View style={{ flexDirection: 'row', alignItems: 'center' }}>
157
157
  <View style={{ flex: 3 }}>
158
158
  <Spacer height={cx(4)} />
159
- <Text style={{ color: props.theme?.global.secondFontColor, marginStart: cx(13), fontFamily: 'helvetica_neue_lt_std_bd' }}>{I18n.getLang('consumption_data_price_per_kwh_headline_text')}</Text>
159
+ <Text style={{ color: props.theme?.global.secondFontColor, marginStart: cx(13) }}>{I18n.getLang('consumption_data_price_per_kwh_headline_text')}</Text>
160
160
  <View style={styles.textInputGroup}>
161
161
  <TextInput
162
162
  value={state.energyData?.price}