@ledvance/ui-biz-bundle 1.0.2 → 1.0.4

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.
Files changed (34) hide show
  1. package/.babelrc +31 -31
  2. package/.eslintignore +5 -5
  3. package/.eslintrc.js +27 -27
  4. package/.prettierrc.js +1 -1
  5. package/.versionrc +5 -5
  6. package/package.json +72 -72
  7. package/rn-cli.config.js +8 -8
  8. package/src/modules/history/HistoryPage.d.ts +2 -2
  9. package/src/modules/history/HistoryPage.tsx +254 -254
  10. package/src/modules/history/SwitchHistoryPageActions.d.ts +13 -13
  11. package/src/modules/history/SwitchHistoryPageActions.ts +53 -53
  12. package/src/modules/hooks/DeviceDpStateHooks.ts +27 -0
  13. package/src/modules/mood/MixLightActions.ts +82 -0
  14. package/src/modules/mood/MixLightSceneActions.ts +259 -0
  15. package/src/modules/mood/MixMoodItem.tsx +138 -0
  16. package/src/modules/mood/MixScene.tsx +131 -0
  17. package/src/modules/mood/MixSceneBeans.ts +62 -0
  18. package/src/modules/mood/MoodAction.ts +222 -0
  19. package/src/modules/mood/MoodItem.tsx +113 -0
  20. package/src/modules/mood/SceneInfo.ts +319 -0
  21. package/src/modules/timeSchedule/DeviceState.tsx +54 -0
  22. package/src/modules/timeSchedule/LdvScheduleItem.tsx +125 -0
  23. package/src/modules/timeSchedule/ManualSetting.tsx +69 -0
  24. package/src/modules/timeSchedule/MoodSetting.tsx +66 -0
  25. package/src/modules/timeSchedule/ScheduleScene.tsx +138 -0
  26. package/src/modules/timeSchedule/SingleLightView.tsx +254 -0
  27. package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +480 -0
  28. package/src/modules/timeSchedule/TimeSchedulePage.tsx +323 -0
  29. package/src/modules/timeSchedule/mix/MixLightBean.ts +10 -0
  30. package/src/modules/timeSchedule/mix/MixLightView.tsx +221 -0
  31. package/src/modules/timeSchedule/utils.ts +7 -0
  32. package/src/modules/timer/TimerPage.tsx +409 -406
  33. package/src/modules/timer/{timerPageAction.ts → TimerPageAction.ts} +91 -91
  34. package/tsconfig.json +50 -50
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { Utils as lampUtils } from "@tuya/tuya-panel-lamp-sdk"
3
+ import { View } from "react-native";
4
+ import { Utils } from 'tuya-panel-kit'
5
+ import SegmentControl from "@ledvance/base/src/components/segmentControl";
6
+ import I18n from "@ledvance/base/src/i18n";
7
+ import ManualSetting from "./ManualSetting";
8
+ import { ScheduleItemDp } from "./TimeScheduleEditpage";
9
+ import MoodSetting from "./MoodSetting";
10
+ import { isPlug } from "@ledvance/base/src/utils/Support";
11
+ const { convertX: cx } = Utils.RatioUtils
12
+ const { isSupportScene } = lampUtils.SupportUtils
13
+ interface DeviceStateProps{
14
+ scheduleItem: any
15
+ dps: ScheduleItemDp[]
16
+ dpCodes: Record<string,string>
17
+ isManual: boolean
18
+ setIsManual?: (isManual: boolean) => void
19
+ setSendDps: (dp: Record<string,any>) => void
20
+ changeSkillEnable: (enable: boolean, index: number) => void
21
+ }
22
+
23
+ const DeviceState = (props: DeviceStateProps) =>{
24
+
25
+ return(
26
+ <View>
27
+ {isSupportScene() && !isPlug(props.dpCodes) && <SegmentControl
28
+ title1={I18n.getLang('timeschedule_add_schedule_switch_tab_manual_text')}
29
+ title2={I18n.getLang('timeschedule_add_schedule_switch_tab_mood_text')}
30
+ isFirst={props.isManual}
31
+ setIsFirst={(v: boolean) => props.setIsManual && props.setIsManual(v)}
32
+ style={{marginHorizontal: cx(0)}}
33
+ />}
34
+ {props.isManual ?
35
+ <ManualSetting
36
+ dpCodes={props.dpCodes}
37
+ dps={props.dps}
38
+ scheduleItem={props.scheduleItem}
39
+ setSendDps={props.setSendDps}
40
+ changeSkillEnable={props.changeSkillEnable}
41
+ /> :
42
+ <MoodSetting
43
+ dpCodes={props.dpCodes}
44
+ dps={props.dps}
45
+ scheduleItem={props.scheduleItem}
46
+ setSendDps={props.setSendDps}
47
+ changeSkillEnable={props.changeSkillEnable}
48
+ />
49
+ }
50
+ </View>
51
+ )
52
+ }
53
+
54
+ export default DeviceState
@@ -0,0 +1,125 @@
1
+ import React, { useCallback } from 'react';
2
+ import { StyleSheet, Text, View, ViewStyle } from 'react-native';
3
+ import { SwitchButton, Utils } from 'tuya-panel-kit';
4
+ import { loopText } from '@ledvance/base/src/utils/common';
5
+ import Card from '@ledvance/base/src/components/Card';
6
+ const { convertX } = Utils.RatioUtils;
7
+
8
+ interface LdvScheduleItemProps {
9
+ item: any
10
+ tags?: {
11
+ label: string
12
+ value: string
13
+ dpId: string
14
+ } []
15
+ style?: ViewStyle
16
+ onEnableChange: (enable: boolean) => void
17
+ onPress: (item: any) => void
18
+ onLongPress: (item:any) => void
19
+ }
20
+
21
+ const LdvScheduleItem = (props: LdvScheduleItemProps) => {
22
+ const { item, tags, style, onEnableChange, onPress, onLongPress } = props;
23
+
24
+ const renderTag = useCallback(() => {
25
+ const tagList = Array.isArray(tags) ? tags.filter(tag => item.dps[tag.dpId] !== undefined) : []
26
+ return tagList.map(t => (
27
+ <Text key={t.dpId} style={styles.typeText}>{t.label}</Text>
28
+ ))
29
+ }, [tags])
30
+
31
+ const showTags = useCallback(() =>{
32
+ return tags && tags?.length > 1
33
+ }, [tags])
34
+
35
+ return (
36
+ <Card
37
+ style={styles.card}
38
+ containerStyle={[styles.container, style]}
39
+ onPress={() => {
40
+ onPress(item);
41
+ }}
42
+ onLongPress={() => {
43
+ onLongPress(item);
44
+ }}>
45
+ <View style={styles.infoContainer}>
46
+ <Text style={styles.time}>{item.time}</Text>
47
+ <Text style={styles.loop}>
48
+ {loopText(item.loops.split('').map(loop => parseInt(loop)))}
49
+ </Text>
50
+ <Text style={styles.name}>{item.aliasName}</Text>
51
+ {showTags() && <View style={styles.typeContainer}>
52
+ {renderTag()}
53
+ </View>}
54
+ </View>
55
+ <View style={styles.switchContainer}>
56
+ <SwitchButton
57
+ value={!!item.status}
58
+ thumbStyle={{ elevation: 0 }}
59
+ onValueChange={() => {
60
+ onEnableChange(item);
61
+ }}
62
+ />
63
+ </View>
64
+ </Card>
65
+ );
66
+ };
67
+
68
+ const styles = StyleSheet.create({
69
+ card: {
70
+ marginHorizontal: convertX(24),
71
+ marginTop: convertX(8),
72
+ marginBottom: convertX(15),
73
+ borderRadius: convertX(8),
74
+ },
75
+ container: {
76
+ flexDirection: 'row',
77
+ justifyContent: 'space-between',
78
+ },
79
+ infoContainer: {
80
+ flex: 1,
81
+ marginTop: convertX(16),
82
+ marginBottom: convertX(16),
83
+ flexDirection: 'column',
84
+ marginLeft: convertX(16),
85
+ },
86
+ time: {
87
+ marginBottom: convertX(5),
88
+ fontSize: 16,
89
+ fontFamily: 'helvetica_neue_lt_std_bd',
90
+ fontWeight: 'bold',
91
+ },
92
+ loop: {
93
+ color: '#000',
94
+ fontSize: convertX(14),
95
+ fontFamily: 'helvetica_neue_lt_std_bd',
96
+ marginTop: convertX(8),
97
+ },
98
+ name: {
99
+ color: '#000',
100
+ fontSize: convertX(14),
101
+ fontFamily: 'helvetica_neue_lt_std_bd',
102
+ marginTop: convertX(8),
103
+ },
104
+ switchContainer: {
105
+ marginRight: convertX(16),
106
+ // backgroundColor: 'red',
107
+ marginTop: convertX(16),
108
+ },
109
+ switch: {},
110
+ typeContainer: {
111
+ flexDirection: 'row',
112
+ marginTop: convertX(8),
113
+ },
114
+ typeText: {
115
+ fontSize: convertX(12),
116
+ backgroundColor: '#E6E7E8',
117
+ color: '#000',
118
+ marginRight: convertX(10),
119
+ borderRadius: convertX(10),
120
+ paddingHorizontal: convertX(8),
121
+ paddingVertical: convertX(2)
122
+ }
123
+ });
124
+
125
+ export default LdvScheduleItem;
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { Utils } from 'tuya-panel-kit'
4
+ import { isMixRGBWLamp } from '@ledvance/base/src/utils/Support'
5
+ import SingleLightView from "./SingleLightView";
6
+ import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
7
+ import Spacer from "@ledvance/base/src/components/Spacer";
8
+ import { ScheduleItemDp } from "./TimeScheduleEditpage";
9
+ import Card from "@ledvance/base/src/components/Card";
10
+ import MixLightView from "./mix/MixLightView";
11
+
12
+
13
+ const { convertX: cx } = Utils.RatioUtils
14
+ interface ManualSettingProps {
15
+ scheduleItem: any
16
+ dps: ScheduleItemDp[]
17
+ dpCodes: Record<string, string>
18
+ setSendDps: (dp: Record<string, any>) => void
19
+ changeSkillEnable: (enable: boolean, index: number) => void
20
+ }
21
+
22
+ const ManualSetting = (props: ManualSettingProps) => {
23
+ const renderContent = () => {
24
+ if (isMixRGBWLamp(props.dpCodes)) {
25
+ return (
26
+ <MixLightView
27
+ dpCodes={props.dpCodes}
28
+ setSendDps={props.setSendDps}
29
+ scheduleItem={props.scheduleItem}
30
+ setEnable={props.changeSkillEnable}
31
+ />
32
+ )
33
+ }
34
+ return (
35
+ props.dps.map((item, idx) => (
36
+ !item.value.includes('light') ?
37
+ <View key={item.dpId}>
38
+ <Spacer width={cx(12)} />
39
+ <Card>
40
+ <LdvSwitch
41
+ title={item.label}
42
+ enable={item.enable}
43
+ setEnable={(v: boolean) => { props.changeSkillEnable(v, idx) }}
44
+ color={''}
45
+ colorAlpha={1}
46
+ />
47
+ </Card>
48
+ <Spacer width={cx(12)} />
49
+ </View> :
50
+ <View key={item.dpId}>
51
+ <SingleLightView
52
+ dpCodes={props.dpCodes}
53
+ scheduleItem={props.scheduleItem}
54
+ setEnable={(v: boolean) => { props.changeSkillEnable(v, idx) }}
55
+ setSendDps={props.setSendDps}
56
+ />
57
+ </View>
58
+ ))
59
+ )
60
+
61
+ }
62
+ return (
63
+ <View>
64
+ {renderContent()}
65
+ </View>
66
+ )
67
+ }
68
+
69
+ export default ManualSetting
@@ -0,0 +1,66 @@
1
+ import React, { useEffect } from "react";
2
+ import { ScheduleItemDp } from "./TimeScheduleEditpage";
3
+ import { isMixRGBWLamp } from '@ledvance/base/src/utils/Support';
4
+ import { obj2Dp as senceObj2Dp, dp2Obj as sencePp2Obj } from "../mood/MoodAction";
5
+ import ScheduleScene from "./ScheduleScene";
6
+ import MixMoodScene from "../mood/MixScene";
7
+ import { useReactive } from 'ahooks'
8
+ import { Buffer } from 'buffer';
9
+ import { SCENE } from "../hooks/DeviceDpStateHooks";
10
+
11
+ interface MoodSettingProps{
12
+ scheduleItem: any
13
+ dps: ScheduleItemDp[]
14
+ dpCodes: Record<string, string>
15
+ setSendDps: (dp: Record<string, any>) => void
16
+ changeSkillEnable: (enable: boolean, index: number) => void
17
+ }
18
+
19
+ const MoodSetting = (props: MoodSettingProps) =>{
20
+ const { scheduleItem, dpCodes, setSendDps} = props
21
+ const state = useReactive({
22
+ actionScene: { id: '', nodes: [] } as any,
23
+ })
24
+
25
+ useEffect(() =>{
26
+ if(scheduleItem){
27
+ if(scheduleItem.dps[dpCodes.scene_data] !== undefined){
28
+ state.actionScene = sencePp2Obj(scheduleItem.dps[dpCodes.scene_data], dpCodes)
29
+ }
30
+ if (scheduleItem.dps[dpCodes.mix_light_scene] !== undefined) {
31
+ const sceneDp = scheduleItem.dps[dpCodes.mix_light_scene]
32
+ state.actionScene = Buffer.from(sceneDp, 'base64').toString('hex')
33
+ }
34
+ }
35
+ }, [])
36
+
37
+ useEffect(() =>{
38
+ const dp = getSendDps()
39
+ setSendDps(dp)
40
+ }, [state.actionScene])
41
+
42
+ const getSendDps = () =>{
43
+ if (isMixRGBWLamp(dpCodes)) {
44
+ return {
45
+ [dpCodes.mix_light_scene]: Buffer.from(state.actionScene?.value, 'hex').toString('base64'),
46
+ [dpCodes.switch_led]: true,
47
+ [dpCodes.work_mode]: SCENE
48
+ }
49
+ } else {
50
+ return {
51
+ [dpCodes.switch_led]: true,
52
+ [dpCodes.scene_data]: senceObj2Dp({ id: Number(state?.actionScene?.id), nodes: state?.actionScene?.nodes }),
53
+ [dpCodes.work_mode]: SCENE,
54
+ };
55
+ }
56
+ }
57
+
58
+ return (
59
+ isMixRGBWLamp(dpCodes) ?
60
+ <MixMoodScene setActionScene={v => state.actionScene = v} mixScene={state.actionScene} /> :
61
+ <ScheduleScene dpCodes={dpCodes} scene={state.actionScene} setScene={s => (state.actionScene = s)} />
62
+ )
63
+
64
+ }
65
+
66
+ export default MoodSetting
@@ -0,0 +1,138 @@
1
+ import React, { useCallback, useEffect } from 'react'
2
+ import I18n from '@ledvance/base/src/i18n'
3
+ import { getRemoteSceneList } from '../mood/ MoodAction'
4
+ import { useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
5
+ import { useReactive } from 'ahooks'
6
+ import { ScenePageUIState, SceneUIState } from '../mood/SceneInfo'
7
+ import res from '@res'
8
+ import { FlatList, StyleSheet, View } from 'react-native'
9
+ import Spacer from '@ledvance/base/src/components/Spacer'
10
+ import Tag from '@ledvance/base/src/components/Tag'
11
+ import { Utils } from 'tuya-panel-kit'
12
+ import InfoText from '@ledvance/base/src/components/InfoText'
13
+ import MoodItem from '../mood/MoodItem'
14
+
15
+ const cx = Utils.RatioUtils.convertX
16
+
17
+ interface MoodUIState extends ScenePageUIState {
18
+ staticTagChecked: boolean
19
+ dynamicTagChecked: boolean
20
+ filteredMoods: SceneUIState[]
21
+ // dpCodes: Record<string, string>
22
+ }
23
+
24
+
25
+ const ScheduleScene = ({ scene, setScene, dpCodes }) => {
26
+ const deviceInfo = useDeviceInfo()
27
+
28
+ const state = useReactive<MoodUIState>({
29
+ currentScene: undefined,
30
+ staticTagChecked: true,
31
+ dynamicTagChecked: true,
32
+ scenes: [],
33
+ flag: Symbol(),
34
+ originScene: [],
35
+ filteredMoods: [],
36
+ })
37
+
38
+ const getSceneList = useCallback(async () => {
39
+ const res = await getRemoteSceneList(deviceInfo.devId, dpCodes)
40
+ if (res.success) {
41
+ state.scenes = res.data || []
42
+ state.currentScene = scene || state.scenes[0]
43
+ setScene(state.currentScene)
44
+ }
45
+ }, [])
46
+
47
+ useEffect(() => {
48
+ state.filteredMoods = state.scenes.filter(item => {
49
+ return (state.staticTagChecked && state.dynamicTagChecked) ||
50
+ (state.staticTagChecked && item.nodes.length < 2) ||
51
+ (state.dynamicTagChecked && item.nodes.length > 1)
52
+ })
53
+ }, [state.staticTagChecked, state.dynamicTagChecked, state.scenes])
54
+
55
+
56
+ useEffect(() => {
57
+ getSceneList().then()
58
+ }, [state.flag])
59
+
60
+ return (
61
+ <>
62
+ <View style={styles.tagLine}>
63
+ <Tag
64
+ checked={state.staticTagChecked}
65
+ text={I18n.getLang('mood_overview_filter_name_text1')}
66
+ onCheckedChange={checked => {
67
+ state.staticTagChecked = checked
68
+ }} />
69
+ <Spacer width={cx(8)} height={0} />
70
+ <Tag
71
+ checked={state.dynamicTagChecked}
72
+ text={I18n.getLang('mood_overview_filter_name_text2')}
73
+ onCheckedChange={checked => {
74
+ state.dynamicTagChecked = checked
75
+ }} />
76
+ </View>
77
+ <Spacer height={cx(10)} />
78
+ <FlatList
79
+ data={state.filteredMoods}
80
+ renderItem={({ item }) => {
81
+ return (
82
+ <MoodItem
83
+ enable={state.currentScene?.id === item.id}
84
+ mood={item}
85
+ onSwitch={async _ => {
86
+ state.currentScene = item
87
+ setScene(item)
88
+ }} />
89
+ )
90
+ }}
91
+ ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
92
+ ItemSeparatorComponent={() => (<Spacer />)}
93
+ ListFooterComponent={() => (
94
+ <View style={styles.infoLine}>
95
+ <Spacer />
96
+ <InfoText
97
+ icon={res.ic_info}
98
+ text={I18n.getLang('mood_overview_information_text')} />
99
+ <Spacer height={cx(40)} />
100
+ </View>
101
+ )}
102
+ keyExtractor={item => `${item.id}`} />
103
+ </>
104
+ )
105
+ }
106
+
107
+ const styles = StyleSheet.create({
108
+ tagLine: {
109
+ flexDirection: 'row',
110
+ marginHorizontal: cx(24),
111
+ marginTop: cx(16)
112
+ },
113
+ infoLine: {
114
+ marginHorizontal: cx(24),
115
+ },
116
+ addMoodPopover: {
117
+ width: cx(171),
118
+ height: cx(90.5),
119
+ marginStart: cx(156),
120
+ marginTop: cx(105),
121
+ backgroundColor: '#fff',
122
+ },
123
+ popoverItem: {
124
+ width: cx(171),
125
+ height: cx(45),
126
+ alignItems: 'flex-start',
127
+ },
128
+ popoverItemText: {
129
+ color: '#000',
130
+ fontSize: cx(16),
131
+ },
132
+ line: {
133
+ height: .5,
134
+ backgroundColor: 'rgba(60,60,67,.36)',
135
+ },
136
+ })
137
+
138
+ export default ScheduleScene