@ledvance/ui-biz-bundle 1.1.170 → 1.1.172

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.170",
7
+ "version": "1.1.172",
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
  }
@@ -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) => {
@@ -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
@@ -128,7 +128,7 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
128
128
  };
129
129
  } else {
130
130
  if (mode === 'add') {
131
- const title = res.msg?.includes('LINKAGE_TIMER_OVER_MAX_LIMIT_30') ? I18n.getLang('repeater_schedule_error_limit') :I18n.getLang('repeater_schedule_error_common.add_fail')
131
+ const title = res.msg?.includes('LINKAGE_TIMER_OVER_MAX_LIMIT_30') ? I18n.getLang('repeater_schedule_error_limit') :I18n.getLang('repeater_schedule_error_common')
132
132
  showDialog({
133
133
  method: 'alert',
134
134
  title: title,