@ledvance/ui-biz-bundle 1.1.139 → 1.1.140
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/timer/TimerPage.tsx +3 -0
- package/src/modules/timer/TimerPageAction.ts +25 -2
- package/src/newModules/timeSchedule/Interface.ts +9 -12
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +6 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +8 -5
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +3 -1
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +28 -2
package/package.json
CHANGED
|
@@ -27,6 +27,8 @@ export type dpItem = {
|
|
|
27
27
|
cloudKey: any
|
|
28
28
|
stringOn: any
|
|
29
29
|
stringOff: any
|
|
30
|
+
dpValueToDisplay?: (value: number) => number
|
|
31
|
+
displayToDpValue?: (value: number) => number
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
type TimerPageRouteParams = {
|
|
@@ -271,6 +273,7 @@ const TimerPage = (props: {theme?: ThemeType}) => {
|
|
|
271
273
|
<Spacer />
|
|
272
274
|
<DeleteButton
|
|
273
275
|
text={I18n.getLang('timer_sockets_button_text')}
|
|
276
|
+
disabled={!state.selectedSkill.length}
|
|
274
277
|
onPress={onStartPress}
|
|
275
278
|
textStyle={{ fontSize: cx(14) }}
|
|
276
279
|
style={{ backgroundColor: !state.selectedSkill.length ? props.theme?.button.disabled : props.theme?.button.primary }}
|
|
@@ -6,11 +6,34 @@ import { useCountDown as useCountDownAHook, useUpdateEffect } from 'ahooks'
|
|
|
6
6
|
import dayjs from "dayjs"
|
|
7
7
|
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
8
8
|
|
|
9
|
+
const useConvertCountdown = (item: dpItem): [number, (value: number) => Promise<Result<any>>] => {
|
|
10
|
+
const [dpValue, setDpValue] = useDp<number, (value: number) => Promise<Result<any>>>(item.dpId);
|
|
11
|
+
const [displayValue, setDisplayValue] = useState<number>(0);
|
|
12
|
+
|
|
13
|
+
// 当设备值变化时,转换为显示值
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
// 如果dpValue是undefined或null,不进行转换
|
|
16
|
+
if (dpValue == null) return;
|
|
17
|
+
|
|
18
|
+
const value = item.dpValueToDisplay ? item.dpValueToDisplay(dpValue) : dpValue;
|
|
19
|
+
setDisplayValue(value);
|
|
20
|
+
}, [dpValue, item.dpValueToDisplay]);
|
|
21
|
+
|
|
22
|
+
// 将显示值转换为设备值并设置
|
|
23
|
+
const handleDisplayValueChange = useCallback((value: number) => {
|
|
24
|
+
if (value == null) return Promise.reject(new Error('Invalid value'));
|
|
25
|
+
|
|
26
|
+
const newDpValue = item.displayToDpValue ? item.displayToDpValue(value) : value;
|
|
27
|
+
return setDpValue(newDpValue);
|
|
28
|
+
}, [setDpValue, item.displayToDpValue]);
|
|
29
|
+
|
|
30
|
+
return [displayValue, handleDisplayValueChange];
|
|
31
|
+
}
|
|
9
32
|
|
|
10
33
|
export const useCountdowns = (dps: dpItem[]) => {
|
|
11
34
|
return dps.map(dp => {
|
|
12
35
|
return ({
|
|
13
|
-
countdown:
|
|
36
|
+
countdown: useConvertCountdown(dp),
|
|
14
37
|
enable: useDp<boolean, (value: boolean) => Promise<Result<any>>>(dp.enableDp),
|
|
15
38
|
...dp
|
|
16
39
|
})
|
|
@@ -24,7 +47,7 @@ type FormateProgressType = {
|
|
|
24
47
|
endTimer: () => void
|
|
25
48
|
}
|
|
26
49
|
const useFormateProgress: (dp: dpItem) => FormateProgressType = (dp) => {
|
|
27
|
-
const [countdown, setCountdown] =
|
|
50
|
+
const [countdown, setCountdown] = useConvertCountdown(dp)
|
|
28
51
|
const [progress, setProgress] = useCountDownAHook({
|
|
29
52
|
interval: 1000,
|
|
30
53
|
onEnd: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import I18n from "@ledvance/base/src/i18n";
|
|
2
|
-
import { AdjustType, DiySceneInfo } from "@ledvance/base/src/utils/interface";
|
|
2
|
+
import { AdjustType, ApplyForItem, DiySceneInfo } from "@ledvance/base/src/utils/interface";
|
|
3
3
|
import { MoodInfo, MoodUIInfo } from "../mood/Interface";
|
|
4
4
|
|
|
5
5
|
export interface Timer {
|
|
@@ -25,17 +25,6 @@ export interface HSV {
|
|
|
25
25
|
v: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type Category = 'light' | 'socket' | 'fan' | 'mainLight' | 'secondaryLight' | 'shutter'
|
|
29
|
-
|
|
30
|
-
export interface ApplyForItem {
|
|
31
|
-
name?: string
|
|
32
|
-
index?: number
|
|
33
|
-
key: string;
|
|
34
|
-
dp: string;
|
|
35
|
-
type: Category;
|
|
36
|
-
enable: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
28
|
interface judgmentSupport {
|
|
40
29
|
isSupportColor: boolean;
|
|
41
30
|
isSupportBrightness: boolean;
|
|
@@ -68,6 +57,7 @@ export enum DeviceType {
|
|
|
68
57
|
FanLight = 'fanLight',
|
|
69
58
|
MoodStrip = 'moodStrip',
|
|
70
59
|
Shutter = 'shutter',
|
|
60
|
+
OsramFanLight = 'osramFanLight'
|
|
71
61
|
}
|
|
72
62
|
// export type DeviceType = 'LightSource' | 'CeilingLight' | 'StringLight' | 'StripLight' | 'MixLight';
|
|
73
63
|
|
|
@@ -111,6 +101,11 @@ export interface ShutterData extends DeviceData {
|
|
|
111
101
|
percentControl: number
|
|
112
102
|
}
|
|
113
103
|
|
|
104
|
+
export interface OsramFanLightData extends DeviceData {
|
|
105
|
+
fanMode: 'fresh' | 'nature'
|
|
106
|
+
fanSpeed: number
|
|
107
|
+
}
|
|
108
|
+
|
|
114
109
|
export type ComponentConfig =
|
|
115
110
|
| { type: DeviceType.LightSource; deviceData: DeviceData }
|
|
116
111
|
| { type: DeviceType.MixLight; deviceData: MixLightData }
|
|
@@ -120,6 +115,8 @@ export type ComponentConfig =
|
|
|
120
115
|
| { type: DeviceType.PowerStrip; deviceData: DeviceData}
|
|
121
116
|
| { type: DeviceType.MoodStrip; deviceData: MoodStripData}
|
|
122
117
|
| { type: DeviceType.Shutter; deviceData: ShutterData}
|
|
118
|
+
| { type: DeviceType.OsramFanLight; deviceData: OsramFanLightData}
|
|
119
|
+
|
|
123
120
|
export interface TimeScheduleDetailState {
|
|
124
121
|
timeSchedule: Timer;
|
|
125
122
|
dps: Record<string, any>;
|
|
@@ -42,6 +42,12 @@ export const defShutterDeviceData = {
|
|
|
42
42
|
percentControl: 100
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
export const defOsramFanLightDeviceData = {
|
|
46
|
+
...defDeviceData,
|
|
47
|
+
fanSpeed: 1,
|
|
48
|
+
fanMode: 'fresh',
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
export const getTimeSchedule = async (deviceId: string): Promise<Timer[]> => {
|
|
46
52
|
const res = await NativeApi.getAllTaskTimer(deviceId);
|
|
47
53
|
if (res.success && Array.isArray(res.data)) {
|
|
@@ -10,7 +10,7 @@ import {SwitchButton, TimerPicker, Utils} from 'tuya-panel-kit';
|
|
|
10
10
|
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
11
11
|
import LdvWeekView from '@ledvance/base/src/components/weekSelect';
|
|
12
12
|
import {convertTo12HourFormat, loopText, showDialog} from '@ledvance/base/src/utils/common';
|
|
13
|
-
import {
|
|
13
|
+
import { ComponentConfig, DeviceType, Timer, TimerActions, TimeScheduleDetailState,} from './Interface';
|
|
14
14
|
import res from '@ledvance/base/src/res';
|
|
15
15
|
import {useDeviceId, useMoods, useSystemTimeFormate,} from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
16
16
|
import {TimeSchedulePageParams} from './TimeSchedulePage';
|
|
@@ -26,7 +26,8 @@ import {
|
|
|
26
26
|
defMixDeviceData,
|
|
27
27
|
defMoodStripDeviceData,
|
|
28
28
|
defStripDeviceData,
|
|
29
|
-
defShutterDeviceData
|
|
29
|
+
defShutterDeviceData,
|
|
30
|
+
defOsramFanLightDeviceData
|
|
30
31
|
} from './TimeScheduleActions';
|
|
31
32
|
import MoodItem from '../mood/MoodItem';
|
|
32
33
|
import {getRemoteMoodList} from '../mood/MoodActions';
|
|
@@ -35,7 +36,7 @@ import Summary from '@ledvance/base/src/components/Summary'
|
|
|
35
36
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
36
37
|
import Tag from "@ledvance/base/src/components/Tag";
|
|
37
38
|
import DiySceneItem from '@ledvance/base/src/components/DiySceneItem';
|
|
38
|
-
import {DiySceneInfo} from "@ledvance/base/src/utils/interface";
|
|
39
|
+
import {ApplyForItem, DiySceneInfo} from "@ledvance/base/src/utils/interface";
|
|
39
40
|
|
|
40
41
|
const { convertX: cx } = Utils.RatioUtils;
|
|
41
42
|
const { toFixedString } = Utils.NumberUtils;
|
|
@@ -688,7 +689,8 @@ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig
|
|
|
688
689
|
isFanLight: DeviceType.FanLight,
|
|
689
690
|
isCeilingLight: DeviceType.CeilingLight,
|
|
690
691
|
isMoodStrip: DeviceType.MoodStrip,
|
|
691
|
-
isShutter: DeviceType.Shutter
|
|
692
|
+
isShutter: DeviceType.Shutter,
|
|
693
|
+
isOsramFanLight: DeviceType.OsramFanLight
|
|
692
694
|
};
|
|
693
695
|
|
|
694
696
|
const deviceType = Object.entries(deviceTypeMap)
|
|
@@ -702,9 +704,10 @@ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig
|
|
|
702
704
|
[DeviceType.FanLight]: defFanLightDeviceData,
|
|
703
705
|
[DeviceType.MoodStrip]: defMoodStripDeviceData,
|
|
704
706
|
[DeviceType.Shutter]: defShutterDeviceData,
|
|
707
|
+
[DeviceType.OsramFanLight]: defOsramFanLightDeviceData,
|
|
705
708
|
[DeviceType.PowerStrip]: defDeviceData,
|
|
706
709
|
[DeviceType.LightSource]: defDeviceData,
|
|
707
|
-
[DeviceType.Plug]: defDeviceData
|
|
710
|
+
[DeviceType.Plug]: defDeviceData,
|
|
708
711
|
};
|
|
709
712
|
|
|
710
713
|
return {
|
|
@@ -14,7 +14,7 @@ import Spacer from '@ledvance/base/src/components/Spacer';
|
|
|
14
14
|
import InfoText from '@ledvance/base/src/components/InfoText';
|
|
15
15
|
import DeleteButton from '@ledvance/base/src/components/DeleteButton';
|
|
16
16
|
import { useReactive, useUpdateEffect } from 'ahooks';
|
|
17
|
-
import {
|
|
17
|
+
import { DeviceStateType, Timer, TimerActions } from './Interface';
|
|
18
18
|
import { getTimeSchedule, manageTimeSchedule } from './TimeScheduleActions';
|
|
19
19
|
import { useParams } from '@ledvance/base/src/hooks/Hooks';
|
|
20
20
|
import ScheduleCard from './components/ScheduleCard';
|
|
@@ -23,6 +23,7 @@ import Tag from '@ledvance/base/src/components/Tag';
|
|
|
23
23
|
import { cloneDeep } from 'lodash';
|
|
24
24
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
25
25
|
import { showDialog } from '@ledvance/base/src/utils/common';
|
|
26
|
+
import { ApplyForItem } from '@ledvance/base/src/utils/interface';
|
|
26
27
|
|
|
27
28
|
const { convertX: cx } = Utils.RatioUtils;
|
|
28
29
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -43,6 +44,7 @@ export interface TimeSchedulePageParams {
|
|
|
43
44
|
isPowerStrip?: boolean
|
|
44
45
|
isMoodStrip?: boolean
|
|
45
46
|
isShutter?: boolean
|
|
47
|
+
isOsramFan?: boolean
|
|
46
48
|
featureId?: string
|
|
47
49
|
applyForList: ApplyForItem[];
|
|
48
50
|
applyForDisabled?: boolean; // 是否可以选择apply for
|
|
@@ -5,10 +5,11 @@ import {
|
|
|
5
5
|
FanLightData,
|
|
6
6
|
ManualSettingProps,
|
|
7
7
|
modeOptions,
|
|
8
|
+
OsramFanLightData,
|
|
8
9
|
ShutterData,
|
|
9
10
|
StripLightData
|
|
10
11
|
} from '../Interface';
|
|
11
|
-
import { View } from 'react-native';
|
|
12
|
+
import { View, Text, } from 'react-native';
|
|
12
13
|
import Card from '@ledvance/base/src/components/Card';
|
|
13
14
|
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
|
|
14
15
|
import { Utils } from 'tuya-panel-kit';
|
|
@@ -26,6 +27,7 @@ import { cctToColor } from '@ledvance/base/src/utils/cctUtils';
|
|
|
26
27
|
import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
|
|
27
28
|
import { AdjustType, ApplyForItem } from "@ledvance/base/src/utils/interface";
|
|
28
29
|
import LdvSlider from '@ledvance/base/src/components/ldvSlider';
|
|
30
|
+
import OsramFanAdjustView from '@ledvance/base/src/components/OsramFanAdjustView'
|
|
29
31
|
|
|
30
32
|
const { convertX: cx } = Utils.RatioUtils;
|
|
31
33
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -112,7 +114,7 @@ function ManualSettings(props: ManualSettingProps) {
|
|
|
112
114
|
state.applyFlag = Symbol()
|
|
113
115
|
}}
|
|
114
116
|
/>
|
|
115
|
-
{item.enable &&
|
|
117
|
+
{item.enable && !['socket', 'fan', 'osramFan'].includes(item.type) && (
|
|
116
118
|
<LampAdjustView
|
|
117
119
|
isSupportColor={props.isSupportColor}
|
|
118
120
|
isSupportBrightness={props.isSupportBrightness}
|
|
@@ -205,6 +207,30 @@ function ManualSettings(props: ManualSettingProps) {
|
|
|
205
207
|
}}
|
|
206
208
|
/>
|
|
207
209
|
)}
|
|
210
|
+
|
|
211
|
+
{item.enable && item.type === 'osramFan' && (
|
|
212
|
+
<OsramFanAdjustView
|
|
213
|
+
hideFanSwitch={true}
|
|
214
|
+
fanSwitch={item.enable}
|
|
215
|
+
setFanSwitch={() => {}}
|
|
216
|
+
fanSpeed={(state.deviceData as OsramFanLightData).fanSpeed}
|
|
217
|
+
setFanSpeed={(v: number) => {
|
|
218
|
+
state.deviceData = {
|
|
219
|
+
...state.deviceData,
|
|
220
|
+
fanSpeed: v
|
|
221
|
+
}
|
|
222
|
+
state.manualFlag = Symbol()
|
|
223
|
+
}}
|
|
224
|
+
fanMode={(state.deviceData as OsramFanLightData).fanMode}
|
|
225
|
+
setFanMode={(v: 'fresh' | 'nature') => {
|
|
226
|
+
state.deviceData = {
|
|
227
|
+
...state.deviceData,
|
|
228
|
+
fanMode: v
|
|
229
|
+
}
|
|
230
|
+
state.manualFlag = Symbol()
|
|
231
|
+
}}
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
208
234
|
</Card>
|
|
209
235
|
<Spacer />
|
|
210
236
|
</View>
|