@ledvance/group-ui-biz-bundle 1.0.131 → 1.0.133
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 +1 -1
- package/src/modules/energyConsumption/EnergyConsumptionCard.tsx +249 -0
- package/src/modules/energyConsumption/EnergyConsumptionChart.tsx +1 -1
- package/src/modules/energyConsumption/EnergyConsumptionPage.tsx +14 -1
- package/src/modules/energyConsumption/component/NewBarChart.tsx +170 -168
- package/src/modules/energyConsumption/res/energy-chart.png +0 -0
- package/src/modules/energyConsumption/res/index.ts +3 -0
- package/src/modules/fixedTimeForPlug/FixedTimeForPlugDetailPage.tsx +1 -1
- package/src/modules/fixedTimingForLight/FixedTimingForLightDetailPage.tsx +1 -1
- package/src/modules/sleepWakeUp/SleepWakeUpDetailPage.tsx +1 -1
- package/src/modules/switchInching/SwitchInching.tsx +1 -1
- package/src/modules/timer/TimerPage.tsx +1 -1
- package/tsconfig.json +71 -46
package/package.json
CHANGED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { DeviceInfo, NativeApi, queryDpIds } from '@ledvance/base/src/api/native'
|
|
2
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
3
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
4
|
+
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
5
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
6
|
+
import { useGroupDevices, useUAGroupInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
7
|
+
import { xLog } from '@ledvance/base/src/utils'
|
|
8
|
+
import { localeNumber } from '@ledvance/base/src/utils/common'
|
|
9
|
+
import { useIsFocused, useNavigation } from '@react-navigation/native'
|
|
10
|
+
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
11
|
+
import React, { useEffect, useMemo, useRef } from 'react'
|
|
12
|
+
import { Image, StyleSheet, Text, View } from 'react-native'
|
|
13
|
+
import { Utils } from 'tuya-panel-kit'
|
|
14
|
+
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
15
|
+
import { getEnergyGenerationValue, } from './EnergyConsumptionActions'
|
|
16
|
+
import { EnergyConsumptionPageProps } from './EnergyConsumptionPage'
|
|
17
|
+
import Res from './res'
|
|
18
|
+
|
|
19
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
20
|
+
const { withTheme } = Utils.ThemeUtils
|
|
21
|
+
|
|
22
|
+
export interface EnergyConsumptionProp {
|
|
23
|
+
theme?: ThemeType
|
|
24
|
+
electricDpCode: string
|
|
25
|
+
powerDpCode: string
|
|
26
|
+
addEleDpCode: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SolarPlugPid = 'rcqe1i17x0vrvws7'
|
|
30
|
+
|
|
31
|
+
const EnergyConsumptionCard = (props: EnergyConsumptionProp) => {
|
|
32
|
+
const navigation = useNavigation()
|
|
33
|
+
const isFocused = useIsFocused()
|
|
34
|
+
const uaGroupInfo = useUAGroupInfo()
|
|
35
|
+
const [groupDevices] = useGroupDevices()
|
|
36
|
+
const updateEnergy: any = useRef()
|
|
37
|
+
|
|
38
|
+
const state = useReactive({
|
|
39
|
+
solarPowerSum: 0,
|
|
40
|
+
solarCurrentSum: 0,
|
|
41
|
+
wifiPowerSum: 0,
|
|
42
|
+
wifiCurrentSum: 0,
|
|
43
|
+
totalPowerSum: 0,
|
|
44
|
+
totalCurrentSum: 0,
|
|
45
|
+
loading: false,
|
|
46
|
+
generationCache: {}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (groupDevices && groupDevices.length) {
|
|
51
|
+
getEnergyConsumption(groupDevices).then()
|
|
52
|
+
}
|
|
53
|
+
}, [groupDevices])
|
|
54
|
+
|
|
55
|
+
const isOnlyGeneration = useMemo(() => groupDevices.every(device => state.generationCache[device.tuyaDeviceId]), [groupDevices, JSON.stringify(state.generationCache)])
|
|
56
|
+
const hasGeneration = useMemo(() => groupDevices.some(device => state.generationCache[device.tuyaDeviceId]), [groupDevices, JSON.stringify(state.generationCache)])
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (isFocused) {
|
|
60
|
+
updateEnergy.current = setInterval(() => {
|
|
61
|
+
xLog('setInterval========')
|
|
62
|
+
groupDevices.forEach(item => {
|
|
63
|
+
const jsonData = JSON.stringify([props.electricDpCode, props.powerDpCode])
|
|
64
|
+
queryDpIds(jsonData, item.tuyaDeviceId).then()
|
|
65
|
+
})
|
|
66
|
+
NativeApi.getGroupDevices(uaGroupInfo.tyGroupId).then(res => {
|
|
67
|
+
if (res.success && res.data) {
|
|
68
|
+
getEnergyConsumption(res.data).then()
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}, 10000)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return () => clearInterval(updateEnergy.current)
|
|
75
|
+
}, [isFocused, groupDevices.length])
|
|
76
|
+
|
|
77
|
+
const isGenerationFromCache = async (tyPid: string, deviceId: string) => {
|
|
78
|
+
const cache = state.generationCache[deviceId]
|
|
79
|
+
if (cache !== undefined) {
|
|
80
|
+
return cache
|
|
81
|
+
}
|
|
82
|
+
const data = await getEnergyGenerationValue(deviceId)
|
|
83
|
+
const generationMode = data?.generationMode || false
|
|
84
|
+
const isGeneration = (tyPid === SolarPlugPid) !== generationMode
|
|
85
|
+
state.generationCache[deviceId] = isGeneration
|
|
86
|
+
return isGeneration
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const getEnergyConsumption = async (groupDevices: DeviceInfo[]) => {
|
|
90
|
+
let power = 0
|
|
91
|
+
let current = 0
|
|
92
|
+
let solarPower = 0
|
|
93
|
+
let solarCurrent = 0
|
|
94
|
+
const powerDp = props.powerDpCode
|
|
95
|
+
const currentDp = props.electricDpCode
|
|
96
|
+
|
|
97
|
+
for (const device of groupDevices) {
|
|
98
|
+
if (device.dps) {
|
|
99
|
+
const isSolarDevice = await isGenerationFromCache(device.tyPid, device.tuyaDeviceId)
|
|
100
|
+
const dps = JSON.parse(device.dps)
|
|
101
|
+
if (isSolarDevice) {
|
|
102
|
+
solarPower += dps[powerDp] ?? 0
|
|
103
|
+
solarCurrent += dps[currentDp] ?? 0
|
|
104
|
+
} else {
|
|
105
|
+
power += dps[powerDp] ?? 0
|
|
106
|
+
current += dps[currentDp] ?? 0
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
state.wifiCurrentSum = current
|
|
111
|
+
state.wifiPowerSum = power / 10
|
|
112
|
+
state.solarCurrentSum = solarCurrent
|
|
113
|
+
state.solarPowerSum = solarPower / 10
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
useUpdateEffect(() => {
|
|
117
|
+
if (hasGeneration) {
|
|
118
|
+
if (isOnlyGeneration) {
|
|
119
|
+
state.totalCurrentSum = state.solarCurrentSum
|
|
120
|
+
state.totalPowerSum = state.solarPowerSum
|
|
121
|
+
} else {
|
|
122
|
+
state.totalCurrentSum = state.wifiCurrentSum - state.solarCurrentSum
|
|
123
|
+
state.totalPowerSum = state.wifiPowerSum - state.solarPowerSum
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
state.totalCurrentSum = state.wifiCurrentSum
|
|
127
|
+
state.totalPowerSum = state.wifiPowerSum
|
|
128
|
+
}
|
|
129
|
+
}, [state.solarCurrentSum, state.solarPowerSum, state.wifiCurrentSum, state.wifiPowerSum, isOnlyGeneration, hasGeneration])
|
|
130
|
+
|
|
131
|
+
const energyText = useMemo(() => {
|
|
132
|
+
return I18n.getLang(isOnlyGeneration ? 'sockets_headline_power' : !hasGeneration ? 'sockets_ce' : 'group_energytotal')
|
|
133
|
+
}, [hasGeneration, isOnlyGeneration])
|
|
134
|
+
|
|
135
|
+
const unitDivision = (str: string) => {
|
|
136
|
+
if (!str) {
|
|
137
|
+
return ['', '']
|
|
138
|
+
}
|
|
139
|
+
const strIndex = str.indexOf('(') || str.indexOf('(')
|
|
140
|
+
const unit = str.substring(strIndex)
|
|
141
|
+
const name = str.split(unit)[0]
|
|
142
|
+
return [name, unit]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const styles = StyleSheet.create({
|
|
146
|
+
consumedEnergyCard: {
|
|
147
|
+
marginHorizontal: cx(24),
|
|
148
|
+
},
|
|
149
|
+
consumedEnergyHeadline: {
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
justifyContent: 'space-between',
|
|
152
|
+
alignItems: 'center',
|
|
153
|
+
marginHorizontal: cx(16),
|
|
154
|
+
},
|
|
155
|
+
consumedEnergyCardTitle: {
|
|
156
|
+
color: props.theme?.global.fontColor,
|
|
157
|
+
fontSize: cx(16),
|
|
158
|
+
// fontFamily: 'helvetica_neue_lt_std_bd',
|
|
159
|
+
fontWeight: 'bold',
|
|
160
|
+
},
|
|
161
|
+
consumedEnergyContent: {
|
|
162
|
+
flexDirection: 'row',
|
|
163
|
+
},
|
|
164
|
+
consumedEnergyItem: {
|
|
165
|
+
flex: 1,
|
|
166
|
+
alignItems: 'center',
|
|
167
|
+
},
|
|
168
|
+
consumedEnergyItemValue: {
|
|
169
|
+
color: props.theme?.global.secondBrand,
|
|
170
|
+
fontSize: cx(24),
|
|
171
|
+
// fontFamily: 'helvetica_neue_lt_std_bd',
|
|
172
|
+
fontWeight: 'bold',
|
|
173
|
+
},
|
|
174
|
+
consumedEnergyItemUnit: {
|
|
175
|
+
color: props.theme?.global.secondFontColor,
|
|
176
|
+
fontSize: cx(14),
|
|
177
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
178
|
+
textAlign: 'center'
|
|
179
|
+
},
|
|
180
|
+
subContent: {
|
|
181
|
+
flex: 1,
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
marginBottom: cx(9)
|
|
184
|
+
},
|
|
185
|
+
valueText: {
|
|
186
|
+
fontSize: cx(24),
|
|
187
|
+
fontWeight: 'bold',
|
|
188
|
+
color: props.theme?.global.secondBrand,
|
|
189
|
+
},
|
|
190
|
+
titleText: {
|
|
191
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
192
|
+
fontSize: cx(14),
|
|
193
|
+
color: props.theme?.global.secondFontColor,
|
|
194
|
+
textAlign: 'center',
|
|
195
|
+
},
|
|
196
|
+
unitText: {
|
|
197
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
198
|
+
fontSize: cx(14),
|
|
199
|
+
color: props.theme?.global.secondFontColor,
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
const ConsumedEnergyItem = (props: { value: number, unit: string }) => {
|
|
204
|
+
return (
|
|
205
|
+
<View style={styles.subContent}>
|
|
206
|
+
<Text style={styles.valueText}>{(props.value) || 0}</Text>
|
|
207
|
+
<Spacer height={cx(4)}/>
|
|
208
|
+
<Text style={styles.titleText}>
|
|
209
|
+
{unitDivision(props.unit)[0]}
|
|
210
|
+
</Text>
|
|
211
|
+
<Text style={styles.titleText}>
|
|
212
|
+
{unitDivision(props.unit)[1]}
|
|
213
|
+
</Text>
|
|
214
|
+
</View>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return <Card
|
|
219
|
+
style={styles.consumedEnergyCard}
|
|
220
|
+
onPress={() => navigation.navigate(ui_biz_routerKey.group_ui_biz_energy_consumption, {
|
|
221
|
+
solarCurrentSum: state.solarCurrentSum,
|
|
222
|
+
solarPowerSum: state.solarPowerSum,
|
|
223
|
+
wifiCurrentSum: state.wifiCurrentSum,
|
|
224
|
+
wifiPowerSum: state.wifiPowerSum,
|
|
225
|
+
solarPlugGroup: groupDevices.filter(device => state.generationCache[device.tuyaDeviceId]).map(d => d.tuyaDeviceId),
|
|
226
|
+
wifiPlugGroup: groupDevices.filter(device => !state.generationCache[device.tuyaDeviceId]).map(d => d.tuyaDeviceId),
|
|
227
|
+
addEleDpCode: props.addEleDpCode,
|
|
228
|
+
backText: energyText
|
|
229
|
+
} as EnergyConsumptionPageProps)}>
|
|
230
|
+
<Spacer height={cx(16)}/>
|
|
231
|
+
<View style={styles.consumedEnergyHeadline}>
|
|
232
|
+
<Text
|
|
233
|
+
style={styles.consumedEnergyCardTitle}>{energyText}</Text>
|
|
234
|
+
<Image source={Res.energyChart} style={{ width: cx(24), height: cx(24), tintColor: props.theme?.icon.normal }}/>
|
|
235
|
+
</View>
|
|
236
|
+
<Spacer height={cx(18)}/>
|
|
237
|
+
<View style={styles.consumedEnergyContent}>
|
|
238
|
+
<ConsumedEnergyItem
|
|
239
|
+
value={localeNumber(state.totalPowerSum)}
|
|
240
|
+
unit={I18n.getLang('consumption_data_field2_value_text1')}/>
|
|
241
|
+
<ConsumedEnergyItem
|
|
242
|
+
value={localeNumber(state.totalCurrentSum)}
|
|
243
|
+
unit={I18n.getLang('consumption_data_field2_value_text2')}/>
|
|
244
|
+
</View>
|
|
245
|
+
<Spacer height={cx(17)}/>
|
|
246
|
+
</Card>
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export default withTheme(EnergyConsumptionCard)
|
|
@@ -132,7 +132,7 @@ const EnergyConsumptionChart = (props: { theme?: ThemeType }) => {
|
|
|
132
132
|
state.headlineText = `${monthFormat(month)} ${year}`;
|
|
133
133
|
break
|
|
134
134
|
case DateType.Day:
|
|
135
|
-
state.headlineText = `${day}/${month}/${year}
|
|
135
|
+
state.headlineText = `${day}/${month}/${year} (${loopsText[dayOfWeek]})`;
|
|
136
136
|
break
|
|
137
137
|
}
|
|
138
138
|
}, [state.dateType, state.headlineText]);
|
|
@@ -346,7 +346,20 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
|
|
|
346
346
|
<Spacer height={cx(10)} />
|
|
347
347
|
</Card>
|
|
348
348
|
<Spacer />
|
|
349
|
-
<Card
|
|
349
|
+
<Card
|
|
350
|
+
style={styles.cardContainer}
|
|
351
|
+
onPress={() => {
|
|
352
|
+
navigation.navigate(ui_biz_routerKey.group_ui_biz_energy_consumption_chart, {
|
|
353
|
+
headlineText: chartHeadline,
|
|
354
|
+
chartData: state.isSolarMode ? state.solarOverviewList : state.wifiOverviewList,
|
|
355
|
+
price: state.price,
|
|
356
|
+
unit: state.unit,
|
|
357
|
+
addEleDpCode: params.addEleDpCode,
|
|
358
|
+
date: (new Date()).getFullYear().toString(),
|
|
359
|
+
deviceIdGroup: state.isSolarMode ? params.solarPlugGroup : params.wifiPlugGroup,
|
|
360
|
+
} as EnergyConsumptionChartProps)
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
350
363
|
<Text style={styles.cardTitle}>
|
|
351
364
|
{I18n.getLang('consumption_data_field2_headline_text')}
|
|
352
365
|
</Text>
|
|
@@ -1,180 +1,182 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import ECharts from '@ledvance/react-native-echarts-pro'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {Utils} from
|
|
7
|
-
import {OverviewItem} from
|
|
1
|
+
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
2
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
3
|
+
import ECharts from '@ledvance/react-native-echarts-pro'
|
|
4
|
+
import React, { useMemo, useRef } from 'react'
|
|
5
|
+
import { View } from 'react-native'
|
|
6
|
+
import { Utils } from 'tuya-panel-kit'
|
|
7
|
+
import { OverviewItem } from '../EnergyConsumptionPage'
|
|
8
8
|
|
|
9
|
-
const {withTheme} = Utils.ThemeUtils
|
|
10
|
-
const cx = Utils.RatioUtils.convertX
|
|
9
|
+
const { withTheme } = Utils.ThemeUtils
|
|
10
|
+
const cx = Utils.RatioUtils.convertX
|
|
11
11
|
|
|
12
12
|
interface BarChartProps {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
theme?: ThemeType
|
|
14
|
+
data: OverviewItem[],
|
|
15
|
+
price: number,
|
|
16
|
+
unit: string,
|
|
17
|
+
height: number
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const BarChartWithTouch = (props: BarChartProps) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
21
|
+
const echarts = useRef()
|
|
22
|
+
const { data, height, price, unit, theme } = props
|
|
23
|
+
const dataX = data?.map(item => {
|
|
24
|
+
return item.chartTitle
|
|
25
|
+
})
|
|
26
|
+
const dataKwhY = data?.map(item => {
|
|
27
|
+
return Number(item.value)
|
|
28
|
+
})
|
|
29
|
+
const dataPriceY = data?.map(item => {
|
|
30
|
+
return ((isNaN(Number(item.value)) ? 0 : Number(item.value)) * price).toFixed(2)
|
|
31
|
+
})
|
|
32
|
+
const maxValue = useMemo(() => {
|
|
33
|
+
let max = Math.max(...dataKwhY)
|
|
34
|
+
if (max < 0.1) {
|
|
35
|
+
max += 0.02
|
|
36
|
+
max = max - (max % 0.02)
|
|
37
|
+
} else if (max < 1) {
|
|
38
|
+
max += 0.2
|
|
39
|
+
max = max - (max % 0.2)
|
|
40
|
+
} else if (max < 10) {
|
|
41
|
+
max = Math.ceil(max) + 2
|
|
42
|
+
max = max - (max % 2)
|
|
43
|
+
}
|
|
44
|
+
return max
|
|
45
|
+
}, [dataKwhY])
|
|
46
|
+
const gridRight = useMemo(() => {
|
|
47
|
+
const max = Math.max(...dataPriceY.map(it => Number(it)))
|
|
48
|
+
return max > 999 ? '15%' : '10%'
|
|
49
|
+
}, [dataPriceY])
|
|
50
|
+
const option = {
|
|
51
|
+
tooltip: {
|
|
52
|
+
show: true,
|
|
53
|
+
triggerOn: 'click',
|
|
54
|
+
trigger: 'axis',
|
|
55
|
+
},
|
|
56
|
+
legend: {
|
|
57
|
+
show: true,
|
|
58
|
+
data: ['kWh', unit],
|
|
59
|
+
textStyle: {
|
|
60
|
+
color: theme?.global.fontColor,
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
grid: {
|
|
64
|
+
right: gridRight,
|
|
65
|
+
},
|
|
66
|
+
xAxis: {
|
|
67
|
+
data: dataX,
|
|
68
|
+
axisTick: {
|
|
69
|
+
show: false,
|
|
70
|
+
},
|
|
71
|
+
axisLabel: {
|
|
72
|
+
show: true,
|
|
73
|
+
color: props.theme?.global.secondFontColor,
|
|
74
|
+
interval: 'auto',
|
|
75
|
+
rotate: 45,
|
|
76
|
+
align: 'right',
|
|
77
|
+
verticalAlign: 'top'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
yAxis: [{
|
|
81
|
+
type: 'value',
|
|
82
|
+
name: I18n.getLang('consumption_data_annual_bar_chart_text'),
|
|
83
|
+
max: Math.max(maxValue, 0.02),
|
|
84
|
+
min: 0,
|
|
85
|
+
position: 'left',
|
|
86
|
+
axisLabel: {
|
|
87
|
+
formatter: function (value) {
|
|
88
|
+
const kwh = parseFloat(value)
|
|
89
|
+
let toFixed = 2
|
|
90
|
+
if (kwh >= 100) {
|
|
91
|
+
toFixed = 0
|
|
92
|
+
} else if (kwh >= 10) {
|
|
93
|
+
toFixed = 1
|
|
94
|
+
}
|
|
95
|
+
return kwh.toFixed(toFixed)
|
|
55
96
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
97
|
+
color: props.theme?.global.secondFontColor,
|
|
98
|
+
},
|
|
99
|
+
nameTextStyle: {
|
|
100
|
+
fontSize: 14,
|
|
101
|
+
align: 'left',
|
|
102
|
+
padding: [0, 0, 0, cx(-30)],
|
|
103
|
+
color: props.theme?.global.secondFontColor,
|
|
104
|
+
},
|
|
105
|
+
}, {
|
|
106
|
+
type: 'value',
|
|
107
|
+
name: I18n.formatValue('format_unit', unit),
|
|
108
|
+
position: 'right',
|
|
109
|
+
alignTicks: true,
|
|
110
|
+
max: Math.ceil(price ? maxValue * price * 1.4 : 0),
|
|
111
|
+
min: 0,
|
|
112
|
+
minInterval: 1,
|
|
113
|
+
axisLabel: {
|
|
114
|
+
formatter: function (value) {
|
|
115
|
+
const price = parseFloat(value)
|
|
116
|
+
let toFixed = 2
|
|
117
|
+
if (price >= 100) {
|
|
118
|
+
toFixed = 0
|
|
119
|
+
} else if (price >= 10) {
|
|
120
|
+
toFixed = 1
|
|
121
|
+
}
|
|
122
|
+
return price.toFixed(toFixed)
|
|
62
123
|
},
|
|
63
|
-
|
|
64
|
-
|
|
124
|
+
color: props.theme?.global.secondFontColor,
|
|
125
|
+
},
|
|
126
|
+
nameTextStyle: {
|
|
127
|
+
fontSize: 14,
|
|
128
|
+
align: 'right',
|
|
129
|
+
padding: [0, cx(-30), 0, 0],
|
|
130
|
+
color: props.theme?.global.secondFontColor,
|
|
131
|
+
},
|
|
132
|
+
}],
|
|
133
|
+
series: [
|
|
134
|
+
{
|
|
135
|
+
name: 'kWh',
|
|
136
|
+
type: 'bar',
|
|
137
|
+
data: dataKwhY,
|
|
138
|
+
itemStyle: {
|
|
139
|
+
emphasis: {
|
|
140
|
+
color: '#FFC2A9', // Color when bar is clicked
|
|
141
|
+
},
|
|
142
|
+
color: '#FFC2A9',
|
|
143
|
+
borderRadius: 2,
|
|
65
144
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
axisLabel: {
|
|
72
|
-
show: true,
|
|
73
|
-
color: props.theme?.global.secondFontColor,
|
|
74
|
-
interval: 0,
|
|
75
|
-
}
|
|
145
|
+
barMaxWidth: 10,
|
|
146
|
+
select: {
|
|
147
|
+
itemStyle: {
|
|
148
|
+
borderColor: '#FFC2A9',
|
|
149
|
+
}
|
|
76
150
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
max: Math.ceil(price ? maxValue * price * 1.4 : 0),
|
|
108
|
-
min: 0,
|
|
109
|
-
minInterval: 1,
|
|
110
|
-
axisLabel: {
|
|
111
|
-
formatter: function (value) {
|
|
112
|
-
const price=parseFloat(value);
|
|
113
|
-
let toFixed = 2;
|
|
114
|
-
if (price >= 100) {
|
|
115
|
-
toFixed = 0;
|
|
116
|
-
} else if (price >= 10) {
|
|
117
|
-
toFixed = 1;
|
|
118
|
-
}
|
|
119
|
-
return price.toFixed(toFixed);
|
|
120
|
-
},
|
|
121
|
-
color:props.theme?.global.secondFontColor,
|
|
122
|
-
},
|
|
123
|
-
nameTextStyle: {
|
|
124
|
-
fontSize: 14,
|
|
125
|
-
align:'right',
|
|
126
|
-
padding: [0, cx(-30), 0, 0],
|
|
127
|
-
color: props.theme?.global.secondFontColor,
|
|
128
|
-
},
|
|
129
|
-
}],
|
|
130
|
-
series: [
|
|
131
|
-
{
|
|
132
|
-
name: 'kWh',
|
|
133
|
-
type: 'bar',
|
|
134
|
-
data: dataKwhY,
|
|
135
|
-
itemStyle: {
|
|
136
|
-
emphasis: {
|
|
137
|
-
color: '#FFC2A9', // Color when bar is clicked
|
|
138
|
-
},
|
|
139
|
-
color: '#FFC2A9',
|
|
140
|
-
borderRadius: 2,
|
|
141
|
-
},
|
|
142
|
-
barMaxWidth: 10,
|
|
143
|
-
select: {
|
|
144
|
-
itemStyle: {
|
|
145
|
-
borderColor: '#FFC2A9',
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
selectedMode: 'single',
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: unit,
|
|
152
|
-
type: 'line',
|
|
153
|
-
data: dataPriceY,
|
|
154
|
-
yAxisIndex: 1,
|
|
155
|
-
smooth: true,
|
|
156
|
-
showSymbol: false,
|
|
157
|
-
color: '#F49431',
|
|
158
|
-
selectedMode: "single",
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
dataZoom: {
|
|
162
|
-
start: 0,
|
|
163
|
-
type: "inside",
|
|
164
|
-
maxValueSpan: 5,
|
|
165
|
-
zoomLock: true,
|
|
166
|
-
},
|
|
167
|
-
customMapData: {}
|
|
168
|
-
};
|
|
169
|
-
return (
|
|
170
|
-
<View style={{flex: 1}}>
|
|
171
|
-
<ECharts
|
|
172
|
-
option={option}
|
|
173
|
-
ref={echarts}
|
|
174
|
-
height={height}
|
|
175
|
-
/>
|
|
176
|
-
</View>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
151
|
+
selectedMode: 'single',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: unit,
|
|
155
|
+
type: 'line',
|
|
156
|
+
data: dataPriceY,
|
|
157
|
+
yAxisIndex: 1,
|
|
158
|
+
smooth: true,
|
|
159
|
+
showSymbol: false,
|
|
160
|
+
color: '#F49431',
|
|
161
|
+
selectedMode: 'single',
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
dataZoom: {
|
|
165
|
+
start: 0,
|
|
166
|
+
type: 'inside',
|
|
167
|
+
zoomLock: true,
|
|
168
|
+
},
|
|
169
|
+
customMapData: {}
|
|
170
|
+
}
|
|
171
|
+
return (
|
|
172
|
+
<View style={{ flex: 1 }}>
|
|
173
|
+
<ECharts
|
|
174
|
+
option={option}
|
|
175
|
+
ref={echarts}
|
|
176
|
+
height={height}
|
|
177
|
+
/>
|
|
178
|
+
</View>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
179
181
|
|
|
180
182
|
export default withTheme(BarChartWithTouch)
|
|
Binary file
|
|
@@ -17,7 +17,7 @@ import Spacer from "@ledvance/base/src/components/Spacer";
|
|
|
17
17
|
import Summary from "./Summary";
|
|
18
18
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
19
19
|
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
20
|
-
import LdvPickerView from "@ledvance/base/src/components/
|
|
20
|
+
import LdvPickerView from "@ledvance/base/src/components/LdvPickerView";
|
|
21
21
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
22
22
|
|
|
23
23
|
const {parseTimer} = Utils.TimeUtils
|
|
@@ -20,7 +20,7 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
20
20
|
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
21
21
|
import LampAdjustView from "@ledvance/base/src/components/LampAdjustView";
|
|
22
22
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
23
|
-
import LdvPickerView from "@ledvance/base/src/components/
|
|
23
|
+
import LdvPickerView from "@ledvance/base/src/components/LdvPickerView";
|
|
24
24
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
25
25
|
|
|
26
26
|
const {parseTimer} = Utils.TimeUtils
|
|
@@ -7,7 +7,7 @@ import res from '@ledvance/base/src/res';
|
|
|
7
7
|
import { TimerPicker, Utils } from 'tuya-panel-kit';
|
|
8
8
|
import { useReactive, useUpdateEffect } from 'ahooks';
|
|
9
9
|
import TextField from '@ledvance/base/src/components/TextField';
|
|
10
|
-
import LdvPickerView from '@ledvance/base/src/components/
|
|
10
|
+
import LdvPickerView from '@ledvance/base/src/components/LdvPickerView';
|
|
11
11
|
import LdvWeekView from '@ledvance/base/src/components/weekSelect';
|
|
12
12
|
import {
|
|
13
13
|
convertMinutesTo12HourFormat,
|
|
@@ -4,7 +4,7 @@ import Page from "@ledvance/base/src/components/Page";
|
|
|
4
4
|
import {useUAGroupInfo} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
5
5
|
import {useNavigation} from '@react-navigation/native'
|
|
6
6
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
7
|
-
import LdvPickerView from "@ledvance/base/src/components/
|
|
7
|
+
import LdvPickerView from "@ledvance/base/src/components/LdvPickerView";
|
|
8
8
|
import I18n from '@ledvance/base/src/i18n'
|
|
9
9
|
import {defSwitchInching, SwitchInchingItem, SwitchInchingPageParams, useSwitchInching} from "./SwitchInchingAction";
|
|
10
10
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
@@ -4,7 +4,7 @@ import I18n from '@ledvance/base/src/i18n'
|
|
|
4
4
|
import Page from '@ledvance/base/src/components/Page'
|
|
5
5
|
import {Utils} from 'tuya-panel-kit'
|
|
6
6
|
import {useUAGroupInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
7
|
-
import LdvPickerView from '@ledvance/base/src/components/
|
|
7
|
+
import LdvPickerView from '@ledvance/base/src/components/LdvPickerView'
|
|
8
8
|
import {useReactive} from 'ahooks'
|
|
9
9
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
10
10
|
import DeleteButton from '@ledvance/base/src/components/DeleteButton'
|
package/tsconfig.json
CHANGED
|
@@ -1,51 +1,76 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "ES2017",
|
|
5
|
+
"lib": ["es2017"],
|
|
6
|
+
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
9
|
+
"jsx": "react",
|
|
10
|
+
/* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
/* Strict Type-Checking Options */
|
|
13
|
+
/* "strict": true /* Enable all strict type-checking options. */
|
|
14
|
+
"noImplicitAny": false,
|
|
15
|
+
/* Raise error on expressions and declarations with an implied 'any' type. */
|
|
16
|
+
"strictNullChecks": true,
|
|
17
|
+
/* Enable strict null checks. */
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/* Additional Checks */
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
/* Report errors on unused locals. */
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
/* Report errors on unused parameters. */
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
/* .d.ts config */
|
|
26
|
+
"declaration": true,
|
|
27
|
+
"emitDeclarationOnly": true,
|
|
28
|
+
/* Module Resolution Options */
|
|
29
|
+
"moduleResolution": "node",
|
|
30
|
+
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' */
|
|
31
|
+
"types": [
|
|
32
|
+
"react",
|
|
33
|
+
"react-native"
|
|
34
|
+
],
|
|
35
|
+
/* Type declaration files to be included in compilation. */
|
|
36
|
+
"typeRoots": [
|
|
37
|
+
"@types/*.d.ts"
|
|
38
|
+
],
|
|
39
|
+
"allowSyntheticDefaultImports": true,
|
|
40
|
+
/* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
41
|
+
"esModuleInterop": true,
|
|
42
|
+
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
43
|
+
"baseUrl": "./src",
|
|
44
|
+
"paths": {
|
|
45
|
+
"@api": [
|
|
46
|
+
"./api"
|
|
47
|
+
],
|
|
48
|
+
"@components": [
|
|
49
|
+
"./components"
|
|
50
|
+
],
|
|
51
|
+
"@config": [
|
|
52
|
+
"./config"
|
|
53
|
+
],
|
|
54
|
+
"@i18n": [
|
|
55
|
+
"./i18n"
|
|
56
|
+
],
|
|
57
|
+
"@models": [
|
|
58
|
+
"./models"
|
|
59
|
+
],
|
|
60
|
+
"@res": [
|
|
61
|
+
"./res"
|
|
62
|
+
],
|
|
63
|
+
"@utils": [
|
|
64
|
+
"./utils"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"include": [
|
|
69
|
+
"src/**/*.ts",
|
|
70
|
+
"src/**/*.tsx"
|
|
71
|
+
],
|
|
72
|
+
"exclude": [
|
|
73
|
+
"node_modules",
|
|
74
|
+
".yalc"
|
|
75
|
+
]
|
|
51
76
|
}
|