@ledvance/ui-biz-bundle 1.0.2 → 1.0.4
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/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/package.json +72 -72
- package/rn-cli.config.js +8 -8
- package/src/modules/history/HistoryPage.d.ts +2 -2
- package/src/modules/history/HistoryPage.tsx +254 -254
- package/src/modules/history/SwitchHistoryPageActions.d.ts +13 -13
- package/src/modules/history/SwitchHistoryPageActions.ts +53 -53
- package/src/modules/hooks/DeviceDpStateHooks.ts +27 -0
- package/src/modules/mood/MixLightActions.ts +82 -0
- package/src/modules/mood/MixLightSceneActions.ts +259 -0
- package/src/modules/mood/MixMoodItem.tsx +138 -0
- package/src/modules/mood/MixScene.tsx +131 -0
- package/src/modules/mood/MixSceneBeans.ts +62 -0
- package/src/modules/mood/MoodAction.ts +222 -0
- package/src/modules/mood/MoodItem.tsx +113 -0
- package/src/modules/mood/SceneInfo.ts +319 -0
- package/src/modules/timeSchedule/DeviceState.tsx +54 -0
- package/src/modules/timeSchedule/LdvScheduleItem.tsx +125 -0
- package/src/modules/timeSchedule/ManualSetting.tsx +69 -0
- package/src/modules/timeSchedule/MoodSetting.tsx +66 -0
- package/src/modules/timeSchedule/ScheduleScene.tsx +138 -0
- package/src/modules/timeSchedule/SingleLightView.tsx +254 -0
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +480 -0
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +323 -0
- package/src/modules/timeSchedule/mix/MixLightBean.ts +10 -0
- package/src/modules/timeSchedule/mix/MixLightView.tsx +221 -0
- package/src/modules/timeSchedule/utils.ts +7 -0
- package/src/modules/timer/TimerPage.tsx +409 -406
- package/src/modules/timer/{timerPageAction.ts → TimerPageAction.ts} +91 -91
- package/tsconfig.json +50 -50
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React, { useCallback, useEffect } from 'react'
|
|
2
|
+
import { View } from 'react-native'
|
|
3
|
+
import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
|
|
4
|
+
|
|
5
|
+
import { Utils as lampUtils } from "@tuya/tuya-panel-lamp-sdk"
|
|
6
|
+
import { isDIMLamp, isGARDOT, isGlassRGBWLamp, isOnlyRGBLamp, isRGBLamp, isRGBWLamp, isTWLamp } from '@ledvance/base/src/utils/Support'
|
|
7
|
+
import { Utils } from 'tuya-panel-kit'
|
|
8
|
+
import { useReactive } from 'ahooks'
|
|
9
|
+
import { getHSVByHex, getHexByHSV, hsv2Hex } from '@ledvance/base/src/utils'
|
|
10
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
11
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
12
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
13
|
+
import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
|
|
14
|
+
import { mapFloatToRange } from '@ledvance/base/src/utils'
|
|
15
|
+
import { COLOUR, WHITE } from '../hooks/DeviceDpStateHooks'
|
|
16
|
+
const { isSupportBright, isSupportTemp } = lampUtils.SupportUtils
|
|
17
|
+
|
|
18
|
+
const { convertX: cx } = Utils.RatioUtils
|
|
19
|
+
|
|
20
|
+
interface SingleLightViewProps {
|
|
21
|
+
scheduleItem: any
|
|
22
|
+
dpCodes: Record<string, string>
|
|
23
|
+
setEnable: (enable: boolean) => void
|
|
24
|
+
setSendDps: (dp: Record<string, any>) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function SingleLightView(props: SingleLightViewProps) {
|
|
28
|
+
const { scheduleItem, dpCodes } = props
|
|
29
|
+
const state = useReactive({
|
|
30
|
+
enable: true,
|
|
31
|
+
isColor: true,
|
|
32
|
+
h: 0,
|
|
33
|
+
s: 100,
|
|
34
|
+
v: 100,
|
|
35
|
+
temperature: 50,
|
|
36
|
+
brightness: 50,
|
|
37
|
+
putControl: Symbol(),
|
|
38
|
+
flag: Symbol()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (props.scheduleItem) {
|
|
43
|
+
if (scheduleItem.dps[dpCodes.switch_led] !== undefined) {
|
|
44
|
+
state.enable = scheduleItem.dps[dpCodes.switch_led]
|
|
45
|
+
}
|
|
46
|
+
if (scheduleItem.dps[dpCodes.work_mode] !== undefined) {
|
|
47
|
+
state.isColor = scheduleItem.dps[dpCodes.work_mode] === COLOUR
|
|
48
|
+
}
|
|
49
|
+
const hsv = getHSVByHex(props.scheduleItem.dps[props.dpCodes.colour_data] || '0000000003e8');
|
|
50
|
+
state.h = hsv.h;
|
|
51
|
+
state.s = Math.round(hsv.s / 10);
|
|
52
|
+
state.v = Math.round(hsv.v / 10);
|
|
53
|
+
}
|
|
54
|
+
}, [])
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const dpRecord = getSendDps()
|
|
58
|
+
props.setSendDps(dpRecord)
|
|
59
|
+
}, [state.flag])
|
|
60
|
+
|
|
61
|
+
const getSendDps = () => {
|
|
62
|
+
if (isDIMLamp(dpCodes)) {
|
|
63
|
+
return {
|
|
64
|
+
[dpCodes.bright_value]: state.brightness * 10,
|
|
65
|
+
};
|
|
66
|
+
}else if (isTWLamp(dpCodes)) {
|
|
67
|
+
return {
|
|
68
|
+
[dpCodes.work_mode]: WHITE,
|
|
69
|
+
[dpCodes.bright_value]: state.brightness * 10,
|
|
70
|
+
[dpCodes.temp_value]: state.temperature * 10,
|
|
71
|
+
};
|
|
72
|
+
}else if (isRGBWLamp(dpCodes)) {
|
|
73
|
+
if (state.isColor) {
|
|
74
|
+
const colorString = getHexByHSV({
|
|
75
|
+
h: state.h,
|
|
76
|
+
s: state.s * 10,
|
|
77
|
+
v: state.v * 10,
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
[dpCodes.work_mode]: COLOUR,
|
|
81
|
+
[dpCodes.colour_data]: colorString,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
[dpCodes.work_mode]: WHITE,
|
|
86
|
+
[dpCodes.temp_value]: state.temperature * 10,
|
|
87
|
+
[dpCodes.bright_value]: state.brightness * 10,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
} else if (isGlassRGBWLamp(dpCodes)) {
|
|
91
|
+
const colorString = getHexByHSV({
|
|
92
|
+
h: state.h,
|
|
93
|
+
s: state.s * 10,
|
|
94
|
+
v: state.v * 10,
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
[dpCodes.work_mode]: COLOUR,
|
|
98
|
+
[dpCodes.colour_data]: colorString,
|
|
99
|
+
};
|
|
100
|
+
} else if (isGARDOT(dpCodes)) {
|
|
101
|
+
const colorString = getHexByHSV({
|
|
102
|
+
h: state.h,
|
|
103
|
+
s: state.s * 10,
|
|
104
|
+
v: state.v * 10,
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
[dpCodes.work_mode]: COLOUR,
|
|
108
|
+
[dpCodes.colour_data]: colorString,
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
const colorString = getHexByHSV({
|
|
112
|
+
h: state.h,
|
|
113
|
+
s: state.s * 10,
|
|
114
|
+
v: state.v * 10,
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
[dpCodes.switch_led]: true,
|
|
118
|
+
[dpCodes.colour_data]: colorString,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const setHSVState = useCallback((h, s, v) => {
|
|
124
|
+
state.h = h
|
|
125
|
+
state.s = s
|
|
126
|
+
state.v = v
|
|
127
|
+
state.putControl = Symbol()
|
|
128
|
+
}, [])
|
|
129
|
+
|
|
130
|
+
const setTemperatureState = useCallback(temperature => {
|
|
131
|
+
state.temperature = temperature
|
|
132
|
+
state.putControl = Symbol()
|
|
133
|
+
}, [])
|
|
134
|
+
|
|
135
|
+
const setBrightnessState = useCallback(brightness => {
|
|
136
|
+
state.brightness = brightness
|
|
137
|
+
state.putControl = Symbol()
|
|
138
|
+
}, [])
|
|
139
|
+
|
|
140
|
+
// useEffect(() =>{
|
|
141
|
+
// putControlDataAction()
|
|
142
|
+
// }, [state.putControl])
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const setEnableStateAction = useCallback(async (enable) => {
|
|
146
|
+
state.enable = enable
|
|
147
|
+
props.setEnable(enable)
|
|
148
|
+
// await userOperation(deviceId, true)
|
|
149
|
+
// await setEnable(deviceId, state.enable)
|
|
150
|
+
// if (!enable) await setWorkMode(deviceId, state.isColor ? COLOUR : WHITE)
|
|
151
|
+
}, [])
|
|
152
|
+
|
|
153
|
+
const setWorkModeStateAction = useCallback(async isColorMode => {
|
|
154
|
+
state.isColor = isColorMode
|
|
155
|
+
state.flag = Symbol()
|
|
156
|
+
// await userOperation(deviceId, true)
|
|
157
|
+
// await setWorkMode(deviceId, state.isColor ? COLOUR : WHITE)
|
|
158
|
+
}, [])
|
|
159
|
+
|
|
160
|
+
const setColourStateAction = useCallback(async (h, s, v) => {
|
|
161
|
+
setHSVState(h, s, v)
|
|
162
|
+
state.flag = Symbol()
|
|
163
|
+
// await userOperation(deviceId, true)
|
|
164
|
+
}, [])
|
|
165
|
+
|
|
166
|
+
const setTemperatureStateAction = useCallback(async (cct: number) => {
|
|
167
|
+
setTemperatureState(cct)
|
|
168
|
+
state.flag = Symbol()
|
|
169
|
+
// await userOperation(deviceId, true)
|
|
170
|
+
// await setTemperature(deviceId, state.temperature * 10)
|
|
171
|
+
}, [])
|
|
172
|
+
|
|
173
|
+
const setBrightnessStateAction = useCallback(async brightness => {
|
|
174
|
+
setBrightnessState(brightness)
|
|
175
|
+
state.flag = Symbol()
|
|
176
|
+
// await userOperation(deviceId, true)
|
|
177
|
+
// await setBrightness(deviceId, state.brightness * 10)
|
|
178
|
+
}, [])
|
|
179
|
+
|
|
180
|
+
/* // 调节预览
|
|
181
|
+
const putControlDataAction = () =>{
|
|
182
|
+
const mode = 1 // 0: 直接 1: 渐变
|
|
183
|
+
const hasColorMode = isRGBLamp() || isRGBWLamp() // 是否支持color mode
|
|
184
|
+
const isColorMode = isOnlyRGBLamp() || (hasColorMode && workMode === COLOUR) // 当前是否是color mode
|
|
185
|
+
|
|
186
|
+
let colorData = !isColorMode ? '000000000000' : getHexByHSV({
|
|
187
|
+
h: state.h,
|
|
188
|
+
s: state.s * 10,
|
|
189
|
+
v: state.v * 10,
|
|
190
|
+
})
|
|
191
|
+
let whiteData = isColorMode ? '00000000' : getHexByBT({
|
|
192
|
+
b: isSupportBrightness() ? state.brightness * 10 : (hasColorMode ? state.v * 10 : '0000'),
|
|
193
|
+
t: isSupportTemperature() ? state.temperature * 10 : (hasColorMode ? state.s * 10 : '0000')
|
|
194
|
+
})
|
|
195
|
+
const hex = mode + colorData + whiteData
|
|
196
|
+
putControlData(deviceId, hex)
|
|
197
|
+
} */
|
|
198
|
+
|
|
199
|
+
const getColorBlockColor = useCallback(() => {
|
|
200
|
+
const s = Math.round(mapFloatToRange(state.s / 100, 30, 100))
|
|
201
|
+
if (isOnlyRGBLamp(props.dpCodes)) {
|
|
202
|
+
return hsv2Hex(state.h, s, 100)
|
|
203
|
+
}
|
|
204
|
+
if (isTWLamp(props.dpCodes)) {
|
|
205
|
+
return cctToColor(state.temperature.toFixed())
|
|
206
|
+
}
|
|
207
|
+
if (isDIMLamp(props.dpCodes)) {
|
|
208
|
+
return '#fff'
|
|
209
|
+
}
|
|
210
|
+
if (state.isColor) {
|
|
211
|
+
return hsv2Hex(state.h, s, 100)
|
|
212
|
+
}
|
|
213
|
+
if (isSupportTemp()) {
|
|
214
|
+
return cctToColor(state.temperature.toFixed())
|
|
215
|
+
}
|
|
216
|
+
}, [state.temperature])
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<Card style={{ marginVertical: cx(12) }}>
|
|
220
|
+
<View>
|
|
221
|
+
<LdvSwitch
|
|
222
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
223
|
+
color={getColorBlockColor()}
|
|
224
|
+
colorAlpha={1}
|
|
225
|
+
enable={state.enable}
|
|
226
|
+
setEnable={setEnableStateAction} />
|
|
227
|
+
{state.enable &&
|
|
228
|
+
<LampAdjustView
|
|
229
|
+
isDIMLamp={isDIMLamp(props.dpCodes)}
|
|
230
|
+
isRGBLamp={isRGBLamp(props.dpCodes)}
|
|
231
|
+
isOnlyRGBLamp={isOnlyRGBLamp(props.dpCodes)}
|
|
232
|
+
isTWLamp={isTWLamp(props.dpCodes)}
|
|
233
|
+
isRGBWLamp={isRGBWLamp(props.dpCodes)}
|
|
234
|
+
isSupportBrightness={isSupportBright()}
|
|
235
|
+
isSupportTemperature={isSupportTemp()}
|
|
236
|
+
isColorMode={state.isColor}
|
|
237
|
+
setIsColorMode={setWorkModeStateAction}
|
|
238
|
+
h={state.h}
|
|
239
|
+
s={state.s}
|
|
240
|
+
v={state.v}
|
|
241
|
+
onHSVChange={setHSVState}
|
|
242
|
+
onHSVChangeComplete={setColourStateAction}
|
|
243
|
+
colorTemp={state.temperature}
|
|
244
|
+
brightness={state.brightness}
|
|
245
|
+
onCCTChange={setTemperatureState}
|
|
246
|
+
onCCTChangeComplete={setTemperatureStateAction}
|
|
247
|
+
onBrightnessChange={setBrightnessState}
|
|
248
|
+
onBrightnessChangeComplete={setBrightnessStateAction}
|
|
249
|
+
// min={1}
|
|
250
|
+
/>}
|
|
251
|
+
</View>
|
|
252
|
+
</Card>
|
|
253
|
+
)
|
|
254
|
+
}
|