@ledvance/ui-biz-bundle 1.1.169 → 1.1.171

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/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.169",
7
+ "version": "1.1.171",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -1,7 +1,9 @@
1
+ import React, { useState, useEffect } from "react";
1
2
  import ThemeType from "@ledvance/base/src/config/themeType";
2
3
  import { parseMinutes, PriceSegment } from "./component/EnergyModal";
3
4
  import { Utils } from 'tuya-panel-kit'
4
5
  import { StyleSheet } from "react-native";
6
+ import {exchangeNumber} from "@ledvance/base/src/utils/common";
5
7
 
6
8
  export const useEditPriceSegment = (segment: PriceSegment | undefined,
7
9
  onSegmentSet: (s: PriceSegment) => void, theme?: ThemeType,) => {
@@ -11,7 +13,14 @@ export const useEditPriceSegment = (segment: PriceSegment | undefined,
11
13
 
12
14
  const startTime = parseMinutes(startMin);
13
15
  const endTime = parseMinutes(endMin);
14
- const currentPrice = segment?.price ?? 0
16
+
17
+ const [priceStr, setPriceStr] = useState<string>(() => {
18
+ if (segment?.price === undefined) {
19
+ return '0';
20
+ }
21
+ return segment.price.toString();
22
+ });
23
+
15
24
  const handleTimeChange = (type: 'startHour' | 'startMinute' | 'endHour' | 'endMinute', value: string) => {
16
25
  let startH = Math.floor(startMin / 60);
17
26
  let startM = startMin % 60;
@@ -32,15 +41,24 @@ export const useEditPriceSegment = (segment: PriceSegment | undefined,
32
41
 
33
42
  onSegmentSet(updatedSegment);
34
43
  };
44
+
35
45
  const handlePriceChange = (t: string) => {
36
- const value = t.replace(/[^0-9.,]/g, '')
37
- const tempPrice = Number(value)
38
- const resultPrice = tempPrice > 999999 ? 999999 : tempPrice
46
+ const cleaned = exchangeNumber(t)
47
+ const parsed = parseFloat(cleaned);
48
+ let numericVal = isNaN(parsed) ? 0 : parsed;
49
+ if (numericVal > 999999) {
50
+ numericVal = 999999;
51
+ setPriceStr('999999');
52
+ } else {
53
+ setPriceStr(t);
54
+ }
55
+
39
56
  onSegmentSet({
40
57
  ...(segment ?? {}),
41
- price: resultPrice
42
- } as PriceSegment)
43
- }
58
+ price: numericVal
59
+ } as PriceSegment);
60
+ };
61
+
44
62
  const style = StyleSheet.create({
45
63
  timerHeader: {
46
64
  fontSize: cx(16),
@@ -84,6 +102,6 @@ export const useEditPriceSegment = (segment: PriceSegment | undefined,
84
102
 
85
103
  })
86
104
  return {
87
- style, startTime, endTime, currentPrice, handleTimeChange, handlePriceChange,
105
+ style, startTime, endTime, currentPrice: priceStr, handleTimeChange, handlePriceChange,
88
106
  }
89
107
  }
@@ -303,6 +303,11 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
303
303
 
304
304
  const updateEnergyData = (data: EnergyData) => {
305
305
  updatePrice(devId, data).then()
306
+ state.network_fixed_data = {
307
+ unit: data.unit,
308
+ energyType: 'fixed',
309
+ [isGeneration ? 'generatePrice' : 'price']: data.price,
310
+ }
306
311
  state.price = data.price || '0'
307
312
  state.unit = data.unit
308
313
  state.energyType = 'fixed'
@@ -709,7 +714,7 @@ const EnergyConsumptionPage = (props: { theme?: ThemeType }) => {
709
714
  title={state.popupType === 'co2' ? I18n.getLang('consumption_data_field3_co2_topic_text') : state.popupType === 'history' ? I18n.getLang('group_energytotal') : ''}
710
715
  cancelText={['co2', 'history'].includes(state.popupType) ? '' : I18n.getLang("auto_scan_system_cancel")}
711
716
  confirmText={I18n.getLang(['co2', 'history'].includes(state.popupType) ? 'home_screen_home_dialog_yes_con' : 'auto_scan_system_wifi_confirm')}
712
- energyData={{ price: state.price, unit: state.unit }}
717
+ energyData={{ price: state.popupType === 'money' ? (state.network_fixed_data?.price ?? '0'): state.price , unit: state.unit }}
713
718
  energyHistory={state.energyGeneration.history}
714
719
  onConfirm={(energyData) => {
715
720
  state.popupType = ''
@@ -42,10 +42,32 @@ export const useSetSegmentPrice = (params: SetSegmentedPricesParams, theme?: The
42
42
  isLoading: false,
43
43
  isDataChanged: false,
44
44
  });
45
+ const findEmptySegment = useCallback(()=>{
46
+ let ptr = 0;
47
+ const TOTAL_MINUTES = 1439; // (0 ~ 1439)
48
+ for (const segment of uiState.segments) {
49
+ if(segment.startMinute > ptr) {
50
+ return {
51
+ startMinute: ptr,
52
+ endMinute: segment.startMinute,
53
+ price: 0,
54
+ }
55
+ }
56
+ ptr = segment.endMinute;
57
+ }
58
+ if(ptr < TOTAL_MINUTES) {
59
+ return {
60
+ startMinute: ptr,
61
+ endMinute: TOTAL_MINUTES,
62
+ price:0,
63
+ }
64
+ }
65
+ return undefined
66
+ },[uiState.segments])
45
67
  const showAddPopup = useCallback(() => {
46
68
  uiState.editingSegmentPrice = {
47
69
  isShow: true,
48
- editingSegmentPrice: undefined,
70
+ editingSegmentPrice: findEmptySegment(),
49
71
  }
50
72
  }, [uiState]);
51
73
  const showEditPopup = useCallback((item: PriceSegment) => {
@@ -389,6 +411,7 @@ export const useSetSegmentPrice = (params: SetSegmentedPricesParams, theme?: The
389
411
  bottom: 0,
390
412
  left: 0,
391
413
  width: cx(40),
414
+ minHeight: cx(320),
392
415
  },
393
416
  segmentItem: {
394
417
  position: 'relative',
@@ -78,16 +78,25 @@ const PowerLineChart = (props: PowerLineChartProps) => {
78
78
  triggerOn: 'mousemove|click',
79
79
  trigger: 'axis',
80
80
  position: ['30%', '50%'],
81
- formatter: function (params) {
82
- if (!params || !params.length) return ''
83
- var item = params[0]
84
- var date = new Date(item.value[0])
85
- function pad(num) {
86
- return num < 10 ? '0' + num : num
81
+ axisPointer: {
82
+ label: {
83
+ backgroundColor: '#6a7985',
84
+ // 这个 formatter 只负责格式化时间
85
+ formatter: (params: { value: number }) => {
86
+ const date = new Date(params.value);
87
+
88
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
89
+ const day = date.getDate().toString().padStart(2, '0');
90
+ const year = date.getFullYear();
91
+
92
+ const hours = date.getHours().toString().padStart(2, '0');
93
+ const minutes = date.getMinutes().toString().padStart(2, '0');
94
+ const seconds = date.getSeconds().toString().padStart(2, '0');
95
+
96
+ // 返回你指定的 DD/MM/YYYY HH:mm:SS 格式
97
+ return day + '/' + month + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds;
98
+ }
87
99
  }
88
- var time = pad(date.getMonth() + 1) + '/' + pad(date.getDate()) + '/' + date.getFullYear() + ' ' +
89
- pad(date.getHours()) + ':' + pad(date.getMinutes()) + ':' + pad(date.getSeconds())
90
- return (time + '<br/>' + item.marker + item.seriesName + ': ' + item.value[1])
91
100
  }
92
101
  },
93
102
  grid: {
@@ -78,7 +78,7 @@ const MoodItem = (props: MoodItemProps) => {
78
78
  <View style={styles.contentContainer}>
79
79
  {/* 顶部内容 */}
80
80
  <View style={styles.row}>
81
- <Text style={styles.headText}>{mood.name}</Text>
81
+ <Text style={styles.headText} numberOfLines={2}>{mood.name}</Text>
82
82
  {/* checkbox 的 TouchableOpacity 现在也应用了阴影样式 */}
83
83
  <TouchableOpacity style={styles.checkbox} onPress={() => onSwitch(!enable)}>
84
84
  <Image