@ledvance/ui-biz-bundle 1.1.35 → 1.1.37
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 +19 -3
- package/src/modules/flags/FlagEditPage.tsx +1 -1
- package/src/modules/flags/FlagInfo.tsx +3 -3
- package/src/modules/flags/FlagPage.tsx +9 -3
- package/src/modules/mood/MixMood/AddMixMoodPage.tsx +333 -0
- package/src/modules/mood/MixMood/MixMoodActions.ts +128 -0
- package/src/modules/mood/MixMood/MixMoodEditPage.tsx +709 -0
- package/src/modules/mood/MixMood/MixMoodItem.tsx +133 -0
- package/src/modules/mood/MixMood/MixMoodPage.tsx +318 -0
- package/src/modules/mood/MixMood/MixSceneBeans.ts +364 -0
- package/src/modules/mood/MixMood/RecommendMixMoodItem.tsx +68 -0
- package/src/modules/timeSchedule/DeviceState.tsx +2 -0
- package/src/modules/timeSchedule/ManualSetting.tsx +54 -13
- package/src/modules/timeSchedule/MoodSetting.tsx +106 -61
- package/src/modules/timeSchedule/TimeScheduleBean.ts +1 -0
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +14 -7
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +1 -1
- package/src/navigation/Routers.ts +42 -0
package/package.json
CHANGED
|
@@ -57,7 +57,19 @@ export const useFlag: UseFlagType = (flagCode, extra) => {
|
|
|
57
57
|
setDps({ [flagCode]: hex})
|
|
58
58
|
}, idx * 50)
|
|
59
59
|
})
|
|
60
|
-
|
|
60
|
+
const extraDps = {}
|
|
61
|
+
if(extra.isCeilingLight){
|
|
62
|
+
extraDps[extra.switchLedCode] = true,
|
|
63
|
+
extraDps[extra.rgbcSwitchLedCode!] = true
|
|
64
|
+
extraDps[extra.rgbcWorkModeCode!] = WORK_MODE.COLOUR
|
|
65
|
+
extraDps[extra.workModeCode] = WORK_MODE.WHITE
|
|
66
|
+
extraDps[extra.brightValueCode!] = flagItem.whiteColors[0]?.brightness * 10
|
|
67
|
+
extraDps[extra.temperatureCode!] = flagItem.whiteColors[0]?.colorTemp * 10
|
|
68
|
+
}else{
|
|
69
|
+
extraDps[extra.switchLedCode] = true
|
|
70
|
+
extraDps[extra.workModeCode] = WORK_MODE.COLOUR
|
|
71
|
+
}
|
|
72
|
+
return setDps(extraDps)
|
|
61
73
|
} else {
|
|
62
74
|
const hex = obj2Dp(flagItem, extra)
|
|
63
75
|
return setDps({ [flagCode]: hex, [extra.workModeCode]: WORK_MODE.SCENE, [extra.switchLedCode]: true })
|
|
@@ -69,6 +81,7 @@ export const useFlag: UseFlagType = (flagCode, extra) => {
|
|
|
69
81
|
export interface FlagOption {
|
|
70
82
|
isMixLight?: boolean
|
|
71
83
|
isStringLight?: boolean
|
|
84
|
+
isCeilingLight?: boolean
|
|
72
85
|
workModeCode: string
|
|
73
86
|
}
|
|
74
87
|
|
|
@@ -129,8 +142,8 @@ export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
|
|
|
129
142
|
} else {
|
|
130
143
|
const switchingIntervalHex = nToHS(flagItem.speed)
|
|
131
144
|
const transitionTimeHex = nToHS(flagItem.speed)
|
|
132
|
-
const transitionModeHex = nToHS(flagItem.mode)
|
|
133
|
-
const
|
|
145
|
+
const transitionModeHex = nToHS(option?.isCeilingLight ? SceneNodeTransitionMode.Static : flagItem.mode)
|
|
146
|
+
const colorHex = flagItem.colors.map(color => {
|
|
134
147
|
const hHex = nToHS(Math.round(color.h), 4)
|
|
135
148
|
const sHex = nToHS(Math.round(color.s * 10), 4)
|
|
136
149
|
const vHex = nToHS(Math.round(color.v * 10), 4)
|
|
@@ -138,6 +151,9 @@ export function obj2Dp(flagItem: FlagItemInfo, option?: FlagOption): string {
|
|
|
138
151
|
const colorTempHex = '0000'
|
|
139
152
|
return switchingIntervalHex + transitionTimeHex + transitionModeHex + hHex + sHex + vHex + brightnessHex + colorTempHex
|
|
140
153
|
}).join('')
|
|
154
|
+
const whiteColor = flagItem.whiteColors[0]
|
|
155
|
+
const whiteHex = switchingIntervalHex + transitionTimeHex + transitionModeHex + '0000' + '0000' + '0000' + nToHS(whiteColor?.brightness * 10, 4) + nToHS(whiteColor?.colorTemp * 10, 4)
|
|
156
|
+
const hex = idHex + (option?.isCeilingLight ? whiteHex : colorHex)
|
|
141
157
|
return hex
|
|
142
158
|
}
|
|
143
159
|
}
|
|
@@ -158,7 +158,7 @@ const FlagEditPage = () => {
|
|
|
158
158
|
<Spacer height={cx(16)} />
|
|
159
159
|
<View style={styles.lightLine}>
|
|
160
160
|
<Text style={styles.light}>
|
|
161
|
-
{I18n.getLang(params.moduleParams.isSupportMixScene
|
|
161
|
+
{I18n.getLang((params.moduleParams.isSupportMixScene || params.moduleParams.isCeilingLight) ? 'light_sources_tile_sec_lighting_headline' : 'light_sources_tile_tw_lighting_headline')}
|
|
162
162
|
</Text>
|
|
163
163
|
</View>
|
|
164
164
|
<Spacer height={cx(10)} />
|
|
@@ -292,7 +292,7 @@ export const defFlagList: FlagUiInfo[] = [
|
|
|
292
292
|
whiteColors: [
|
|
293
293
|
{ brightness: 100, colorTemp: 0},
|
|
294
294
|
],
|
|
295
|
-
colors: [{h:
|
|
295
|
+
colors: [{h: 218, s: 100, v: 100},{h: 0, s: 0, v: 100}, {h: 360, s: 100, v: 100}]
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
id: 232,
|
|
@@ -587,7 +587,7 @@ export const def2FlagList: FlagUiInfo[] = [
|
|
|
587
587
|
whiteColors: [
|
|
588
588
|
{ brightness: 100, colorTemp: 0},
|
|
589
589
|
],
|
|
590
|
-
colors: [{h:
|
|
590
|
+
colors: [{h: 231, s: 100, v: 100}, {h: 360, s: 100, v: 100}, {h: 0, s: 0, v: 100}, {h: 360, s: 100, v: 100}]
|
|
591
591
|
},
|
|
592
592
|
{
|
|
593
593
|
id: 232,
|
|
@@ -881,7 +881,7 @@ export const def3FlagList: FlagUiInfo[] = [
|
|
|
881
881
|
whiteColors: [
|
|
882
882
|
{ brightness: 100, colorTemp: 0},
|
|
883
883
|
],
|
|
884
|
-
colors: [{h:
|
|
884
|
+
colors: [{h: 218, s: 100, v: 100}, {h: 0, s: 0, v: 100}, {h: 360, s: 100, v: 100}]
|
|
885
885
|
},
|
|
886
886
|
{
|
|
887
887
|
id: 232,
|
|
@@ -27,6 +27,7 @@ export interface FlagPageProps {
|
|
|
27
27
|
isSupportTemperature?: boolean
|
|
28
28
|
isStringLight?: boolean
|
|
29
29
|
isStripLight?: boolean
|
|
30
|
+
isCeilingLight?: boolean
|
|
30
31
|
isSupportMixScene?: boolean
|
|
31
32
|
drawToolLight?: {
|
|
32
33
|
drawToolCode: string
|
|
@@ -37,6 +38,10 @@ export interface FlagPageProps {
|
|
|
37
38
|
sceneDataCode?: string
|
|
38
39
|
workModeCode: string
|
|
39
40
|
switchLedCode: string
|
|
41
|
+
rgbcWorkModeCode?: string
|
|
42
|
+
rgbcSwitchLedCode?: string
|
|
43
|
+
brightValueCode?: string
|
|
44
|
+
temperatureCode?: string
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
const FlagPage = () => {
|
|
@@ -48,9 +53,10 @@ const FlagPage = () => {
|
|
|
48
53
|
const [moods, setMoods] = useMoods()
|
|
49
54
|
const [flags, setFlags] = useFlags()
|
|
50
55
|
const [flagMode, setFlagMode] = useFlagMode()
|
|
51
|
-
const [flagState, setFlag] = useFlag((params.isStripLight ? params?.drawToolLight?.drawToolCode : params.sceneDataCode)!!, {
|
|
56
|
+
const [flagState, setFlag] = useFlag(((params.isStripLight || params.isCeilingLight) ? params?.drawToolLight?.drawToolCode : params.sceneDataCode)!!, {
|
|
52
57
|
isMixLight: params.isSupportMixScene,
|
|
53
58
|
isStringLight: params.isStringLight,
|
|
59
|
+
isCeilingLight: params.isCeilingLight,
|
|
54
60
|
...params
|
|
55
61
|
})
|
|
56
62
|
const state = useReactive({
|
|
@@ -74,7 +80,7 @@ const FlagPage = () => {
|
|
|
74
80
|
return -1
|
|
75
81
|
}, [JSON.stringify(flagState), JSON.stringify(state.flags), flagMode])
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
console.log(flags, '< --- flags')
|
|
78
84
|
useEffect(() => {
|
|
79
85
|
if(!devInfo.devId) return
|
|
80
86
|
if(!flags?.length){
|
|
@@ -216,7 +222,7 @@ const FlagPage = () => {
|
|
|
216
222
|
<FlatList
|
|
217
223
|
data={state.flags}
|
|
218
224
|
renderItem={({ item }) => <FlagItem
|
|
219
|
-
enable={flagMode?.flagMode && dps[params.workModeCode] === (params.isStripLight ? WORK_MODE.COLOUR : WORK_MODE.SCENE) && flagId === item.id}
|
|
225
|
+
enable={flagMode?.flagMode && dps[params.workModeCode] === (params.isCeilingLight ? WORK_MODE.WHITE : params.isStripLight ? WORK_MODE.COLOUR : WORK_MODE.SCENE) && flagId === item.id}
|
|
220
226
|
title={item.name}
|
|
221
227
|
icon={item.icon}
|
|
222
228
|
colors={params.isStripLight ? item.colors.map(item => hsv2Hex(item.h, item.s, item.v)).reverse() : item.colors.map(item => hsv2Hex(item.h, item.s, item.v))}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { FlatList, StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { MixSceneInfo } from './MixSceneBeans'
|
|
4
|
+
import Page from '@ledvance/base/src/components/Page'
|
|
5
|
+
import { Utils } from 'tuya-panel-kit'
|
|
6
|
+
import { useNavigation, useRoute } from '@react-navigation/native'
|
|
7
|
+
import { useCreation, useReactive } from 'ahooks'
|
|
8
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
9
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
10
|
+
import RecommendMixMoodItem from './RecommendMixMoodItem'
|
|
11
|
+
import { SceneNodeTransitionMode } from '@ledvance/ui-biz-bundle/src/modules/scene/SceneInfo'
|
|
12
|
+
import { ui_biz_routerKey } from '../../../navigation/Routers'
|
|
13
|
+
import { difference, last, map, range } from 'lodash'
|
|
14
|
+
import { Result } from '@ledvance/base/src/models/modules/Result'
|
|
15
|
+
import { MixMoodPageProps } from './MixMoodPage'
|
|
16
|
+
|
|
17
|
+
const cx = Utils.RatioUtils.convertX
|
|
18
|
+
|
|
19
|
+
export interface AddMixMoodPageParams {
|
|
20
|
+
isStatic: boolean,
|
|
21
|
+
mixMoods: MixSceneInfo[],
|
|
22
|
+
modDeleteFlag: (mode: 'add' | 'edit' | 'del', isStatic: boolean, currentMood: MixSceneInfo) => Promise<Result<any>>
|
|
23
|
+
moduleParams: MixMoodPageProps
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface RecommendMixMood {
|
|
27
|
+
title: string
|
|
28
|
+
mixMood?: MixSceneInfo
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface AddMoodPageState {
|
|
32
|
+
recommendMixMoods: RecommendMixMood[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const AddMixMoodPage = () => {
|
|
36
|
+
const navigation = useNavigation()
|
|
37
|
+
const routeParams = useRoute().params as AddMixMoodPageParams
|
|
38
|
+
const { mainId, secondlyId } = useCreation(() => {
|
|
39
|
+
const mixMoods: any[] = []
|
|
40
|
+
routeParams.mixMoods.forEach(mix => {
|
|
41
|
+
mixMoods.push(mix.mainLamp)
|
|
42
|
+
mixMoods.push(mix.secondlyLamp)
|
|
43
|
+
})
|
|
44
|
+
const useIds = map(mixMoods, 'id')
|
|
45
|
+
const idRange = range(0, 256)
|
|
46
|
+
const mainId: number = last(difference(idRange, useIds)) || -1
|
|
47
|
+
useIds.push(mainId)
|
|
48
|
+
const secondlyId: number = last(difference(idRange, useIds)) || -1
|
|
49
|
+
return { mainId, secondlyId }
|
|
50
|
+
}, [routeParams.mixMoods])
|
|
51
|
+
const state = useReactive<AddMoodPageState>({
|
|
52
|
+
recommendMixMoods: getRecommendMixMoods(routeParams.isStatic, mainId, secondlyId),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Page
|
|
57
|
+
backText={I18n.getLang('add_new_static_mood_system_back')}
|
|
58
|
+
headlineText={I18n.getLang(routeParams.isStatic ? 'add_new_static_mood_headline_text' : 'add_new_dynamic_mood_headline_text')}>
|
|
59
|
+
<View style={styles.root}>
|
|
60
|
+
<Text style={styles.desc}>
|
|
61
|
+
{I18n.getLang(routeParams.isStatic ? 'add_new_static_mood_description_text' : 'add_new_dynamic_mood_description_text')}
|
|
62
|
+
</Text>
|
|
63
|
+
<FlatList
|
|
64
|
+
style={{ flex: 1 }}
|
|
65
|
+
data={state.recommendMixMoods}
|
|
66
|
+
renderItem={({ item }) => {
|
|
67
|
+
return (
|
|
68
|
+
<RecommendMixMoodItem
|
|
69
|
+
title={item.title}
|
|
70
|
+
mixMood={item.mixMood}
|
|
71
|
+
isStatic={routeParams.isStatic}
|
|
72
|
+
onPress={() => {
|
|
73
|
+
const params = {
|
|
74
|
+
mode: 'add',
|
|
75
|
+
isStatic: routeParams.isStatic,
|
|
76
|
+
currentMood: !!item.mixMood ? item.mixMood : newMixMood(mainId, secondlyId, routeParams.isStatic),
|
|
77
|
+
moods: routeParams.mixMoods,
|
|
78
|
+
modDeleteFlag: routeParams.modDeleteFlag,
|
|
79
|
+
moduleParams: routeParams.moduleParams
|
|
80
|
+
}
|
|
81
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_mix_mood_edit, params)
|
|
82
|
+
}} />
|
|
83
|
+
)
|
|
84
|
+
}}
|
|
85
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
86
|
+
ListHeaderComponent={() => <Spacer />}
|
|
87
|
+
ListFooterComponent={() => <Spacer />}
|
|
88
|
+
keyExtractor={item => item.title} />
|
|
89
|
+
</View>
|
|
90
|
+
</Page>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const defSecondly = {
|
|
95
|
+
version: 0,
|
|
96
|
+
expand: 0,
|
|
97
|
+
reserved1: 0,
|
|
98
|
+
reserved2: 0,
|
|
99
|
+
segmented: 0,
|
|
100
|
+
loop: 0,
|
|
101
|
+
excessive: 0,
|
|
102
|
+
direction: 0,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function newMixMood(mainId: number, secondlyId: number, isStatic: boolean): MixSceneInfo {
|
|
106
|
+
return {
|
|
107
|
+
name: '',
|
|
108
|
+
mainLamp: {
|
|
109
|
+
id: mainId,
|
|
110
|
+
speed: 100,
|
|
111
|
+
mode: isStatic ? SceneNodeTransitionMode.Static : 1,
|
|
112
|
+
nodes: [
|
|
113
|
+
{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 0 },
|
|
114
|
+
{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 0 }
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
secondlyLamp: {
|
|
118
|
+
...defSecondly,
|
|
119
|
+
id: secondlyId,
|
|
120
|
+
speed: 100,
|
|
121
|
+
mode: 10,
|
|
122
|
+
nodes: [
|
|
123
|
+
{ h: 0, s: 100, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
|
|
124
|
+
{ h: 0, s: 100, v: 100, brightness: 0, colorTemp: 0, isColorNode: true }
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function getRecommendMixMoods(isStatic: boolean, mainId: number, secondlyId: number): RecommendMixMood[] {
|
|
131
|
+
console.log(mainId, secondlyId, '< -- mainId secondlyId')
|
|
132
|
+
if (isStatic) {
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
title: I18n.getLang('add_new_static_mood_field_headline_text1'),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
title: I18n.getLang('add_new_static_mood_field_headline_text2'),
|
|
139
|
+
mixMood: {
|
|
140
|
+
name: I18n.getLang('add_new_static_mood_field_headline_text2'),
|
|
141
|
+
mainLamp: {
|
|
142
|
+
id: mainId,
|
|
143
|
+
mode: SceneNodeTransitionMode.Static,
|
|
144
|
+
speed: 0,
|
|
145
|
+
nodes: [
|
|
146
|
+
{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 20 }
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
secondlyLamp: {
|
|
150
|
+
...defSecondly,
|
|
151
|
+
id: -1,
|
|
152
|
+
speed: 100,
|
|
153
|
+
mode: 10,
|
|
154
|
+
nodes: []
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
title: I18n.getLang('add_new_dynamic_mood_field_headline_text3'),
|
|
160
|
+
mixMood: {
|
|
161
|
+
name: I18n.getLang('add_new_dynamic_mood_field_headline_text3'),
|
|
162
|
+
mainLamp: {
|
|
163
|
+
id: mainId,
|
|
164
|
+
mode: SceneNodeTransitionMode.Static,
|
|
165
|
+
speed: 0,
|
|
166
|
+
nodes: [
|
|
167
|
+
{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 40 },
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
secondlyLamp: {
|
|
171
|
+
...defSecondly,
|
|
172
|
+
id: -1,
|
|
173
|
+
speed: 100,
|
|
174
|
+
mode: 10,
|
|
175
|
+
nodes: []
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: I18n.getLang('add_new_static_mood_field_headline_text4'),
|
|
181
|
+
mixMood: {
|
|
182
|
+
name: I18n.getLang('add_new_static_mood_field_headline_text4'),
|
|
183
|
+
mainLamp: {
|
|
184
|
+
id: mainId,
|
|
185
|
+
mode: SceneNodeTransitionMode.Static,
|
|
186
|
+
speed: 0,
|
|
187
|
+
nodes: [
|
|
188
|
+
{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 50 },
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
secondlyLamp: {
|
|
192
|
+
...defSecondly,
|
|
193
|
+
id: -1,
|
|
194
|
+
speed: 100,
|
|
195
|
+
mode: 10,
|
|
196
|
+
nodes: []
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
return [
|
|
203
|
+
{
|
|
204
|
+
title: I18n.getLang('add_new_static_mood_field_headline_text1'),
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
title: I18n.getLang('add_new_static_mood_field_headline_text2'),
|
|
208
|
+
mixMood: {
|
|
209
|
+
name: I18n.getLang('add_new_static_mood_field_headline_text2'),
|
|
210
|
+
mainLamp: {
|
|
211
|
+
id: mainId,
|
|
212
|
+
speed: 14,
|
|
213
|
+
mode: SceneNodeTransitionMode.Jump,
|
|
214
|
+
nodes: [
|
|
215
|
+
{ h: 0, s: 0, v: 0, brightness: 30, colorTemp: 30 },
|
|
216
|
+
{ h: 0, s: 0, v: 0, brightness: 60, colorTemp: 60 },
|
|
217
|
+
{ h: 0, s: 0, v: 0, brightness: 90, colorTemp: 90 }
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
secondlyLamp: {
|
|
221
|
+
...defSecondly,
|
|
222
|
+
id: secondlyId,
|
|
223
|
+
speed: 14,
|
|
224
|
+
mode: 10,
|
|
225
|
+
nodes: [
|
|
226
|
+
{ h: 60, s: 20, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
|
|
227
|
+
{ h: 180, s: 40, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
|
|
228
|
+
{ h: 300, s: 60, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
// {
|
|
234
|
+
// title: I18n.getLang('add_new_dynamic_mood_field_headline_text3'),
|
|
235
|
+
// mixMood: {
|
|
236
|
+
// name: I18n.getLang('add_new_dynamic_mood_field_headline_text3'),
|
|
237
|
+
// image: '',
|
|
238
|
+
// value: '',
|
|
239
|
+
// version: 0,
|
|
240
|
+
// id: id,
|
|
241
|
+
// lamps: [
|
|
242
|
+
// {
|
|
243
|
+
// enable: true,
|
|
244
|
+
// type: 2,
|
|
245
|
+
// nodes: [
|
|
246
|
+
// {
|
|
247
|
+
// intervalTime: 14,
|
|
248
|
+
// changeTime: 14,
|
|
249
|
+
// changeType: SceneNodeTransitionMode.Jump,
|
|
250
|
+
// hue: 0,
|
|
251
|
+
// sat: 0,
|
|
252
|
+
// lightness: 0,
|
|
253
|
+
// brightness: 100,
|
|
254
|
+
// colorTemp: 30,
|
|
255
|
+
// },
|
|
256
|
+
// {
|
|
257
|
+
// intervalTime: 14,
|
|
258
|
+
// changeTime: 14,
|
|
259
|
+
// changeType: SceneNodeTransitionMode.Jump,
|
|
260
|
+
// hue: 0,
|
|
261
|
+
// sat: 0,
|
|
262
|
+
// lightness: 0,
|
|
263
|
+
// brightness: 100,
|
|
264
|
+
// colorTemp: 60,
|
|
265
|
+
// },
|
|
266
|
+
// {
|
|
267
|
+
// intervalTime: 14,
|
|
268
|
+
// changeTime: 14,
|
|
269
|
+
// changeType: SceneNodeTransitionMode.Jump,
|
|
270
|
+
// hue: 0,
|
|
271
|
+
// sat: 0,
|
|
272
|
+
// lightness: 0,
|
|
273
|
+
// brightness: 100,
|
|
274
|
+
// colorTemp: 90,
|
|
275
|
+
// },
|
|
276
|
+
// ],
|
|
277
|
+
// },
|
|
278
|
+
// {
|
|
279
|
+
// enable: true,
|
|
280
|
+
// type: 3,
|
|
281
|
+
// nodes: [
|
|
282
|
+
// {
|
|
283
|
+
// intervalTime: 14,
|
|
284
|
+
// changeTime: 14,
|
|
285
|
+
// changeType: SceneNodeTransitionMode.Gradient,
|
|
286
|
+
// hue: 330,
|
|
287
|
+
// sat: 50,
|
|
288
|
+
// lightness: 100,
|
|
289
|
+
// brightness: 0,
|
|
290
|
+
// colorTemp: 0,
|
|
291
|
+
// },
|
|
292
|
+
// {
|
|
293
|
+
// intervalTime: 14,
|
|
294
|
+
// changeTime: 14,
|
|
295
|
+
// changeType: SceneNodeTransitionMode.Gradient,
|
|
296
|
+
// hue: 270,
|
|
297
|
+
// sat: 50,
|
|
298
|
+
// lightness: 100,
|
|
299
|
+
// brightness: 0,
|
|
300
|
+
// colorTemp: 0,
|
|
301
|
+
// },
|
|
302
|
+
// {
|
|
303
|
+
// intervalTime: 14,
|
|
304
|
+
// changeTime: 14,
|
|
305
|
+
// changeType: SceneNodeTransitionMode.Gradient,
|
|
306
|
+
// hue: 210,
|
|
307
|
+
// sat: 50,
|
|
308
|
+
// lightness: 100,
|
|
309
|
+
// brightness: 0,
|
|
310
|
+
// colorTemp: 0,
|
|
311
|
+
// },
|
|
312
|
+
// ],
|
|
313
|
+
// },
|
|
314
|
+
// ],
|
|
315
|
+
// },
|
|
316
|
+
// },
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const styles = StyleSheet.create({
|
|
321
|
+
root: {
|
|
322
|
+
flex: 1,
|
|
323
|
+
flexDirection: 'column',
|
|
324
|
+
},
|
|
325
|
+
desc: {
|
|
326
|
+
color: '#000',
|
|
327
|
+
fontSize: cx(16),
|
|
328
|
+
marginHorizontal: cx(24),
|
|
329
|
+
marginTop: cx(12),
|
|
330
|
+
},
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
export default AddMixMoodPage
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
2
|
+
import { parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils"
|
|
3
|
+
import { MixSceneInfo, getMixSceneList } from './MixSceneBeans'
|
|
4
|
+
import { RemoteSceneInfo } from '../../scene/SceneInfo'
|
|
5
|
+
import { stripObj2Dp, stripDp2Obj } from '../../scene/SceneAction'
|
|
6
|
+
import { hex2Int, spliceByStep } from "@ledvance/base/src/utils/common"
|
|
7
|
+
import { MixMainLampInfo, MixSceneNodeInfo } from './MixSceneBeans'
|
|
8
|
+
|
|
9
|
+
export const getRemoteMixScene = async (devId: string, featureId = 'SimplifyScene') => {
|
|
10
|
+
const res = await NativeApi.getJson(devId, featureId)
|
|
11
|
+
const isNormalData = Array.isArray(parseJSON(res?.data))
|
|
12
|
+
if (res.success && isNormalData) {
|
|
13
|
+
return {
|
|
14
|
+
success: true,
|
|
15
|
+
data: JSON.parse(res.data)?.map(item => remoteMixSceneInfo2SceneUIState(item)),
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
if (res.msg?.includes('资源未找到') || !isNormalData) {
|
|
19
|
+
const defaultScene = getMixSceneList()
|
|
20
|
+
const res = await NativeApi.putJson(devId, featureId, JSON.stringify(defaultScene))
|
|
21
|
+
if (res.success) {
|
|
22
|
+
return {
|
|
23
|
+
success: true,
|
|
24
|
+
data: defaultScene.map(item => remoteMixSceneInfo2SceneUIState(item))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { success: false }
|
|
28
|
+
}
|
|
29
|
+
return { success: false }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const saveMixMood = (devId: string, scenes: MixSceneInfo[], featureId = 'SimplifyScene') => {
|
|
34
|
+
const newScenes: RemoteSceneInfo[] = scenes.map(s => {
|
|
35
|
+
const { mainLamp, secondlyLamp, name } = s
|
|
36
|
+
return {
|
|
37
|
+
n: name,
|
|
38
|
+
i: mainLamp.nodes?.length ? obj2Dp(mainLamp) : '',
|
|
39
|
+
s: secondlyLamp.nodes?.length ? stripObj2Dp(secondlyLamp) : '',
|
|
40
|
+
t: 0,
|
|
41
|
+
e: false,
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
console.log(newScenes, '< --- newScenes')
|
|
45
|
+
return NativeApi.putJson(devId, featureId, JSON.stringify(newScenes))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function obj2Dp(scene: MixMainLampInfo): string {
|
|
49
|
+
const idHex = scene.id.toString(16).padStart(2, '0')
|
|
50
|
+
const hex = idHex + scene.nodes?.map(node => {
|
|
51
|
+
const switchingIntervalHex = scene.speed.toString(16).padStart(2, '0')
|
|
52
|
+
const transitionTimeHex = scene.speed.toString(16).padStart(2, '0')
|
|
53
|
+
const transitionModeHex = scene.mode.toString(16).padStart(2, '0')
|
|
54
|
+
const hHex = node.h.toString(16).padStart(4, '0')
|
|
55
|
+
const sHex = (node.s * 10).toString(16).padStart(4, '0')
|
|
56
|
+
const vHex = (node.v * 10).toString(16).padStart(4, '0')
|
|
57
|
+
const brightnessHex = (node.brightness * 10).toString(16).padStart(4, '0')
|
|
58
|
+
const colorTempHex = (node.colorTemp * 10).toString(16).padStart(4, '0')
|
|
59
|
+
return switchingIntervalHex + transitionTimeHex + transitionModeHex + hHex + sHex + vHex + brightnessHex + colorTempHex
|
|
60
|
+
}).join('')
|
|
61
|
+
return hex
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const defScene = {
|
|
65
|
+
id: -1,
|
|
66
|
+
mode: 0,
|
|
67
|
+
nodes: [],
|
|
68
|
+
speed: 100
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function dp2Obj(dp: string): MixMainLampInfo {
|
|
72
|
+
if (!dp) return defScene
|
|
73
|
+
let dpCopy = dp
|
|
74
|
+
const id = hex2Int(dpCopy.slice(0, 2))
|
|
75
|
+
let speed = 100
|
|
76
|
+
let mode = 0
|
|
77
|
+
dpCopy = dpCopy.slice(2)
|
|
78
|
+
const nodes: MixSceneNodeInfo[] = spliceByStep(dpCopy, 26).map(nodeHex => {
|
|
79
|
+
let hex = nodeHex
|
|
80
|
+
speed = hex2Int(hex.slice(0, 2))
|
|
81
|
+
hex = hex.slice(2)
|
|
82
|
+
speed = hex2Int(hex.slice(0, 2))
|
|
83
|
+
hex = hex.slice(2)
|
|
84
|
+
mode = hex2Int(hex.slice(0, 2))
|
|
85
|
+
hex = hex.slice(2)
|
|
86
|
+
const h = hex2Int(hex.slice(0, 4))
|
|
87
|
+
hex = hex.slice(4)
|
|
88
|
+
const s = Math.round(hex2Int(hex.slice(0, 4)) / 10)
|
|
89
|
+
hex = hex.slice(4)
|
|
90
|
+
const v = Math.round(hex2Int(hex.slice(0, 4)) / 10)
|
|
91
|
+
hex = hex.slice(4)
|
|
92
|
+
const brightness = Math.round(hex2Int(hex.slice(0, 4)) / 10)
|
|
93
|
+
hex = hex.slice(4)
|
|
94
|
+
const colorTemp = Math.round(hex2Int(hex.slice(0, 4)) / 10)
|
|
95
|
+
return {
|
|
96
|
+
h,
|
|
97
|
+
s,
|
|
98
|
+
v,
|
|
99
|
+
brightness,
|
|
100
|
+
colorTemp,
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
nodes,
|
|
106
|
+
speed,
|
|
107
|
+
mode
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const remoteMixSceneInfo2SceneUIState = (remoteScene: RemoteSceneInfo): MixSceneInfo => {
|
|
112
|
+
return {
|
|
113
|
+
name: remoteScene.n,
|
|
114
|
+
mainLamp: remoteScene.i ? dp2Obj(remoteScene.i) : defScene,
|
|
115
|
+
secondlyLamp: remoteScene.s ? stripDp2Obj(remoteScene.s) : {
|
|
116
|
+
...defScene,
|
|
117
|
+
version: 0,
|
|
118
|
+
expand: 0,
|
|
119
|
+
reserved1: 0,
|
|
120
|
+
reserved2: 0,
|
|
121
|
+
segmented: 0,
|
|
122
|
+
loop: 0,
|
|
123
|
+
excessive: 0,
|
|
124
|
+
direction: 0,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|