@ledvance/ui-biz-bundle 1.1.70 → 1.1.72

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/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.70",
7
+ "version": "1.1.72",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -129,3 +129,14 @@ export const useProgress = (dps: dpItem[]) => {
129
129
  ...dp
130
130
  }))
131
131
  }
132
+
133
+ export function timeFormat(time: number): string {
134
+ let hour = Math.trunc(time / 3600)
135
+ const beforeMin = (time % 3600) / 60
136
+ let min = Math.ceil(beforeMin)
137
+ if (min === 60) {
138
+ hour += 1
139
+ min = 0
140
+ }
141
+ return `${hour > 0 ? `${hour} h ` : ''}${min > 0 ? `${min} min` : ''}`
142
+ }
@@ -43,4 +43,5 @@ export const ui_biz_routerKey = {
43
43
  'ui_biz_light_mode': 'ui_biz_light_mode',
44
44
  'ui_biz_overcharge_switch': 'ui_biz_overcharge_switch',
45
45
  'ui_biz_child_lock': 'ui_biz_child_lock',
46
+ 'ui_biz_remote_control': 'ui_biz_remote_control'
46
47
  }
@@ -91,7 +91,7 @@ export const useFixedTime: UseFixedTimeType = (dpKey, isPlug, disableFeature) =>
91
91
  return {
92
92
  ...item,
93
93
  index: idx,
94
- name: featureItem ? featureItem?.n : `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
94
+ name: featureItem && featureItem?.n ? featureItem?.n : `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
95
95
  }
96
96
  })
97
97
  setFixedTimeUiList(uiPlan)
@@ -218,7 +218,7 @@ const fixedTimeObj2Dp = (randomTimerData: FixedTimerData, isPlug?: boolean) => {
218
218
 
219
219
  const fixedTimeToHex = (fixedTime: FixedTimer, isPlug?: boolean, isFeatureData?: boolean) => {
220
220
  const { weeks, startTime, endTime, openTime, closeTime, channel, enable } = fixedTime
221
- const channelStr = padStart((channel ?? 0).toString(2), 7, '0');
221
+ const channelStr = padStart((channel ?? (isPlug ? 0 : 1)).toString(2), 7, '0');
222
222
  const powerChannel = parseInt(`${channelStr}${enable ? 1 : 0}`, 2);
223
223
  const powerChannelStr = to16(powerChannel, 2);
224
224
  const weeksValue: string = padStart([...weeks].reverse().join(''), 8, '0');
@@ -146,7 +146,7 @@ const FixedTimeDetailPage = () => {
146
146
  {state.fixedTime.channel === undefined ?
147
147
  <Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
148
148
  <View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}>
149
- <Text style={{ color: '#000' }}>{params.applyForList[state.fixedTime.channel]?.key}</Text>
149
+ <Text style={{ color: '#000' }}>{params.applyForList[params.isPlug ? state.fixedTime.channel : 0]?.key}</Text>
150
150
  {params.applyForList.length > 1 && <TouchableOpacity
151
151
  onPress={() => {
152
152
  state.fixedTime.channel = undefined
@@ -158,13 +158,13 @@ const FixedTimeDetailPage = () => {
158
158
  }
159
159
  </View>
160
160
  {params.applyForList.map((item, index) => {
161
- if (state.fixedTime.channel === index) return null
161
+ if ((params.isPlug ? state.fixedTime.channel : 0)=== index) return null
162
162
  return (
163
163
  <TouchableOpacity
164
164
  style={styles.applyItem}
165
165
  key={item.key}
166
166
  onPress={() => {
167
- state.fixedTime.channel = index
167
+ state.fixedTime.channel = params.isPlug ? index : 1
168
168
  }}>
169
169
  <Text style={{ color: '#000' }}>{item.key}</Text>
170
170
  <Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
@@ -117,7 +117,7 @@ const FixedTimePage = () => {
117
117
  loading={state.loading}
118
118
  onBackClick={navigation.goBack}
119
119
  onHeadlineIconClick={() => {
120
- navigateToEdit('add', newFixedTime())
120
+ navigateToEdit('add', newFixedTime(!!params.isPlug))
121
121
  }}
122
122
  >
123
123
  <ScrollView nestedScrollEnabled={true}>
@@ -185,7 +185,7 @@ const FixedTimePage = () => {
185
185
  }}
186
186
  textStyle={{ color: '#fff' }}
187
187
  onPress={() => {
188
- navigateToEdit('add', newFixedTime())
188
+ navigateToEdit('add', newFixedTime(!!params.isPlug))
189
189
  }} />}
190
190
  </View>}
191
191
  </ScrollView>
@@ -230,7 +230,7 @@ const FixedTimeCard = memo((props: {
230
230
  )
231
231
  })
232
232
 
233
- const newFixedTime = () => {
233
+ const newFixedTime = (isPlug: boolean) => {
234
234
  const startTime = dayjs().hour() * 60 + dayjs().minute()
235
235
  return {
236
236
  name: '',
@@ -240,7 +240,7 @@ const newFixedTime = () => {
240
240
  endTime: startTime + 60,
241
241
  closeTime: 1,
242
242
  openTime: 1,
243
- channel: 0,
243
+ channel: isPlug ? 0 : 1,
244
244
  color: {
245
245
  h: 0,
246
246
  s: 100,
@@ -1,194 +1,194 @@
1
- import Strings from '@ledvance/base/src/i18n';
2
- import Page from '@ledvance/base/src/components/Page';
3
- import React, { useCallback } from 'react';
4
- import { FlatList, StyleSheet, Text, View } from 'react-native';
5
- import { Utils } from 'tuya-panel-kit';
6
- import RecommendMoodItem from './RecommendMoodItem';
7
- import Spacer from '@ledvance/base/src/components/Spacer';
8
- import { useReactive } from 'ahooks';
9
- import { useNavigation, useRoute } from '@react-navigation/native';
10
- import {
11
- MoodPageParams,
12
- MoodNodeTransitionMode,
13
- MoodUIInfo,
14
- MoodJumpGradientMode,
15
- } from './Interface';
16
- import { Result } from '@ledvance/base/src/models/modules/Result';
17
- import { ui_biz_routerKey } from '../../navigation/Routers'
18
- import { difference, head, range } from 'lodash';
19
- import { RecommendMood, getRecommendMixMoods, getRecommendMoods } from './MoodInfo';
20
-
21
- const cx = Utils.RatioUtils.convertX;
22
-
23
- export interface AddMoodPageParams {
24
- isStatic: boolean;
25
- moodIds: number[];
26
- moduleParams: MoodPageParams;
27
- nameRepeat: (mood: MoodUIInfo) => boolean
28
- modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
29
- }
30
-
31
- interface AddMoodPageState {
32
- data: RecommendMood[];
33
- }
34
-
35
- const AddMoodPage = () => {
36
- const navigation = useNavigation();
37
- const routeParams = useRoute().params as AddMoodPageParams;
38
- const moduleParams = routeParams.moduleParams;
39
- const isMix = !!(moduleParams.isMixLight || moduleParams.isCeilingLight);
40
- const state = useReactive<AddMoodPageState>({
41
- data: isMix
42
- ? getRecommendMixMoods(routeParams.isStatic, moduleParams)
43
- : getRecommendMoods(routeParams.isStatic, moduleParams),
44
- });
45
-
46
- const getFormateItem = item => {
47
- return {
48
- ...item,
49
- version: 0,
50
- secondaryLamp: item.secondaryLamp ?? {
51
- nodes: [],
52
- mode: 0,
53
- speed: 75,
54
- },
55
- };
56
- };
57
-
58
- const onMoodItemClick = useCallback(
59
- (moodItem: RecommendMood) => {
60
- const idRange = range(0, 256);
61
- const mainId: number = head(difference(idRange, routeParams.moodIds)) || 0;
62
- const secondaryId: number = moduleParams.isCeilingLight ? head(difference(idRange, [...routeParams.moodIds, mainId])) || 0 : 0
63
- const url = routeParams.isStatic
64
- ? ui_biz_routerKey.ui_biz_static_mood_edit
65
- : !!(moduleParams.isCeilingLight || moduleParams.isMixLight)
66
- ? ui_biz_routerKey.ui_biz_dynamic_mix_mood_edit
67
- : ui_biz_routerKey.ui_biz_dynamic_mood_edit;
68
- const currentMood = moodItem.mainLamp
69
- ? { ...moodItem, id: mainId, mainLamp: { ...moodItem.mainLamp, id: mainId }, secondaryLamp: { ...moodItem.secondaryLamp, id: secondaryId } }
70
- : newMood(mainId, secondaryId, moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
71
- navigation.navigate(url, {
72
- ...routeParams,
73
- mode: 'add',
74
- currentMood,
75
- });
76
- },
77
- [routeParams]
78
- );
79
-
80
- return (
81
- <Page
82
- backText={Strings.getLang('add_new_static_mood_system_back')}
83
- headlineText={Strings.getLang(
84
- routeParams.isStatic
85
- ? 'add_new_static_mood_headline_text'
86
- : 'add_new_dynamic_mood_headline_text'
87
- )}
88
- >
89
- <View style={styles.root}>
90
- <Text style={styles.desc}>
91
- {Strings.getLang(
92
- routeParams.isStatic
93
- ? 'add_new_static_mood_description_text'
94
- : 'add_new_dynamic_mood_description_text'
95
- )}
96
- </Text>
97
- <FlatList
98
- style={{ flex: 1 }}
99
- data={state.data}
100
- renderItem={({ item }) => {
101
- return (
102
- <RecommendMoodItem
103
- title={item.name}
104
- isMix={isMix}
105
- mood={getFormateItem(item)}
106
- deviceTypeOption={moduleParams}
107
- onPress={() => {
108
- onMoodItemClick(item);
109
- }}
110
- />
111
- );
112
- }}
113
- ItemSeparatorComponent={() => <Spacer />}
114
- ListHeaderComponent={() => <Spacer />}
115
- ListFooterComponent={() => <Spacer />}
116
- keyExtractor={item => item.name}
117
- />
118
- </View>
119
- </Page>
120
- );
121
- };
122
-
123
- const styles = StyleSheet.create({
124
- root: {
125
- flex: 1,
126
- flexDirection: 'column',
127
- },
128
- desc: {
129
- color: '#000',
130
- fontSize: cx(16),
131
- marginHorizontal: cx(24),
132
- marginTop: cx(12),
133
- },
134
- });
135
-
136
- export default AddMoodPage;
137
-
138
- const defStripConfig = {
139
- version: 0,
140
- expand: 0,
141
- reserved1: 0,
142
- reserved2: 0,
143
- segmented: 0,
144
- loop: 0,
145
- excessive: 0,
146
- direction: 0,
147
- }
148
-
149
- function newMood(
150
- mainId: number,
151
- secondaryId: number,
152
- isColorMode: boolean,
153
- isStatic: boolean,
154
- moduleParams: MoodPageParams
155
- ): MoodUIInfo {
156
- const jump = moduleParams.isStringLight
157
- ? MoodJumpGradientMode.StringJump
158
- : moduleParams.isStripLight
159
- ? MoodJumpGradientMode.StripJump
160
- : MoodJumpGradientMode.SourceJump;
161
- const node = {
162
- brightness: 100,
163
- colorTemp: 100,
164
- h: 0,
165
- s: 100,
166
- v: 100,
167
- isColorNode: !!(moduleParams.isCeilingLight || moduleParams.isMixLight) ? false : isColorMode,
168
- };
169
- return {
170
- version: 0,
171
- name: '',
172
- image: '',
173
- id: mainId,
174
- mainLamp: {
175
- id: mainId,
176
- speed: 75,
177
- enable: true,
178
- fanEnable: true,
179
- fanSpeed: 1,
180
- ...defStripConfig,
181
- mode: isStatic ? MoodNodeTransitionMode.Static : jump,
182
- nodes: isStatic ? [node] : [node, { ...node }],
183
- },
184
- secondaryLamp: {
185
- id: secondaryId,
186
- enable: true,
187
- mode: MoodJumpGradientMode.StripJump,
188
- speed: 75,
189
- ...defStripConfig,
190
- version: 1,
191
- nodes: isStatic ? [] : [{ ...node, isColorNode: true }, { ...node, isColorNode: true }],
192
- },
193
- };
194
- }
1
+ import Strings from '@ledvance/base/src/i18n';
2
+ import Page from '@ledvance/base/src/components/Page';
3
+ import React, { useCallback } from 'react';
4
+ import { FlatList, StyleSheet, Text, View } from 'react-native';
5
+ import { Utils } from 'tuya-panel-kit';
6
+ import RecommendMoodItem from './RecommendMoodItem';
7
+ import Spacer from '@ledvance/base/src/components/Spacer';
8
+ import { useReactive } from 'ahooks';
9
+ import { useNavigation, useRoute } from '@react-navigation/native';
10
+ import {
11
+ MoodPageParams,
12
+ MoodNodeTransitionMode,
13
+ MoodUIInfo,
14
+ MoodJumpGradientMode,
15
+ } from './Interface';
16
+ import { Result } from '@ledvance/base/src/models/modules/Result';
17
+ import { ui_biz_routerKey } from '../../navigation/Routers'
18
+ import { difference, head, range } from 'lodash';
19
+ import { RecommendMood, getRecommendMixMoods, getRecommendMoods } from './MoodInfo';
20
+
21
+ const cx = Utils.RatioUtils.convertX;
22
+
23
+ export interface AddMoodPageParams {
24
+ isStatic: boolean;
25
+ moodIds: number[];
26
+ moduleParams: MoodPageParams;
27
+ nameRepeat: (mood: MoodUIInfo) => boolean
28
+ modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: MoodUIInfo) => Promise<Result<any>>;
29
+ }
30
+
31
+ interface AddMoodPageState {
32
+ data: RecommendMood[];
33
+ }
34
+
35
+ const AddMoodPage = () => {
36
+ const navigation = useNavigation();
37
+ const routeParams = useRoute().params as AddMoodPageParams;
38
+ const moduleParams = routeParams.moduleParams;
39
+ const isMix = !!(moduleParams.isMixLight || moduleParams.isCeilingLight);
40
+ const state = useReactive<AddMoodPageState>({
41
+ data: isMix
42
+ ? getRecommendMixMoods(routeParams.isStatic, moduleParams)
43
+ : getRecommendMoods(routeParams.isStatic, moduleParams),
44
+ });
45
+
46
+ const getFormateItem = item => {
47
+ return {
48
+ ...item,
49
+ version: 0,
50
+ secondaryLamp: item.secondaryLamp ?? {
51
+ nodes: [],
52
+ mode: 0,
53
+ speed: 75,
54
+ },
55
+ };
56
+ };
57
+
58
+ const onMoodItemClick = useCallback(
59
+ (moodItem: RecommendMood) => {
60
+ const idRange = range(0, 256);
61
+ const mainId: number = head(difference(idRange, routeParams.moodIds)) || 0;
62
+ const secondaryId: number = moduleParams.isCeilingLight ? head(difference(idRange, [...routeParams.moodIds, mainId])) || 0 : 0
63
+ const url = routeParams.isStatic
64
+ ? ui_biz_routerKey.ui_biz_static_mood_edit
65
+ : !!(moduleParams.isCeilingLight || moduleParams.isMixLight)
66
+ ? ui_biz_routerKey.ui_biz_dynamic_mix_mood_edit
67
+ : ui_biz_routerKey.ui_biz_dynamic_mood_edit;
68
+ const currentMood = moodItem.mainLamp
69
+ ? { ...moodItem, id: mainId, mainLamp: { ...moodItem.mainLamp, id: mainId }, secondaryLamp: { ...moodItem.secondaryLamp, id: secondaryId } }
70
+ : newMood(mainId, secondaryId, moduleParams.isSupportColor, routeParams.isStatic, moduleParams);
71
+ navigation.navigate(url, {
72
+ ...routeParams,
73
+ mode: 'add',
74
+ currentMood,
75
+ });
76
+ },
77
+ [routeParams]
78
+ );
79
+
80
+ return (
81
+ <Page
82
+ backText={Strings.getLang('add_new_static_mood_system_back')}
83
+ headlineText={Strings.getLang(
84
+ routeParams.isStatic
85
+ ? 'add_new_static_mood_headline_text'
86
+ : 'add_new_dynamic_mood_headline_text'
87
+ )}
88
+ >
89
+ <View style={styles.root}>
90
+ <Text style={styles.desc}>
91
+ {Strings.getLang(
92
+ routeParams.isStatic
93
+ ? 'add_new_static_mood_description_text'
94
+ : 'add_new_dynamic_mood_description_text'
95
+ )}
96
+ </Text>
97
+ <FlatList
98
+ style={{ flex: 1 }}
99
+ data={state.data}
100
+ renderItem={({ item }) => {
101
+ return (
102
+ <RecommendMoodItem
103
+ title={item.name}
104
+ isMix={isMix}
105
+ mood={getFormateItem(item)}
106
+ deviceTypeOption={moduleParams}
107
+ onPress={() => {
108
+ onMoodItemClick(item);
109
+ }}
110
+ />
111
+ );
112
+ }}
113
+ ItemSeparatorComponent={() => <Spacer />}
114
+ ListHeaderComponent={() => <Spacer />}
115
+ ListFooterComponent={() => <Spacer />}
116
+ keyExtractor={item => item.name}
117
+ />
118
+ </View>
119
+ </Page>
120
+ );
121
+ };
122
+
123
+ const styles = StyleSheet.create({
124
+ root: {
125
+ flex: 1,
126
+ flexDirection: 'column',
127
+ },
128
+ desc: {
129
+ color: '#000',
130
+ fontSize: cx(16),
131
+ marginHorizontal: cx(24),
132
+ marginTop: cx(12),
133
+ },
134
+ });
135
+
136
+ export default AddMoodPage;
137
+
138
+ const defStripConfig = {
139
+ version: 0,
140
+ expand: 0,
141
+ reserved1: 0,
142
+ reserved2: 0,
143
+ segmented: 0,
144
+ loop: 0,
145
+ excessive: 0,
146
+ direction: 0,
147
+ }
148
+
149
+ function newMood(
150
+ mainId: number,
151
+ secondaryId: number,
152
+ isColorMode: boolean,
153
+ isStatic: boolean,
154
+ moduleParams: MoodPageParams
155
+ ): MoodUIInfo {
156
+ const jump = moduleParams.isStringLight
157
+ ? MoodJumpGradientMode.StringJump
158
+ : moduleParams.isStripLight
159
+ ? MoodJumpGradientMode.StripJump
160
+ : MoodJumpGradientMode.SourceJump;
161
+ const node = {
162
+ brightness: 100,
163
+ colorTemp: 100,
164
+ h: 0,
165
+ s: 100,
166
+ v: 100,
167
+ isColorNode: !!(moduleParams.isCeilingLight || moduleParams.isMixLight) ? false : isColorMode,
168
+ };
169
+ return {
170
+ version: 0,
171
+ name: '',
172
+ image: '',
173
+ id: mainId,
174
+ mainLamp: {
175
+ id: mainId,
176
+ speed: 75,
177
+ enable: true,
178
+ fanEnable: true,
179
+ fanSpeed: 1,
180
+ ...defStripConfig,
181
+ mode: isStatic ? MoodNodeTransitionMode.Static : jump,
182
+ nodes: isStatic ? [node] : [node, { ...node }],
183
+ },
184
+ secondaryLamp: {
185
+ id: secondaryId,
186
+ enable: true,
187
+ mode: MoodJumpGradientMode.StripJump,
188
+ speed: 75,
189
+ ...defStripConfig,
190
+ version: 1,
191
+ nodes: isStatic ? [] : [{ ...node, isColorNode: true }, { ...node, isColorNode: true }],
192
+ },
193
+ };
194
+ }