@ledvance/ui-biz-bundle 1.1.64 → 1.1.66

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.
@@ -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';
@@ -12,26 +12,24 @@ import Spacer from '@ledvance/base/src/components/Spacer';
12
12
  import res from '@ledvance/base/src/res';
13
13
  import TextButton from '@ledvance/base/src/components/TextButton';
14
14
  import { useFanMaxSpeed } from '@ledvance/base/src/models/modules/NativePropsSlice';
15
- import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
16
15
  import FanAdjustView from '@ledvance/base/src/components/FanAdjustView';
17
- import { showDeleteMoodDialog } from './tools';
18
16
  import { MoodNodeInfo, MoodPageParams, MoodUIInfo } from './Interface';
19
17
  import { Result } from '@ledvance/base/src/models/modules/Result';
20
18
  import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
21
19
  import { cctToColor } from '@ledvance/base/src/utils/cctUtils';
22
20
  import { useParams } from '@ledvance/base/src/hooks/Hooks';
23
- import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
24
- import { RouterKey } from 'navigation/Router';
21
+ import LampAdjustView2 from '@ledvance/base/src/components/LampAdjustView2';
22
+ import { ui_biz_routerKey } from '../../navigation/Routers'
25
23
  import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
24
+ import { showDialog } from '@ledvance/base/src/utils/common';
26
25
 
27
26
  const cx = Utils.RatioUtils.convertX;
28
27
 
29
28
  export interface StaticMoodEditorPageParams {
30
29
  mode: 'add' | 'edit';
31
- moods: MoodUIInfo[];
32
30
  currentMood: MoodUIInfo;
33
- onSave: () => void;
34
31
  moduleParams: MoodPageParams;
32
+ nameRepeat: (mood: MoodUIInfo) => boolean
35
33
  modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
36
34
  }
37
35
 
@@ -53,7 +51,7 @@ const StaticMoodEditorPage = () => {
53
51
  headline: '',
54
52
  mood: params.currentMood,
55
53
  mainNode: params.currentMood.mainLamp.nodes[0],
56
- secondaryNode: params.currentMood?.secondaryLamp?.nodes[0],
54
+ secondaryNode: params.currentMood?.secondaryLamp?.nodes?.[0],
57
55
  loading: false,
58
56
  });
59
57
 
@@ -73,10 +71,7 @@ const StaticMoodEditorPage = () => {
73
71
  }, []);
74
72
 
75
73
  const onRightClick = async () => {
76
- if (getButtonStatus()) {
77
- return
78
- }
79
- if (state.loading) return;
74
+ if (state.loading || !canSaveMoodData) return;
80
75
  state.loading = true;
81
76
  const newMood: MoodUIInfo = {
82
77
  ...state.mood,
@@ -84,8 +79,12 @@ const StaticMoodEditorPage = () => {
84
79
  ...state.mood.mainLamp,
85
80
  nodes: [cloneDeep(state.mainNode)],
86
81
  },
82
+ secondaryLamp: {
83
+ ...state.mood.secondaryLamp,
84
+ id: undefined
85
+ }
87
86
  };
88
- if (isMix) {
87
+ if (isMix && moduleParams.isMixLight) {
89
88
  newMood.secondaryLamp = {
90
89
  ...newMood.secondaryLamp,
91
90
  nodes: [cloneDeep(state.secondaryNode)],
@@ -101,37 +100,26 @@ const StaticMoodEditorPage = () => {
101
100
  const res = await params.modDeleteMood(params.mode, newMood);
102
101
  state.loading = false;
103
102
  if (res.success) {
104
- navigation.navigate(RouterKey.ui_biz_mood);
103
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
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
 
121
- useEffect(() =>{
122
- console.log(state.mood, '< --- state mood --- >')
123
- console.log(params.currentMood, '< --- currentMood --- >')
124
- }, [JSON.stringify(state.mood)])
125
-
111
+ const checkMoodChanged = useMemo(() =>{
112
+ return isEqual(state.mood, params.currentMood)
113
+ }, [JSON.stringify(state.mood), params.currentMood])
126
114
 
127
- const showBackDialog = (): boolean => {
128
- return !isEqual(state.mood, routeParams.currentMood);
129
- }
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])
130
118
 
131
119
  return (
132
120
  <Page
133
121
  backText={I18n.getLang('mesh_device_detail_mode')}
134
- showBackDialog={showBackDialog()}
122
+ showBackDialog={!checkMoodChanged}
135
123
  backDialogTitle={I18n.getLang(
136
124
  params.mode === 'add'
137
125
  ? 'string_light_pp_dialog_sm_add_headline_c'
@@ -143,7 +131,7 @@ const StaticMoodEditorPage = () => {
143
131
  : 'strip_light_static_mood_editor_step_2_dialog_text'
144
132
  )}
145
133
  headlineText={state.headline}
146
- rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
134
+ rightButtonIcon={canSaveMoodData ? res.ic_check : res.ic_uncheck}
147
135
  rightButtonIconClick={onRightClick}
148
136
  loading={state.loading}
149
137
  >
@@ -180,86 +168,33 @@ const StaticMoodEditorPage = () => {
180
168
  showSwitch={!!moduleParams.isMixLight}
181
169
  />
182
170
  {(!moduleParams.isMixLight || state.mood.mainLamp.enable) && (
183
- <LampAdjustView
171
+ <LampAdjustView2
184
172
  isSupportColor={isMix ? false : moduleParams.isSupportColor}
185
173
  isSupportBrightness={moduleParams.isSupportBrightness}
186
- isSupportTemperature={moduleParams.isSupportTemperature}
174
+ isSupportCCT={moduleParams.isSupportTemperature}
187
175
  isColorMode={state.mainNode.isColorNode}
188
176
  reserveSV={true}
189
177
  setIsColorMode={isColorMode => {
190
178
  state.mainNode.isColorNode = isColorMode;
191
179
  }}
192
- h={state.mainNode.h}
193
- s={state.mainNode.s}
194
- v={state.mainNode.v}
195
- onHSVChange={(h, s, v) => {
196
- state.mainNode.h = h
197
- state.mainNode.s = s
198
- state.mainNode.v = v
180
+ hsv={state.mainNode}
181
+ onHSVChange={(hsv) => {
182
+ state.mainNode.h = hsv.h
183
+ state.mainNode.s = hsv.s
184
+ state.mainNode.v = hsv.v
199
185
  }}
200
- onHSVChangeComplete={(h, s, v) => {
201
- state.mainNode.h = h
202
- state.mainNode.s = s
203
- state.mainNode.v = v
204
- }}
205
- colorTemp={state.mainNode.colorTemp}
186
+ cct={state.mainNode.colorTemp}
206
187
  brightness={state.mainNode.brightness}
207
- onCCTChange={() => {}}
208
- onCCTChangeComplete={cct => {
188
+ onCCTChange={(cct) => {
209
189
  state.mainNode.colorTemp = cct;
210
190
  }}
211
- onBrightnessChange={() => {}}
212
- onBrightnessChangeComplete={brightness => {
191
+ onBrightnessChange={(brightness) => {
213
192
  state.mainNode.brightness = brightness;
214
193
  }}
215
194
  />
216
195
  )}
217
196
  </Card>
218
197
  <Spacer />
219
- {isMix && (
220
- <Card style={styles.fanAdjustCard}>
221
- <LdvSwitch
222
- title={I18n.getLang('light_sources_tile_sec_lighting_headline')}
223
- color={'#fff'}
224
- colorAlpha={1}
225
- enable={!!state.mood.secondaryLamp.enable}
226
- setEnable={v => {
227
- if(v && !state.mood.secondaryLamp.nodes.length){
228
- state.mood.secondaryLamp.nodes.push(
229
- {
230
- h: 0,
231
- s: 100,
232
- v: 100,
233
- brightness: 0,
234
- colorTemp: 0,
235
- isColorNode: true,
236
- },
237
- )
238
- state.secondaryNode = state.mood.secondaryLamp.nodes[0]
239
- }
240
- state.mood.secondaryLamp.enable = v;
241
- }}
242
- showSwitch={!!moduleParams.isMixLight}
243
- />
244
- {(!moduleParams.isMixLight || state.mood.secondaryLamp.enable) && (
245
- <>
246
- <ColorAdjustView
247
- h={state.secondaryNode.h}
248
- s={state.secondaryNode.s}
249
- v={state.secondaryNode.v}
250
- reserveSV={true}
251
- onHSVChange={() => {}}
252
- onHSVChangeComplete={(h, s, v) => {
253
- state.secondaryNode.h = h
254
- state.secondaryNode.s = s
255
- state.secondaryNode.v = v
256
- }}
257
- />
258
- <Spacer height={cx(16)}/>
259
- </>
260
- )}
261
- </Card>
262
- )}
263
198
  {!!(moduleParams.isFanLight || moduleParams.isUVCFan) && (
264
199
  <FanAdjustView
265
200
  fanEnable={!!state.mood.mainLamp.fanEnable}
@@ -284,15 +219,20 @@ const StaticMoodEditorPage = () => {
284
219
  textStyle={styles.deleteBtnText}
285
220
  text={I18n.getLang('edit_static_mood_button_delete_text')}
286
221
  onPress={() => {
287
- showDeleteMoodDialog(async (_, { close }) => {
288
- state.loading = true;
289
- close();
290
- const res = await params.modDeleteMood('del', state.mood);
291
- if (res.success) {
292
- navigation.navigate(RouterKey.ui_biz_mood);
222
+ showDialog({
223
+ method: 'confirm',
224
+ title: I18n.getLang('string_light_pp_dialog_sm_ed_headline_d'),
225
+ subTitle: I18n.getLang(`strip_light_static_mood_edit_dialog_text`),
226
+ onConfirm: async (_, {close})=>{
227
+ close();
228
+ state.loading = true;
229
+ const res = await params.modDeleteMood('del', state.mood);
230
+ state.loading = false;
231
+ if (res.success) {
232
+ navigation.navigate(ui_biz_routerKey.ui_biz_mood);
233
+ }
293
234
  }
294
- state.loading = false;
295
- });
235
+ })
296
236
  }}
297
237
  />
298
238
  </View>
@@ -115,9 +115,7 @@ export const useRandomTime: UseFixedTimeType = (dpKey: string, isPlug?: boolean,
115
115
  v: isPlug ? JSON.stringify({dp: randomHex}) : randomHex
116
116
  }
117
117
  })
118
- console.log(randomData, '< --- randomData')
119
118
  const cloudStatus = await putFeatureFn(deviceId, isPlug ? plug_randomFeatureId : randomFeatureId, JSON.stringify(randomData))
120
- console.log(cloudStatus, '< --- cloudStatus')
121
119
  if (cloudStatus) {
122
120
  const randomTimerData = {
123
121
  version: 0,
@@ -168,10 +168,10 @@ const RandomTimeDetailPage = () => {
168
168
  </View>
169
169
  <Spacer />
170
170
  {/* Devices */}
171
- <View style={styles.cardContainer}>
171
+ {!!state.randomTime.color && !params.isPlug && <View style={styles.cardContainer}>
172
172
  <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
173
173
  <Spacer height={cx(10)} />
174
- {state.randomTime.color && !params.isPlug && <Card>
174
+ <Card>
175
175
  <LdvSwitch
176
176
  title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
177
177
  color={'#fff'}
@@ -213,9 +213,9 @@ const RandomTimeDetailPage = () => {
213
213
  }
214
214
  }}
215
215
  />
216
- </Card>}
216
+ </Card>
217
217
  <Spacer />
218
- </View>
218
+ </View>}
219
219
  {/* summary */}
220
220
  <Summary
221
221
  frequency={loopText(state.randomTime.weeks)}
@@ -19,7 +19,7 @@ interface SummaryProps {
19
19
  const Summary = (props: SummaryProps) => {
20
20
  return (
21
21
  <View style={styles.cardContainer}>
22
- <Text style={styles.itemTitle}>{I18n.getLang('add_randomtimecycle_subheadline_text')}</Text>
22
+ <Text style={styles.itemTitle}>{I18n.getLang('add_sleepschedule_one_source_subheadline4_text')}</Text>
23
23
  <Spacer height={cx(10)} />
24
24
  <View style={{}}>
25
25
  <View style={styles.summaryContainer}>
@@ -0,0 +1,17 @@
1
+ import {NavigationRoute, TransitionPresets} from "tuya-panel-kit";
2
+ import SelectPage from "./SelectPage";
3
+ import {ui_biz_routerKey} from "../../navigation/Routers";
4
+
5
+ const SelectPagePageRouters: NavigationRoute[] = [
6
+ {
7
+ name: ui_biz_routerKey.ui_biz_select_page,
8
+ component: SelectPage,
9
+ options: {
10
+ hideTopbar: true,
11
+ showOfflineView: false,
12
+ ...TransitionPresets.ModalPresentationIOS,
13
+ },
14
+ }
15
+ ]
16
+
17
+ export default SelectPagePageRouters
@@ -0,0 +1,12 @@
1
+ export interface SelectPageData<T> {
2
+ text: string;
3
+ selected: boolean;
4
+ value: T;
5
+ }
6
+ export interface SelectPageParams<T> {
7
+ title: string;
8
+ data: SelectPageData<T>[];
9
+ onSelect: (selectPageData: SelectPageData<T>) => void;
10
+ }
11
+ declare const SelectPage: () => any;
12
+ export default SelectPage;
@@ -0,0 +1,138 @@
1
+ import {FlatList, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
2
+ import React from 'react'
3
+ import {useNavigation, useRoute} from '@react-navigation/core'
4
+ import {Utils} from 'tuya-panel-kit'
5
+ import Spacer from '@ledvance/base/src/components/Spacer'
6
+ import I18n from '@ledvance/base/src/i18n'
7
+ import Card from '@ledvance/base/src/components/Card'
8
+ import res from '@ledvance/base/src/res'
9
+
10
+ const cx = Utils.RatioUtils.convertX
11
+
12
+ export interface SelectPageData<T> {
13
+ text: string
14
+ selected: boolean
15
+ value: T
16
+ }
17
+
18
+ export interface SelectPageParams<T> {
19
+ title: string
20
+ data: SelectPageData<T>[]
21
+ onSelect: (selectPageData: SelectPageData<T>) => void
22
+ }
23
+
24
+ const SelectPage = () => {
25
+ const params = useRoute().params as SelectPageParams<any>
26
+ const navigation = useNavigation()
27
+ return (
28
+ <View style={styles.root}>
29
+ <View style={styles.topBar}>
30
+ <View style={styles.topContent}>
31
+ <Text style={styles.title}>{params.title}</Text>
32
+ <TouchableOpacity
33
+ onPress={() => {
34
+ navigation.goBack()
35
+ }}>
36
+ <Text style={styles.cancel}>{I18n.getLang('auto_scan_system_cancel')}</Text>
37
+ </TouchableOpacity>
38
+ </View>
39
+ <View style={styles.line}/>
40
+ </View>
41
+ <ScrollView nestedScrollEnabled={true}>
42
+ <View>
43
+ <Spacer height={cx(40)}/>
44
+ <Card style={styles.card}>
45
+ <FlatList
46
+ data={params.data}
47
+ renderItem={({item}) => {
48
+ return (
49
+ <TouchableOpacity
50
+ onPress={() => {
51
+ params.onSelect(item)
52
+ navigation.goBack()
53
+ }}>
54
+ <View style={styles.item}>
55
+ <Text style={styles.itemText}>{item.text}</Text>
56
+ <Image
57
+ style={[
58
+ styles.itemIcon,
59
+ {
60
+ opacity: item.selected ? 1 : 0,
61
+ },
62
+ ]}
63
+ source={{uri: res.ic_check}}/>
64
+ </View>
65
+ </TouchableOpacity>
66
+ )
67
+ }}
68
+ ItemSeparatorComponent={() => <View style={styles.itemLine}/>}
69
+ keyExtractor={(_, index) => `${index}`}/>
70
+ </Card>
71
+ <Spacer height={cx(40)}/>
72
+ </View>
73
+ </ScrollView>
74
+ </View>
75
+ )
76
+ }
77
+
78
+ const styles = StyleSheet.create({
79
+ root: {
80
+ flex: 1,
81
+ },
82
+ topBar: {
83
+ backgroundColor: '#eaeaea',
84
+ },
85
+ line: {
86
+ height: cx(1),
87
+ backgroundColor: '#d9d9d9',
88
+ },
89
+ topContent: {
90
+ paddingVertical: cx(30),
91
+ flexDirection: 'row',
92
+ alignItems: 'center',
93
+ },
94
+ cancel: {
95
+ marginStart: cx(16),
96
+ color: '#f60',
97
+ fontSize: cx(17),
98
+ fontFamily: 'helvetica_neue_lt_std_roman',
99
+ },
100
+ title: {
101
+ width: '100%',
102
+ position: 'absolute',
103
+ start: 0,
104
+ textAlign: 'center',
105
+ color: '#000',
106
+ fontSize: cx(17),
107
+ paddingHorizontal: cx(110),
108
+ fontFamily: 'helvetica_neue_lt_std_bd',
109
+ },
110
+ card: {
111
+ marginHorizontal: cx(16),
112
+ },
113
+ item: {
114
+ height: cx(44),
115
+ flexDirection: 'row',
116
+ alignItems: 'center',
117
+ },
118
+ itemText: {
119
+ flex: 1,
120
+ marginStart: cx(13),
121
+ color: '#000',
122
+ fontSize: cx(17),
123
+ fontFamily: 'helvetica_neue_lt_std_roman',
124
+ },
125
+ itemLine: {
126
+ height: cx(1),
127
+ marginStart: cx(13),
128
+ backgroundColor: '#ccc',
129
+ },
130
+ itemIcon: {
131
+ width: cx(30),
132
+ height: cx(30),
133
+ marginEnd: cx(13),
134
+ tintColor: '#f60',
135
+ },
136
+ })
137
+
138
+ export default SelectPage
@@ -1,12 +0,0 @@
1
- import { Dialog } from 'tuya-panel-kit'
2
- import Strings from '@ledvance/base/src/i18n'
3
-
4
- export const showDeleteMoodDialog = (onConfirm: (data: any, args: { close: () => void }) => void) => {
5
- Dialog.confirm({
6
- title: Strings.getLang('string_light_pp_dialog_sm_ed_headline_d'),
7
- subTitle: Strings.getLang(`strip_light_static_mood_edit_dialog_text`),
8
- cancelText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
9
- confirmText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
10
- onConfirm: onConfirm,
11
- })
12
- }