@ledvance/group-ui-biz-bundle 1.0.107 → 1.0.109

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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/group-ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.107",
7
+ "version": "1.0.109",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -1,14 +1,15 @@
1
1
  import React from 'react'
2
- import {SwitchButton, Utils} from "tuya-panel-kit";
2
+ import {Utils} from "tuya-panel-kit";
3
3
  import Page from "@ledvance/base/src/components/Page";
4
4
  import I18n from "@ledvance/base/src/i18n/index";
5
5
  import {useDeviceInfo, useFeatureHook} from "@ledvance/base/src/models/modules/NativePropsSlice";
6
6
  import {useReactive} from "ahooks";
7
- import Spacer from "@ledvance/base/src/components/Spacer";
8
7
  import {View, Text, StyleSheet, Image} from "react-native";
9
8
  import {Result} from "@ledvance/base/src/models/modules/Result";
10
9
  import res from "@ledvance/base/src/res";
11
10
  import ThemeType from '@ledvance/base/src/config/themeType'
11
+ import Card from "@ledvance/base/src/components/Card";
12
+ import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
12
13
 
13
14
  const { convertX: cx } = Utils.RatioUtils
14
15
  const { withTheme } = Utils.ThemeUtils
@@ -40,36 +41,6 @@ const ChildLockPage = (props: { theme?: ThemeType }) => {
40
41
  marginRight: cx(5),
41
42
  tintColor: props.theme?.global.fontColor
42
43
  },
43
- titleBGView: {
44
- flexDirection: 'row',
45
- alignItems: 'center',
46
- paddingHorizontal: cx(16),
47
- marginHorizontal: cx(24),
48
- },
49
- colorBlock: {
50
- width: cx(20),
51
- height: cx(20),
52
- marginStart: cx(12),
53
- borderRadius: cx(4),
54
- },
55
- title: {
56
- color: props.theme?.global.fontColor,
57
- fontSize: cx(14),
58
- fontFamily: 'helvetica_neue_lt_std_bd',
59
- paddingVertical: cx(16),
60
- },
61
- shadow: {
62
- shadowColor: props.theme?.card.shadowColor,
63
- shadowOpacity: 0.2,
64
- shadowRadius: 8,
65
- elevation:8,
66
- shadowOffset: {
67
- width: 0,
68
- height: 4,
69
- },
70
- backgroundColor: props.theme?.card.background,
71
- borderRadius: 8,
72
- },
73
44
  })
74
45
 
75
46
  return (<Page
@@ -82,18 +53,20 @@ const ChildLockPage = (props: { theme?: ThemeType }) => {
82
53
  {I18n.getLang('childlock_overview_description_text')}
83
54
  </Text>
84
55
  </View>
85
- <View style={[styles.titleBGView, styles.shadow]}>
86
- <Text style={styles.title}>{I18n.getLang('sockets_specific_settings_child_lock')}</Text>
87
- <View style={[styles.colorBlock, { backgroundColor: 'red', opacity: 0 }]} />
88
- <Spacer style={{ flex: 1 }} height={0} width={0} />
89
- <SwitchButton value={childLock} onValueChange={async v => {
90
- state.loading = true
91
- await setChildLock(v, undefined, {
92
- 'controlLock': v
93
- })
94
- state.loading = false
95
- } } />
96
- </View>
56
+ <Card style={{marginHorizontal: cx(24)}}>
57
+ <LdvSwitch
58
+ title={I18n.getLang('sockets_specific_settings_child_lock')}
59
+ colorAlpha={1}
60
+ enable={childLock}
61
+ setEnable={async (enable: boolean) => {
62
+ state.loading = true
63
+ await setChildLock(enable, undefined, {
64
+ 'controlLock': enable
65
+ })
66
+ state.loading = false
67
+ }}
68
+ />
69
+ </Card>
97
70
  </Page>)
98
71
  }
99
72
 
@@ -203,9 +203,9 @@ const DiySceneEditorPage = (props: { theme?: ThemeType }) => {
203
203
  state.sceneInfo.type !== 'DIY' && <TouchableOpacity onPress={() => {
204
204
  toggleLoveScene(state.sceneInfo.id)
205
205
  }}>
206
- {isLove ? <Image source={res.like} style={{width: cx(24), height: cx(24)}}/>
206
+ {isLove ? <Image source={res.like} style={{width: cx(30), height: cx(26)}}/>
207
207
  : <Image source={res.un_like}
208
- style={{width: cx(24), height: cx(24), tintColor: props.theme?.global.fontColor}}/>}
208
+ style={{width: cx(30), height: cx(26), tintColor: props.theme?.global.fontColor}}/>}
209
209
  </TouchableOpacity>
210
210
  }
211
211
  rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
@@ -7,12 +7,13 @@ import {
7
7
  } from "@ledvance/base/src/models/TuyaApi";
8
8
  import { overDays } from "@ledvance/base/src/utils";
9
9
  import { exportCsvFile, loopsText, monthFormat, monthFormatShort } from "@ledvance/base/src/utils/common";
10
- import { DateType } from "@ledvance/group-ui-biz-bundle/src/modules/energyConsumption/co2Data";
11
- import { OverviewItem } from "@ledvance/group-ui-biz-bundle/src/modules/energyConsumption/EnergyConsumptionPage";
10
+ import { DateType } from "./co2Data";
11
+ import { OverviewItem } from "./EnergyConsumptionPage";
12
12
  import dayjs from "dayjs";
13
13
  import { isNumber } from "lodash";
14
14
  import { EnergyData, UnitList } from "./component/EnergyModal";
15
15
  import I18n from "@ledvance/base/src/i18n";
16
+ import {NativeApi} from "@ledvance/base/src/api/native";
16
17
 
17
18
  interface LightConfig {
18
19
  energyConsumption?: EnergyData
@@ -177,4 +178,29 @@ export const exportEnergyCsv = (values: any[][], unit: string) => {
177
178
  const headers = [I18n.getLang('date'), `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`, `Price(${unit})`]
178
179
  const functionName = `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')}`
179
180
  exportCsvFile(headers, values, functionName)
180
- }
181
+ }
182
+
183
+ const EnergyGenerationId = 'EnergyGeneration'
184
+
185
+ export interface EnergyHistory {
186
+ time: number
187
+ generationMode: boolean
188
+ type: 'Consumption' | 'Generation'
189
+ value: number
190
+ }
191
+
192
+ export interface EnergyGeneration {
193
+ generationMode: boolean
194
+ totalElectricity: number
195
+ history: EnergyHistory[]
196
+ }
197
+
198
+ export async function getEnergyGenerationValue(devId: string): Promise<EnergyGeneration | undefined> {
199
+ const res = await NativeApi.getJson(devId, EnergyGenerationId)
200
+ if (res.success && res.data) {
201
+ return JSON.parse(res.data)
202
+ } else {
203
+ console.log('getEnergyGenerationValue failed', res)
204
+ return undefined
205
+ }
206
+ }
@@ -13,14 +13,14 @@ import { useReactive, useUpdateEffect } from 'ahooks';
13
13
  import { ui_biz_routerKey } from '../../navigation/Routers'
14
14
  import { DpResultByMonthResData, getDpResultByMonth } from '@ledvance/base/src/models/TuyaApi';
15
15
  import { useTimeZoneCity } from '@ledvance/base/src/models/modules/NativePropsSlice';
16
- import { flattenDeep, isNumber, sumBy } from 'lodash';
16
+ import {flattenDeep, isNumber, sum, sumBy} from 'lodash';
17
17
  import {
18
18
  exchangeNumber,
19
19
  localeNumber,
20
20
  monthFormat,
21
21
  monthFormatShort,
22
22
  } from '@ledvance/base/src/utils/common';
23
- import { unitDivision, useEnergyConsumption } from './EnergyConsumptionActions';
23
+ import {getEnergyGenerationValue, unitDivision, useEnergyConsumption} from './EnergyConsumptionActions';
24
24
  import EnergyPopup, { EnergyData } from './component/EnergyModal';
25
25
  import { carbonDioxideEmission, countryAndRegion } from './co2Data';
26
26
  import { EnergyConsumptionDetailProps } from './EnergyConsumptionDetail';
@@ -49,7 +49,7 @@ export interface OverviewItem {
49
49
  headlineText: string;
50
50
  chartTitle: string;
51
51
  }
52
- export type PopupType = 'co2' | 'money' | 'unit' | '';
52
+ export type PopupType = 'co2' | 'money' | 'unit' | ''
53
53
 
54
54
  interface EnergyConsumptionState {
55
55
  solarTodayElectricity: string
@@ -118,13 +118,23 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
118
118
  const solarPromise = params.solarPlugGroup.map(devId =>
119
119
  getDpResultByMonth(devId, params.addEleDpCode, 'sum').catch(error => ({ error }))
120
120
  );
121
+ const solarEnergyGenerationPromise = params.solarPlugGroup.map(devId =>
122
+ getEnergyGenerationValue(devId)
123
+ );
121
124
  const wifiPromise = params.wifiPlugGroup.map(devId =>
122
125
  getDpResultByMonth(devId, params.addEleDpCode, 'sum').catch(error => ({ error }))
123
126
  );
127
+ const wifiEnergyGenerationPromise = params.wifiPlugGroup.map(devId =>
128
+ getEnergyGenerationValue(devId)
129
+ );
124
130
  state.loading = true
125
131
  const solarRes = await Promise.all(solarPromise);
126
132
  const wifiRes = await Promise.all(wifiPromise)
133
+ const solarEnergyGenerationRes = await Promise.all(solarEnergyGenerationPromise);
134
+ const wifiEnergyGenerationRes = await Promise.all(wifiEnergyGenerationPromise);
127
135
  state.loading = false
136
+ const solarEnergy: number = sum(solarEnergyGenerationRes.map(item => item?.totalElectricity || 0))
137
+ const wifiEnergy: number = sum(wifiEnergyGenerationRes.map(item => item?.totalElectricity || 0))
128
138
  // @ts-ignore
129
139
  const solarGroup: DpResultByMonthResData[] = solarRes.filter(v => !v.error);
130
140
  // @ts-ignore
@@ -133,10 +143,10 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
133
143
  const solarData = getMergeData(solarGroup)
134
144
  const wifiData = getMergeData(wifiGroup)
135
145
  state.solarTodayElectricity = solarData.thisDay
136
- state.solarTotalElectricity = solarData.sum
146
+ state.solarTotalElectricity = Math.max(Number(solarData.sum) - solarEnergy, 0).toFixed(2)
137
147
  state.solarOverviewList = flattenDeep(solarData.overviewList)
138
148
  state.wifiTodayElectricity = wifiData.thisDay
139
- state.wifiTotalElectricity = wifiData.sum
149
+ state.wifiTotalElectricity = Math.max(Number(wifiData.sum) - wifiEnergy, 0).toFixed(2)
140
150
  state.wifiOverviewList = flattenDeep(wifiData.overviewList)
141
151
  };
142
152
 
@@ -458,19 +468,19 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
458
468
  <Spacer height={cx(30)} />
459
469
  {/* Annual overview */}
460
470
  <OverView
461
- style={{marginHorizontal: cx(24)}}
462
- headlineText={I18n.getLang('consumption_data_field4_headline_text')}
463
- headlineClick={() => {
464
- navigation.navigate(ui_biz_routerKey.group_ui_biz_energy_consumption_chart, {
465
- headlineText: chartHeadline,
466
- chartData: state.isSolarMode ? state.solarOverviewList : state.wifiOverviewList,
467
- price: state.price,
468
- unit: state.unit,
469
- addEleDpCode: params.addEleDpCode,
470
- date: (new Date()).getFullYear().toString(),
471
- deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
472
- } as EnergyConsumptionChartProps)
473
- }}
471
+ style={{marginHorizontal: cx(24)}}
472
+ headlineText={I18n.getLang('consumption_data_field4_headline_text')}
473
+ headlineClick={() => {
474
+ navigation.navigate(ui_biz_routerKey.group_ui_biz_energy_consumption_chart, {
475
+ headlineText: chartHeadline,
476
+ chartData: state.isSolarMode ? state.solarOverviewList : state.wifiOverviewList,
477
+ price: state.price,
478
+ unit: state.unit,
479
+ addEleDpCode: params.addEleDpCode,
480
+ date: (new Date()).getFullYear().toString(),
481
+ deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
482
+ } as EnergyConsumptionChartProps)
483
+ }}
474
484
  overviewItemClick={(item) => {
475
485
  navigation.navigate(ui_biz_routerKey.group_ui_biz_energy_consumption_detail, {
476
486
  addEleDpCode: params.addEleDpCode,
@@ -1,13 +1,15 @@
1
1
  import React from 'react'
2
- import {SwitchButton, Utils} from "tuya-panel-kit";
2
+ import {Utils} from "tuya-panel-kit";
3
3
  import Page from "@ledvance/base/src/components/Page";
4
4
  import I18n from "@ledvance/base/src/i18n/index";
5
5
  import {useDeviceInfo, useFeatureHook} from "@ledvance/base/src/models/modules/NativePropsSlice";
6
6
  import {useReactive} from "ahooks";
7
7
  import Spacer from "@ledvance/base/src/components/Spacer";
8
- import {StyleSheet, Text, View} from "react-native";
8
+ import {StyleSheet, Text} from "react-native";
9
9
  import {Result} from "@ledvance/base/src/models/modules/Result";
10
10
  import ThemeType from '@ledvance/base/src/config/themeType'
11
+ import Card from "@ledvance/base/src/components/Card";
12
+ import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
11
13
 
12
14
  const { convertX: cx } = Utils.RatioUtils
13
15
  const { withTheme } = Utils.ThemeUtils
@@ -28,55 +30,34 @@ const OverchargeSwitchPage = (props: { theme?: ThemeType }) => {
28
30
  })
29
31
 
30
32
  const styles = StyleSheet.create({
31
- titleBGView: {
32
- flexDirection: 'row',
33
- alignItems: 'center',
34
- paddingHorizontal: cx(16),
35
- marginHorizontal: cx(24),
36
- marginTop: cx(30)
37
- },
38
33
  title: {
39
34
  color: props.theme?.global.fontColor,
40
- fontSize: cx(14),
35
+ fontSize: cx(16),
36
+ fontWeight: 'bold',
41
37
  fontFamily: 'helvetica_neue_lt_std_bd',
42
- paddingVertical: cx(16),
43
- },
44
- desc: {
45
- color: props.theme?.global.fontColor,
46
- },
47
- shadow: {
48
- shadowColor: props.theme?.card.shadowColor,
49
- shadowOpacity: 0.2,
50
- shadowRadius: 8,
51
- elevation:8,
52
- shadowOffset: {
53
- width: 0,
54
- height: 4,
55
- },
56
- backgroundColor: props.theme?.card.background,
57
- borderRadius: 8,
38
+ paddingTop: cx(16),
39
+ paddingHorizontal: cx(16),
58
40
  },
59
41
  })
60
42
 
61
43
  return (<Page
62
44
  backText={devInfo.name}
63
45
  loading={state.loading}>
64
- <View style={[styles.titleBGView, styles.shadow]}>
65
- <View style={{ flex: 7 }}>
66
- <View>
67
- <Text style={styles.title}>{I18n.getLang('switch_overcharge_headline_text')}</Text>
68
- </View>
69
- <View style={{ paddingBottom: cx(16) }}>
70
- <Text style={styles.desc}>{I18n.getLang('switch_overcharge_headline_description')}</Text>
71
- </View>
72
- </View>
73
- <Spacer style={{ flex: 1 }} height={0} width={0} />
74
- <SwitchButton value={overchargeSwitch} onValueChange={async v => {
75
- state.loading = true
76
- await setOverchargeSwitch(v)
77
- state.loading = false
78
- } } />
79
- </View>
46
+ <Spacer height={cx(24)}/>
47
+ <Card style={{marginHorizontal: cx(24)}}>
48
+ <Text style={styles.title}>{I18n.getLang('switch_overcharge_headline_text')}</Text>
49
+ <LdvSwitch
50
+ title={I18n.getLang('switch_overcharge_headline_description')}
51
+ titleStyle={{fontWeight: 'normal', fontSize: cx(14)}}
52
+ colorAlpha={1}
53
+ enable={overchargeSwitch}
54
+ setEnable={async (v) => {
55
+ state.loading = true
56
+ await setOverchargeSwitch(v)
57
+ state.loading = false
58
+ }}
59
+ />
60
+ </Card>
80
61
  </Page>)
81
62
  }
82
63