@ledvance/ui-biz-bundle 1.1.4 → 1.1.7
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/flags/FlagActions.ts +205 -0
- package/src/modules/flags/FlagEditPage.tsx +432 -0
- package/src/modules/flags/FlagInfo.tsx +298 -0
- package/src/modules/flags/FlagItem.tsx +84 -0
- package/src/modules/flags/FlagPage.tsx +200 -0
- package/src/modules/mood/DynamicMoodEditorPage.tsx +3 -3
- package/src/modules/mood/FantasyMoodEditPage.tsx +4 -5
- package/src/modules/mood/MoodPage.tsx +38 -39
- package/src/modules/mood/StaticMoodEditorPage.tsx +4 -5
- package/src/modules/timeSchedule/MoodSetting.tsx +2 -0
- package/src/navigation/Routers.ts +24 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
2
|
+
import { SceneNodeTransitionMode } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneInfo";
|
|
3
|
+
|
|
4
|
+
type HSV = {
|
|
5
|
+
h: number
|
|
6
|
+
s: number
|
|
7
|
+
v: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type BT = {
|
|
11
|
+
brightness: number
|
|
12
|
+
colorTemp: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FlagItemInfo {
|
|
16
|
+
id: number
|
|
17
|
+
version?: number
|
|
18
|
+
mode: number
|
|
19
|
+
speed: number
|
|
20
|
+
colors: HSV[]
|
|
21
|
+
whiteColors: BT []
|
|
22
|
+
fanEnable?: boolean
|
|
23
|
+
fanSpeed?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FlagUiInfo extends FlagItemInfo{
|
|
27
|
+
name: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const defFlagList: FlagUiInfo[] = [
|
|
31
|
+
{
|
|
32
|
+
id: 255,
|
|
33
|
+
version: 0,
|
|
34
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
35
|
+
speed: 70,
|
|
36
|
+
name: I18n.getLang('country_DE'),
|
|
37
|
+
whiteColors: [
|
|
38
|
+
{ brightness: 100, colorTemp: 0},
|
|
39
|
+
],
|
|
40
|
+
colors: [
|
|
41
|
+
{h: 48, s: 100, v: 100},
|
|
42
|
+
{h: 360, s: 100, v: 86},
|
|
43
|
+
{h: 0, s: 0, v:0}],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 254,
|
|
47
|
+
version: 0,
|
|
48
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
49
|
+
speed: 70,
|
|
50
|
+
name: I18n.getLang('country_BE'),
|
|
51
|
+
whiteColors: [
|
|
52
|
+
{ brightness: 100, colorTemp: 0},
|
|
53
|
+
],
|
|
54
|
+
colors: [{h: 350, s: 92, v: 78}, {h: 48, s: 100, v: 100}, {h: 25, s: 15, v: 17}]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 253,
|
|
58
|
+
version: 0,
|
|
59
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
60
|
+
speed: 70,
|
|
61
|
+
name: I18n.getLang('country_FR'),
|
|
62
|
+
whiteColors: [
|
|
63
|
+
{ brightness: 100, colorTemp: 0},
|
|
64
|
+
],
|
|
65
|
+
colors: [{h: 355, s: 82, v: 92}, {h: 0, s: 0, v: 100}, {h: 212, s: 100, v: 32}]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 252,
|
|
69
|
+
version: 0,
|
|
70
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
71
|
+
speed: 70,
|
|
72
|
+
name: I18n.getLang('country_PT'),
|
|
73
|
+
whiteColors: [
|
|
74
|
+
{ brightness: 100, colorTemp: 0},
|
|
75
|
+
],
|
|
76
|
+
colors: [{h: 4, s: 87, v: 85}, {h: 4, s: 87, v: 85}, {h: 150, s: 96, v: 41}]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 251,
|
|
80
|
+
version: 0,
|
|
81
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
82
|
+
speed: 70,
|
|
83
|
+
name: I18n.getLang('country_scotland'),
|
|
84
|
+
whiteColors: [
|
|
85
|
+
{ brightness: 100, colorTemp: 0},
|
|
86
|
+
],
|
|
87
|
+
colors: [{h: 209, s: 100, v: 72}, {h: 0, s: 0, v: 100}, {h: 209, s: 100, v: 72}]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 250,
|
|
91
|
+
version: 0,
|
|
92
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
93
|
+
speed: 70,
|
|
94
|
+
name: I18n.getLang('country_ES'),
|
|
95
|
+
whiteColors: [
|
|
96
|
+
{ brightness: 100, colorTemp: 0},
|
|
97
|
+
],
|
|
98
|
+
colors: [{h: 357, s: 87, v: 66}, {h: 47, s: 100, v: 94}, {h: 357, s: 87, v: 66}]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 249,
|
|
102
|
+
version: 0,
|
|
103
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
104
|
+
speed: 70,
|
|
105
|
+
name: I18n.getLang('country_TR'),
|
|
106
|
+
whiteColors: [
|
|
107
|
+
{ brightness: 100, colorTemp: 0},
|
|
108
|
+
],
|
|
109
|
+
colors: [{h: 350, s: 92, v: 78}, {h: 350, s: 92, v: 78}, {h: 0, s: 0, v: 100}]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 248,
|
|
113
|
+
version: 0,
|
|
114
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
115
|
+
speed: 70,
|
|
116
|
+
name: I18n.getLang('country_AT'),
|
|
117
|
+
whiteColors: [
|
|
118
|
+
{ brightness: 100, colorTemp: 0},
|
|
119
|
+
],
|
|
120
|
+
colors: [{h: 355, s: 78, v: 93}, {h: 0, s: 0, v: 100}, {h: 355, s: 78, v: 93}]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 247,
|
|
124
|
+
version: 0,
|
|
125
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
126
|
+
speed: 70,
|
|
127
|
+
name: I18n.getLang('country_england'),
|
|
128
|
+
whiteColors: [
|
|
129
|
+
{ brightness: 100, colorTemp: 0},
|
|
130
|
+
],
|
|
131
|
+
colors: [{h: 0, s: 0, v: 100}, {h: 353, s: 91, v: 80}, {h: 0, s: 0, v: 100}]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 246,
|
|
135
|
+
version: 0,
|
|
136
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
137
|
+
speed: 70,
|
|
138
|
+
name: I18n.getLang('country_HU'),
|
|
139
|
+
whiteColors: [
|
|
140
|
+
{ brightness: 100, colorTemp: 0},
|
|
141
|
+
],
|
|
142
|
+
colors: [{h: 133, s: 36, v: 43}, {h: 0, s: 0, v: 100}, {h: 354, s: 80, v: 80}]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 245,
|
|
146
|
+
version: 0,
|
|
147
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
148
|
+
speed: 70,
|
|
149
|
+
name: I18n.getLang('country_SK'),
|
|
150
|
+
whiteColors: [
|
|
151
|
+
{ brightness: 100, colorTemp: 0},
|
|
152
|
+
],
|
|
153
|
+
colors: [{h: 357, s: 88, v: 93}, {h: 213, s: 93, v: 63}, {h: 0, s: 0, v: 100}]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: 244,
|
|
157
|
+
version: 0,
|
|
158
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
159
|
+
speed: 70,
|
|
160
|
+
name: I18n.getLang('country_AL'),
|
|
161
|
+
whiteColors: [
|
|
162
|
+
{ brightness: 100, colorTemp: 0},
|
|
163
|
+
],
|
|
164
|
+
colors: [{h: 4, s: 87, v: 85}, {h: 0, s: 0, v:0}, {h: 4, s: 87, v: 85}]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 243,
|
|
168
|
+
version: 0,
|
|
169
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
170
|
+
speed: 70,
|
|
171
|
+
name: I18n.getLang('country_DK'),
|
|
172
|
+
whiteColors: [
|
|
173
|
+
{ brightness: 100, colorTemp: 0},
|
|
174
|
+
],
|
|
175
|
+
colors: [{h: 350, s: 92, v: 78}, {h: 0, s: 0, v:0}, {h: 350, s: 92, v: 78}]
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: 242,
|
|
179
|
+
version: 0,
|
|
180
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
181
|
+
speed: 70,
|
|
182
|
+
name: I18n.getLang('country_NL'),
|
|
183
|
+
whiteColors: [
|
|
184
|
+
{ brightness: 100, colorTemp: 0},
|
|
185
|
+
],
|
|
186
|
+
colors: [{h: 217, s: 100, v: 64}, {h: 0, s: 0, v:0}, {h: 350, s: 92, v: 78}]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: 241,
|
|
190
|
+
version: 0,
|
|
191
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
192
|
+
speed: 70,
|
|
193
|
+
name: I18n.getLang('country_RO'),
|
|
194
|
+
whiteColors: [
|
|
195
|
+
{ brightness: 100, colorTemp: 0},
|
|
196
|
+
],
|
|
197
|
+
colors: [{h: 353, s: 91, v: 80}, {h: 48, s: 91, v: 98}, {h: 219, s: 100, v: 49}]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: 240,
|
|
201
|
+
version: 0,
|
|
202
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
203
|
+
speed: 70,
|
|
204
|
+
name: I18n.getLang('country_CH'),
|
|
205
|
+
whiteColors: [
|
|
206
|
+
{ brightness: 100, colorTemp: 0},
|
|
207
|
+
],
|
|
208
|
+
colors: [{h: 4, s: 87, v: 85}, {h: 0, s: 0, v: 100}, {h: 4, s: 87, v: 85}]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
id: 239,
|
|
212
|
+
version: 0,
|
|
213
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
214
|
+
speed: 70,
|
|
215
|
+
name: I18n.getLang('country_RS'),
|
|
216
|
+
whiteColors: [
|
|
217
|
+
{ brightness: 100, colorTemp: 0},
|
|
218
|
+
],
|
|
219
|
+
colors: [{h: 0, s: 0, v: 100}, {h: 210, s: 89, v: 46}, {h: 357, s: 72, v: 77}]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: 238,
|
|
223
|
+
version: 0,
|
|
224
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
225
|
+
speed: 70,
|
|
226
|
+
name: I18n.getLang('country_IT'),
|
|
227
|
+
whiteColors: [
|
|
228
|
+
{ brightness: 100, colorTemp: 0},
|
|
229
|
+
],
|
|
230
|
+
colors: [{h: 366, s: 83, v: 80}, {h: 212, s: 4, v: 100}, {h: 149, s: 100, v: 54}]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: 237,
|
|
234
|
+
version: 0,
|
|
235
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
236
|
+
speed: 70,
|
|
237
|
+
name: I18n.getLang('country_CZ'),
|
|
238
|
+
whiteColors: [
|
|
239
|
+
{ brightness: 100, colorTemp: 0},
|
|
240
|
+
],
|
|
241
|
+
colors: [{h: 358, s: 90, v: 84}, {h: 0, s: 0, v: 100}, {h: 211, s: 86, v: 49}]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
id: 236,
|
|
245
|
+
version: 0,
|
|
246
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
247
|
+
speed: 70,
|
|
248
|
+
name: I18n.getLang('country_SI'),
|
|
249
|
+
whiteColors: [
|
|
250
|
+
{ brightness: 100, colorTemp: 0},
|
|
251
|
+
],
|
|
252
|
+
colors: [{h: 360, s: 100, v: 100}, {h: 217, s: 100, v: 64}, {h: 0, s: 0, v: 100}]
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
id: 235,
|
|
256
|
+
version: 0,
|
|
257
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
258
|
+
speed: 70,
|
|
259
|
+
name: I18n.getLang('country_HR'),
|
|
260
|
+
whiteColors: [
|
|
261
|
+
{ brightness: 100, colorTemp: 0},
|
|
262
|
+
],
|
|
263
|
+
colors: [{h: 0, s: 0, v: 100}, {h: 220, s: 89, v: 54}, {h: 2, s: 89, v: 90}]
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: 234,
|
|
267
|
+
version: 0,
|
|
268
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
269
|
+
speed: 70,
|
|
270
|
+
name: I18n.getLang('country_SE'),
|
|
271
|
+
whiteColors: [
|
|
272
|
+
{ brightness: 100, colorTemp: 0},
|
|
273
|
+
],
|
|
274
|
+
colors: [{h: 201, s: 100, v: 65}, {h: 48, s: 99, v: 99}, {h: 201, s: 100, v: 65}]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: 233,
|
|
278
|
+
version: 0,
|
|
279
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
280
|
+
speed: 70,
|
|
281
|
+
name: I18n.getLang('country_NO'),
|
|
282
|
+
whiteColors: [
|
|
283
|
+
{ brightness: 100, colorTemp: 0},
|
|
284
|
+
],
|
|
285
|
+
colors: [{h: 0, s: 0, v: 100}, {h: 218, s: 100, v: 35}, {h: 347, s: 93, v: 72}]
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
id: 232,
|
|
289
|
+
version: 0,
|
|
290
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
291
|
+
speed: 70,
|
|
292
|
+
name: I18n.getLang('country_PL'),
|
|
293
|
+
whiteColors: [
|
|
294
|
+
{ brightness: 100, colorTemp: 0},
|
|
295
|
+
],
|
|
296
|
+
colors: [{h: 348, s: 90, v: 86}, {h: 0, s: 0, v: 100}]
|
|
297
|
+
},
|
|
298
|
+
]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { StyleSheet, View, Text, ViewStyle } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
4
|
+
import { SwitchButton, Utils } from 'tuya-panel-kit'
|
|
5
|
+
import MoodColorsLine from '@ledvance/base/src/components/MoodColorsLine'
|
|
6
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
7
|
+
|
|
8
|
+
const cx = Utils.RatioUtils.convertX
|
|
9
|
+
|
|
10
|
+
interface RecommendMoodItemProps {
|
|
11
|
+
enable: boolean
|
|
12
|
+
title: string
|
|
13
|
+
colors: string[]
|
|
14
|
+
style?: ViewStyle
|
|
15
|
+
onPress?: () => void
|
|
16
|
+
onSwitch: (enable: boolean) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function FlagItem(props: RecommendMoodItemProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Card
|
|
22
|
+
style={[styles.card, props.style]}
|
|
23
|
+
onPress={props.onPress}>
|
|
24
|
+
<View>
|
|
25
|
+
<Spacer height={cx(16)} />
|
|
26
|
+
<View style={styles.headline}>
|
|
27
|
+
<Text style={styles.headText}>{props.title}</Text>
|
|
28
|
+
<SwitchButton
|
|
29
|
+
thumbStyle={{ elevation: 0 }}
|
|
30
|
+
value={props.enable}
|
|
31
|
+
onValueChange={props.onSwitch} />
|
|
32
|
+
</View>
|
|
33
|
+
<Spacer />
|
|
34
|
+
<View style={styles.gradientItem}>
|
|
35
|
+
<MoodColorsLine
|
|
36
|
+
type={'separate'}
|
|
37
|
+
nodeStyle={{ borderColor: '#ccc', borderWidth: 1 }}
|
|
38
|
+
colors={props.colors} />
|
|
39
|
+
</View>
|
|
40
|
+
<Spacer height={cx(16)} />
|
|
41
|
+
</View>
|
|
42
|
+
</Card>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
card: {
|
|
48
|
+
marginHorizontal: cx(24),
|
|
49
|
+
},
|
|
50
|
+
headline: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
marginHorizontal: cx(16),
|
|
53
|
+
},
|
|
54
|
+
headText: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
color: '#000',
|
|
57
|
+
fontSize: cx(16),
|
|
58
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
59
|
+
lineHeight: cx(20),
|
|
60
|
+
},
|
|
61
|
+
gradientItem: {
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
},
|
|
64
|
+
gradient: {
|
|
65
|
+
borderRadius: cx(8),
|
|
66
|
+
},
|
|
67
|
+
moodTypeItem: {
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
},
|
|
70
|
+
moodTypeLabel: {
|
|
71
|
+
marginStart: cx(16),
|
|
72
|
+
paddingHorizontal: cx(12.5),
|
|
73
|
+
backgroundColor: '#E6E7E8',
|
|
74
|
+
borderRadius: cx(8),
|
|
75
|
+
},
|
|
76
|
+
moodTypeLabelText: {
|
|
77
|
+
height: cx(16),
|
|
78
|
+
color: '#000000DD',
|
|
79
|
+
fontSize: cx(10),
|
|
80
|
+
textAlignVertical: 'center',
|
|
81
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
82
|
+
lineHeight: cx(16),
|
|
83
|
+
},
|
|
84
|
+
})
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
|
2
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
3
|
+
import { useDeviceId, useDeviceInfo } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
4
|
+
import { FlatList } from "react-native";
|
|
5
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
6
|
+
import { Utils } from "tuya-panel-kit";
|
|
7
|
+
import FlagItem from "./FlagItem";
|
|
8
|
+
import { FlagUiInfo } from "./FlagInfo";
|
|
9
|
+
import { getRemoteFlag, saveFlag, useFlag } from "./FlagActions";
|
|
10
|
+
import { useRoute, useNavigation } from '@react-navigation/core'
|
|
11
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
12
|
+
import { useReactive } from "ahooks";
|
|
13
|
+
import { cloneDeep, difference, isEqual, last, map, range } from "lodash";
|
|
14
|
+
import { ui_biz_routerKey} from "../../navigation/Routers";
|
|
15
|
+
import res from "@ledvance/base/src/res";
|
|
16
|
+
import { hsv2Hex } from "@ledvance/base/src/utils";
|
|
17
|
+
import { SceneNodeTransitionMode } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneInfo";
|
|
18
|
+
import { Result } from "@ledvance/base/src/models/modules/Result";
|
|
19
|
+
import { useDps } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
20
|
+
import { WORK_MODE } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
21
|
+
const cx = Utils.RatioUtils.convertX
|
|
22
|
+
|
|
23
|
+
export interface FlagPageProps {
|
|
24
|
+
isSupportColor?: boolean
|
|
25
|
+
isSupportBrightness?: boolean
|
|
26
|
+
isSupportTemperature?: boolean
|
|
27
|
+
isSupportFan?: boolean
|
|
28
|
+
isSupportUVCFan?: boolean
|
|
29
|
+
isSupportMixScene?: boolean
|
|
30
|
+
drawToolLight?: {
|
|
31
|
+
drawToolCode: string
|
|
32
|
+
drawToolObj2dp: (colors: string[]) => string
|
|
33
|
+
drawToolDp2Obj: (dp: string) => string[]
|
|
34
|
+
}
|
|
35
|
+
getRemoteMoodList?: (devId: string) => Promise<Result<any>>
|
|
36
|
+
sceneDataCode?: string
|
|
37
|
+
workModeCode: string
|
|
38
|
+
switchLed?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const FlagPage = () => {
|
|
42
|
+
const params = useRoute().params as FlagPageProps
|
|
43
|
+
const devInfo = useDeviceInfo()
|
|
44
|
+
const devId = useDeviceId()
|
|
45
|
+
const navigation = useNavigation()
|
|
46
|
+
const [, setDps] = useDps()
|
|
47
|
+
const [flagState, setFlag] = useFlag((params.sceneDataCode || params?.drawToolLight?.drawToolCode)!!, {
|
|
48
|
+
isFan: params.isSupportFan,
|
|
49
|
+
isUVCFan: params.isSupportUVCFan,
|
|
50
|
+
isMixLight: params.isSupportMixScene,
|
|
51
|
+
...params
|
|
52
|
+
})
|
|
53
|
+
const state = useReactive({
|
|
54
|
+
loading: true,
|
|
55
|
+
flags: [] as FlagUiInfo[],
|
|
56
|
+
moods: [] as any[]
|
|
57
|
+
})
|
|
58
|
+
const flagId = useMemo(() =>{
|
|
59
|
+
if(flagState.colors !== undefined){
|
|
60
|
+
const flag = state.flags.find(item => {
|
|
61
|
+
const hexColors = item.colors.map(c => hsv2Hex(c.h, c.s, c.v).toLocaleUpperCase())
|
|
62
|
+
return isEqual(hexColors, flagState.colors)
|
|
63
|
+
})
|
|
64
|
+
return flag?.id
|
|
65
|
+
}
|
|
66
|
+
if(flagState.id !== undefined){
|
|
67
|
+
return flagState
|
|
68
|
+
}
|
|
69
|
+
return -1
|
|
70
|
+
}, [JSON.stringify(flagState), JSON.stringify(state.flags)])
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
getRemoteFlagInfo().then()
|
|
75
|
+
if(params.getRemoteMoodList){
|
|
76
|
+
params.getRemoteMoodList(devId).then(res =>{
|
|
77
|
+
if(res.success && Array.isArray(res.data)){
|
|
78
|
+
state.moods = res.data
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
const getRemoteFlagInfo = async () => {
|
|
85
|
+
const res = await getRemoteFlag(devId)
|
|
86
|
+
if (res.success) {
|
|
87
|
+
state.flags = cloneDeep(res.data) || []
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const navigationRoute = (mode: 'add' | 'edit', currentMood?: FlagUiInfo) => {
|
|
92
|
+
const path = ui_biz_routerKey.ui_biz_flag_page_edit
|
|
93
|
+
navigation.navigate(path, {
|
|
94
|
+
mode,
|
|
95
|
+
moods: state.flags,
|
|
96
|
+
currentMood,
|
|
97
|
+
moduleParams: params,
|
|
98
|
+
modDeleteFlag
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const modDeleteFlag = async (mode: 'add' | 'edit' | 'del', currentMood: FlagUiInfo) => {
|
|
103
|
+
const checkedMood: FlagUiInfo = {
|
|
104
|
+
...currentMood,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let newScene: FlagUiInfo[] = []
|
|
108
|
+
if (mode === 'add') {
|
|
109
|
+
newScene = [
|
|
110
|
+
checkedMood,
|
|
111
|
+
...state.flags,
|
|
112
|
+
]
|
|
113
|
+
} else if (mode === 'del') {
|
|
114
|
+
newScene = state.flags.filter(item => item.id !== checkedMood.id)
|
|
115
|
+
} else {
|
|
116
|
+
newScene = state.flags.map(item => {
|
|
117
|
+
if (item.id === checkedMood.id) {
|
|
118
|
+
return checkedMood
|
|
119
|
+
}
|
|
120
|
+
return item
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
const mood = mode === 'del' ? (newScene.length === 0 ? undefined : newScene[0]) : checkedMood
|
|
124
|
+
const res = await saveFlag(devId, cloneDeep(newScene))
|
|
125
|
+
if (res.success) {
|
|
126
|
+
state.flags = cloneDeep(newScene)
|
|
127
|
+
if(mood){
|
|
128
|
+
setFlag(mood)
|
|
129
|
+
}else{
|
|
130
|
+
setDps({[params.workModeCode!!]: params.isSupportColor ? WORK_MODE.COLOUR : WORK_MODE.WHITE})
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
success: true
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
success: false
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Page
|
|
143
|
+
headlineText={I18n.getLang('Feature_devicepanel_flags')}
|
|
144
|
+
backText={devInfo.name}
|
|
145
|
+
headlineIcon={res.add}
|
|
146
|
+
onHeadlineIconClick={() => {
|
|
147
|
+
const useIds = map([
|
|
148
|
+
...state.flags,
|
|
149
|
+
...state.moods
|
|
150
|
+
], 'id')
|
|
151
|
+
console.log(useIds, '< --- useIds')
|
|
152
|
+
const idRange = range(0, 256)
|
|
153
|
+
const unuseId = last(difference(idRange, useIds))
|
|
154
|
+
if(unuseId !== undefined){
|
|
155
|
+
navigationRoute('add', newFlag(unuseId))
|
|
156
|
+
}
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<FlatList
|
|
160
|
+
data={state.flags}
|
|
161
|
+
renderItem={({ item }) => <FlagItem
|
|
162
|
+
enable={flagId === item.id}
|
|
163
|
+
title={item.name}
|
|
164
|
+
colors={item.colors.map(item => hsv2Hex(item.h, item.s, item.v))}
|
|
165
|
+
onSwitch={async (enable) => {
|
|
166
|
+
if (enable) {
|
|
167
|
+
await setFlag(item)
|
|
168
|
+
}
|
|
169
|
+
}}
|
|
170
|
+
onPress={() => {
|
|
171
|
+
navigationRoute('edit', item)
|
|
172
|
+
}}
|
|
173
|
+
/>}
|
|
174
|
+
keyExtractor={item => item.name}
|
|
175
|
+
ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
|
|
176
|
+
ItemSeparatorComponent={() => (<Spacer />)}
|
|
177
|
+
ListFooterComponent={() => (<Spacer />)}
|
|
178
|
+
/>
|
|
179
|
+
</Page>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export const newFlag = (id: number) => {
|
|
184
|
+
return {
|
|
185
|
+
version: 0,
|
|
186
|
+
id,
|
|
187
|
+
name: '',
|
|
188
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
189
|
+
speed: 70,
|
|
190
|
+
colors: [
|
|
191
|
+
{ h: 48, s: 100, v: 100 },
|
|
192
|
+
{ h: 360, s: 100, v: 86 },
|
|
193
|
+
],
|
|
194
|
+
whiteColors: [{ brightness: 100, colorTemp: 0 }],
|
|
195
|
+
fanEnable: undefined,
|
|
196
|
+
fanSpeed: undefined
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default FlagPage
|
|
@@ -5,7 +5,7 @@ import {useNavigation, useRoute} from '@react-navigation/native'
|
|
|
5
5
|
import {StackNavigationProp} from '@react-navigation/stack'
|
|
6
6
|
import React, {useCallback, useEffect, useMemo} from 'react'
|
|
7
7
|
import {useReactive} from 'ahooks'
|
|
8
|
-
import {COLOUR, useWorkMode, WHITE} from 'hooks/DeviceDpStateHooks'
|
|
8
|
+
import {COLOUR, SCENE, useWorkMode, WHITE} from 'hooks/DeviceDpStateHooks'
|
|
9
9
|
import {hsv2Hex, mapFloatToRange} from '@ledvance/base/src/utils'
|
|
10
10
|
import {cctToColor} from '@ledvance/base/src/utils/cctUtils'
|
|
11
11
|
import res from '@ledvance/base/src/res'
|
|
@@ -38,7 +38,7 @@ const DynamicMoodEditorPage = () => {
|
|
|
38
38
|
const moduleParams = params.moduleParams
|
|
39
39
|
const deviceId = useDeviceId()
|
|
40
40
|
const [moodId, setScene] = useScene(moduleParams.sceneDpCode)
|
|
41
|
-
const [, setWorkMode] = useWorkMode(moduleParams.workModeDpCode)
|
|
41
|
+
const [workMode, setWorkMode] = useWorkMode(moduleParams.workModeDpCode)
|
|
42
42
|
const isUVCFan = isUVCFanDevice()
|
|
43
43
|
const role = useRole()
|
|
44
44
|
const state = useReactive<DynamicMoodEditorPageState>({
|
|
@@ -101,7 +101,7 @@ const DynamicMoodEditorPage = () => {
|
|
|
101
101
|
)
|
|
102
102
|
if (saveRes.success) {
|
|
103
103
|
if (list.length > 0) {
|
|
104
|
-
if (isDelete && currentMood.id === moodId) {
|
|
104
|
+
if (isDelete && currentMood.id === moodId && workMode === SCENE) {
|
|
105
105
|
const setSceneRes = await setScene(
|
|
106
106
|
deviceId,
|
|
107
107
|
list[0],
|
|
@@ -4,7 +4,7 @@ import { useNavigation, useRoute } from '@react-navigation/native'
|
|
|
4
4
|
import { StackNavigationProp } from '@react-navigation/stack'
|
|
5
5
|
import React, { useCallback, useEffect, useMemo } from 'react'
|
|
6
6
|
import { useReactive } from 'ahooks'
|
|
7
|
-
import { useWorkMode, COLOUR } from 'hooks/DeviceDpStateHooks'
|
|
7
|
+
import { useWorkMode, COLOUR, SCENE } from 'hooks/DeviceDpStateHooks'
|
|
8
8
|
import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils'
|
|
9
9
|
import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
|
|
10
10
|
import res from '@ledvance/base/src/res'
|
|
@@ -16,7 +16,7 @@ import Spacer from '@ledvance/base/src/components/Spacer'
|
|
|
16
16
|
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
17
17
|
import { Utils } from 'tuya-panel-kit'
|
|
18
18
|
import LdvSlider from '@ledvance/base/src/components/ldvSlider'
|
|
19
|
-
import { useDeviceId
|
|
19
|
+
import { useDeviceId } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
20
20
|
import TextButton from '@ledvance/base/src/components/TextButton'
|
|
21
21
|
import { stringLightSceneMode, stripLightSceneMode, StripSceneUIState, StripNodeInfo, StripLightSceneMode } from '../scene/SceneInfo'
|
|
22
22
|
import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton'
|
|
@@ -49,9 +49,8 @@ const FantasyMoodEditPage = () => {
|
|
|
49
49
|
const params = cloneDeep(routeParams)
|
|
50
50
|
const moduleParams = params.moduleParams
|
|
51
51
|
const deviceId = useDeviceId()
|
|
52
|
-
const [, setWorkMode] = useWorkMode(moduleParams.workModeDpCode)
|
|
52
|
+
const [workMode, setWorkMode] = useWorkMode(moduleParams.workModeDpCode)
|
|
53
53
|
const [, setFantasyScene] = useFantasyScene(params.moduleParams.sceneDpCode, params.moduleParams.workModeDpCode, params.moduleParams.switchLedDpCode, moduleParams.isStringLight)
|
|
54
|
-
const role = useRole()
|
|
55
54
|
const state = useReactive<FantasyMoodEditPageState>({
|
|
56
55
|
headline: '',
|
|
57
56
|
mood: params.currentMood,
|
|
@@ -107,7 +106,7 @@ const FantasyMoodEditPage = () => {
|
|
|
107
106
|
const saveRes = await saveFantasyScene(deviceId, params.moduleParams.featureId, list, moduleParams.isStringLight)
|
|
108
107
|
if (saveRes.success) {
|
|
109
108
|
if (list.length > 0) {
|
|
110
|
-
if (isDelete) {
|
|
109
|
+
if (isDelete && workMode === SCENE) {
|
|
111
110
|
await setFantasyScene(list[0])
|
|
112
111
|
} else {
|
|
113
112
|
await setFantasyScene(currentMood)
|