@ledvance/group-ui-biz-bundle 1.0.45 → 1.0.47
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/biorhythm/BiorhythmActions.ts +5 -13
- package/src/modules/biorhythm/BiorhythmBean.ts +6 -6
- package/src/modules/biorhythm/BiorhythmPage.tsx +14 -38
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTimeForPlug/Router.ts +25 -0
- package/src/modules/fixedTimingForLight/Router.ts +25 -0
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/mood_new/AddMoodPage.tsx +197 -0
- package/src/modules/mood_new/DynamicMoodEditorPage.tsx +654 -0
- package/src/modules/mood_new/Interface.ts +219 -0
- package/src/modules/mood_new/MixDynamicMoodEditor.tsx +788 -0
- package/src/modules/mood_new/MoodActions.ts +227 -0
- package/src/modules/mood_new/MoodInfo.ts +2151 -0
- package/src/modules/mood_new/MoodItem.tsx +148 -0
- package/src/modules/mood_new/MoodPage.tsx +374 -0
- package/src/modules/mood_new/MoodParse.ts +442 -0
- package/src/modules/mood_new/RecommendMoodItem.tsx +69 -0
- package/src/modules/mood_new/Router.ts +43 -0
- package/src/modules/mood_new/StaticMoodEditorPage.tsx +293 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/randomTimeForPlug/Router.ts +25 -0
- package/src/modules/randomTimingForLight/Router.ts +25 -0
- package/src/modules/remoteSwitch/Router.ts +16 -0
- package/src/modules/select/Router.ts +16 -0
- package/src/modules/switchGradient/Router.ts +16 -0
- package/src/modules/timeSchedule/Interface.ts +150 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timeSchedule/TimeScheduleActions.ts +140 -0
- package/src/modules/timeSchedule/TimeScheduleDetailPage.tsx +625 -0
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +220 -0
- package/src/modules/timeSchedule/components/ManuaSettings.tsx +376 -0
- package/src/modules/timeSchedule/components/ScheduleCard.tsx +109 -0
- package/src/modules/timeSchedule/components/Summary.tsx +124 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.ts +1 -0
package/package.json
CHANGED
|
@@ -7,11 +7,10 @@ import {
|
|
|
7
7
|
Plan,
|
|
8
8
|
} from './BiorhythmBean'
|
|
9
9
|
import { useFeatureHook} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
10
|
-
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
11
10
|
import {hex2Int, spliceByStep} from '@ledvance/base/src/utils/common'
|
|
12
11
|
import I18n from '@ledvance/base/src/i18n'
|
|
13
12
|
import BiologicalRes from './res/BiologicalRes'
|
|
14
|
-
import
|
|
13
|
+
import { to16 } from '@tuya/tuya-panel-lamp-sdk/lib/utils'
|
|
15
14
|
|
|
16
15
|
interface BiorhythmConfig {
|
|
17
16
|
rhythm_mode: BiorhythmBean
|
|
@@ -23,12 +22,6 @@ export const useBiorhythm = () => {
|
|
|
23
22
|
})
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
export const userOperation = async (deviceId: string, value: boolean) => {
|
|
27
|
-
const currentTime = dayjs().format('YYYY-MM-DD')
|
|
28
|
-
const json = JSON.stringify({status: value, suspendTime: value && currentTime || ''})
|
|
29
|
-
return await NativeApi.putJson(deviceId, 'suspendTime', json)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
25
|
export function dp2Obj(dp: string): BiorhythmBean {
|
|
33
26
|
if (!dp || dp === '0000000000') {
|
|
34
27
|
return dp2Obj('0000007f0501060000000000000001061e00000000141901090000000000646401140000000000503201171e000000000000')
|
|
@@ -75,7 +68,7 @@ export function dp2Obj(dp: string): BiorhythmBean {
|
|
|
75
68
|
// 分钟
|
|
76
69
|
const minute = hex2Int(hex.slice(0, 2)).toString().padStart(2, '0')
|
|
77
70
|
hex = hex.slice(2)
|
|
78
|
-
const
|
|
71
|
+
const time = hour * 60 + minute
|
|
79
72
|
// 色调 (色相)
|
|
80
73
|
hex2Int(hex.slice(0, 4))
|
|
81
74
|
hex = hex.slice(4)
|
|
@@ -94,7 +87,7 @@ export function dp2Obj(dp: string): BiorhythmBean {
|
|
|
94
87
|
id: index,
|
|
95
88
|
enable: enable,
|
|
96
89
|
icon: getNodeIconByIndex(index),
|
|
97
|
-
|
|
90
|
+
time,
|
|
98
91
|
name: getNodeNameByIndex(index),
|
|
99
92
|
colorTemperature: colorTemperature,
|
|
100
93
|
brightness: brightness,
|
|
@@ -203,9 +196,8 @@ function obj2Dp(obj: BiorhythmBean): string {
|
|
|
203
196
|
const planListHex = obj.planList
|
|
204
197
|
.map(plan => {
|
|
205
198
|
const enableHex = plan.enable ? '01' : '00'
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
const minuteHex = parseInt(startTime[1]).toString(16).padStart(2, '0')
|
|
199
|
+
const hourHex = to16(Math.trunc(plan.time / 60))
|
|
200
|
+
const minuteHex = to16(plan.time % 60)
|
|
209
201
|
const hsvHex = '00000000'
|
|
210
202
|
const brightnessHex = plan.brightness.toString(16).padStart(2, '0')
|
|
211
203
|
const colorTemperatureHex = plan.colorTemperature.toString(16).padStart(2, '0')
|
|
@@ -29,7 +29,7 @@ export interface Plan {
|
|
|
29
29
|
id: number;
|
|
30
30
|
enable: boolean;
|
|
31
31
|
icon: string;
|
|
32
|
-
|
|
32
|
+
time: number;
|
|
33
33
|
name: string;
|
|
34
34
|
colorTemperature: number;
|
|
35
35
|
brightness: number;
|
|
@@ -71,7 +71,7 @@ export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
|
71
71
|
{
|
|
72
72
|
id: 0,
|
|
73
73
|
icon: icon1,
|
|
74
|
-
|
|
74
|
+
time: 360,
|
|
75
75
|
name: I18n.getLang('bio_ryhthm_default_field_text'),
|
|
76
76
|
colorTemperature: 0,
|
|
77
77
|
brightness: 0,
|
|
@@ -91,7 +91,7 @@ export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
|
91
91
|
{
|
|
92
92
|
id: 1,
|
|
93
93
|
icon: icon12,
|
|
94
|
-
|
|
94
|
+
time: 420,
|
|
95
95
|
name: I18n.getLang('bio_ryhthm_default_field_text2'),
|
|
96
96
|
colorTemperature: 25,
|
|
97
97
|
brightness: 20,
|
|
@@ -111,7 +111,7 @@ export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
|
111
111
|
{
|
|
112
112
|
id: 2,
|
|
113
113
|
icon: icon2,
|
|
114
|
-
|
|
114
|
+
time: 540,
|
|
115
115
|
name: I18n.getLang('bio_ryhthm_default_field_text3'),
|
|
116
116
|
colorTemperature: 100,
|
|
117
117
|
brightness: 100,
|
|
@@ -131,7 +131,7 @@ export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
|
131
131
|
{
|
|
132
132
|
id: 3,
|
|
133
133
|
icon: icon3,
|
|
134
|
-
|
|
134
|
+
time: 1200,
|
|
135
135
|
name: I18n.getLang('bio_ryhthm_default_field_text4'),
|
|
136
136
|
colorTemperature: 50,
|
|
137
137
|
brightness: 80,
|
|
@@ -151,7 +151,7 @@ export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
|
151
151
|
{
|
|
152
152
|
id: 4,
|
|
153
153
|
icon: icon4,
|
|
154
|
-
|
|
154
|
+
time: 1410,
|
|
155
155
|
name: I18n.getLang('bio_ryhthm_default_field_text5'),
|
|
156
156
|
colorTemperature: 0,
|
|
157
157
|
brightness: 0,
|
|
@@ -88,19 +88,10 @@ const BiorhythmPage = () => {
|
|
|
88
88
|
state.flag = Symbol()
|
|
89
89
|
}, [])
|
|
90
90
|
|
|
91
|
-
const requestSetBiorhythm
|
|
91
|
+
const requestSetBiorhythm = useCallback(async () => {
|
|
92
|
+
state.loading = true
|
|
92
93
|
const planList = state.planList?.map(item => { return { ...item, icon: `${item.icon}` } })
|
|
93
|
-
.sort((a, b) =>
|
|
94
|
-
const timeA = a.startTime.split(":");
|
|
95
|
-
const timeB = b.startTime.split(":");
|
|
96
|
-
// 比较小时
|
|
97
|
-
if (parseInt(timeA[0]) !== parseInt(timeB[0])) {
|
|
98
|
-
return parseInt(timeA[0]) - parseInt(timeB[0]);
|
|
99
|
-
}
|
|
100
|
-
// 如果小时相等,比较分钟
|
|
101
|
-
return parseInt(timeA[1]) - parseInt(timeB[1]);
|
|
102
|
-
});
|
|
103
|
-
// await userOperation(deviceId, false)
|
|
94
|
+
.sort((a, b) => a.time - b.time);
|
|
104
95
|
const res = await setBiorhythm(cloneDeep({ ...state, planList }))
|
|
105
96
|
state.loading = false
|
|
106
97
|
console.log('设置生物节律res', res)
|
|
@@ -123,28 +114,20 @@ const BiorhythmPage = () => {
|
|
|
123
114
|
}
|
|
124
115
|
}
|
|
125
116
|
|
|
126
|
-
const minimumEnable = (plan: Plan) => {
|
|
127
|
-
const [h, m] = plan.startTime.split(':').map(str => parseInt(str, 10))
|
|
128
|
-
const min = h * 60 + m
|
|
129
|
-
const minutes = state.planList
|
|
130
|
-
.filter(item => item.id !== plan.id && item.enable)
|
|
131
|
-
.map(item => {
|
|
132
|
-
const [hour, minute] = item.startTime.split(':').map(str => parseInt(str, 10))
|
|
133
|
-
return hour * 60 + minute
|
|
134
|
-
})
|
|
117
|
+
const minimumEnable = useCallback((plan: Plan) => {
|
|
135
118
|
let enable = false
|
|
136
|
-
|
|
137
|
-
const diff = Math.abs(
|
|
119
|
+
state.planList.filter(p => p.index !== plan.id).forEach(item => {
|
|
120
|
+
const diff = Math.abs(plan.time - item.time)
|
|
138
121
|
if (diff < 15) enable = true
|
|
139
122
|
})
|
|
140
123
|
return enable
|
|
141
|
-
}
|
|
124
|
+
}, [state.planList])
|
|
142
125
|
|
|
143
126
|
const showDeleteBtn = useMemo(() => {
|
|
144
127
|
return state.planList?.length > 1
|
|
145
128
|
}, [state.planList?.length])
|
|
146
129
|
|
|
147
|
-
const { run } = useDebounceFn(requestSetBiorhythm, { wait:
|
|
130
|
+
const { run } = useDebounceFn(requestSetBiorhythm, { wait: 300 })
|
|
148
131
|
|
|
149
132
|
useUpdateEffect(() => {
|
|
150
133
|
run()
|
|
@@ -315,21 +298,14 @@ const BiorhythmPage = () => {
|
|
|
315
298
|
marginHorizontal: cx(24),
|
|
316
299
|
}}
|
|
317
300
|
>
|
|
318
|
-
{state.repeatPeriod.map((period
|
|
301
|
+
{state.repeatPeriod.map((period) => {
|
|
319
302
|
return (
|
|
320
303
|
<TouchableOpacity
|
|
321
304
|
key={period.title}
|
|
322
305
|
onPress={() => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
...period,
|
|
327
|
-
enabled: !period.enabled
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return period
|
|
331
|
-
})
|
|
332
|
-
// period.enabled = !period.enabled
|
|
306
|
+
const periodNum = state.repeatPeriod.filter(p => p.enabled)?.length
|
|
307
|
+
if (periodNum === 1 && period.enabled) return
|
|
308
|
+
period.enabled = !period.enabled
|
|
333
309
|
state.flag = Symbol()
|
|
334
310
|
}}
|
|
335
311
|
>
|
|
@@ -408,7 +384,7 @@ const BiorhythmPage = () => {
|
|
|
408
384
|
state.planList = state.planList.map(plan => {
|
|
409
385
|
return {
|
|
410
386
|
...plan,
|
|
411
|
-
|
|
387
|
+
time: plan.index === id ? time : plan.time,
|
|
412
388
|
}
|
|
413
389
|
})
|
|
414
390
|
state.flag = Symbol()
|
|
@@ -447,7 +423,7 @@ const BiorhythmPage = () => {
|
|
|
447
423
|
const newPlan: Plan = {
|
|
448
424
|
id: Math.max(...ids) + 1,
|
|
449
425
|
icon: res.rhythm_icon1,
|
|
450
|
-
|
|
426
|
+
time: 0,
|
|
451
427
|
name: '',
|
|
452
428
|
colorTemperature: 0,
|
|
453
429
|
brightness: 100,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import BiorhythmPage from "./BiorhythmPage";
|
|
3
|
+
import BiorhythmEditPage from "./BiorhythmDetailPage";
|
|
4
|
+
import BiorhythmIconSelectPage from "./IconSelect"
|
|
5
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
6
|
+
|
|
7
|
+
const BiorhythmPageRouters: NavigationRoute[] = [
|
|
8
|
+
{
|
|
9
|
+
name: ui_biz_routerKey.group_ui_biz_biological,
|
|
10
|
+
component: BiorhythmPage,
|
|
11
|
+
options:{
|
|
12
|
+
hideTopbar: true,
|
|
13
|
+
showOfflineView: false,
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: ui_biz_routerKey.group_ui_biz_biological_detail,
|
|
18
|
+
component: BiorhythmEditPage,
|
|
19
|
+
options:{
|
|
20
|
+
hideTopbar: true,
|
|
21
|
+
showOfflineView: false,
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: ui_biz_routerKey.group_ui_biz_biological_icon_select,
|
|
26
|
+
component: BiorhythmIconSelectPage,
|
|
27
|
+
options:{
|
|
28
|
+
hideTopbar: true,
|
|
29
|
+
showOfflineView: false,
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
export default BiorhythmPageRouters
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import FixedTimeForPlugPage from "./FixedTimeForPlugPage";
|
|
3
|
+
import FixedTimeForPlugDetailPage from "./FixedTimeForPlugDetailPage";
|
|
4
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
5
|
+
|
|
6
|
+
const FixedTimeForPlugRouters: NavigationRoute[] = [
|
|
7
|
+
{
|
|
8
|
+
name: ui_biz_routerKey.group_ui_biz_fixed_time_plug,
|
|
9
|
+
component: FixedTimeForPlugPage,
|
|
10
|
+
options:{
|
|
11
|
+
hideTopbar: true,
|
|
12
|
+
showOfflineView: false,
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: ui_biz_routerKey.group_ui_biz_fixed_time_plug_detail,
|
|
17
|
+
component: FixedTimeForPlugDetailPage,
|
|
18
|
+
options:{
|
|
19
|
+
hideTopbar: true,
|
|
20
|
+
showOfflineView: false,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
export default FixedTimeForPlugRouters
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import FixedTimingForLightPage from "./FixedTimingForLightPage";
|
|
3
|
+
import FixedTimingForLightDetailPage from "./FixedTimingForLightDetailPage";
|
|
4
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
5
|
+
|
|
6
|
+
const FixedTimingForLightRouters: NavigationRoute[] = [
|
|
7
|
+
{
|
|
8
|
+
name: ui_biz_routerKey.group_ui_biz_fixed_timing_light,
|
|
9
|
+
component: FixedTimingForLightPage,
|
|
10
|
+
options:{
|
|
11
|
+
hideTopbar: true,
|
|
12
|
+
showOfflineView: false,
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: ui_biz_routerKey.group_ui_biz_fixed_timing_light_detail,
|
|
17
|
+
component: FixedTimingForLightDetailPage,
|
|
18
|
+
options:{
|
|
19
|
+
hideTopbar: true,
|
|
20
|
+
showOfflineView: false,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
export default FixedTimingForLightRouters
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {NavigationRoute} from "tuya-panel-kit";
|
|
2
|
+
import FlagPage from "./FlagPage";
|
|
3
|
+
import FlagEditPage from "./FlagEditPage";
|
|
4
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
5
|
+
|
|
6
|
+
const FlagPageRouters: NavigationRoute[] = [
|
|
7
|
+
{
|
|
8
|
+
name: ui_biz_routerKey.group_ui_biz_flag_page,
|
|
9
|
+
component: FlagPage,
|
|
10
|
+
options:{
|
|
11
|
+
hideTopbar: true,
|
|
12
|
+
showOfflineView: false,
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: ui_biz_routerKey.group_ui_biz_flag_page_edit,
|
|
17
|
+
component: FlagEditPage,
|
|
18
|
+
options:{
|
|
19
|
+
hideTopbar: true,
|
|
20
|
+
showOfflineView: false,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
export default FlagPageRouters
|
|
@@ -0,0 +1,197 @@
|
|
|
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, map, 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
|
+
moods: MoodUIInfo[];
|
|
26
|
+
moduleParams: MoodPageParams;
|
|
27
|
+
modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface AddMoodPageState {
|
|
31
|
+
data: RecommendMood[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const AddMoodPage = () => {
|
|
35
|
+
const navigation = useNavigation();
|
|
36
|
+
const routeParams = useRoute().params as AddMoodPageParams;
|
|
37
|
+
const moduleParams = routeParams.moduleParams;
|
|
38
|
+
const isMix = !!(moduleParams.isMixLight || moduleParams.isCeilingLight);
|
|
39
|
+
const state = useReactive<AddMoodPageState>({
|
|
40
|
+
data: isMix
|
|
41
|
+
? getRecommendMixMoods(routeParams.isStatic, moduleParams)
|
|
42
|
+
: getRecommendMoods(routeParams.isStatic, moduleParams),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const getFormateItem = item => {
|
|
46
|
+
return {
|
|
47
|
+
...item,
|
|
48
|
+
version: 0,
|
|
49
|
+
secondaryLamp: item.secondaryLamp ?? {
|
|
50
|
+
nodes: [],
|
|
51
|
+
mode: 0,
|
|
52
|
+
speed: 75,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const onMoodItemClick = useCallback(
|
|
58
|
+
(moodItem: RecommendMood) => {
|
|
59
|
+
let useIds: any[] = []
|
|
60
|
+
if(moduleParams.isCeilingLight){
|
|
61
|
+
const mainIds = map(routeParams.moods.map(m => m.mainLamp), 'id') ?? 0
|
|
62
|
+
const secondaryIds = map(routeParams.moods.map(m => m.secondaryLamp), 'id') ?? 0
|
|
63
|
+
useIds = [...mainIds, ...secondaryIds]
|
|
64
|
+
}else{
|
|
65
|
+
useIds = map(routeParams.moods, 'id');
|
|
66
|
+
}
|
|
67
|
+
const idRange = range(0, 256);
|
|
68
|
+
const mainId: number = head(difference(idRange, useIds));
|
|
69
|
+
const secondaryId: number = head(difference(idRange, [...useIds, mainId]))
|
|
70
|
+
console.log(mainId, secondaryId, '< --- iddddddddd ')
|
|
71
|
+
const url = routeParams.isStatic
|
|
72
|
+
? ui_biz_routerKey.group_ui_biz_static_mood_edit
|
|
73
|
+
: !!(moduleParams.isCeilingLight || moduleParams.isMixLight)
|
|
74
|
+
? ui_biz_routerKey.group_ui_biz_dynamic_mix_mood_edit
|
|
75
|
+
: ui_biz_routerKey.group_ui_biz_dynamic_mood_edit;
|
|
76
|
+
const currentMood = moodItem.mainLamp
|
|
77
|
+
? { ...moodItem, id: mainId, mainLamp: {...moodItem.mainLamp, id: mainId}, secondaryLamp: {...moodItem.secondaryLamp, id: secondaryId}}
|
|
78
|
+
: newMood(mainId, secondaryId ,moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
|
|
79
|
+
navigation.navigate(url, {
|
|
80
|
+
mode: 'add',
|
|
81
|
+
currentMood,
|
|
82
|
+
moods: routeParams.moods,
|
|
83
|
+
moduleParams,
|
|
84
|
+
modDeleteMood: routeParams.modDeleteMood,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
[routeParams]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Page
|
|
92
|
+
backText={Strings.getLang('add_new_static_mood_system_back')}
|
|
93
|
+
headlineText={Strings.getLang(
|
|
94
|
+
routeParams.isStatic
|
|
95
|
+
? 'add_new_static_mood_headline_text'
|
|
96
|
+
: 'add_new_dynamic_mood_headline_text'
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
<View style={styles.root}>
|
|
100
|
+
<Text style={styles.desc}>
|
|
101
|
+
{Strings.getLang(
|
|
102
|
+
routeParams.isStatic
|
|
103
|
+
? 'add_new_static_mood_description_text'
|
|
104
|
+
: 'add_new_dynamic_mood_description_text'
|
|
105
|
+
)}
|
|
106
|
+
</Text>
|
|
107
|
+
<FlatList
|
|
108
|
+
style={{ flex: 1 }}
|
|
109
|
+
data={state.data}
|
|
110
|
+
renderItem={({ item }) => {
|
|
111
|
+
return (
|
|
112
|
+
<RecommendMoodItem
|
|
113
|
+
title={item.name}
|
|
114
|
+
isMix={isMix}
|
|
115
|
+
mood={getFormateItem(item)}
|
|
116
|
+
onPress={() => {
|
|
117
|
+
onMoodItemClick(item);
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}}
|
|
122
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
123
|
+
ListHeaderComponent={() => <Spacer />}
|
|
124
|
+
ListFooterComponent={() => <Spacer />}
|
|
125
|
+
keyExtractor={item => item.name}
|
|
126
|
+
/>
|
|
127
|
+
</View>
|
|
128
|
+
</Page>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const styles = StyleSheet.create({
|
|
133
|
+
root: {
|
|
134
|
+
flex: 1,
|
|
135
|
+
flexDirection: 'column',
|
|
136
|
+
},
|
|
137
|
+
desc: {
|
|
138
|
+
color: '#000',
|
|
139
|
+
fontSize: cx(16),
|
|
140
|
+
marginHorizontal: cx(24),
|
|
141
|
+
marginTop: cx(12),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export default AddMoodPage;
|
|
146
|
+
|
|
147
|
+
function newMood(
|
|
148
|
+
mainId: number,
|
|
149
|
+
secondaryId: number,
|
|
150
|
+
isColorMode: boolean,
|
|
151
|
+
isStatic: boolean,
|
|
152
|
+
moduleParams: MoodPageParams
|
|
153
|
+
): MoodUIInfo {
|
|
154
|
+
const jump = moduleParams.isStringLight
|
|
155
|
+
? MoodJumpGradientMode.StringJump
|
|
156
|
+
: moduleParams.isStripLight
|
|
157
|
+
? MoodJumpGradientMode.StripJump
|
|
158
|
+
: MoodJumpGradientMode.SourceJump;
|
|
159
|
+
const node = {
|
|
160
|
+
brightness: 100,
|
|
161
|
+
colorTemp: 100,
|
|
162
|
+
h: 0,
|
|
163
|
+
s: 100,
|
|
164
|
+
v: 100,
|
|
165
|
+
isColorNode: !!(moduleParams.isCeilingLight || moduleParams.isMixLight) ? false : isColorMode,
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
version: 0,
|
|
169
|
+
name: '',
|
|
170
|
+
image: '',
|
|
171
|
+
id: mainId,
|
|
172
|
+
mainLamp: {
|
|
173
|
+
id: mainId,
|
|
174
|
+
speed: 75,
|
|
175
|
+
enable: true,
|
|
176
|
+
fanEnable: true,
|
|
177
|
+
fanSpeed: 1,
|
|
178
|
+
mode: isStatic ? MoodNodeTransitionMode.Static : jump,
|
|
179
|
+
nodes: isStatic ? [node] : [node, { ...node }],
|
|
180
|
+
},
|
|
181
|
+
secondaryLamp: {
|
|
182
|
+
id: secondaryId,
|
|
183
|
+
enable: true,
|
|
184
|
+
mode: MoodJumpGradientMode.StripJump,
|
|
185
|
+
speed: 75,
|
|
186
|
+
version: 0,
|
|
187
|
+
expand: 0,
|
|
188
|
+
reserved1: 0,
|
|
189
|
+
reserved2: 0,
|
|
190
|
+
segmented: 0,
|
|
191
|
+
loop: 0,
|
|
192
|
+
excessive: 0,
|
|
193
|
+
direction: 0,
|
|
194
|
+
nodes: isStatic ? [] : [{...node, isColorNode: true}, {...node, isColorNode: true}],
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|