@ledvance/group-ui-biz-bundle 1.0.50 → 1.0.52

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/group-ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.50",
7
+ "version": "1.0.52",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -11,15 +11,35 @@ import {hex2Int, spliceByStep} from '@ledvance/base/src/utils/common'
11
11
  import I18n from '@ledvance/base/src/i18n'
12
12
  import BiologicalRes from './res/BiologicalRes'
13
13
  import { to16 } from '@tuya/tuya-panel-lamp-sdk/lib/utils'
14
+ import { useCallback } from 'react'
15
+ import { Result } from '@ledvance/base/src/models/modules/Result'
14
16
 
15
17
  interface BiorhythmConfig {
16
18
  rhythm_mode: BiorhythmBean
17
19
  }
18
20
 
19
- export const useBiorhythm = () => {
20
- return useFeatureHook<BiorhythmConfig, BiorhythmBean>('rhythm_mode', getDefBiorhythmUIState(), (val) => {
21
+ export const useBiorhythm = (): [BiorhythmBean, (value: BiorhythmBean) => Promise<Result<any>>] => {
22
+ const [config, setConfig] = useFeatureHook<BiorhythmConfig, BiorhythmBean>('rhythm_mode', getDefBiorhythmUIState(), (val) => {
21
23
  return obj2Dp(val)
22
24
  })
25
+ const supportOldData = useCallback((oldData: BiorhythmBean) =>{
26
+ return {
27
+ ...oldData,
28
+ planList: oldData.planList.map(p => {
29
+ // @ts-ignore 老数据中使用的是startTime
30
+ if (!p.hasOwnProperty('time') && p.startTime){
31
+ // @ts-ignore
32
+ const t = p.startTime.split(':')
33
+ return {
34
+ ...p,
35
+ time: Number(t[0]) * 60 + Number(t[1])
36
+ }
37
+ }
38
+ return p
39
+ })
40
+ }
41
+ }, [])
42
+ return [supportOldData(config), setConfig]
23
43
  }
24
44
 
25
45
  export function dp2Obj(dp: string): BiorhythmBean {
@@ -39,7 +39,7 @@ export interface FlagConfigType {
39
39
  export const useFlagMode = () : [FlagMode, (flagMode: FlagMode) => Promise<Result<any>>] =>{
40
40
  const uaGroupInfo = useUAGroupInfo()
41
41
  const [config, setConfig] = useGroupEzvizConfig<FlagConfigType, FlagMode>('flagMode', undefined)
42
- const [cloudConfig, setCloudConfig] = useState()
42
+ const [cloudConfig, setCloudConfig] = useState<FlagMode>({flagMode: false, flagId: undefined})
43
43
  useEffect(() =>{
44
44
  if (!config) {
45
45
  getFlagMode(uaGroupInfo.tyGroupId.toString()).then(res =>{
@@ -15,15 +15,16 @@ import {
15
15
  } from './Interface';
16
16
  import { Result } from '@ledvance/base/src/models/modules/Result';
17
17
  import { ui_biz_routerKey } from '../../navigation/Routers'
18
- import { difference, head, map, range } from 'lodash';
18
+ import { difference, head, range } from 'lodash';
19
19
  import { RecommendMood, getRecommendMixMoods, getRecommendMoods } from './MoodInfo';
20
20
 
21
21
  const cx = Utils.RatioUtils.convertX;
22
22
 
23
23
  export interface AddMoodPageParams {
24
24
  isStatic: boolean;
25
- moods: MoodUIInfo[];
25
+ moodIds: number[];
26
26
  moduleParams: MoodPageParams;
27
+ nameRepeat: (mood: MoodUIInfo) => boolean
27
28
  modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
28
29
  }
29
30
 
@@ -56,32 +57,21 @@ const AddMoodPage = () => {
56
57
 
57
58
  const onMoodItemClick = useCallback(
58
59
  (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
60
  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 ')
61
+ const mainId: number = head(difference(idRange, routeParams.moodIds)) || 0;
62
+ const secondaryId: number = moduleParams.isCeilingLight ? head(difference(idRange, [...routeParams.moodIds, mainId])) || 0 : 0
71
63
  const url = routeParams.isStatic
72
64
  ? ui_biz_routerKey.group_ui_biz_static_mood_edit
73
65
  : !!(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;
66
+ ? ui_biz_routerKey.group_ui_biz_dynamic_mix_mood_edit
67
+ : ui_biz_routerKey.group_ui_biz_dynamic_mood_edit;
76
68
  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);
69
+ ? { ...moodItem, id: mainId, mainLamp: { ...moodItem.mainLamp, id: mainId }, secondaryLamp: { ...moodItem.secondaryLamp, id: secondaryId } }
70
+ : newMood(mainId, secondaryId, moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
79
71
  navigation.navigate(url, {
72
+ ...routeParams,
80
73
  mode: 'add',
81
74
  currentMood,
82
- moods: routeParams.moods,
83
- moduleParams,
84
- modDeleteMood: routeParams.modDeleteMood,
85
75
  });
86
76
  },
87
77
  [routeParams]
@@ -113,6 +103,7 @@ const AddMoodPage = () => {
113
103
  title={item.name}
114
104
  isMix={isMix}
115
105
  mood={getFormateItem(item)}
106
+ deviceTypeOption={moduleParams}
116
107
  onPress={() => {
117
108
  onMoodItemClick(item);
118
109
  }}
@@ -144,6 +135,17 @@ const styles = StyleSheet.create({
144
135
 
145
136
  export default AddMoodPage;
146
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
+
147
149
  function newMood(
148
150
  mainId: number,
149
151
  secondaryId: number,
@@ -154,8 +156,8 @@ function newMood(
154
156
  const jump = moduleParams.isStringLight
155
157
  ? MoodJumpGradientMode.StringJump
156
158
  : moduleParams.isStripLight
157
- ? MoodJumpGradientMode.StripJump
158
- : MoodJumpGradientMode.SourceJump;
159
+ ? MoodJumpGradientMode.StripJump
160
+ : MoodJumpGradientMode.SourceJump;
159
161
  const node = {
160
162
  brightness: 100,
161
163
  colorTemp: 100,
@@ -175,6 +177,7 @@ function newMood(
175
177
  enable: true,
176
178
  fanEnable: true,
177
179
  fanSpeed: 1,
180
+ ...defStripConfig,
178
181
  mode: isStatic ? MoodNodeTransitionMode.Static : jump,
179
182
  nodes: isStatic ? [node] : [node, { ...node }],
180
183
  },
@@ -183,15 +186,9 @@ function newMood(
183
186
  enable: true,
184
187
  mode: MoodJumpGradientMode.StripJump,
185
188
  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}],
189
+ ...defStripConfig,
190
+ version: 1,
191
+ nodes: isStatic ? [] : [{ ...node, isColorNode: true }, { ...node, isColorNode: true }],
195
192
  },
196
193
  };
197
194
  }
@@ -10,9 +10,8 @@ import {
10
10
  } from 'react-native';
11
11
  import { Utils } from 'tuya-panel-kit';
12
12
  import { useReactive } from 'ahooks';
13
- import { cloneDeep, find, isEqual } from 'lodash';
13
+ import { cloneDeep, isEqual } from 'lodash';
14
14
  import Page from '@ledvance/base/src/components/Page';
15
- import Strings from '@ledvance/base/src/i18n';
16
15
  import { StaticMoodEditorPageParams } from './StaticMoodEditorPage';
17
16
  import { useNavigation } from '@react-navigation/native';
18
17
  import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
@@ -71,7 +70,7 @@ const DynamicMoodEditorPage = () => {
71
70
  });
72
71
 
73
72
  useEffect(() => {
74
- state.headline = Strings.getLang(
73
+ state.headline = I18n.getLang(
75
74
  params.mode === 'add'
76
75
  ? 'add_new_dynamic_mood_headline_text'
77
76
  : 'edit_static_mood_headline_text'
@@ -95,15 +94,6 @@ const DynamicMoodEditorPage = () => {
95
94
  return cctToColor(node.colorTemp.toFixed());
96
95
  }, []);
97
96
 
98
- const getButtonStatus = () => {
99
- return (
100
- (params.mode === 'edit' && isEqual(state.mood, routeParams.currentMood)) ||
101
- !!!state.mood.name ||
102
- nameRepeat ||
103
- state.mood.name.length > 32
104
- );
105
- };
106
-
107
97
  const createSelectModeData = useCallback(
108
98
  (mode: number, moodMode?: StripLightMoodMode) => {
109
99
  return Object.values(moodMode ? moodMode : state.sceneMode).map(scene => {
@@ -133,31 +123,38 @@ const DynamicMoodEditorPage = () => {
133
123
  }, []);
134
124
 
135
125
  const nameRepeat = useMemo(() => {
136
- return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
126
+ return params.nameRepeat(state.mood)
137
127
  }, [state.mood.name]);
138
128
 
129
+ const checkMoodChanged = useMemo(() =>{
130
+ return isEqual(state.mood, params.currentMood)
131
+ }, [JSON.stringify(state.mood), params.currentMood])
132
+
133
+ const canSaveMoodData = useMemo(() =>{
134
+ return state.mood.name.length > 0 && state.mood.name.length < 33 && !nameRepeat && (params.mode === 'add' || !checkMoodChanged)
135
+ }, [nameRepeat, state.mood.name, checkMoodChanged, params.mode])
139
136
 
140
137
  return (
141
138
  <Page
142
- backText={Strings.getLang('mesh_device_detail_mode')}
143
- showBackDialog={true}
144
- backDialogTitle={Strings.getLang(
139
+ backText={I18n.getLang('mesh_device_detail_mode')}
140
+ showBackDialog={!checkMoodChanged}
141
+ backDialogTitle={I18n.getLang(
145
142
  params.mode === 'add'
146
143
  ? 'string_light_pp_dialog_sm_add_headline_c'
147
144
  : 'manage_user_unsaved_changes_dialog_headline'
148
145
  )}
149
- backDialogContent={Strings.getLang(
146
+ backDialogContent={I18n.getLang(
150
147
  params.mode === 'add'
151
148
  ? 'strip_light_static_mood_add_step_2_dialog_text'
152
149
  : 'strip_light_static_mood_editor_step_2_dialog_text'
153
150
  )}
154
151
  headlineText={state.headline}
155
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
156
- rightButtonDisabled={getButtonStatus()}
152
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
157
153
  rightButtonIconClick={async () => {
158
- if (state.loading) return;
154
+ if (state.loading || !canSaveMoodData) return;
159
155
  state.loading = true;
160
156
  const res = await params.modDeleteMood(params.mode, cloneDeep(state.mood));
157
+ console.log(res, '< --- res ---- >')
161
158
  if (res.success) {
162
159
  navigation.navigate(ui_biz_routerKey.group_ui_biz_mood);
163
160
  }
@@ -170,7 +167,7 @@ const DynamicMoodEditorPage = () => {
170
167
  <TextField
171
168
  style={styles.name}
172
169
  value={state.mood.name}
173
- placeholder={Strings.getLang('edit_static_mood_inputfield_topic_text')}
170
+ placeholder={I18n.getLang('edit_static_mood_inputfield_topic_text')}
174
171
  onChangeText={text => {
175
172
  state.mood.name = text;
176
173
  }}
@@ -178,7 +175,7 @@ const DynamicMoodEditorPage = () => {
178
175
  showError={state.mood.name.length > 32 || nameRepeat}
179
176
  tipColor={nameRepeat ? '#f00' : undefined}
180
177
  tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
181
- errorText={Strings.getLang(
178
+ errorText={I18n.getLang(
182
179
  nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text'
183
180
  )}
184
181
  />
@@ -186,14 +183,14 @@ const DynamicMoodEditorPage = () => {
186
183
  <Spacer height={cx(16)} />
187
184
  <View style={styles.lightLine}>
188
185
  <Text style={styles.light}>
189
- {Strings.getLang('light_sources_tile_tw_lighting_headline')}
186
+ {I18n.getLang('light_sources_tile_tw_lighting_headline')}
190
187
  </Text>
191
188
  </View>
192
189
  <Spacer height={cx(18)} />
193
190
  <TextFieldStyleButton
194
191
  style={styles.transitionMode}
195
192
  text={state.sceneMode[state.mood.mainLamp.mode]?.title}
196
- placeholder={Strings.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
193
+ placeholder={I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline')}
197
194
  onPress={() => {
198
195
  const paramsSelect: SelectPageParams<number> = {
199
196
  title: I18n.getLang('add_new_dynamic_mood_color_changing_mode_headline'),
@@ -207,7 +204,7 @@ const DynamicMoodEditorPage = () => {
207
204
  />
208
205
  <Spacer height={cx(10)} />
209
206
  <LdvSlider
210
- title={Strings.getLang('add_new_dynamic_mood_lights_field_speed_topic_text')}
207
+ title={I18n.getLang('add_new_dynamic_mood_lights_field_speed_topic_text')}
211
208
  value={state.mood.mainLamp.speed}
212
209
  onValueChange={() => {}}
213
210
  onSlidingComplete={value => {
@@ -386,7 +383,7 @@ const DynamicMoodEditorPage = () => {
386
383
  <Spacer />
387
384
  <View style={styles.lightLine}>
388
385
  <Text style={styles.light}>
389
- {Strings.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
386
+ {I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
390
387
  </Text>
391
388
  <View
392
389
  style={[styles.preview, { backgroundColor: getColorBlockColor(state.mainNode) }]}
@@ -527,7 +524,7 @@ const DynamicMoodEditorPage = () => {
527
524
  <TextButton
528
525
  style={styles.deleteBtn}
529
526
  textStyle={styles.deleteBtnText}
530
- text={Strings.getLang('edit_static_mood_button_delete_text')}
527
+ text={I18n.getLang('edit_static_mood_button_delete_text')}
531
528
  onPress={() => {
532
529
  showDialog({
533
530
  method: 'confirm',
@@ -648,7 +645,7 @@ const styles = StyleSheet.create({
648
645
  export default DynamicMoodEditorPage;
649
646
  export function getTransitionModeString(transitionMode: MoodNodeTransitionMode): string {
650
647
  if (transitionMode === MoodNodeTransitionMode.Jump) {
651
- return Strings.getLang('other_lights_modes_jump_text');
648
+ return I18n.getLang('other_lights_modes_jump_text');
652
649
  }
653
- return Strings.getLang('other_lights_modes_gradient_text');
650
+ return I18n.getLang('other_lights_modes_gradient_text');
654
651
  }
@@ -10,7 +10,7 @@ import {
10
10
  } from 'react-native';
11
11
  import { Utils } from 'tuya-panel-kit';
12
12
  import { useReactive } from 'ahooks';
13
- import { cloneDeep, find, isEqual } from 'lodash';
13
+ import { cloneDeep, isEqual } from 'lodash';
14
14
  import Page from '@ledvance/base/src/components/Page';
15
15
  import { StaticMoodEditorPageParams, StaticMoodEditorPageState } from './StaticMoodEditorPage';
16
16
  import { useNavigation } from '@react-navigation/native';
@@ -91,15 +91,6 @@ const MixDynamicMoodEditorPage = () => {
91
91
  return cctToColor(node.colorTemp.toFixed());
92
92
  }, []);
93
93
 
94
- const getButtonStatus = () => {
95
- return (
96
- (params.mode === 'edit' && isEqual(state.mood, routeParams.currentMood)) ||
97
- !!!state.mood.name ||
98
- nameRepeat ||
99
- state.mood.name.length > 32
100
- );
101
- };
102
-
103
94
  const createSelectModeData = useCallback(
104
95
  (mode: number, moodMode: StripLightMoodMode) => {
105
96
  return Object.values(moodMode).map(scene => {
@@ -129,13 +120,21 @@ const MixDynamicMoodEditorPage = () => {
129
120
  }, []);
130
121
 
131
122
  const nameRepeat = useMemo(() => {
132
- return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
123
+ return params.nameRepeat(state.mood)
133
124
  }, [state.mood.name]);
134
125
 
126
+ const checkMoodChanged = useMemo(() =>{
127
+ return isEqual(state.mood, params.currentMood)
128
+ }, [JSON.stringify(state.mood), params.currentMood])
129
+
130
+ const canSaveMoodData = useMemo(() =>{
131
+ return state.mood.name.length > 0 && state.mood.name.length < 33 && !nameRepeat && (params.mode === 'add' || !checkMoodChanged)
132
+ }, [nameRepeat, state.mood.name, checkMoodChanged, params.mode])
133
+
135
134
  return (
136
135
  <Page
137
136
  backText={I18n.getLang('mesh_device_detail_mode')}
138
- showBackDialog={true}
137
+ showBackDialog={!checkMoodChanged}
139
138
  backDialogTitle={I18n.getLang(
140
139
  params.mode === 'add'
141
140
  ? 'string_light_pp_dialog_sm_add_headline_c'
@@ -147,10 +146,9 @@ const MixDynamicMoodEditorPage = () => {
147
146
  : 'strip_light_static_mood_editor_step_2_dialog_text'
148
147
  )}
149
148
  headlineText={state.headline}
150
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
151
- rightButtonDisabled={getButtonStatus()}
149
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
152
150
  rightButtonIconClick={async () => {
153
- if (state.loading) return;
151
+ if (state.loading || !canSaveMoodData) return;
154
152
  state.loading = true;
155
153
  const newMood = cloneDeep(state.mood)
156
154
  if(moduleParams.isMixLight){
@@ -3,6 +3,7 @@ import {
3
3
  DefMoodOption,
4
4
  LightCategory,
5
5
  MixRemoteMoodInfo,
6
+ MoodPageParams,
6
7
  MoodUIInfo,
7
8
  RemoteMoodInfo,
8
9
  } from './Interface';
@@ -35,16 +36,12 @@ export interface SceneDataConfigType {
35
36
  switch_led: boolean
36
37
  colour_switch: boolean
37
38
  white_switch: boolean
39
+ switch: boolean
38
40
  }
39
41
 
40
- interface LightType {
41
- isStringLight?: boolean
42
- isStripLight?: boolean
43
- isCeilingLight?: boolean
44
- isFanLight?: boolean
45
- isMixLight?: boolean
46
- isUVCFan?: boolean
47
- isMatterLight?: boolean
42
+ export function useSwitchLed(params: MoodPageParams): boolean {
43
+ const [switchLed] = useGroupDp<boolean>(getGlobalParamsDp(params.isMatterLight ? 'switch' : 'switch_led'))
44
+ return switchLed
48
45
  }
49
46
 
50
47
  export function useWorkMode(): WorkMode {
@@ -57,28 +54,21 @@ export function useRgbicWorkMode(): WorkMode {
57
54
  return rgbicWorkMode
58
55
  }
59
56
 
60
- export function useMoodScene(params: LightType): [SceneDataType, (value: SceneDataType) => Promise<Result<any>>] {
57
+ export function useMoodScene(params: MoodPageParams): [SceneDataType, (value: SceneDataType) => Promise<Result<any>>] {
61
58
  const defConfig = {
62
59
  scene: undefined
63
60
  }
64
- // const [] = useGroupDp<MoodUIInfo>(getGlobalParamsDp('scene_data'))
65
- // const [] = useGroupDp<MoodUIInfo>(getGlobalParamsDp(''))
66
61
  const [config, setConfig] = useFeatureHook<SceneDataConfigType, SceneDataType>('sceneConfig', defConfig, undefined,
67
62
  (moodInfo) => {
68
63
  if (moodInfo?.scene) {
69
- console.log(moodInfo.scene, '< --- moodInfo.scene')
70
64
  const dps = {}
71
65
  const { mainLamp, secondaryLamp } = moodInfo.scene
72
66
  if (mainLamp?.nodes?.length) {
73
67
  const mainDp = getMoodDp(params.isCeilingLight ? ({...moodInfo.scene, id: mainLamp.id!}) : moodInfo.scene, params)
74
- if (mainDp && getGlobalParamsDp('scene_data')) {
75
- dps[getGlobalParamsDp('scene_data')] = mainDp
76
- dps[getGlobalParamsDp('work_mode')] = WorkMode.Scene
77
- if (params.isCeilingLight) {
78
- dps[getGlobalParamsDp('white_switch')] = true
79
- } else {
80
- dps[getGlobalParamsDp('switch_led')] = true
81
- }
68
+ if (mainDp && params.mainDp) {
69
+ dps[params.mainDp] = mainDp
70
+ dps[params.mainSwitch] = true
71
+ dps[params.mainWorkMode] = WorkMode.Scene
82
72
  }
83
73
  }
84
74
  if (secondaryLamp.nodes.length && params.isCeilingLight) {
@@ -87,10 +77,10 @@ export function useMoodScene(params: LightType): [SceneDataType, (value: SceneDa
87
77
  mainLamp: secondaryLamp,
88
78
  id: secondaryLamp.id!
89
79
  });
90
- if (secondaryDp && getGlobalParamsDp('dreamlight_scene_mode')) {
91
- dps[getGlobalParamsDp('dreamlight_scene_mode')] = secondaryDp
92
- dps[getGlobalParamsDp('rgbic_work_mode')] = WorkMode.Scene
93
- dps[getGlobalParamsDp('colour_switch')] = true
80
+ if (secondaryDp && params.secondaryDp) {
81
+ dps[params.secondaryDp] = secondaryDp
82
+ dps[params.secondaryWorkMode!] = WorkMode.Scene
83
+ dps[params.secondarySwitch!] = true
94
84
  }
95
85
  }
96
86
  return dps
@@ -103,6 +93,8 @@ export function useMoodScene(params: LightType): [SceneDataType, (value: SceneDa
103
93
  config.work_mode = WorkMode.Scene
104
94
  if (params.isCeilingLight) {
105
95
  config.white_switch = true
96
+ }else if(params.isMatterLight){
97
+ config.switch = true
106
98
  } else {
107
99
  config.switch_led = true
108
100
  }
@@ -149,7 +141,7 @@ const getMoodDp = (moodInfo: MoodUIInfo, option: LightCategory) => {
149
141
 
150
142
  const remoteMoodInfo2MoodUIState = (
151
143
  remoteMoodInfo,
152
- index: number,
144
+ _: number,
153
145
  option: DefMoodOption
154
146
  ): MoodUIInfo => {
155
147
  const moodInfo = option.isMixLight
@@ -166,8 +158,6 @@ export const getRemoteMoodList = async (
166
158
  devId: string,
167
159
  option: DefMoodOption,
168
160
  ) => {
169
- // const defaultScene = getDefMoodList(option);
170
- // await setRemoteMoodList(devId, defaultScene, SceneFeatureId);
171
161
  const res = await NativeApi.getJson(devId, SceneFeatureId);
172
162
  const isNormalData = Array.isArray(parseJSON(res?.data));
173
163
  if (res.success && isNormalData) {
@@ -66,7 +66,7 @@ export function getDefMoodList(option: DefMoodOption) {
66
66
  if (option.isSupportTemperature && option.isSupportBrightness) {
67
67
  return getRGBWDefSceneList();
68
68
  }
69
- if (option.isSupportTemperature) {
69
+ if (option.isSupportBrightness) {
70
70
  return getRGBDefSceneList();
71
71
  }
72
72
  return getOnlyRGBDefSceneList();
@@ -135,43 +135,35 @@ function getRGBDefSceneList(): RemoteMoodInfo[] {
135
135
  s: '',
136
136
  t: 0,
137
137
  e: false,
138
- },
139
- {
138
+ },
139
+ {
140
140
  n: I18n.getLang('mesh_device_detail_lighting_read'),
141
141
  i: '010e0d0000000000000003e803e8',
142
142
  s: '',
143
143
  t: 0,
144
144
  e: false,
145
- },
146
- {
145
+ },
146
+ {
147
147
  n: I18n.getLang('mesh_device_detail_lighting_work'),
148
148
  i: '020e0d0000000000000003e803e8',
149
149
  s: '',
150
150
  t: 0,
151
151
  e: false,
152
- },
153
- {
152
+ },
153
+ {
154
154
  n: I18n.getLang('mesh_device_detail_lighting_leisure'),
155
155
  i: '030e0d0000000000000001f403e8',
156
156
  s: '',
157
157
  t: 0,
158
158
  e: false,
159
- },
160
- {
159
+ },
160
+ {
161
161
  n: I18n.getLang('mesh_device_detail_lighting_color_mode'),
162
- i:
163
- '05464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000464601003d03e803e80000000046460100ae03e803e800000000464601011303e803e800000000',
162
+ i: '05464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000464601003d03e803e80000000046460100ae03e803e800000000464601011303e803e800000000',
164
163
  s: '',
165
164
  t: 0,
166
165
  e: false,
167
- },
168
- {
169
- n: I18n.getLang('mesh_device_detail_lighting_white_mode'),
170
- i: '0646460100000000000003e8000046460100000000000003e8019046460100000000000003e803e8',
171
- s: '',
172
- t: 0,
173
- e: false,
174
- },
166
+ },
175
167
  ...defColorSceneList,
176
168
  ];
177
169
  }
@@ -1454,6 +1446,16 @@ export type RecommendMood = {
1454
1446
  secondaryLamp?: MoodLampInfo;
1455
1447
  };
1456
1448
 
1449
+ const defStripConfig = {
1450
+ expand: 0,
1451
+ reserved1: 0,
1452
+ reserved2: 0,
1453
+ segmented: 0,
1454
+ loop: 0,
1455
+ excessive: 0,
1456
+ direction: 0,
1457
+ };
1458
+
1457
1459
  export function getRecommendMoods(
1458
1460
  isStatic: boolean,
1459
1461
  moduleParams: MoodPageParams
@@ -1697,6 +1699,7 @@ export function getRecommendMoods(
1697
1699
  fanEnable: true,
1698
1700
  fanSpeed: 1,
1699
1701
  enable: true,
1702
+ ...defStripConfig,
1700
1703
  nodes: [
1701
1704
  {
1702
1705
  h: 75,
@@ -1734,6 +1737,7 @@ export function getRecommendMoods(
1734
1737
  fanEnable: true,
1735
1738
  enable: true,
1736
1739
  fanSpeed: 1,
1740
+ ...defStripConfig,
1737
1741
  nodes: [
1738
1742
  {
1739
1743
  h: 40,
@@ -1771,6 +1775,7 @@ export function getRecommendMoods(
1771
1775
  fanEnable: true,
1772
1776
  fanSpeed: 1,
1773
1777
  enable: true,
1778
+ ...defStripConfig,
1774
1779
  nodes: [
1775
1780
  {
1776
1781
  h: 300,
@@ -1815,6 +1820,7 @@ export function getRecommendMoods(
1815
1820
  fanEnable: true,
1816
1821
  fanSpeed: 1,
1817
1822
  enable: true,
1823
+ ...defStripConfig,
1818
1824
  nodes: [
1819
1825
  {
1820
1826
  h: 0,
@@ -1852,6 +1858,7 @@ export function getRecommendMoods(
1852
1858
  fanEnable: true,
1853
1859
  fanSpeed: 1,
1854
1860
  enable: true,
1861
+ ...defStripConfig,
1855
1862
  nodes: [
1856
1863
  {
1857
1864
  h: 0,
@@ -1889,6 +1896,7 @@ export function getRecommendMoods(
1889
1896
  fanEnable: true,
1890
1897
  fanSpeed: 1,
1891
1898
  enable: true,
1899
+ ...defStripConfig,
1892
1900
  nodes: [
1893
1901
  {
1894
1902
  h: 0,
@@ -1933,6 +1941,7 @@ export function getRecommendMoods(
1933
1941
  fanEnable: true,
1934
1942
  fanSpeed: 1,
1935
1943
  enable: true,
1944
+ ...defStripConfig,
1936
1945
  nodes: [
1937
1946
  {
1938
1947
  h: 0,
@@ -1970,6 +1979,7 @@ export function getRecommendMoods(
1970
1979
  fanEnable: true,
1971
1980
  fanSpeed: 1,
1972
1981
  enable: true,
1982
+ ...defStripConfig,
1973
1983
  nodes: [
1974
1984
  {
1975
1985
  h: 0,
@@ -2007,6 +2017,7 @@ export function getRecommendMoods(
2007
2017
  fanEnable: true,
2008
2018
  fanSpeed: 1,
2009
2019
  enable: true,
2020
+ ...defStripConfig,
2010
2021
  nodes: [
2011
2022
  {
2012
2023
  h: 0,
@@ -2039,17 +2050,6 @@ export function getRecommendMoods(
2039
2050
  }
2040
2051
  }
2041
2052
 
2042
- const defSecondly = {
2043
- version: 0,
2044
- expand: 0,
2045
- reserved1: 0,
2046
- reserved2: 0,
2047
- segmented: 0,
2048
- loop: 0,
2049
- excessive: 0,
2050
- direction: 0,
2051
- };
2052
-
2053
2053
  export function getRecommendMixMoods(
2054
2054
  isStatic: boolean,
2055
2055
  moduleParams: MoodPageParams
@@ -2069,7 +2069,7 @@ export function getRecommendMixMoods(
2069
2069
  nodes: [{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 20, isColorNode: false }],
2070
2070
  },
2071
2071
  secondaryLamp: {
2072
- ...defSecondly,
2072
+ ...defStripConfig,
2073
2073
  enable: false,
2074
2074
  id: -1,
2075
2075
  speed: 100,
@@ -2087,7 +2087,7 @@ export function getRecommendMixMoods(
2087
2087
  nodes: [{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 40, isColorNode: false }],
2088
2088
  },
2089
2089
  secondaryLamp: {
2090
- ...defSecondly,
2090
+ ...defStripConfig,
2091
2091
  enable: false,
2092
2092
  id: -1,
2093
2093
  speed: 100,
@@ -2105,7 +2105,7 @@ export function getRecommendMixMoods(
2105
2105
  nodes: [{ h: 0, s: 0, v: 0, brightness: 100, colorTemp: 50, isColorNode: false }],
2106
2106
  },
2107
2107
  secondaryLamp: {
2108
- ...defSecondly,
2108
+ ...defStripConfig,
2109
2109
  enable: false,
2110
2110
  id: -1,
2111
2111
  speed: 100,
@@ -2133,7 +2133,7 @@ export function getRecommendMixMoods(
2133
2133
  ],
2134
2134
  },
2135
2135
  secondaryLamp: {
2136
- ...defSecondly,
2136
+ ...defStripConfig,
2137
2137
  id: 0,
2138
2138
  speed: 14,
2139
2139
  mode: moduleParams.isCeilingLight
@@ -7,27 +7,38 @@ import { mapFloatToRange } from '@ledvance/base/src/utils';
7
7
  import Card from '@ledvance/base/src/components/Card';
8
8
  import Spacer from '@ledvance/base/src/components/Spacer';
9
9
  import MoodColorsLine from '@ledvance/base/src/components/MoodColorsLine';
10
- import { MoodLampInfo, MoodUIInfo } from './Interface';
10
+ import { MoodJumpGradientMode, MoodLampInfo, MoodUIInfo } from './Interface';
11
11
  import I18n from '@ledvance/base/src/i18n';
12
12
  import res from '@ledvance/base/src/res';
13
13
 
14
14
  const cx = Utils.RatioUtils.convertX;
15
15
 
16
+ interface LightCategory {
17
+ isMixLight?: boolean
18
+ isStripLight?: boolean
19
+ isStringLight?: boolean
20
+ isCeilingLight?: boolean
21
+ }
22
+
16
23
  interface MoodItemProps extends ViewProps {
17
24
  enable: boolean;
18
25
  isMix: boolean;
19
26
  mood: MoodUIInfo;
20
27
  style?: ViewStyle;
28
+ deviceTypeOption?: LightCategory
21
29
  onPress?: () => void;
22
30
  onSwitch: (enable: boolean) => void;
23
31
  }
24
32
 
25
33
  const MoodItem = (props: MoodItemProps) => {
26
- const { mood, isMix } = props;
34
+ const { mood, isMix, deviceTypeOption } = props;
27
35
  const isDynamic = useMemo(() => {
28
36
  return mood.mainLamp.nodes?.length > 1 || mood.secondaryLamp.nodes?.length > 1;
29
37
  }, [mood.mainLamp.nodes, mood.secondaryLamp.nodes]);
30
38
 
39
+ const gradientMode = useMemo(() => (
40
+ deviceTypeOption?.isStringLight ? MoodJumpGradientMode.StringGradient : (deviceTypeOption?.isStripLight || deviceTypeOption?.isCeilingLight) ? MoodJumpGradientMode.StripGradient : MoodJumpGradientMode.SourceGradient
41
+ ), [MoodJumpGradientMode, deviceTypeOption])
31
42
  return (
32
43
  <Card style={[styles.card, props.style]} onPress={props.onPress}>
33
44
  <View>
@@ -41,11 +52,11 @@ const MoodItem = (props: MoodItemProps) => {
41
52
  />
42
53
  </View>
43
54
  <Spacer />
44
- <MixMoodColorsLine mixSubLight={mood.mainLamp} isMix={isMix} />
55
+ <MixMoodColorsLine mixSubLight={mood.mainLamp} isMix={isMix} type={mood.mainLamp.mode === gradientMode ? 'gradient' : 'separate'}/>
45
56
  {(isMix && !!mood.secondaryLamp.nodes.length) && (
46
57
  <>
47
58
  <Spacer height={cx(7)} />
48
- <MixMoodColorsLine mixSubLight={mood.secondaryLamp} isMix={isMix} />
59
+ <MixMoodColorsLine mixSubLight={mood.secondaryLamp} isMix={isMix} type={mood.secondaryLamp.mode === gradientMode ? 'gradient' : 'separate'}/>
49
60
  </>
50
61
  )}
51
62
  <Spacer height={cx(12)} />
@@ -66,7 +77,7 @@ const MoodItem = (props: MoodItemProps) => {
66
77
 
67
78
  export default MoodItem;
68
79
 
69
- export function MixMoodColorsLine(props: { mixSubLight: MoodLampInfo; isMix: boolean }) {
80
+ export function MixMoodColorsLine(props: { mixSubLight: MoodLampInfo; isMix: boolean, type: 'gradient' | 'separate' }) {
70
81
  const { mixSubLight, isMix } = props;
71
82
  const lightColors = !!(mixSubLight.enable && mixSubLight.nodes.length) ? mixSubLight.nodes?.map(n => {
72
83
  return n.isColorNode
@@ -79,7 +90,7 @@ export function MixMoodColorsLine(props: { mixSubLight: MoodLampInfo; isMix: boo
79
90
  <MoodColorsLine
80
91
  nodeStyle={{ borderColor: '#ccc', borderWidth: 1 }}
81
92
  width={isMix ? cx(264) : undefined}
82
- type={'separate'}
93
+ type={props.type}
83
94
  colors={lightColors}
84
95
  />
85
96
  {isMix && (
@@ -1,7 +1,7 @@
1
- import React, { useCallback, useEffect } from 'react';
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import Page from '@ledvance/base/src/components/Page';
3
3
  import { Utils } from 'tuya-panel-kit';
4
- import { saveMoodList, useRgbicWorkMode, useWorkMode } from './MoodActions';
4
+ import { saveMoodList, useRgbicWorkMode, useSwitchLed, useWorkMode } from './MoodActions';
5
5
  import {
6
6
  useDeviceInfo,
7
7
  useMoods,
@@ -21,7 +21,7 @@ import { MoodPageParams, MoodPageState, MoodUIInfo } from './Interface';
21
21
  import { getRemoteMoodList, useMoodScene } from './MoodActions';
22
22
  import { useParams } from '@ledvance/base/src/hooks/Hooks';
23
23
  import { ui_biz_routerKey } from '../../navigation/Routers'
24
- import { cloneDeep } from 'lodash';
24
+ import { cloneDeep, filter, map } from 'lodash';
25
25
  import { useFlagMode } from '../flags/FlagActions';
26
26
  import { WorkMode } from '@ledvance/base/src/utils/interface';
27
27
 
@@ -34,17 +34,9 @@ const MoodPage = () => {
34
34
  const deviceInfo = useDeviceInfo();
35
35
  const uaGroupInfo = useUAGroupInfo()
36
36
  const navigation = useNavigation();
37
- const option = {
38
- isCeilingLight: params.isCeilingLight,
39
- isStripLight: params.isStripLight,
40
- isStringLight: params.isStringLight,
41
- isFanLight: params.isFanLight,
42
- isMixLight: params.isMixLight,
43
- isUVCFan: params.isUVCFan,
44
- isMatterLight: params.isMatterLight,
45
- };
46
- const [moodInfo, setMoodInfo] = useMoodScene(option);
37
+ const [moodInfo, setMoodInfo] = useMoodScene(params);
47
38
  const workMode = useWorkMode()
39
+ const switchLed = useSwitchLed(params)
48
40
  const rgbicWorkMode = useRgbicWorkMode()
49
41
  const [moods, setMoods] = useMoods();
50
42
  const [flagMode, setFlagMode] = useFlagMode();
@@ -60,22 +52,23 @@ const MoodPage = () => {
60
52
  flag: Symbol(),
61
53
  });
62
54
 
55
+ const moodIds = useMemo(() =>{
56
+ const mainIds = map(state.originMoods, 'id').filter(v => v !== undefined)
57
+ const secondaryIds = map(state.originMoods.map(m => m.secondaryLamp) || [], 'id')
58
+ return filter([...mainIds, ... secondaryIds], v => v !== undefined) as number[]
59
+ }, [JSON.stringify(state.originMoods)])
60
+
63
61
  useEffect(() => {
64
62
  state.timerId = setTimeout(() => {
65
63
  state.loading = true
66
64
  getRemoteMoodList(
67
65
  uaGroupInfo.tyGroupId.toString(),
68
- {
69
- ...option,
70
- isSupportBrightness: params.isSupportBrightness,
71
- isSupportColor: params.isSupportColor,
72
- isSupportTemperature: params.isSupportTemperature,
73
- }
66
+ params
74
67
  ).then(res => {
75
68
  state.loading = false
76
- console.log(res.data, '< --- res.data --- >')
77
69
  if (res.success && Array.isArray(res.data)) {
78
70
  state.originMoods = cloneDeep(res.data);
71
+ console.log(state.originMoods, '< --- originMoods')
79
72
  }
80
73
  });
81
74
  }, 200);
@@ -110,9 +103,10 @@ const MoodPage = () => {
110
103
  navigation.navigate(path, {
111
104
  mode,
112
105
  isStatic,
113
- moods: state.originMoods,
114
106
  currentMood,
115
107
  moduleParams: params,
108
+ moodIds,
109
+ nameRepeat,
116
110
  modDeleteMood,
117
111
  });
118
112
  };
@@ -142,7 +136,7 @@ const MoodPage = () => {
142
136
  },
143
137
  secondaryLamp: {
144
138
  ...currentMood.secondaryLamp,
145
- nodes: currentMood.secondaryLamp
139
+ nodes: currentMood.secondaryLamp && currentMood.secondaryLamp.nodes?.length
146
140
  ? currentMood.secondaryLamp.nodes.map(node => {
147
141
  if (mode !== 'del') {
148
142
  if (node.isColorNode) {
@@ -160,6 +154,7 @@ const MoodPage = () => {
160
154
  : [],
161
155
  },
162
156
  };
157
+
163
158
  if (mode === 'set') {
164
159
  return setMoodInfo({
165
160
  scene: checkedMood,
@@ -192,14 +187,15 @@ const MoodPage = () => {
192
187
  }
193
188
  }
194
189
  const mood = mode === 'del' ? (newScene.length === 0 ? undefined : newScene[0]) : checkedMood;
195
- const res = await saveMoodList(uaGroupInfo.tyGroupId.toString(), newScene, option);
190
+ const res = await saveMoodList(uaGroupInfo.tyGroupId.toString(), newScene, params);
191
+ console.log(res, '< --- save res')
196
192
  if (res.success) {
197
193
  state.originMoods = cloneDeep(newScene);
198
194
  setMoods(cloneDeep(newScene));
199
195
  if ((mode === 'del' && (params.isCeilingLight ?
200
196
  (moodInfo.scene?.mainLamp.id !== checkedMood.mainLamp.id || moodInfo.scene?.secondaryLamp.id !== checkedMood.secondaryLamp.id) :
201
197
  moodInfo.scene?.id !== checkedMood.id)) ||
202
- (params.isCeilingLight ? (workMode !== WorkMode.Scene && rgbicWorkMode !== WorkMode.Scene) : workMode !== WorkMode.Scene)) {
198
+ (params.isCeilingLight ? (workMode !== WorkMode.Scene && rgbicWorkMode !== WorkMode.Scene) : workMode !== WorkMode.Scene) || !switchLed) {
203
199
  return {
204
200
  success: true
205
201
  }
@@ -235,19 +231,22 @@ const MoodPage = () => {
235
231
 
236
232
  const getItemEnable = useCallback(
237
233
  (moodItem: MoodUIInfo) => {
238
- if (option.isCeilingLight) {
234
+ if (params.isCeilingLight) {
239
235
  return (
240
236
  moodInfo.scene?.mainLamp?.id === moodItem.mainLamp.id &&
241
237
  moodInfo.scene?.secondaryLamp.id === moodItem.secondaryLamp.id &&
242
- (workMode === WorkMode.Scene || rgbicWorkMode === WorkMode.Scene)
238
+ (workMode === WorkMode.Scene || rgbicWorkMode === WorkMode.Scene) && switchLed
243
239
  );
244
240
  } else {
245
- return moodInfo.scene?.id === moodItem.id && workMode === WorkMode.Scene && !flagMode.flagMode;
241
+ return moodInfo.scene?.id === moodItem.id && workMode === WorkMode.Scene && !flagMode.flagMode && switchLed;
246
242
  }
247
243
  },
248
244
  [moodInfo]
249
245
  );
250
-
246
+
247
+ const nameRepeat = useCallback((mood: MoodUIInfo) => {
248
+ return !!state.originMoods.filter(m => !(params.isCeilingLight ? (m.mainLamp.id === mood.mainLamp.id && m.secondaryLamp.id === mood.secondaryLamp.id) : (m.id === mood.id))).find(m => m.name === mood.name)
249
+ }, [state.originMoods, params.isCeilingLight])
251
250
 
252
251
  return (
253
252
  <>
@@ -264,7 +263,7 @@ const MoodPage = () => {
264
263
  }}
265
264
  loading={state.loading}
266
265
  >
267
- <View style={styles.tagLine}>
266
+ {!params.isStripLight && <View style={styles.tagLine}>
268
267
  <Tag
269
268
  checked={state.staticTagChecked}
270
269
  text={Strings.getLang('mood_overview_filter_name_text1')}
@@ -280,7 +279,7 @@ const MoodPage = () => {
280
279
  state.dynamicTagChecked = checked;
281
280
  }}
282
281
  />
283
- </View>
282
+ </View>}
284
283
  <Spacer height={cx(10)} />
285
284
  {state.originMoods.length >= MAX_MOOD_COUNT && (
286
285
  <View style={styles.infoLine}>
@@ -300,6 +299,7 @@ const MoodPage = () => {
300
299
  <MoodItem
301
300
  enable={getItemEnable(item)}
302
301
  isMix={!!(params.isMixLight || params.isCeilingLight)}
302
+ deviceTypeOption={params}
303
303
  mood={item}
304
304
  onPress={() => {
305
305
  navigationRoute(item.mainLamp.nodes.length === 1, 'edit', item);
@@ -192,7 +192,7 @@ export function stripObj2Dp(mood: MoodInfo, isStringLight: boolean = false) {
192
192
  speed,
193
193
  nodes,
194
194
  } = mood.mainLamp;
195
- const versionHex = nToHS(mood.version);
195
+ const versionHex = nToHS(1);
196
196
  const idHex = nToHS(mood.id);
197
197
  const modeHex = nToHS(mode);
198
198
  const intervalTimeHex = nToHS(speed);
@@ -1,24 +1,36 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { Utils } from 'tuya-panel-kit';
3
3
  import Card from '@ledvance/base/src/components/Card';
4
4
  import { CellContent } from '@ledvance/base/src/components/Cell';
5
5
  import { StyleSheet, View } from 'react-native';
6
6
  import Spacer from '@ledvance/base/src/components/Spacer';
7
- import { MoodUIInfo } from './Interface';
7
+ import { MoodJumpGradientMode, MoodUIInfo } from './Interface';
8
8
  import { MixMoodColorsLine } from './MoodItem';
9
9
 
10
10
  const cx = Utils.RatioUtils.convertX;
11
11
 
12
+ interface LightCategory {
13
+ isMixLight?: boolean
14
+ isStripLight?: boolean
15
+ isStringLight?: boolean
16
+ isCeilingLight?: boolean
17
+ }
18
+
12
19
  interface RecommendMixMoodItemProps {
13
20
  title: string;
14
21
  isMix: boolean;
15
22
  mood: MoodUIInfo;
23
+ deviceTypeOption?: LightCategory
16
24
  onPress: () => void;
17
25
  }
18
26
 
19
27
  const RecommendMixMoodItem = (props: RecommendMixMoodItemProps) => {
20
- const { mood, isMix } = props;
28
+ const { mood, isMix, deviceTypeOption } = props;
21
29
 
30
+ const gradientMode = useMemo(() => (
31
+ deviceTypeOption?.isStringLight ? MoodJumpGradientMode.StringGradient : (deviceTypeOption?.isStripLight || deviceTypeOption?.isCeilingLight) ? MoodJumpGradientMode.StripGradient : MoodJumpGradientMode.SourceGradient
32
+ ), [MoodJumpGradientMode, deviceTypeOption])
33
+
22
34
  return (
23
35
  <Card style={styles.root} onPress={props.onPress}>
24
36
  <CellContent
@@ -34,9 +46,9 @@ const RecommendMixMoodItem = (props: RecommendMixMoodItemProps) => {
34
46
  {!!(mood.mainLamp) && (
35
47
  <>
36
48
  <View style={styles.lineStyle}>
37
- <MixMoodColorsLine mixSubLight={mood?.mainLamp} isMix={isMix} />
49
+ <MixMoodColorsLine mixSubLight={mood?.mainLamp} isMix={isMix} type={mood.mainLamp.mode === gradientMode ? 'gradient' : 'separate'}/>
38
50
  <Spacer height={cx(7)} />
39
- {(isMix && !!mood.secondaryLamp.nodes.length) && <MixMoodColorsLine mixSubLight={mood.secondaryLamp} isMix={isMix} />}
51
+ {(isMix && !!mood.secondaryLamp.nodes.length) && <MixMoodColorsLine mixSubLight={mood.secondaryLamp} isMix={isMix} type={mood.secondaryLamp.mode === gradientMode ? 'gradient' : 'separate'}/>}
40
52
  </View>
41
53
  <Spacer height={cx(24)} />
42
54
  </>
@@ -53,8 +65,8 @@ const styles = StyleSheet.create({
53
65
  },
54
66
  content: {
55
67
  height: cx(56),
56
- display: 'flex',
57
68
  marginHorizontal: cx(16),
69
+ width: cx(295)
58
70
  },
59
71
  title: {
60
72
  color: '#000',
@@ -3,6 +3,7 @@ import MoodPage from "./MoodPage";
3
3
  import DynamicMoodEditorPage from "./DynamicMoodEditorPage";
4
4
  import StaticMoodEditorPage from "./StaticMoodEditorPage";
5
5
  import MixDynamicMoodEditorPage from "./MixDynamicMoodEditor";
6
+ import AddMoodPage from "./AddMoodPage"
6
7
  import {ui_biz_routerKey} from "../../navigation/Routers";
7
8
 
8
9
  const MoodPageRouters: NavigationRoute[] = [
@@ -14,6 +15,14 @@ const MoodPageRouters: NavigationRoute[] = [
14
15
  showOfflineView: false,
15
16
  }
16
17
  },
18
+ {
19
+ name: ui_biz_routerKey.group_ui_biz_mood_add,
20
+ component: AddMoodPage,
21
+ options:{
22
+ hideTopbar: true,
23
+ showOfflineView: false,
24
+ }
25
+ },
17
26
  {
18
27
  name: ui_biz_routerKey.group_ui_biz_dynamic_mood_edit,
19
28
  component: DynamicMoodEditorPage,
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import { ScrollView, StyleSheet, View } from 'react-native';
3
- import { cloneDeep, find, isEqual } from 'lodash';
3
+ import { cloneDeep, isEqual } from 'lodash';
4
4
  import { useReactive } from 'ahooks';
5
5
  import Page from '@ledvance/base/src/components/Page';
6
6
  import I18n from '@ledvance/base/src/i18n';
@@ -27,10 +27,9 @@ const cx = Utils.RatioUtils.convertX;
27
27
 
28
28
  export interface StaticMoodEditorPageParams {
29
29
  mode: 'add' | 'edit';
30
- moods: MoodUIInfo[];
31
30
  currentMood: MoodUIInfo;
32
- onSave: () => void;
33
31
  moduleParams: MoodPageParams;
32
+ nameRepeat: (mood: MoodUIInfo) => boolean
34
33
  modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
35
34
  }
36
35
 
@@ -72,7 +71,7 @@ const StaticMoodEditorPage = () => {
72
71
  }, []);
73
72
 
74
73
  const onRightClick = async () => {
75
- if (state.loading) return;
74
+ if (state.loading || !canSaveMoodData) return;
76
75
  state.loading = true;
77
76
  const newMood: MoodUIInfo = {
78
77
  ...state.mood,
@@ -105,23 +104,22 @@ const StaticMoodEditorPage = () => {
105
104
  }
106
105
  };
107
106
 
108
- const getButtonStatus = () => {
109
- return (
110
- (params.mode === 'edit' && isEqual(state.mood, params.currentMood)) ||
111
- !state.mood.name ||
112
- nameRepeat ||
113
- state.mood.name.length > 32
114
- );
115
- };
116
-
117
107
  const nameRepeat = useMemo(() => {
118
- return !!find(params.moods, m => m.id !== state.mood.id && m.name === state.mood.name);
108
+ return params.nameRepeat(state.mood)
119
109
  }, [state.mood.name]);
120
110
 
111
+ const checkMoodChanged = useMemo(() =>{
112
+ return isEqual(state.mood, params.currentMood)
113
+ }, [JSON.stringify(state.mood), params.currentMood])
114
+
115
+ const canSaveMoodData = useMemo(() =>{
116
+ return state.mood.name.length > 0 && state.mood.name.length < 33 && !nameRepeat && (params.mode === 'add' || !checkMoodChanged)
117
+ }, [nameRepeat, state.mood.name, checkMoodChanged, params.mode])
118
+
121
119
  return (
122
120
  <Page
123
121
  backText={I18n.getLang('mesh_device_detail_mode')}
124
- showBackDialog={true}
122
+ showBackDialog={!checkMoodChanged}
125
123
  backDialogTitle={I18n.getLang(
126
124
  params.mode === 'add'
127
125
  ? 'string_light_pp_dialog_sm_add_headline_c'
@@ -133,8 +131,7 @@ const StaticMoodEditorPage = () => {
133
131
  : 'strip_light_static_mood_editor_step_2_dialog_text'
134
132
  )}
135
133
  headlineText={state.headline}
136
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
137
- rightButtonDisabled={getButtonStatus()}
134
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
138
135
  rightButtonIconClick={onRightClick}
139
136
  loading={state.loading}
140
137
  >