@ledvance/ui-biz-bundle 1.1.70 → 1.1.71
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/newModules/mood/AddMoodPage.tsx +194 -194
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +650 -650
- package/src/newModules/mood/Interface.ts +225 -220
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +789 -786
- package/src/newModules/mood/MoodActions.ts +244 -232
- package/src/newModules/mood/MoodInfo.ts +2151 -2151
- package/src/newModules/mood/MoodItem.tsx +160 -160
- package/src/newModules/mood/MoodPage.tsx +402 -386
- package/src/newModules/mood/MoodParse.ts +442 -443
- package/src/newModules/mood/RecommendMoodItem.tsx +81 -81
- package/src/newModules/mood/Router.ts +52 -43
- package/src/newModules/mood/StaticMoodEditorPage.tsx +290 -290
package/package.json
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
import Strings from '@ledvance/base/src/i18n';
|
|
2
|
-
import Page from '@ledvance/base/src/components/Page';
|
|
3
|
-
import React, { useCallback } from 'react';
|
|
4
|
-
import { FlatList, StyleSheet, Text, View } from 'react-native';
|
|
5
|
-
import { Utils } from 'tuya-panel-kit';
|
|
6
|
-
import RecommendMoodItem from './RecommendMoodItem';
|
|
7
|
-
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
8
|
-
import { useReactive } from 'ahooks';
|
|
9
|
-
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
10
|
-
import {
|
|
11
|
-
MoodPageParams,
|
|
12
|
-
MoodNodeTransitionMode,
|
|
13
|
-
MoodUIInfo,
|
|
14
|
-
MoodJumpGradientMode,
|
|
15
|
-
} from './Interface';
|
|
16
|
-
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
17
|
-
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
18
|
-
import { difference, head, range } from 'lodash';
|
|
19
|
-
import { RecommendMood, getRecommendMixMoods, getRecommendMoods } from './MoodInfo';
|
|
20
|
-
|
|
21
|
-
const cx = Utils.RatioUtils.convertX;
|
|
22
|
-
|
|
23
|
-
export interface AddMoodPageParams {
|
|
24
|
-
isStatic: boolean;
|
|
25
|
-
moodIds: number[];
|
|
26
|
-
moduleParams: MoodPageParams;
|
|
27
|
-
nameRepeat: (mood: MoodUIInfo) => boolean
|
|
28
|
-
modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface AddMoodPageState {
|
|
32
|
-
data: RecommendMood[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const AddMoodPage = () => {
|
|
36
|
-
const navigation = useNavigation();
|
|
37
|
-
const routeParams = useRoute().params as AddMoodPageParams;
|
|
38
|
-
const moduleParams = routeParams.moduleParams;
|
|
39
|
-
const isMix = !!(moduleParams.isMixLight || moduleParams.isCeilingLight);
|
|
40
|
-
const state = useReactive<AddMoodPageState>({
|
|
41
|
-
data: isMix
|
|
42
|
-
? getRecommendMixMoods(routeParams.isStatic, moduleParams)
|
|
43
|
-
: getRecommendMoods(routeParams.isStatic, moduleParams),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const getFormateItem = item => {
|
|
47
|
-
return {
|
|
48
|
-
...item,
|
|
49
|
-
version: 0,
|
|
50
|
-
secondaryLamp: item.secondaryLamp ?? {
|
|
51
|
-
nodes: [],
|
|
52
|
-
mode: 0,
|
|
53
|
-
speed: 75,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const onMoodItemClick = useCallback(
|
|
59
|
-
(moodItem: RecommendMood) => {
|
|
60
|
-
const idRange = range(0, 256);
|
|
61
|
-
const mainId: number = head(difference(idRange, routeParams.moodIds)) || 0;
|
|
62
|
-
const secondaryId: number = moduleParams.isCeilingLight ? head(difference(idRange, [...routeParams.moodIds, mainId])) || 0 : 0
|
|
63
|
-
const url = routeParams.isStatic
|
|
64
|
-
? ui_biz_routerKey.ui_biz_static_mood_edit
|
|
65
|
-
: !!(moduleParams.isCeilingLight || moduleParams.isMixLight)
|
|
66
|
-
? ui_biz_routerKey.ui_biz_dynamic_mix_mood_edit
|
|
67
|
-
: ui_biz_routerKey.ui_biz_dynamic_mood_edit;
|
|
68
|
-
const currentMood = moodItem.mainLamp
|
|
69
|
-
? { ...moodItem, id: mainId, mainLamp: { ...moodItem.mainLamp, id: mainId }, secondaryLamp: { ...moodItem.secondaryLamp, id: secondaryId } }
|
|
70
|
-
: newMood(mainId, secondaryId, moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
|
|
71
|
-
navigation.navigate(url, {
|
|
72
|
-
...routeParams,
|
|
73
|
-
mode: 'add',
|
|
74
|
-
currentMood,
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
[routeParams]
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Page
|
|
82
|
-
backText={Strings.getLang('add_new_static_mood_system_back')}
|
|
83
|
-
headlineText={Strings.getLang(
|
|
84
|
-
routeParams.isStatic
|
|
85
|
-
? 'add_new_static_mood_headline_text'
|
|
86
|
-
: 'add_new_dynamic_mood_headline_text'
|
|
87
|
-
)}
|
|
88
|
-
>
|
|
89
|
-
<View style={styles.root}>
|
|
90
|
-
<Text style={styles.desc}>
|
|
91
|
-
{Strings.getLang(
|
|
92
|
-
routeParams.isStatic
|
|
93
|
-
? 'add_new_static_mood_description_text'
|
|
94
|
-
: 'add_new_dynamic_mood_description_text'
|
|
95
|
-
)}
|
|
96
|
-
</Text>
|
|
97
|
-
<FlatList
|
|
98
|
-
style={{ flex: 1 }}
|
|
99
|
-
data={state.data}
|
|
100
|
-
renderItem={({ item }) => {
|
|
101
|
-
return (
|
|
102
|
-
<RecommendMoodItem
|
|
103
|
-
title={item.name}
|
|
104
|
-
isMix={isMix}
|
|
105
|
-
mood={getFormateItem(item)}
|
|
106
|
-
deviceTypeOption={moduleParams}
|
|
107
|
-
onPress={() => {
|
|
108
|
-
onMoodItemClick(item);
|
|
109
|
-
}}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
112
|
-
}}
|
|
113
|
-
ItemSeparatorComponent={() => <Spacer />}
|
|
114
|
-
ListHeaderComponent={() => <Spacer />}
|
|
115
|
-
ListFooterComponent={() => <Spacer />}
|
|
116
|
-
keyExtractor={item => item.name}
|
|
117
|
-
/>
|
|
118
|
-
</View>
|
|
119
|
-
</Page>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const styles = StyleSheet.create({
|
|
124
|
-
root: {
|
|
125
|
-
flex: 1,
|
|
126
|
-
flexDirection: 'column',
|
|
127
|
-
},
|
|
128
|
-
desc: {
|
|
129
|
-
color: '#000',
|
|
130
|
-
fontSize: cx(16),
|
|
131
|
-
marginHorizontal: cx(24),
|
|
132
|
-
marginTop: cx(12),
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
export default AddMoodPage;
|
|
137
|
-
|
|
138
|
-
const defStripConfig = {
|
|
139
|
-
version: 0,
|
|
140
|
-
expand: 0,
|
|
141
|
-
reserved1: 0,
|
|
142
|
-
reserved2: 0,
|
|
143
|
-
segmented: 0,
|
|
144
|
-
loop: 0,
|
|
145
|
-
excessive: 0,
|
|
146
|
-
direction: 0,
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function newMood(
|
|
150
|
-
mainId: number,
|
|
151
|
-
secondaryId: number,
|
|
152
|
-
isColorMode: boolean,
|
|
153
|
-
isStatic: boolean,
|
|
154
|
-
moduleParams: MoodPageParams
|
|
155
|
-
): MoodUIInfo {
|
|
156
|
-
const jump = moduleParams.isStringLight
|
|
157
|
-
? MoodJumpGradientMode.StringJump
|
|
158
|
-
: moduleParams.isStripLight
|
|
159
|
-
? MoodJumpGradientMode.StripJump
|
|
160
|
-
: MoodJumpGradientMode.SourceJump;
|
|
161
|
-
const node = {
|
|
162
|
-
brightness: 100,
|
|
163
|
-
colorTemp: 100,
|
|
164
|
-
h: 0,
|
|
165
|
-
s: 100,
|
|
166
|
-
v: 100,
|
|
167
|
-
isColorNode: !!(moduleParams.isCeilingLight || moduleParams.isMixLight) ? false : isColorMode,
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
version: 0,
|
|
171
|
-
name: '',
|
|
172
|
-
image: '',
|
|
173
|
-
id: mainId,
|
|
174
|
-
mainLamp: {
|
|
175
|
-
id: mainId,
|
|
176
|
-
speed: 75,
|
|
177
|
-
enable: true,
|
|
178
|
-
fanEnable: true,
|
|
179
|
-
fanSpeed: 1,
|
|
180
|
-
...defStripConfig,
|
|
181
|
-
mode: isStatic ? MoodNodeTransitionMode.Static : jump,
|
|
182
|
-
nodes: isStatic ? [node] : [node, { ...node }],
|
|
183
|
-
},
|
|
184
|
-
secondaryLamp: {
|
|
185
|
-
id: secondaryId,
|
|
186
|
-
enable: true,
|
|
187
|
-
mode: MoodJumpGradientMode.StripJump,
|
|
188
|
-
speed: 75,
|
|
189
|
-
...defStripConfig,
|
|
190
|
-
version: 1,
|
|
191
|
-
nodes: isStatic ? [] : [{ ...node, isColorNode: true }, { ...node, isColorNode: true }],
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
1
|
+
import Strings from '@ledvance/base/src/i18n';
|
|
2
|
+
import Page from '@ledvance/base/src/components/Page';
|
|
3
|
+
import React, { useCallback } from 'react';
|
|
4
|
+
import { FlatList, StyleSheet, Text, View } from 'react-native';
|
|
5
|
+
import { Utils } from 'tuya-panel-kit';
|
|
6
|
+
import RecommendMoodItem from './RecommendMoodItem';
|
|
7
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
8
|
+
import { useReactive } from 'ahooks';
|
|
9
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
10
|
+
import {
|
|
11
|
+
MoodPageParams,
|
|
12
|
+
MoodNodeTransitionMode,
|
|
13
|
+
MoodUIInfo,
|
|
14
|
+
MoodJumpGradientMode,
|
|
15
|
+
} from './Interface';
|
|
16
|
+
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
17
|
+
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
18
|
+
import { difference, head, range } from 'lodash';
|
|
19
|
+
import { RecommendMood, getRecommendMixMoods, getRecommendMoods } from './MoodInfo';
|
|
20
|
+
|
|
21
|
+
const cx = Utils.RatioUtils.convertX;
|
|
22
|
+
|
|
23
|
+
export interface AddMoodPageParams {
|
|
24
|
+
isStatic: boolean;
|
|
25
|
+
moodIds: number[];
|
|
26
|
+
moduleParams: MoodPageParams;
|
|
27
|
+
nameRepeat: (mood: MoodUIInfo) => boolean
|
|
28
|
+
modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface AddMoodPageState {
|
|
32
|
+
data: RecommendMood[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const AddMoodPage = () => {
|
|
36
|
+
const navigation = useNavigation();
|
|
37
|
+
const routeParams = useRoute().params as AddMoodPageParams;
|
|
38
|
+
const moduleParams = routeParams.moduleParams;
|
|
39
|
+
const isMix = !!(moduleParams.isMixLight || moduleParams.isCeilingLight);
|
|
40
|
+
const state = useReactive<AddMoodPageState>({
|
|
41
|
+
data: isMix
|
|
42
|
+
? getRecommendMixMoods(routeParams.isStatic, moduleParams)
|
|
43
|
+
: getRecommendMoods(routeParams.isStatic, moduleParams),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const getFormateItem = item => {
|
|
47
|
+
return {
|
|
48
|
+
...item,
|
|
49
|
+
version: 0,
|
|
50
|
+
secondaryLamp: item.secondaryLamp ?? {
|
|
51
|
+
nodes: [],
|
|
52
|
+
mode: 0,
|
|
53
|
+
speed: 75,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onMoodItemClick = useCallback(
|
|
59
|
+
(moodItem: RecommendMood) => {
|
|
60
|
+
const idRange = range(0, 256);
|
|
61
|
+
const mainId: number = head(difference(idRange, routeParams.moodIds)) || 0;
|
|
62
|
+
const secondaryId: number = moduleParams.isCeilingLight ? head(difference(idRange, [...routeParams.moodIds, mainId])) || 0 : 0
|
|
63
|
+
const url = routeParams.isStatic
|
|
64
|
+
? ui_biz_routerKey.ui_biz_static_mood_edit
|
|
65
|
+
: !!(moduleParams.isCeilingLight || moduleParams.isMixLight)
|
|
66
|
+
? ui_biz_routerKey.ui_biz_dynamic_mix_mood_edit
|
|
67
|
+
: ui_biz_routerKey.ui_biz_dynamic_mood_edit;
|
|
68
|
+
const currentMood = moodItem.mainLamp
|
|
69
|
+
? { ...moodItem, id: mainId, mainLamp: { ...moodItem.mainLamp, id: mainId }, secondaryLamp: { ...moodItem.secondaryLamp, id: secondaryId } }
|
|
70
|
+
: newMood(mainId, secondaryId, moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
|
|
71
|
+
navigation.navigate(url, {
|
|
72
|
+
...routeParams,
|
|
73
|
+
mode: 'add',
|
|
74
|
+
currentMood,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
[routeParams]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Page
|
|
82
|
+
backText={Strings.getLang('add_new_static_mood_system_back')}
|
|
83
|
+
headlineText={Strings.getLang(
|
|
84
|
+
routeParams.isStatic
|
|
85
|
+
? 'add_new_static_mood_headline_text'
|
|
86
|
+
: 'add_new_dynamic_mood_headline_text'
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
<View style={styles.root}>
|
|
90
|
+
<Text style={styles.desc}>
|
|
91
|
+
{Strings.getLang(
|
|
92
|
+
routeParams.isStatic
|
|
93
|
+
? 'add_new_static_mood_description_text'
|
|
94
|
+
: 'add_new_dynamic_mood_description_text'
|
|
95
|
+
)}
|
|
96
|
+
</Text>
|
|
97
|
+
<FlatList
|
|
98
|
+
style={{ flex: 1 }}
|
|
99
|
+
data={state.data}
|
|
100
|
+
renderItem={({ item }) => {
|
|
101
|
+
return (
|
|
102
|
+
<RecommendMoodItem
|
|
103
|
+
title={item.name}
|
|
104
|
+
isMix={isMix}
|
|
105
|
+
mood={getFormateItem(item)}
|
|
106
|
+
deviceTypeOption={moduleParams}
|
|
107
|
+
onPress={() => {
|
|
108
|
+
onMoodItemClick(item);
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}}
|
|
113
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
114
|
+
ListHeaderComponent={() => <Spacer />}
|
|
115
|
+
ListFooterComponent={() => <Spacer />}
|
|
116
|
+
keyExtractor={item => item.name}
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
119
|
+
</Page>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const styles = StyleSheet.create({
|
|
124
|
+
root: {
|
|
125
|
+
flex: 1,
|
|
126
|
+
flexDirection: 'column',
|
|
127
|
+
},
|
|
128
|
+
desc: {
|
|
129
|
+
color: '#000',
|
|
130
|
+
fontSize: cx(16),
|
|
131
|
+
marginHorizontal: cx(24),
|
|
132
|
+
marginTop: cx(12),
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export default AddMoodPage;
|
|
137
|
+
|
|
138
|
+
const defStripConfig = {
|
|
139
|
+
version: 0,
|
|
140
|
+
expand: 0,
|
|
141
|
+
reserved1: 0,
|
|
142
|
+
reserved2: 0,
|
|
143
|
+
segmented: 0,
|
|
144
|
+
loop: 0,
|
|
145
|
+
excessive: 0,
|
|
146
|
+
direction: 0,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function newMood(
|
|
150
|
+
mainId: number,
|
|
151
|
+
secondaryId: number,
|
|
152
|
+
isColorMode: boolean,
|
|
153
|
+
isStatic: boolean,
|
|
154
|
+
moduleParams: MoodPageParams
|
|
155
|
+
): MoodUIInfo {
|
|
156
|
+
const jump = moduleParams.isStringLight
|
|
157
|
+
? MoodJumpGradientMode.StringJump
|
|
158
|
+
: moduleParams.isStripLight
|
|
159
|
+
? MoodJumpGradientMode.StripJump
|
|
160
|
+
: MoodJumpGradientMode.SourceJump;
|
|
161
|
+
const node = {
|
|
162
|
+
brightness: 100,
|
|
163
|
+
colorTemp: 100,
|
|
164
|
+
h: 0,
|
|
165
|
+
s: 100,
|
|
166
|
+
v: 100,
|
|
167
|
+
isColorNode: !!(moduleParams.isCeilingLight || moduleParams.isMixLight) ? false : isColorMode,
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
version: 0,
|
|
171
|
+
name: '',
|
|
172
|
+
image: '',
|
|
173
|
+
id: mainId,
|
|
174
|
+
mainLamp: {
|
|
175
|
+
id: mainId,
|
|
176
|
+
speed: 75,
|
|
177
|
+
enable: true,
|
|
178
|
+
fanEnable: true,
|
|
179
|
+
fanSpeed: 1,
|
|
180
|
+
...defStripConfig,
|
|
181
|
+
mode: isStatic ? MoodNodeTransitionMode.Static : jump,
|
|
182
|
+
nodes: isStatic ? [node] : [node, { ...node }],
|
|
183
|
+
},
|
|
184
|
+
secondaryLamp: {
|
|
185
|
+
id: secondaryId,
|
|
186
|
+
enable: true,
|
|
187
|
+
mode: MoodJumpGradientMode.StripJump,
|
|
188
|
+
speed: 75,
|
|
189
|
+
...defStripConfig,
|
|
190
|
+
version: 1,
|
|
191
|
+
nodes: isStatic ? [] : [{ ...node, isColorNode: true }, { ...node, isColorNode: true }],
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|