@ledvance/ui-biz-bundle 1.1.36 → 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.
@@ -0,0 +1,709 @@
1
+ import Page from '@ledvance/base/src/components/Page'
2
+ import I18n from '@ledvance/base/src/i18n'
3
+ import { useNavigation, useRoute } from '@react-navigation/native'
4
+ import { StackNavigationProp } from '@react-navigation/stack'
5
+ import React, { useCallback, useEffect, useMemo } from 'react'
6
+ import { useReactive } from 'ahooks'
7
+ import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils'
8
+ import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
9
+ import res from '@ledvance/base/src/res'
10
+ import { cloneDeep, find, isEqual } from 'lodash'
11
+ import { FlatList, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
12
+ import TextField from '@ledvance/base/src/components/TextField'
13
+ import Card from '@ledvance/base/src/components/Card'
14
+ import Spacer from '@ledvance/base/src/components/Spacer'
15
+ import { Utils } from 'tuya-panel-kit'
16
+ import LdvSlider from '@ledvance/base/src/components/ldvSlider'
17
+ import TextButton from '@ledvance/base/src/components/TextButton'
18
+ import { stripLightSceneMode, StripNodeInfo, SceneNodeInfo, StripLightSceneMode, CeilingLightSceneMode, StripSceneInfo } from '../../scene/SceneInfo'
19
+ import { MixSceneInfo, MixMainLampInfo, MixSceneNodeInfo } from './MixSceneBeans'
20
+ import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton'
21
+ import { SelectPageParams } from '../../select/SelectPage'
22
+ import { showDeleteMoodDialog } from '../tools'
23
+ import { ui_biz_routerKey } from '../../../navigation/Routers'
24
+ import { MixMoodPageProps } from '@ledvance/ui-biz-bundle/src/modules/mood/MixMood/MixMoodPage'
25
+ import Segmented from '@ledvance/base/src/components/Segmented'
26
+ import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
27
+ import ColorTempAdjustView from '@ledvance/base/src/components/ColorTempAdjustView'
28
+ import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView'
29
+ import { Result } from '@ledvance/base/src/models/modules/Result'
30
+ const cx = Utils.RatioUtils.convertX
31
+
32
+ interface MixMoodEditPageState {
33
+ headline: string
34
+ mood: MixSceneInfo
35
+ currentColorNodeIdx: number
36
+ currentWhiteNodeIdx: number
37
+ paintBucketSelected: boolean
38
+ paintWhiteBucketSelected: boolean
39
+ sceneMode: StripLightSceneMode
40
+ mainLamp: MixMainLampInfo
41
+ secondlyLamp: StripSceneInfo
42
+ loading: boolean
43
+ }
44
+
45
+ export interface MixMoodEditParams {
46
+ mode: 'add' | 'edit'
47
+ isStatic: boolean
48
+ currentMood: MixSceneInfo
49
+ moods: MixSceneInfo[]
50
+ modDeleteFlag: (mode: 'add' | 'edit' | 'del', currentMood: MixSceneInfo) => Promise<Result<any>>
51
+ onSave: () => void
52
+ moduleParams: MixMoodPageProps
53
+ }
54
+ const RgbcMoodEditPage = () => {
55
+ const navigation = useNavigation<StackNavigationProp<any>>()
56
+ const routeParams = useRoute().params as MixMoodEditParams
57
+ const params = cloneDeep(routeParams)
58
+ const moduleParams = params.moduleParams
59
+ const { mainLamp, secondlyLamp } = params.currentMood
60
+ const state = useReactive<MixMoodEditPageState>({
61
+ headline: '',
62
+ mood: params.currentMood,
63
+ mainLamp,
64
+ secondlyLamp,
65
+ currentWhiteNodeIdx: mainLamp.nodes?.length ? mainLamp.nodes.length - 1 : 1,
66
+ currentColorNodeIdx: secondlyLamp.nodes?.length ? secondlyLamp.nodes?.length - 1 : 1,
67
+ paintBucketSelected: false,
68
+ paintWhiteBucketSelected: false,
69
+ sceneMode: stripLightSceneMode,
70
+ loading: false
71
+ })
72
+
73
+ useEffect(() => {
74
+ state.headline = I18n.getLang(params.mode === 'add' ?
75
+ (params.isStatic ? 'add_new_static_mood_headline_text' : 'add_new_dynamic_mood_headline_text') :
76
+ (params.isStatic ? 'edit_static_mood_headline_text' : 'edit_static_mood_headline_text'))
77
+ }, [params.mode, params.isStatic])
78
+
79
+ const getColorBlockColor = useCallback(() => {
80
+ if (state.secondlyLamp?.nodes?.length) {
81
+ const currentNode = state.secondlyLamp?.nodes[state.currentColorNodeIdx]
82
+ const s = Math.round(mapFloatToRange(currentNode.s / 100, 30, 100))
83
+ if (currentNode.isColorNode) {
84
+ return hsv2Hex(currentNode.h, s, 100)
85
+ }
86
+ }
87
+ return '#fff'
88
+ }, [state.currentColorNodeIdx, state.secondlyLamp?.nodes])
89
+
90
+ const getNodeColor = useCallback((node: MixSceneNodeInfo, isColorNode) => {
91
+ if (isColorNode) {
92
+ return hsv2Hex(node.h, node.s, node.v)
93
+ } else {
94
+ return cctToColor(node.colorTemp)
95
+ }
96
+ }, [])
97
+
98
+ const createSecondlySelectModeData = useCallback(() => {
99
+ return Object.values(state.sceneMode).map(scene => {
100
+ return {
101
+ text: scene.title,
102
+ selected: scene.mode === state.secondlyLamp.mode,
103
+ value: scene.mode,
104
+ }
105
+ })
106
+ }, [state.secondlyLamp.mode, state.sceneMode])
107
+
108
+ const createMainSelectModeData = useCallback(() => {
109
+ return Object.values(CeilingLightSceneMode).map(scene => {
110
+ return {
111
+ text: scene.title,
112
+ selected: scene.mode === state.mainLamp.mode,
113
+ value: scene.mode,
114
+ }
115
+ })
116
+ }, [state.mainLamp.mode])
117
+
118
+ const createSelectOtherData = useCallback((otherData) => {
119
+ return otherData.map(other => {
120
+ return {
121
+ text: other.label,
122
+ selected: other.value === state.secondlyLamp.expand,
123
+ value: other.value,
124
+ }
125
+ })
126
+ }, [state.secondlyLamp.expand])
127
+
128
+ const getSelectOther = useCallback((otherData) => {
129
+ const currentOther = otherData.find(other => other.value === state.secondlyLamp.expand)
130
+ return currentOther.label
131
+ }, [state.secondlyLamp.expand])
132
+
133
+ const getButtonStatus = () => {
134
+ return isEqual({
135
+ ...state.mood,
136
+ mainLamp: state.mainLamp,
137
+ secondlyLamp: state.secondlyLamp
138
+ }, params.currentMood)
139
+ }
140
+
141
+ const nameRepeat = useMemo(() => {
142
+ return !!find(params.moods, m => ((m.mainLamp.id !== state.mood.mainLamp.id && (params.isStatic ? params.isStatic : m.secondlyLamp.id !== state.mood.secondlyLamp.id)) && m.name === state.mood.name))
143
+ }, [state.mood.name, params.isStatic])
144
+
145
+ useEffect(() =>{
146
+ console.log(nameRepeat, '< --- anmeRepeat')
147
+ }, [nameRepeat])
148
+ return (
149
+ <Page
150
+ backText={I18n.getLang('mesh_device_detail_mode')}
151
+ showBackDialog={true}
152
+ loading={state.loading}
153
+ backDialogTitle={
154
+ I18n.getLang(params.mode === 'add' ?
155
+ 'string_light_pp_dialog_sm_add_headline_c' :
156
+ 'manage_user_unsaved_changes_dialog_headline')
157
+ }
158
+ backDialogContent={
159
+ I18n.getLang(params.mode === 'add' ?
160
+ 'strip_light_static_mood_add_step_2_dialog_text' :
161
+ 'strip_light_static_mood_editor_step_2_dialog_text')
162
+ }
163
+ headlineText={state.headline}
164
+ rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
165
+ rightButtonDisabled={getButtonStatus()}
166
+ rightButtonIconClick={async () => {
167
+ if(state.loading) return
168
+ state.loading = true
169
+ const res = await params.modDeleteFlag(params.mode, {
170
+ ...state.mood,
171
+ mainLamp: state.mainLamp,
172
+ secondlyLamp: state.secondlyLamp
173
+ })
174
+ state.loading = false
175
+ if (res.success) {
176
+ navigation.navigate(ui_biz_routerKey.ui_biz_mix_mood)
177
+ }
178
+ }}>
179
+ <ScrollView
180
+ style={{ flex: 1 }}
181
+ nestedScrollEnabled={true}>
182
+ <View style={styles.root}>
183
+ <TextField
184
+ style={styles.name}
185
+ value={state.mood.name}
186
+ placeholder={I18n.getLang('edit_static_mood_inputfield_topic_text')}
187
+ onChangeText={text => {
188
+ state.mood.name = text
189
+ }}
190
+ showError={state.mood.name.length > 32 || nameRepeat}
191
+ maxLength={33}
192
+ tipColor={nameRepeat ? '#f00' : undefined}
193
+ tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
194
+ errorText={I18n.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')} />
195
+ {params.isStatic ? <Card style={styles.adjustCard}>
196
+ <LdvSwitch
197
+ title={I18n.getLang('light_sources_tile_main_lighting_headline')}
198
+ color="#fff"
199
+ colorAlpha={1}
200
+ enable={false}
201
+ setEnable={() => { }}
202
+ showSwitch={false}
203
+ />
204
+ <ColorTempAdjustView
205
+ isSupportBrightness={moduleParams.isSupportBrightness}
206
+ isSupportTemperature={moduleParams.isSupportTemperature}
207
+ colorTemp={state.mainLamp.nodes[state.currentWhiteNodeIdx].colorTemp}
208
+ brightness={state.mainLamp.nodes[state.currentWhiteNodeIdx].brightness}
209
+ onBrightnessChangeComplete={(bright) => {
210
+ state.mainLamp.nodes.forEach(node => {
211
+ node.brightness = bright
212
+ })
213
+ }}
214
+ onCCTChangeComplete={(cct) => {
215
+ state.mainLamp.nodes.forEach(node => {
216
+ node.colorTemp = cct
217
+ })
218
+ }}
219
+ />
220
+ <Spacer height={cx(16)}/>
221
+ </Card> :
222
+ <>
223
+ <Card style={styles.adjustCard}>
224
+ <LdvSwitch
225
+ title={I18n.getLang('light_sources_tile_main_lighting_headline')}
226
+ color="#fff"
227
+ colorAlpha={1}
228
+ enable={false}
229
+ setEnable={() => { }}
230
+ showSwitch={false}
231
+ />
232
+ <TextFieldStyleButton
233
+ style={styles.transitionMode}
234
+ text={CeilingLightSceneMode[state.mainLamp.mode]?.title}
235
+ placeholder={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
236
+ onPress={() => {
237
+ const paramsSelect: SelectPageParams<number> = {
238
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline'),
239
+ data: createMainSelectModeData(),
240
+ onSelect: selectPageData => {
241
+ state.mainLamp.mode = selectPageData.value
242
+ },
243
+ }
244
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect)
245
+ }} />
246
+ <Spacer height={cx(10)} />
247
+ <LdvSlider
248
+ title={I18n.getLang('add_new_dynamic_mood_lights_field_speed_topic_text')}
249
+ value={state.mainLamp.speed}
250
+ onValueChange={() => { }}
251
+ onSlidingComplete={value => {
252
+ state.mainLamp.speed = value
253
+ }} />
254
+ <Spacer height={cx(16)} />
255
+ <View style={styles.nodesAdjust}>
256
+ <View style={styles.adjustButtons}>
257
+ <TouchableOpacity
258
+ onPress={() => {
259
+ state.paintWhiteBucketSelected = true
260
+ }}>
261
+ <Image
262
+ style={[styles.adjustButton, { tintColor: state.paintWhiteBucketSelected ? '#f60' : '#666' }]}
263
+ source={res.ic_paint_bucket} />
264
+ </TouchableOpacity>
265
+ <TouchableOpacity
266
+ onPress={() => {
267
+ state.paintWhiteBucketSelected = false
268
+ }}>
269
+ <Image
270
+ style={[styles.adjustButton, { tintColor: state.paintWhiteBucketSelected ? '#666' : '#f60' }]}
271
+ source={res.ic_colorize} />
272
+ </TouchableOpacity>
273
+ </View>
274
+ <FlatList
275
+ data={state.mainLamp.nodes}
276
+ style={styles.nodeList}
277
+ renderItem={({ item, index }) => {
278
+ return (
279
+ <View style={styles.nodeItem}>
280
+ <TouchableOpacity
281
+ style={[
282
+ styles.nodeBlock,
283
+ {
284
+ backgroundColor: getNodeColor(item, false),
285
+ },
286
+ ]}
287
+ onPress={() => {
288
+ state.currentWhiteNodeIdx = index
289
+ }} />
290
+ <TouchableOpacity
291
+ style={styles.nodeDeleteBtn}
292
+ disabled={state.mainLamp.nodes.length < 3}
293
+ onPress={() => {
294
+ state.mainLamp.nodes.splice(index, 1)
295
+ state.currentWhiteNodeIdx = state.mainLamp.nodes.length - 1
296
+ }}>
297
+ <Image
298
+ style={[
299
+ styles.nodeDeleteIcon,
300
+ {
301
+ tintColor: state.mainLamp.nodes.length < 3 ? '#ccc' : '#666',
302
+ },
303
+ ]}
304
+ source={res.ic_mood_del} />
305
+ </TouchableOpacity>
306
+ </View>
307
+ )
308
+ }}
309
+ keyExtractor={(_, index) => `${index}`}
310
+ ItemSeparatorComponent={() => <Spacer height={cx(12)} />}
311
+ ListFooterComponent={() => {
312
+ if (state.mainLamp.nodes.length >= 8) {
313
+ return (<></>)
314
+ }
315
+ return (
316
+ <View>
317
+ <Spacer height={cx(12)} />
318
+ <TouchableOpacity
319
+ style={styles.nodeAddBtn}
320
+ onPress={() => {
321
+ const node = {
322
+ ...state.mainLamp.nodes[state.currentWhiteNodeIdx],
323
+ }
324
+ state.mainLamp.nodes.push(node)
325
+ state.currentWhiteNodeIdx = state.mainLamp.nodes.length - 1
326
+ }}>
327
+ <Image
328
+ style={{
329
+ width: cx(18),
330
+ height: cx(18),
331
+ tintColor: '#000',
332
+ }}
333
+ source={{ uri: res.add }} />
334
+ </TouchableOpacity>
335
+ </View>
336
+ )
337
+ }} />
338
+ </View>
339
+ <Spacer />
340
+ <ColorTempAdjustView
341
+ isSupportBrightness={moduleParams.isSupportBrightness}
342
+ isSupportTemperature={moduleParams.isSupportTemperature}
343
+ colorTemp={state.mainLamp.nodes[state.currentWhiteNodeIdx].colorTemp}
344
+ brightness={state.mainLamp.nodes[state.currentWhiteNodeIdx].brightness}
345
+ onBrightnessChangeComplete={(bright) => {
346
+ state.mainLamp.nodes.forEach((node, idx) => {
347
+ if (state.paintWhiteBucketSelected) {
348
+ node.brightness = bright
349
+ }
350
+ if (state.currentWhiteNodeIdx === idx) {
351
+ node.brightness = bright
352
+ }
353
+ })
354
+ }}
355
+ onCCTChangeComplete={(cct) => {
356
+ state.mainLamp.nodes.forEach((node, idx) => {
357
+ if (state.paintWhiteBucketSelected) {
358
+ node.colorTemp = cct
359
+ }
360
+ if (state.currentWhiteNodeIdx === idx) {
361
+ node.colorTemp = cct
362
+ }
363
+ })
364
+ }}
365
+ />
366
+ <Spacer height={cx(10)} />
367
+ </Card>
368
+ <Card style={styles.adjustCard}>
369
+ <LdvSwitch
370
+ title={I18n.getLang('light_sources_tile_sec_lighting_headline')}
371
+ color={'#fff'}
372
+ colorAlpha={1}
373
+ enable={false}
374
+ setEnable={() => { }}
375
+ showSwitch={false}
376
+ />
377
+ <TextFieldStyleButton
378
+ style={styles.transitionMode}
379
+ text={state.sceneMode[state.secondlyLamp.mode]?.title}
380
+ placeholder={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
381
+ onPress={() => {
382
+ const paramsSelect: SelectPageParams<number> = {
383
+ title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline'),
384
+ data: createSecondlySelectModeData(),
385
+ onSelect: selectPageData => {
386
+ state.secondlyLamp.mode = selectPageData.value
387
+ },
388
+ }
389
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect)
390
+ }} />
391
+ <Spacer height={cx(10)} />
392
+ <LdvSlider
393
+ title={I18n.getLang('add_new_dynamic_mood_lights_field_speed_topic_text')}
394
+ value={state.secondlyLamp.speed}
395
+ onValueChange={() => { }}
396
+ onSlidingComplete={value => {
397
+ state.secondlyLamp.speed = value
398
+ }} />
399
+ <Spacer height={cx(16)} />
400
+ {state.sceneMode[state.secondlyLamp.mode]?.turnOn && <View style={styles.transitionMode}>
401
+ <Segmented
402
+ value={state.secondlyLamp.direction}
403
+ options={[
404
+ {
405
+ label: I18n.getLang('add_new_dynamic_mood_strip_lights_switch_tab_text1'),
406
+ value: 0
407
+ },
408
+ {
409
+ label: I18n.getLang('add_new_dynamic_mood_strip_lights_switch_tab_text2'),
410
+ value: 1
411
+ },
412
+ ]}
413
+ onChange={(v) => state.secondlyLamp.direction = Number(v)}
414
+ />
415
+ <Spacer />
416
+ </View>}
417
+ {state.sceneMode[state.secondlyLamp.mode]?.paragraph && <View style={styles.transitionMode}>
418
+ <Segmented
419
+ value={state.secondlyLamp.segmented}
420
+ options={[
421
+ {
422
+ label: I18n.getLang('add_new_dynamic_mood_strip_lights_switch_tab_text3'),
423
+ value: 0
424
+ },
425
+ {
426
+ label: I18n.getLang('add_new_dynamic_mood_strip_lights_switch_tab_text4'),
427
+ value: 1
428
+ },
429
+ ]}
430
+ onChange={(v) => state.secondlyLamp.segmented = Number(v)}
431
+ />
432
+ <Spacer />
433
+ </View>}
434
+ {state.sceneMode[state.secondlyLamp.mode]?.other && <>
435
+ <TextFieldStyleButton
436
+ style={styles.transitionMode}
437
+ text={getSelectOther(state.sceneMode[state.secondlyLamp.mode]?.other)}
438
+ placeholder={I18n.getLang('add_new_dynamic_mood_strip_lights_selectionfield2_topic_text')}
439
+ onPress={() => {
440
+ const paramsSelect: SelectPageParams<number> = {
441
+ title: I18n.getLang('add_new_dynamic_mood_strip_lights_selectionfield2_topic_text'),
442
+ data: createSelectOtherData(state.sceneMode[state.secondlyLamp.mode]?.other),
443
+ onSelect: selectPageData => {
444
+ state.secondlyLamp.expand = selectPageData.value
445
+ },
446
+ }
447
+ navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect)
448
+ }} />
449
+ <Spacer />
450
+ </>}
451
+ <View style={styles.nodesAdjust}>
452
+ <View style={styles.adjustButtons}>
453
+ <TouchableOpacity
454
+ onPress={() => {
455
+ state.paintBucketSelected = true
456
+ }}>
457
+ <Image
458
+ style={[styles.adjustButton, { tintColor: state.paintBucketSelected ? '#f60' : '#666' }]}
459
+ source={res.ic_paint_bucket} />
460
+ </TouchableOpacity>
461
+ <TouchableOpacity
462
+ onPress={() => {
463
+ state.paintBucketSelected = false
464
+ }}>
465
+ <Image
466
+ style={[styles.adjustButton, { tintColor: state.paintBucketSelected ? '#666' : '#f60' }]}
467
+ source={res.ic_colorize} />
468
+ </TouchableOpacity>
469
+ </View>
470
+ <FlatList
471
+ data={state.secondlyLamp.nodes}
472
+ style={styles.nodeList}
473
+ renderItem={({ item, index }) => {
474
+ return (
475
+ <View style={styles.nodeItem}>
476
+ <TouchableOpacity
477
+ style={[
478
+ styles.nodeBlock,
479
+ {
480
+ backgroundColor: getNodeColor(item, true),
481
+ },
482
+ ]}
483
+ onPress={() => {
484
+ state.currentColorNodeIdx = index
485
+ }} />
486
+ <TouchableOpacity
487
+ style={styles.nodeDeleteBtn}
488
+ disabled={state.secondlyLamp.nodes.length < 3}
489
+ onPress={() => {
490
+ state.secondlyLamp.nodes.splice(index, 1)
491
+ state.currentColorNodeIdx = state.secondlyLamp.nodes.length - 1
492
+ }}>
493
+ <Image
494
+ style={[
495
+ styles.nodeDeleteIcon,
496
+ {
497
+ tintColor: state.secondlyLamp.nodes.length < 3 ? '#ccc' : '#666',
498
+ },
499
+ ]}
500
+ source={res.ic_mood_del} />
501
+ </TouchableOpacity>
502
+ </View>
503
+ )
504
+ }}
505
+ keyExtractor={(_, index) => `${index}`}
506
+ ItemSeparatorComponent={() => <Spacer height={cx(12)} />}
507
+ ListFooterComponent={() => {
508
+ if (state.secondlyLamp.nodes.length >= 8) {
509
+ return (<></>)
510
+ }
511
+ return (
512
+ <View>
513
+ <Spacer height={cx(12)} />
514
+ <TouchableOpacity
515
+ style={styles.nodeAddBtn}
516
+ onPress={() => {
517
+ const node = {
518
+ ...state.secondlyLamp.nodes[state.currentWhiteNodeIdx],
519
+ }
520
+ state.secondlyLamp.nodes.push(node)
521
+ state.currentWhiteNodeIdx = state.secondlyLamp.nodes.length - 1
522
+ }}>
523
+ <Image
524
+ style={{
525
+ width: cx(18),
526
+ height: cx(18),
527
+ tintColor: '#000',
528
+ }}
529
+ source={{ uri: res.add }} />
530
+ </TouchableOpacity>
531
+ </View>
532
+ )
533
+ }} />
534
+ </View>
535
+ <Spacer />
536
+ <View style={styles.lightLine}>
537
+ <Text style={styles.light}>
538
+ {I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
539
+ </Text>
540
+ <View style={[styles.preview, { backgroundColor: getColorBlockColor() }]} />
541
+ </View>
542
+ <Spacer />
543
+ <ColorAdjustView
544
+ h={state.secondlyLamp.nodes[state.currentColorNodeIdx].h}
545
+ s={state.secondlyLamp.nodes[state.currentColorNodeIdx].s}
546
+ v={state.secondlyLamp.nodes[state.currentColorNodeIdx].v}
547
+ onHSVChange={() => { }}
548
+ onHSVChangeComplete={(h, s, v) => {
549
+ state.secondlyLamp.nodes.forEach((node, idx) => {
550
+ if (state.paintBucketSelected) {
551
+ node.h = h
552
+ node.s = s
553
+ node.v = v
554
+ }
555
+ if (state.currentColorNodeIdx === idx) {
556
+ node.h = h
557
+ node.s = s
558
+ node.v = v
559
+ }
560
+ })
561
+ }}
562
+ />
563
+ <Spacer height={cx(10)} />
564
+ </Card>
565
+ </>}
566
+
567
+ <Spacer />
568
+ {params.mode === 'edit' &&
569
+ <View style={{ marginTop: cx(20), marginHorizontal: cx(24) }}>
570
+ <TextButton
571
+ style={styles.deleteBtn}
572
+ textStyle={styles.deleteBtnText}
573
+ text={I18n.getLang('edit_static_mood_button_delete_text')}
574
+ onPress={() => {
575
+ showDeleteMoodDialog(async (_, { close }) => {
576
+ close()
577
+ params.modDeleteFlag('del', state.mood)
578
+ })
579
+ }} />
580
+ </View>}
581
+ <Spacer />
582
+ </View>
583
+ </ScrollView>
584
+ </Page>
585
+ )
586
+ }
587
+ const styles = StyleSheet.create({
588
+ root: {
589
+ flex: 1,
590
+ flexDirection: 'column',
591
+ },
592
+ name: {
593
+ marginHorizontal: cx(24),
594
+ },
595
+ adjustCard: {
596
+ marginVertical: cx(12),
597
+ marginHorizontal: cx(24),
598
+ },
599
+ fanAdjustCard: {
600
+ marginHorizontal: cx(24),
601
+ },
602
+ lightLine: {
603
+ flexDirection: 'row',
604
+ marginHorizontal: cx(16),
605
+ },
606
+ light: {
607
+ color: '#000',
608
+ fontSize: cx(18),
609
+ fontFamily: 'helvetica_neue_lt_std_bd',
610
+ },
611
+ transitionMode: {
612
+ marginHorizontal: cx(16),
613
+ },
614
+ preview: {
615
+ width: cx(20),
616
+ height: cx(20),
617
+ marginStart: cx(12),
618
+ borderRadius: cx(4),
619
+ },
620
+ nodesAdjust: {
621
+ flexDirection: 'row',
622
+ alignItems: 'center',
623
+ },
624
+ adjustButtons: {
625
+ width: cx(44),
626
+ marginStart: cx(16),
627
+ },
628
+ adjustButton: {
629
+ width: cx(44),
630
+ height: cx(44),
631
+ },
632
+ nodeList: {
633
+ flex: 1,
634
+ marginHorizontal: cx(16),
635
+ },
636
+ nodeItem: {
637
+ flexDirection: 'row',
638
+ alignItems: 'center',
639
+ },
640
+ nodeBlock: {
641
+ flex: 1,
642
+ height: cx(40),
643
+ borderRadius: cx(8),
644
+ },
645
+ nodeDeleteBtn: {
646
+ width: cx(24),
647
+ height: cx(30),
648
+ justifyContent: 'center',
649
+ alignItems: 'center',
650
+ },
651
+ nodeDeleteIcon: {
652
+ width: cx(16),
653
+ height: cx(16),
654
+ },
655
+ nodeAddBtn: {
656
+ height: cx(40),
657
+ justifyContent: 'center',
658
+ alignItems: 'center',
659
+ marginEnd: cx(26),
660
+ borderRadius: cx(8),
661
+ borderWidth: cx(1),
662
+ borderStyle: 'dashed',
663
+ borderColor: '#666',
664
+ backgroundColor: '#f6f6f6',
665
+ },
666
+ deleteBtn: {
667
+ width: '100%',
668
+ height: cx(50),
669
+ backgroundColor: '#666',
670
+ borderRadius: cx(8),
671
+ },
672
+ deleteBtnText: {
673
+ color: '#fff',
674
+ fontSize: cx(16),
675
+ fontFamily: 'helvetica_neue_lt_std_bd',
676
+ },
677
+ })
678
+
679
+ export const defWhiteNode: SceneNodeInfo[] = [
680
+ {
681
+ h: 0,
682
+ s: 0,
683
+ v: 0,
684
+ brightness: 100,
685
+ colorTemp: 0,
686
+ switchingInterval: 50,
687
+ transitionTime: 50,
688
+ transitionMode: 1,
689
+ isColorNode: false
690
+ },
691
+ {
692
+ h: 0,
693
+ s: 0,
694
+ v: 0,
695
+ brightness: 100,
696
+ colorTemp: 0,
697
+ switchingInterval: 50,
698
+ transitionTime: 50,
699
+ transitionMode: 1,
700
+ isColorNode: false
701
+ },
702
+ ]
703
+
704
+ export const defColorNode: StripNodeInfo[] = [
705
+ { h: 0, s: 100, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
706
+ { h: 0, s: 100, v: 100, brightness: 0, colorTemp: 0, isColorNode: true },
707
+ ]
708
+
709
+ export default RgbcMoodEditPage