@ledvance/ui-biz-bundle 1.1.62 → 1.1.64

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,5 +1,5 @@
1
1
  import React, { memo, useMemo } from 'react';
2
- import { DeviceType, ManualSettingProps } from '../Interface';
2
+ import { CeilingLightData, DeviceType, directOptions, ManualSettingProps, modeOptions, StripLightData } from '../Interface';
3
3
  import { View } from 'react-native';
4
4
  import Card from '@ledvance/base/src/components/Card';
5
5
  import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
@@ -11,9 +11,14 @@ import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
11
11
  import I18n from '@ledvance/base/src/i18n';
12
12
  import StripAdjustView from '@ledvance/base/src/components/StripAdjustView';
13
13
  import Spacer from '@ledvance/base/src/components/Spacer';
14
+ import { FanAdjustViewContent } from '@ledvance/base/src/components/FanAdjustView';
15
+ import SocketItem from '@ledvance/base/src/components/SocketItem'
16
+ import res from '@ledvance/base/src/res';
14
17
  const { convertX: cx } = Utils.RatioUtils;
15
18
  const { withTheme } = Utils.ThemeUtils
16
19
 
20
+ const PowerStripIcon = [res.switch_1, res.switch_2, res.switch_3, res.switch_4]
21
+
17
22
  function ManualSettings(props: ManualSettingProps) {
18
23
  const state = useReactive({
19
24
  deviceData: props.manualData.deviceData,
@@ -27,11 +32,11 @@ function ManualSettings(props: ManualSettingProps) {
27
32
  state.deviceData = props.manualData.deviceData;
28
33
  }, [props.applyForList, props.manualData]);
29
34
 
30
- useUpdateEffect(() =>{
35
+ useUpdateEffect(() => {
31
36
  props.onApplyChange && props.onApplyChange(state.applyForList)
32
37
  }, [state.applyFlag])
33
38
 
34
- useUpdateEffect(() =>{
39
+ useUpdateEffect(() => {
35
40
  props.onManualChange && props.onManualChange(state.deviceData)
36
41
  }, [state.manualFlag])
37
42
 
@@ -47,6 +52,9 @@ function ManualSettings(props: ManualSettingProps) {
47
52
  ),
48
53
  },
49
54
  ];
55
+ if (props.isCeilingLight) {
56
+ return tabs.filter(tab => tab.key !== 0)
57
+ }
50
58
  if (!isSupportWhite) {
51
59
  return tabs.filter(tab => tab.key !== 0);
52
60
  }
@@ -61,7 +69,7 @@ function ManualSettings(props: ManualSettingProps) {
61
69
  return (
62
70
  <View>
63
71
  {state.applyForList.map((item, idx) => (
64
- <View key={item.dp}>
72
+ <View key={item.dp}>
65
73
  <Card style={{ marginHorizontal: cx(24) }}>
66
74
  <LdvSwitch
67
75
  title={item.key}
@@ -81,7 +89,7 @@ function ManualSettings(props: ManualSettingProps) {
81
89
  state.applyFlag = Symbol()
82
90
  }}
83
91
  />
84
- {item.enable && item.type !== 'socket' && (
92
+ {item.enable && (item.type !== 'socket' && item.type !== 'fan') && (
85
93
  <LampAdjustView
86
94
  isSupportColor={props.isSupportColor}
87
95
  isSupportBrightness={props.isSupportBrightness}
@@ -125,6 +133,53 @@ function ManualSettings(props: ManualSettingProps) {
125
133
  }}
126
134
  />
127
135
  )}
136
+
137
+ {item.enable && item.type === 'fan' && (
138
+ <FanAdjustViewContent
139
+ hideEnable={true}
140
+ fanEnable={item.enable}
141
+ maxFanSpeed={props.isUVCFan ? 20 : 3}
142
+ isSupportDirection={props.isUVCFan}
143
+ isSupportDisinfect={props.isUVCFan}
144
+ isSupportMode={props.isUVCFan}
145
+ directValue={''}
146
+ disinfect={true}
147
+ modeValue={''}
148
+ directOptions={directOptions}
149
+ modeOptions={modeOptions}
150
+ directChange={(direction: any) => {
151
+ state.deviceData = {
152
+ ...state.deviceData,
153
+ direction
154
+ }
155
+ state.manualFlag = Symbol()
156
+ }}
157
+ modeChange={(mode: any) => {
158
+ state.deviceData = {
159
+ ...state.deviceData,
160
+ mode
161
+ }
162
+ state.manualFlag = Symbol()
163
+ }}
164
+ disinfectChange={(disinfect: any) => {
165
+ state.deviceData = {
166
+ ...state.deviceData,
167
+ disinfect
168
+ }
169
+ state.manualFlag = Symbol()
170
+ }}
171
+ // @ts-ignore
172
+ fanSpeed={deviceData.fanSpeed}
173
+ onFanSwitch={() => { }}
174
+ onFanSpeedChangeComplete={(fanSpeed) => {
175
+ state.deviceData = {
176
+ ...state.deviceData,
177
+ fanSpeed
178
+ }
179
+ state.manualFlag = Symbol()
180
+ }}
181
+ />
182
+ )}
128
183
  </Card>
129
184
  <Spacer />
130
185
  </View>
@@ -137,7 +192,7 @@ function ManualSettings(props: ManualSettingProps) {
137
192
  return (
138
193
  <View>
139
194
  {state.applyForList.map((item, idx) => (
140
- <View key={item.dp}>
195
+ <View key={item.dp}>
141
196
  <Card style={{ marginHorizontal: cx(24) }}>
142
197
  <LdvSwitch
143
198
  title={item.key}
@@ -195,6 +250,7 @@ function ManualSettings(props: ManualSettingProps) {
195
250
  }, [state.deviceData, state.applyForList, props.theme.type]);
196
251
 
197
252
  const stripLightCard = useMemo(() => {
253
+ const deviceData = state.deviceData as StripLightData
198
254
  return (
199
255
  <View>
200
256
  <Card>
@@ -214,8 +270,24 @@ function ManualSettings(props: ManualSettingProps) {
214
270
  isSupportTemperature={props.isSupportTemperature}
215
271
  lampTabs={tabList}
216
272
  reserveSV={true}
217
- activeKey={0}
218
- onActiveKeyChange={() => {}}
273
+ activeKey={deviceData.activeKey}
274
+ colorDiskActiveKey={deviceData.colorDiskActiveKey}
275
+ onActiveKeyChange={(activekey) => {
276
+ state.deviceData = {
277
+ ...state.deviceData,
278
+ activeKey: Number(activekey),
279
+ isColorMode: !(Number(activekey) === 0)
280
+ }
281
+ state.manualFlag = Symbol()
282
+ }}
283
+ onColorDiskChange={(colors, idx) => {
284
+ state.deviceData = {
285
+ ...state.deviceData,
286
+ colors,
287
+ colorDiskActiveKey: idx
288
+ }
289
+ state.manualFlag = Symbol()
290
+ }}
219
291
  h={state.deviceData.h}
220
292
  s={state.deviceData.s}
221
293
  v={state.deviceData.v}
@@ -243,13 +315,141 @@ function ManualSettings(props: ManualSettingProps) {
243
315
  );
244
316
  }, [state.deviceData, state.applyForList, props.theme.type]);
245
317
 
318
+ const ceilingLightCard = useMemo(() => {
319
+ const deviceData = state.deviceData as CeilingLightData
320
+ return (
321
+ <View>
322
+ {state.applyForList.map((item, idx) => (
323
+ <View key={item.dp}>
324
+ <Card style={{ marginHorizontal: cx(24) }}>
325
+ <LdvSwitch
326
+ title={item.key}
327
+ color={'#fff'}
328
+ colorAlpha={1}
329
+ enable={item.enable}
330
+ setEnable={(enable: boolean) => {
331
+ state.applyForList[idx].enable = enable;
332
+ state.applyFlag = Symbol()
333
+ }}
334
+ />
335
+ {item.enable &&
336
+ (item.type === 'mainLight' ? (
337
+ <View>
338
+ <ColorTempAdjustView
339
+ isSupportBrightness={props.isSupportBrightness}
340
+ isSupportTemperature={props.isSupportTemperature}
341
+ colorTemp={deviceData.temperature}
342
+ brightness={deviceData.brightness}
343
+ onBrightnessChangeComplete={bright => {
344
+ state.deviceData.brightness = bright;
345
+ state.manualFlag = Symbol()
346
+ }}
347
+ onCCTChangeComplete={cct => {
348
+ state.deviceData.temperature = cct;
349
+ state.manualFlag = Symbol()
350
+ }}
351
+ />
352
+ <Spacer height={cx(16)} />
353
+ </View>
354
+ ) : (
355
+ <View>
356
+ <StripAdjustView
357
+ isSupportBrightness={false}
358
+ isSupportTemperature={false}
359
+ lampTabs={tabList}
360
+ reserveSV={true}
361
+ activeKey={deviceData.activeKey}
362
+ colorDiskActiveKey={deviceData.colorDiskActiveKey}
363
+ onActiveKeyChange={(activekey) => {
364
+ state.deviceData = {
365
+ ...state.deviceData,
366
+ activeKey: Number(activekey)
367
+ }
368
+ state.manualFlag = Symbol()
369
+ }}
370
+ onColorDiskChange={(colors, idx) => {
371
+ state.deviceData = {
372
+ ...state.deviceData,
373
+ colors,
374
+ colorDiskActiveKey: idx
375
+ }
376
+ state.manualFlag = Symbol()
377
+ }}
378
+ h={deviceData.h}
379
+ s={deviceData.s}
380
+ v={deviceData.v}
381
+ brightness={deviceData.brightness}
382
+ colorTemp={deviceData.temperature}
383
+ onHSVChangeComplete={(h, s, v) => {
384
+ state.deviceData.h = h;
385
+ state.deviceData.s = s;
386
+ state.deviceData.v = v;
387
+ state.manualFlag = Symbol()
388
+ }}
389
+ onBrightnessChangeComplete={bright => {
390
+ state.deviceData.brightness = bright;
391
+ state.manualFlag = Symbol()
392
+ }}
393
+ onCCTChangeComplete={cct => {
394
+ state.deviceData.temperature = cct;
395
+ state.manualFlag = Symbol()
396
+ }}
397
+ />
398
+ <Spacer />
399
+ </View>
400
+ ))}
401
+ <Spacer height={cx(16)} />
402
+ </Card>
403
+ <Spacer />
404
+ </View>
405
+ ))}
406
+ </View>
407
+ )
408
+ }, [state.deviceData, state.applyForList])
409
+
410
+ const powerStripCard = useMemo(() => {
411
+ return (
412
+ <View>
413
+ {state.applyForList.map((item, idx) => (
414
+ <View key={item.dp}>
415
+ <SocketItem
416
+ title={item.key}
417
+ name={item.name!}
418
+ icon={{ uri: PowerStripIcon[item.index ?? 0] }}
419
+ disabledEdit={true}
420
+ onNameChange={() => { }}
421
+ enabled={item.enable}
422
+ onSwitchChange={async enable => {
423
+ state.applyForList = state.applyForList.map((apply, index) => {
424
+ if (idx === index) {
425
+ return {
426
+ ...apply,
427
+ enable,
428
+ };
429
+ }
430
+ return apply;
431
+ });
432
+ state.applyFlag = Symbol()
433
+ }}
434
+ />
435
+ <Spacer />
436
+ </View>
437
+ ))}
438
+ </View>
439
+ )
440
+ }, [state.deviceData, state.applyForList])
441
+
246
442
  const componentRender = useMemo(() => {
247
443
  const component =
248
444
  props.manualData.type === DeviceType.MixLight
249
445
  ? mixLightCard
250
446
  : props.manualData.type === DeviceType.StripLight
251
447
  ? stripLightCard
252
- : lightSourceCard;
448
+ : props.manualData.type === DeviceType.CeilingLight
449
+ ? ceilingLightCard
450
+ : props.manualData.type === DeviceType.PowerStrip
451
+ ? powerStripCard
452
+ : lightSourceCard;
253
453
  return component;
254
454
  }, [props.manualData, state.applyForList, state.deviceData, props.theme.type]);
255
455
 
@@ -1,9 +1,9 @@
1
- import React from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { ViewStyle, View, Text, StyleSheet } from "react-native";
3
3
  import Card from "@ledvance/base/src/components/Card";
4
4
  import { SwitchButton, Utils } from 'tuya-panel-kit';
5
5
  import { convertTo12HourFormat, loopText } from '@ledvance/base/src/utils/common';
6
- import { Timer } from "../Interface";
6
+ import { ApplyForItem, Timer } from "../Interface";
7
7
  import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
8
8
  const { convertX: cx } = Utils.RatioUtils;
9
9
  const { withTheme } = Utils.ThemeUtils
@@ -12,13 +12,18 @@ interface ScheduleCardProps {
12
12
  theme?: any
13
13
  item: Timer
14
14
  style?: ViewStyle
15
+ showTag?: boolean
16
+ tags: ApplyForItem[]
15
17
  onEnableChange: (enable: boolean) => void
16
18
  onPress: (item: any) => void
17
19
  }
18
20
 
19
21
  const ScheduleCard = (props: ScheduleCardProps) => {
20
- const { item, style, onEnableChange, onPress } = props;
22
+ const { item, style, showTag, tags, onEnableChange, onPress } = props;
21
23
  const is24HourClock = useSystemTimeFormate()
24
+ const showTags = useMemo(() => {
25
+ return tags.filter(tag => item.dps.hasOwnProperty(tag.dp))
26
+ }, [tags, item.dps])
22
27
 
23
28
  const styles = StyleSheet.create({
24
29
  card: {
@@ -65,17 +70,19 @@ const ScheduleCard = (props: ScheduleCardProps) => {
65
70
  flexDirection: 'row',
66
71
  marginTop: cx(8),
67
72
  },
68
- typeWrap: {
69
- backgroundColor: props.theme.card.head,
73
+ tag: {
74
+ borderRadius: cx(16),
75
+ height: cx(16),
76
+ backgroundColor: '#E6E7E8',
70
77
  marginRight: cx(10),
71
- borderRadius: cx(10),
78
+ paddingHorizontal: cx(12)
79
+ },
80
+ tagTitle: {
81
+ fontSize: cx(10),
82
+ textAlign: 'center',
83
+ fontFamily: 'PingFangSC-Medium',
84
+ color: '#000'
72
85
  },
73
- typeText: {
74
- fontSize: cx(12),
75
- color: props.theme.global.fontColor,
76
- paddingHorizontal: cx(8),
77
- paddingVertical: cx(2)
78
- }
79
86
  });
80
87
  return (
81
88
  <Card
@@ -91,9 +98,15 @@ const ScheduleCard = (props: ScheduleCardProps) => {
91
98
  {loopText(item.loops.split('').map(loop => parseInt(loop)), item.time)}
92
99
  </Text>
93
100
  <Text style={styles.name}>{item.name}</Text>
94
- {/* {showTags() && <View style={styles.typeContainer}>
95
- {renderTag()}
96
- </View>} */}
101
+ {showTag && <View style={styles.typeContainer}>
102
+ {showTags.map(tag => (
103
+ <View style={styles.tag} key={tag.dp}>
104
+ <Text style={styles.tagTitle}>
105
+ {tag.key}
106
+ </Text>
107
+ </View>
108
+ ))}
109
+ </View>}
97
110
  </View>
98
111
  <View style={styles.switchContainer}>
99
112
  <SwitchButton