@ledvance/ui-biz-bundle 1.1.159 → 1.1.160

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.159",
7
+ "version": "1.1.160",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -364,7 +364,7 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
364
364
  style={{ position: 'relative' }}
365
365
  backText={backTitle}
366
366
  headlineText={backTitle}
367
- headlineIcon={res.ic_refresh}
367
+ headlineIcon={res.ic_reset_energy}
368
368
  onHeadlineIconClick={() => {
369
369
  showDialog({
370
370
  method: 'confirm',
@@ -1,5 +1,5 @@
1
1
  import I18n from "@ledvance/base/src/i18n";
2
- import { AdjustType, ApplyForItem, DiySceneInfo } from "@ledvance/base/src/utils/interface";
2
+ import {AdjustType, AlarmState, ApplyForItem, DiySceneInfo} from "@ledvance/base/src/utils/interface";
3
3
  import { MoodInfo, MoodUIInfo } from "../mood/Interface";
4
4
 
5
5
  export interface Timer {
@@ -36,6 +36,7 @@ interface judgmentSupport {
36
36
  isFanLight?: boolean;
37
37
  isUVCFan?: boolean;
38
38
  isMoodStrip?: boolean;
39
+ isSiren?: boolean;
39
40
  }
40
41
 
41
42
  export interface ManualSettingProps extends judgmentSupport {
@@ -57,7 +58,8 @@ export enum DeviceType {
57
58
  FanLight = 'fanLight',
58
59
  MoodStrip = 'moodStrip',
59
60
  Shutter = 'shutter',
60
- OsramFanLight = 'osramFanLight'
61
+ OsramFanLight = 'osramFanLight',
62
+ Siren = 'Siren'
61
63
  }
62
64
  // export type DeviceType = 'LightSource' | 'CeilingLight' | 'StringLight' | 'StripLight' | 'MixLight';
63
65
 
@@ -106,6 +108,10 @@ export interface OsramFanLightData extends DeviceData {
106
108
  fanSpeed: number
107
109
  }
108
110
 
111
+ export interface SirenData extends DeviceData {
112
+ alarmState: AlarmState
113
+ }
114
+
109
115
  export type ComponentConfig =
110
116
  | { type: DeviceType.LightSource; deviceData: DeviceData }
111
117
  | { type: DeviceType.MixLight; deviceData: MixLightData }
@@ -116,6 +122,7 @@ export type ComponentConfig =
116
122
  | { type: DeviceType.MoodStrip; deviceData: MoodStripData}
117
123
  | { type: DeviceType.Shutter; deviceData: ShutterData}
118
124
  | { type: DeviceType.OsramFanLight; deviceData: OsramFanLightData}
125
+ | { type: DeviceType.Siren; deviceData: SirenData}
119
126
 
120
127
  export interface TimeScheduleDetailState {
121
128
  timeSchedule: Timer;
@@ -142,6 +149,11 @@ export interface DeviceStateType {
142
149
  isManual: boolean
143
150
  }
144
151
 
152
+ export interface SuggestItem {
153
+ name: string;
154
+ suggestValue: boolean | undefined;
155
+ }
156
+
145
157
  export const directOptions = [
146
158
  {label: I18n.getLang('ceiling_fan_tile_uvc_fan_direction_opt_1'), value: 'forward'},
147
159
  {label: I18n.getLang('ceiling_fan_tile_uvc_fan_direction_opt_2'), value: 'reverse'}
@@ -1,8 +1,8 @@
1
1
  import { NativeApi } from '@ledvance/base/src/api/native';
2
- import { Timer, TimerActions } from './Interface';
2
+ import { Timer, TimerActions} from './Interface';
3
3
  import { parseJSON } from '@tuya/tuya-panel-lamp-sdk/lib/utils';
4
4
  import { ColorList } from '@ledvance/base/src/components/StripAdjustView';
5
- import {AdjustType} from "@ledvance/base/src/utils/interface";
5
+ import {AdjustType, AlarmState} from "@ledvance/base/src/utils/interface";
6
6
  import { TimeScheduleDetailPageParams } from './TimeScheduleDetailPage'
7
7
 
8
8
  export const defDeviceData = {
@@ -45,6 +45,16 @@ export const defShutterDeviceData = (props: TimeScheduleDetailPageParams) => {
45
45
  }
46
46
  };
47
47
 
48
+ export const defSirenDeviceData = (props: TimeScheduleDetailPageParams) => {
49
+ return {
50
+ alarmState: props.suggestValue === undefined
51
+ ? AlarmState.AlarmSound
52
+ : props.suggestValue
53
+ ? AlarmState.AlarmLight
54
+ : AlarmState.AlarmSoundAndLight
55
+ }
56
+ };
57
+
48
58
  export const defOsramFanLightDeviceData = {
49
59
  ...defDeviceData,
50
60
  fanSpeed: 1,
@@ -14,6 +14,16 @@ import { TimeScheduleDetailPageParams } from './TimeScheduleDetailPage'
14
14
 
15
15
  const { convertX: cx } = Utils.RatioUtils
16
16
  const { withTheme } = Utils.ThemeUtils
17
+ const DEFAULT_SUGGEST_ITEMS = [
18
+ {
19
+ name: I18n.getLang('timeschedule_on'),
20
+ suggestValue: true,
21
+ },
22
+ {
23
+ name: I18n.getLang('timeschedule_off'),
24
+ suggestValue: false,
25
+ },
26
+ ]
17
27
 
18
28
  interface TimeScheduleAddProps {
19
29
  theme?: ThemeType
@@ -21,6 +31,8 @@ interface TimeScheduleAddProps {
21
31
 
22
32
  const TimeScheduleAddPage = (props: TimeScheduleAddProps) => {
23
33
  const params = useParams<TimeScheduleDetailPageParams>()
34
+ const suggestItems = params.suggestList ?? DEFAULT_SUGGEST_ITEMS
35
+
24
36
  const navigation = useNavigation()
25
37
  const state = useReactive({
26
38
  loading: false,
@@ -55,14 +67,16 @@ const TimeScheduleAddPage = (props: TimeScheduleAddProps) => {
55
67
  <Card style={styles.card} onPress={() => nextPage()}>
56
68
  <Text style={styles.text}>{I18n.getLang('timeschedule_own')}</Text>
57
69
  </Card>
58
- <Spacer/>
59
- <Card style={styles.card} onPress={() => nextPage(true)}>
60
- <Text style={styles.text}>{I18n.getLang('timeschedule_on')}</Text>
61
- </Card>
62
- <Spacer/>
63
- <Card style={styles.card} onPress={() => nextPage(false)}>
64
- <Text style={styles.text}>{I18n.getLang('timeschedule_off')}</Text>
65
- </Card>
70
+ {suggestItems.map((item) => {
71
+ return (
72
+ <View key={item.name}>
73
+ <Spacer/>
74
+ <Card style={styles.card} onPress={() => nextPage(item.suggestValue)}>
75
+ <Text style={styles.text}>{item.name}</Text>
76
+ </Card>
77
+ </View>
78
+ )
79
+ })}
66
80
  </View>
67
81
  </Page>
68
82
  )
@@ -15,7 +15,7 @@ import { useDeviceId, useMoods, useSystemTimeFormate, } from '@ledvance/base/src
15
15
  import { Result } from '@ledvance/base/src/models/modules/Result'
16
16
  import res from '@ledvance/base/src/res'
17
17
  import { convertTo12HourFormat, loopText, showDialog } from '@ledvance/base/src/utils/common'
18
- import { ApplyForItem, DiySceneInfo } from '@ledvance/base/src/utils/interface'
18
+ import {AlarmState, ApplyForItem, DiySceneInfo} from '@ledvance/base/src/utils/interface'
19
19
  import { ui_biz_routerKey } from '../../navigation/Routers'
20
20
  import { useNavigation } from '@react-navigation/core'
21
21
  import { useReactive } from 'ahooks'
@@ -27,14 +27,14 @@ import { MoodInfo, MoodUIInfo } from '../mood/Interface'
27
27
  import { getRemoteMoodList } from '../mood/MoodActions'
28
28
  import MoodItem from '../mood/MoodItem'
29
29
  import ManualSettings from './components/ManuaSettings'
30
- import { ComponentConfig, DeviceType, Timer, TimerActions, TimeScheduleDetailState, } from './Interface'
30
+ import {ComponentConfig, DeviceType, SirenData, Timer, TimerActions, TimeScheduleDetailState,} from './Interface'
31
31
  import {
32
32
  defDeviceData,
33
33
  defFanLightDeviceData,
34
34
  defMixDeviceData,
35
35
  defMoodStripDeviceData,
36
36
  defOsramFanLightDeviceData,
37
- defShutterDeviceData,
37
+ defShutterDeviceData, defSirenDeviceData,
38
38
  defStripDeviceData
39
39
  } from './TimeScheduleActions'
40
40
  import { TimeSchedulePageParams } from './TimeSchedulePage'
@@ -238,6 +238,14 @@ const TimeScheduleDetailPage = (props: { theme?: ThemeType }) => {
238
238
  return params.isCeilingLight ? ((item.mainLamp.id === (state.mood as MoodInfo)?.mainLamp?.id) && (item.secondaryLamp.id === (state.mood as MoodInfo)?.secondaryLamp?.id)) : item.id === state.mood?.id
239
239
  }, [state.mood, params.isCeilingLight])
240
240
 
241
+ const alarmStateValueMap = useMemo(() => {
242
+ return {
243
+ [AlarmState.AlarmSound]: I18n.getLang('siren_alarm_type_sound'),
244
+ [AlarmState.AlarmLight]: I18n.getLang('siren_alarm_type_light'),
245
+ [AlarmState.AlarmSoundAndLight]: I18n.getLang('siren_alarm_type_sound_light'),
246
+ }
247
+ }, [])
248
+
241
249
  const renderSkillGroup = (skills: ApplyForItem[], i18nString: string) => {
242
250
  if (!skills.length) return null;
243
251
 
@@ -263,6 +271,31 @@ const TimeScheduleDetailPage = (props: { theme?: ThemeType }) => {
263
271
  );
264
272
  };
265
273
 
274
+ const renderSirenSkillGroup = (skills: ApplyForItem[]) => {
275
+ if (!skills.length) return null;
276
+ return (
277
+ <>
278
+ {skills.map(item => (
279
+ <View key={item.dp}>
280
+ <Text style={{fontSize: cx(14), color: props.theme?.global.fontColor}}>
281
+ {item.key}
282
+ </Text>
283
+ <View style={{flexDirection: 'row', flexWrap: 'wrap'}}>
284
+ <View
285
+ style={[
286
+ styles.summaryRight,
287
+ {marginRight: cx(5), marginBottom: cx(5)},
288
+ ]}
289
+ >
290
+ <Text
291
+ style={styles.rightItem}>{alarmStateValueMap[(state.manualData.deviceData as SirenData).alarmState]}</Text>
292
+ </View>
293
+ </View>
294
+ </View>))}
295
+ </>
296
+ );
297
+ };
298
+
266
299
  const styles = StyleSheet.create({
267
300
  cardContainer: {
268
301
  marginHorizontal: cx(24),
@@ -629,8 +662,9 @@ const TimeScheduleDetailPage = (props: { theme?: ThemeType }) => {
629
662
  {state.isManual ? (
630
663
  state.selectedSkill.length ? (
631
664
  <>
632
- {renderSkillGroup(state.selectedSkill.filter(skill => skill.enable), I18n.getLang(params.isShutter ? 'curtain_summary_action_txt_1' : 'feature_summary_action_txt_1'))}
633
- {renderSkillGroup(state.selectedSkill.filter(skill => !skill.enable), I18n.getLang(params.isShutter ? 'curtain_summary_action_txt_2' : 'feature_summary_action_txt_2'))}
665
+ {!params.isSiren && renderSkillGroup(state.selectedSkill.filter(skill => skill.enable), I18n.getLang(params.isShutter ? 'curtain_summary_action_txt_1' : 'feature_summary_action_txt_1'))}
666
+ {!params.isSiren && renderSkillGroup(state.selectedSkill.filter(skill => !skill.enable), I18n.getLang(params.isShutter ? 'curtain_summary_action_txt_2' : 'feature_summary_action_txt_2'))}
667
+ {params.isSiren && renderSirenSkillGroup(state.selectedSkill)}
634
668
  </>
635
669
  ) : null
636
670
  ) : (
@@ -698,7 +732,8 @@ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig
698
732
  isCeilingLight: DeviceType.CeilingLight,
699
733
  isMoodStrip: DeviceType.MoodStrip,
700
734
  isShutter: DeviceType.Shutter,
701
- isOsramFanLight: DeviceType.OsramFanLight
735
+ isOsramFanLight: DeviceType.OsramFanLight,
736
+ isSiren: DeviceType.Siren
702
737
  };
703
738
 
704
739
  const deviceType = Object.entries(deviceTypeMap)
@@ -716,6 +751,7 @@ const getDefaultManual = (props: TimeScheduleDetailPageParams): ComponentConfig
716
751
  [DeviceType.PowerStrip]: defDeviceData,
717
752
  [DeviceType.LightSource]: defDeviceData,
718
753
  [DeviceType.Plug]: defDeviceData,
754
+ [DeviceType.Siren]: defSirenDeviceData(props),
719
755
  };
720
756
 
721
757
  return {
@@ -14,7 +14,7 @@ import Spacer from '@ledvance/base/src/components/Spacer';
14
14
  import InfoText from '@ledvance/base/src/components/InfoText';
15
15
  import DeleteButton from '@ledvance/base/src/components/DeleteButton';
16
16
  import { useReactive, useUpdateEffect } from 'ahooks';
17
- import { DeviceStateType, Timer, TimerActions } from './Interface';
17
+ import {DeviceStateType, SuggestItem, Timer, TimerActions} from './Interface';
18
18
  import { getTimeSchedule, manageTimeSchedule } from './TimeScheduleActions';
19
19
  import { useParams } from '@ledvance/base/src/hooks/Hooks';
20
20
  import ScheduleCard from './components/ScheduleCard';
@@ -46,8 +46,11 @@ export interface TimeSchedulePageParams {
46
46
  isMoodStrip?: boolean
47
47
  isShutter?: boolean
48
48
  isOsramFan?: boolean
49
+ isSiren?: boolean
50
+ showPresets?: boolean
49
51
  featureId?: string
50
52
  applyForList: ApplyForItem[];
53
+ suggestList?: SuggestItem[];
51
54
  applyForDisabled?: boolean; // 是否可以选择apply for
52
55
  manualDataDp2Obj: (dps: Record<string, any>) => DeviceStateType;
53
56
  manualDataObj2Dp: (deviceState: DeviceStateType, applyForList: ApplyForItem[]) => Record<string, any>;
@@ -130,7 +133,8 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
130
133
  };
131
134
 
132
135
  const navigateToEdit = useCallback((mode: 'add' | 'update', timeSchedule?: Timer) => {
133
- const path = mode === 'add' ? ui_biz_routerKey.ui_biz_time_schedule_add_new : ui_biz_routerKey.ui_biz_time_schedule_edit_new;
136
+ const {showPresets = true} = params;
137
+ const path = mode === 'add' && showPresets ? ui_biz_routerKey.ui_biz_time_schedule_add_new : ui_biz_routerKey.ui_biz_time_schedule_edit_new;
134
138
  navigation.navigate(path, {
135
139
  mode,
136
140
  name: path,
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import {Utils} from 'tuya-panel-kit';
3
+ import ThemeType from '@ledvance/base/src/config/themeType'
4
+ import OptionGroup from "@ledvance/base/src/components/OptionGroup";
5
+ import I18n from "@ledvance/base/src/i18n";
6
+ import {useReactive} from "ahooks";
7
+ import {AlarmState} from "@ledvance/base/src/utils/interface";
8
+
9
+ const {withTheme} = Utils.ThemeUtils
10
+
11
+ interface AlarmModeItemProps {
12
+ theme?: ThemeType
13
+ name: string
14
+ alarmState: AlarmState
15
+ onAlarmStateChange: (alarmState: AlarmState) => void
16
+ }
17
+
18
+ const AlarmModeItem = (props: AlarmModeItemProps) => {
19
+ const {name, alarmState, onAlarmStateChange} = props;
20
+ const state = useReactive({
21
+ alarmState: alarmState,
22
+ });
23
+ return (
24
+ <OptionGroup
25
+ tips={name}
26
+ selected={state.alarmState}
27
+ options={[{
28
+ title: I18n.getLang('siren_alarm_type_sound'),
29
+ value: AlarmState.AlarmSound,
30
+ onPress: (value) => {
31
+ state.alarmState = value
32
+ onAlarmStateChange(value)
33
+ }
34
+ }, {
35
+ title: I18n.getLang('siren_alarm_type_light'),
36
+ value: AlarmState.AlarmLight,
37
+ onPress: (value) => {
38
+ state.alarmState = value
39
+ onAlarmStateChange(value)
40
+ }
41
+ }, {
42
+ title: I18n.getLang('siren_alarm_type_sound_light'),
43
+ value: AlarmState.AlarmSoundAndLight,
44
+ onPress: (value) => {
45
+ state.alarmState = value
46
+ onAlarmStateChange(value)
47
+ }
48
+ }]}
49
+ />
50
+ )
51
+
52
+ }
53
+
54
+ export default withTheme(AlarmModeItem) as React.ComponentType<AlarmModeItemProps>
@@ -6,7 +6,7 @@ import {
6
6
  ManualSettingProps,
7
7
  modeOptions,
8
8
  OsramFanLightData,
9
- ShutterData,
9
+ ShutterData, SirenData,
10
10
  StripLightData
11
11
  } from '../Interface';
12
12
  import { View, Text, } from 'react-native';
@@ -28,6 +28,7 @@ import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils';
28
28
  import { AdjustType, ApplyForItem } from "@ledvance/base/src/utils/interface";
29
29
  import LdvSlider from '@ledvance/base/src/components/ldvSlider';
30
30
  import OsramFanAdjustView from '@ledvance/base/src/components/OsramFanAdjustView'
31
+ import AlarmModeItem from "./AlarmModeItem";
31
32
 
32
33
  const { convertX: cx } = Utils.RatioUtils;
33
34
  const { withTheme } = Utils.ThemeUtils
@@ -524,7 +525,7 @@ function ManualSettings(props: ManualSettingProps) {
524
525
  <Card style={{ marginHorizontal: cx(24) }}>
525
526
  <Spacer height={cx(16)} />
526
527
  <LdvSlider
527
- title={'Curtain'}
528
+ title={I18n.getLang('curtain_control_headline_text')}
528
529
  value={(state.deviceData as ShutterData).percentControl}
529
530
  min={0}
530
531
  max={100}
@@ -544,22 +545,37 @@ function ManualSettings(props: ManualSettingProps) {
544
545
  )
545
546
  }, [state.deviceData, state.applyForList, props.theme?.type])
546
547
 
547
- const componentRender = useMemo(() => {
548
- const component =
549
- props.manualData.type === DeviceType.MixLight
550
- ? mixLightCard
551
- : props.manualData.type === DeviceType.StripLight
552
- ? stripLightCard
553
- : props.manualData.type === DeviceType.CeilingLight
554
- ? ceilingLightCard
555
- : props.manualData.type === DeviceType.PowerStrip
556
- ? powerStripCard
557
- : props.manualData.type === DeviceType.Shutter
558
- ? shutterCard
559
- : lightSourceCard;
560
- return component;
561
- }, [props.manualData, state.applyForList, state.deviceData, props.theme?.type]);
548
+ const sirenCard = useMemo(() => {
549
+ return (
550
+ <View>
551
+ {state.applyForList.map((item, idx) => (
552
+ <View key={item.dp}>
553
+ <AlarmModeItem
554
+ name={item.name!}
555
+ alarmState={(state.deviceData as SirenData).alarmState}
556
+ onAlarmStateChange={async (alarmState) => {
557
+ (state.deviceData as SirenData).alarmState = alarmState
558
+ state.manualFlag = Symbol()
559
+ }}
560
+ />
561
+ <Spacer />
562
+ </View>
563
+ ))}
564
+ </View>
565
+ )
566
+ }, [state.deviceData, state.applyForList, props.theme?.type])
567
+
568
+ const componentMap = {
569
+ [DeviceType.MixLight]: mixLightCard,
570
+ [DeviceType.StripLight]: stripLightCard,
571
+ [DeviceType.CeilingLight]: ceilingLightCard,
572
+ [DeviceType.PowerStrip]: powerStripCard,
573
+ [DeviceType.Shutter]: shutterCard,
574
+ [DeviceType.Siren]: sirenCard,
575
+ };
562
576
 
577
+ const componentRender =
578
+ componentMap[props.manualData.type] ?? lightSourceCard;
563
579
 
564
580
  return <View>{componentRender}</View>;
565
581
  }