@ledvance/ui-biz-bundle 1.1.55 → 1.1.57
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 +2 -1
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTime/Router.ts +26 -0
- package/src/modules/flags/FlagActions.ts +12 -4
- package/src/modules/flags/FlagPage.tsx +31 -11
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/history/Router.ts +16 -0
- package/src/modules/mood/FantasyRouter.ts +35 -0
- package/src/modules/mood/MixMood/Router.ts +44 -0
- package/src/modules/mood/Router.ts +53 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/powerOnBehavior/Router.ts +16 -0
- package/src/modules/randomTime/Router.ts +25 -0
- package/src/modules/sleepWakeup/Router.ts +25 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.d.ts +0 -7
- package/src/navigation/Routers.ts +15 -304
- package/src/newModules/childLock/ChildLockPage.tsx +97 -0
- package/src/newModules/childLock/Router.ts +16 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
- package/src/newModules/energyConsumption/Router.ts +34 -0
- package/src/newModules/energyConsumption/co2Data.ts +23655 -0
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
- package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
- package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
- package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
- package/src/newModules/fixedTime/Router.ts +25 -0
- package/src/newModules/lightMode/LightModePage.tsx +204 -0
- package/src/newModules/lightMode/Router.ts +16 -0
- package/src/newModules/mood/AddMoodPage.tsx +178 -0
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
- package/src/newModules/mood/Interface.ts +219 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
- package/src/newModules/mood/MoodActions.ts +235 -0
- package/src/newModules/mood/MoodInfo.ts +2151 -0
- package/src/newModules/mood/MoodItem.tsx +148 -0
- package/src/newModules/mood/MoodPage.tsx +385 -0
- package/src/newModules/mood/MoodParse.ts +442 -0
- package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
- package/src/newModules/mood/Router.ts +53 -0
- package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
- package/src/newModules/mood/tools.ts +12 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
- package/src/newModules/overchargeSwitch/Router.ts +16 -0
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
- package/src/newModules/powerOnBehavior/Router.ts +16 -0
- package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
- package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
- package/src/newModules/randomTime/Router.ts +25 -0
- package/src/newModules/randomTime/Summary.tsx +116 -0
- package/src/newModules/swithInching/Router.ts +16 -0
- package/src/newModules/swithInching/SwithInching.tsx +231 -0
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
- package/src/newModules/swithInching/pickerView.tsx +91 -0
- package/src/newModules/timeSchedule/Interface.ts +111 -0
- package/src/newModules/timeSchedule/Router.ts +25 -0
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { ScrollView, Text, StyleSheet, FlatList, View, Image } from 'react-native';
|
|
3
|
+
import { useNavigation } from '@react-navigation/core';
|
|
4
|
+
import { Utils } from 'tuya-panel-kit';
|
|
5
|
+
import Page from '@ledvance/base/src/components/Page';
|
|
6
|
+
import I18n from '@ledvance/base/src/i18n';
|
|
7
|
+
import {
|
|
8
|
+
useDeviceId,
|
|
9
|
+
useDeviceInfo,
|
|
10
|
+
useTimeSchedule,
|
|
11
|
+
} from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
12
|
+
import res from '@ledvance/base/src/res';
|
|
13
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
14
|
+
import InfoText from '@ledvance/base/src/components/InfoText';
|
|
15
|
+
import DeleteButton from '@ledvance/base/src/components/DeleteButton';
|
|
16
|
+
import { useReactive, useUpdateEffect } from 'ahooks';
|
|
17
|
+
import { ApplyForItem, DeviceStateType, Timer, TimerActions } from './Interface';
|
|
18
|
+
import { getTimeSchedule, manageTimeSchedule } from './TimeScheduleActions';
|
|
19
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks';
|
|
20
|
+
import ScheduleCard from './components/ScheduleCard';
|
|
21
|
+
import { ui_biz_routerKey } from '../../navigation/Routers';
|
|
22
|
+
|
|
23
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
24
|
+
const MAX_NUM = 30;
|
|
25
|
+
|
|
26
|
+
export interface TimeSchedulePageParams {
|
|
27
|
+
isSupportColor: boolean;
|
|
28
|
+
isSupportTemperature: boolean;
|
|
29
|
+
isSupportBrightness: boolean;
|
|
30
|
+
isSupportMood?: boolean;
|
|
31
|
+
isStringLight?: boolean;
|
|
32
|
+
isStripLight?: boolean;
|
|
33
|
+
isMatterLight?: boolean;
|
|
34
|
+
isCeilingLight?: boolean;
|
|
35
|
+
isMixLight?: boolean;
|
|
36
|
+
isSupportFan?: boolean;
|
|
37
|
+
isSupportUVC?: boolean;
|
|
38
|
+
switchLedCode?: string;
|
|
39
|
+
switchFan?: string;
|
|
40
|
+
fanModeCode?: string;
|
|
41
|
+
fanSpeedCode?: string;
|
|
42
|
+
workModeCode: string;
|
|
43
|
+
brightValueCode?: string;
|
|
44
|
+
featureId?: string
|
|
45
|
+
applyForList: ApplyForItem[];
|
|
46
|
+
applyForDisabled: boolean; // 是否可以选择apply for
|
|
47
|
+
manualDataDp2Obj: (dps: Record<string, any>) => DeviceStateType;
|
|
48
|
+
manualDataObj2Dp: (deviceState: DeviceStateType, applyForList: ApplyForItem[]) => Record<string, any>;
|
|
49
|
+
tempValueCode?: string;
|
|
50
|
+
sceneDataCode?: string;
|
|
51
|
+
colorDataCode?: string;
|
|
52
|
+
drawToolDataCode?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const TimeSchedulePage = () => {
|
|
56
|
+
const deviceInfo = useDeviceInfo();
|
|
57
|
+
const devId = useDeviceId();
|
|
58
|
+
const navigation = useNavigation();
|
|
59
|
+
const [timeScheduleStatus, setTimeScheduleStatus] = useTimeSchedule();
|
|
60
|
+
const params = useParams<TimeSchedulePageParams>();
|
|
61
|
+
const state = useReactive({
|
|
62
|
+
timeScheduleList: [] as Timer[],
|
|
63
|
+
flag: Symbol(),
|
|
64
|
+
loading: false,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const isMaxSchedule = useMemo(() => state.timeScheduleList.length >= MAX_NUM, [
|
|
68
|
+
state.timeScheduleList,
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
useUpdateEffect(() => {
|
|
72
|
+
const status = state.timeScheduleList.some(item => item.enable);
|
|
73
|
+
if (status !== timeScheduleStatus) {
|
|
74
|
+
setTimeScheduleStatus(status);
|
|
75
|
+
}
|
|
76
|
+
}, [JSON.stringify(state.timeScheduleList)]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
getTimeSchedule(devId).then(res => {
|
|
80
|
+
state.timeScheduleList = res;
|
|
81
|
+
});
|
|
82
|
+
}, [state.flag]);
|
|
83
|
+
|
|
84
|
+
const modDeleteTimeSchedule = async (mode: TimerActions, timeSchedule: Timer) => {
|
|
85
|
+
const res = await manageTimeSchedule(devId, timeSchedule, mode);
|
|
86
|
+
if (res.success) {
|
|
87
|
+
if (mode === 'add') {
|
|
88
|
+
state.flag = Symbol();
|
|
89
|
+
} else {
|
|
90
|
+
state.timeScheduleList =
|
|
91
|
+
mode === 'update'
|
|
92
|
+
? state.timeScheduleList.map(item => {
|
|
93
|
+
if (item.id === timeSchedule.id) {
|
|
94
|
+
return timeSchedule;
|
|
95
|
+
}
|
|
96
|
+
return item;
|
|
97
|
+
})
|
|
98
|
+
: state.timeScheduleList.filter(item => item.id !== timeSchedule.id);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return res;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const navigateToEdit = useCallback((mode: 'add' | 'update', timeSchedule?: Timer) => {
|
|
108
|
+
const path = ui_biz_routerKey.ui_biz_time_schedule_edit_new;
|
|
109
|
+
navigation.navigate(path, {
|
|
110
|
+
mode,
|
|
111
|
+
name: path,
|
|
112
|
+
timeSchedule,
|
|
113
|
+
modDeleteTimeSchedule,
|
|
114
|
+
refreshFn: () => {
|
|
115
|
+
state.flag = Symbol();
|
|
116
|
+
},
|
|
117
|
+
...params,
|
|
118
|
+
});
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Page
|
|
123
|
+
backText={deviceInfo.name}
|
|
124
|
+
onBackClick={navigation.goBack}
|
|
125
|
+
headlineText={I18n.getLang('timeschedule_overview_headline_text')}
|
|
126
|
+
headlineIcon={isMaxSchedule ? undefined : res.device_panel_schedule_add}
|
|
127
|
+
onHeadlineIconClick={() => {
|
|
128
|
+
navigateToEdit('add');
|
|
129
|
+
}}
|
|
130
|
+
loading={state.loading}
|
|
131
|
+
>
|
|
132
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
133
|
+
<Text style={styles.overviewDescription}>
|
|
134
|
+
{I18n.getLang('timeschedule_overview_description_text')}
|
|
135
|
+
</Text>
|
|
136
|
+
<Spacer height={cx(10)} />
|
|
137
|
+
{isMaxSchedule && (
|
|
138
|
+
<InfoText
|
|
139
|
+
text={I18n.getLang('motion_detection_time_schedule_notifications_warning_text')}
|
|
140
|
+
icon={res.ic_warning_amber}
|
|
141
|
+
style={{ marginHorizontal: cx(24) }}
|
|
142
|
+
textStyle={{ color: '#000' }}
|
|
143
|
+
iconStyle={{ tintColor: '#ff9500' }}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
<FlatList
|
|
147
|
+
data={state.timeScheduleList}
|
|
148
|
+
renderItem={({ item }) => (
|
|
149
|
+
<ScheduleCard
|
|
150
|
+
item={item}
|
|
151
|
+
onEnableChange={async enable => {
|
|
152
|
+
state.loading = true;
|
|
153
|
+
await modDeleteTimeSchedule('update', {
|
|
154
|
+
...item,
|
|
155
|
+
enable,
|
|
156
|
+
});
|
|
157
|
+
state.loading = false;
|
|
158
|
+
}}
|
|
159
|
+
onPress={() => {
|
|
160
|
+
navigateToEdit('update', item);
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
164
|
+
keyExtractor={item => item.id.toString()}
|
|
165
|
+
ListEmptyComponent={() => (
|
|
166
|
+
<View style={styles.emptyContainer}>
|
|
167
|
+
<Spacer height={cx(60)} />
|
|
168
|
+
<Image
|
|
169
|
+
style={styles.emptyImage}
|
|
170
|
+
source={{ uri: res.ldv_timer_empty }}
|
|
171
|
+
resizeMode="contain"
|
|
172
|
+
/>
|
|
173
|
+
<InfoText
|
|
174
|
+
icon={res.device_panel_schedule_alert}
|
|
175
|
+
text={I18n.getLang('timeschedule_overview_empty_information_text')}
|
|
176
|
+
style={{ width: 'auto', alignItems: 'center' }}
|
|
177
|
+
textStyle={{ color: '#000', flex: undefined }}
|
|
178
|
+
iconStyle={{ tintColor: '#000' }}
|
|
179
|
+
/>
|
|
180
|
+
<Spacer height={cx(16)} />
|
|
181
|
+
<DeleteButton
|
|
182
|
+
style={styles.addBtn}
|
|
183
|
+
text={`${I18n.getLang('timeschedule_overview_empty_button_add_text')}`}
|
|
184
|
+
textStyle={{ fontSize: cx(12) }}
|
|
185
|
+
onPress={() => {
|
|
186
|
+
navigateToEdit('add');
|
|
187
|
+
}}
|
|
188
|
+
/>
|
|
189
|
+
</View>
|
|
190
|
+
)}
|
|
191
|
+
ListHeaderComponent={() => <Spacer height={cx(10)} />}
|
|
192
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
193
|
+
ListFooterComponent={() => <Spacer height={cx(30)} />}
|
|
194
|
+
/>
|
|
195
|
+
</ScrollView>
|
|
196
|
+
</Page>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const styles = StyleSheet.create({
|
|
201
|
+
overviewDescription: {
|
|
202
|
+
color: '#000',
|
|
203
|
+
marginHorizontal: cx(24),
|
|
204
|
+
},
|
|
205
|
+
emptyImage: {
|
|
206
|
+
width: cx(225),
|
|
207
|
+
height: cx(198),
|
|
208
|
+
},
|
|
209
|
+
emptyContainer: {
|
|
210
|
+
marginHorizontal: cx(24),
|
|
211
|
+
alignItems: 'center',
|
|
212
|
+
},
|
|
213
|
+
addBtn: {
|
|
214
|
+
height: cx(40),
|
|
215
|
+
width: 'auto',
|
|
216
|
+
minWidth: cx(150),
|
|
217
|
+
paddingHorizontal: cx(16),
|
|
218
|
+
backgroundColor: '#f60',
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
export default TimeSchedulePage;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { DeviceType, ManualSettingProps } from '../Interface';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import Card from '@ledvance/base/src/components/Card';
|
|
5
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView';
|
|
6
|
+
import { Utils } from 'tuya-panel-kit';
|
|
7
|
+
import { useCreation, useReactive, useUpdateEffect } from 'ahooks';
|
|
8
|
+
import LdvSwitch from '@ledvance/base/src/components/ldvSwitch';
|
|
9
|
+
import ColorTempAdjustView from '@ledvance/base/src/components/ColorTempAdjustView';
|
|
10
|
+
import ColorAdjustView from '@ledvance/base/src/components/ColorAdjustView';
|
|
11
|
+
import I18n from '@ledvance/base/src/i18n';
|
|
12
|
+
import StripAdjustView from '@ledvance/base/src/components/StripAdjustView';
|
|
13
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
14
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
15
|
+
|
|
16
|
+
function ManualSettings(props: ManualSettingProps) {
|
|
17
|
+
const state = useReactive({
|
|
18
|
+
deviceData: props.manualData.deviceData,
|
|
19
|
+
applyForList: props.applyForList,
|
|
20
|
+
applyFlag: Symbol(),
|
|
21
|
+
manualFlag: Symbol()
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
useUpdateEffect(() => {
|
|
25
|
+
state.applyForList = props.applyForList;
|
|
26
|
+
state.deviceData = props.manualData.deviceData;
|
|
27
|
+
}, [props.applyForList, props.manualData]);
|
|
28
|
+
|
|
29
|
+
useUpdateEffect(() =>{
|
|
30
|
+
props.onApplyChange && props.onApplyChange(state.applyForList)
|
|
31
|
+
}, [state.applyFlag])
|
|
32
|
+
|
|
33
|
+
useUpdateEffect(() =>{
|
|
34
|
+
props.onManualChange && props.onManualChange(state.deviceData)
|
|
35
|
+
}, [state.manualFlag])
|
|
36
|
+
|
|
37
|
+
const tabList = useCreation(() => {
|
|
38
|
+
const isSupportWhite = props.isSupportBrightness || props.isSupportTemperature;
|
|
39
|
+
const tabs = [
|
|
40
|
+
{ key: 1, title: I18n.getLang('add_new_static_mood_lights_schedule_switch_tab_color_text') },
|
|
41
|
+
{ key: 0, title: I18n.getLang('add_new_static_mood_lights_schedule_switch_tab_white_text') },
|
|
42
|
+
{
|
|
43
|
+
key: 3,
|
|
44
|
+
title: I18n.getLang(
|
|
45
|
+
'add_new_dynamic_mood_strip_lights_schedule_switch_tab_combination_text'
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
if (!isSupportWhite) {
|
|
50
|
+
return tabs.filter(tab => tab.key !== 0);
|
|
51
|
+
}
|
|
52
|
+
if (!props.isSupportColor) {
|
|
53
|
+
return tabs.filter(tab => tab.key === 0);
|
|
54
|
+
}
|
|
55
|
+
return tabs;
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const lightSourceCard = useMemo(() => {
|
|
59
|
+
const { deviceData } = state;
|
|
60
|
+
return (
|
|
61
|
+
<View>
|
|
62
|
+
{state.applyForList.map((item, idx) => (
|
|
63
|
+
<View key={item.dp}>
|
|
64
|
+
<Card style={{ marginHorizontal: cx(24) }}>
|
|
65
|
+
<LdvSwitch
|
|
66
|
+
title={item.key}
|
|
67
|
+
color={'#fff'}
|
|
68
|
+
colorAlpha={1}
|
|
69
|
+
enable={item.enable}
|
|
70
|
+
setEnable={(enable: boolean) => {
|
|
71
|
+
state.applyForList = state.applyForList.map((apply, index) => {
|
|
72
|
+
if (idx === index) {
|
|
73
|
+
return {
|
|
74
|
+
...apply,
|
|
75
|
+
enable,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return apply;
|
|
79
|
+
});
|
|
80
|
+
state.applyFlag = Symbol()
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
{item.enable && item.type !== 'socket' && (
|
|
84
|
+
<LampAdjustView
|
|
85
|
+
isSupportColor={props.isSupportColor}
|
|
86
|
+
isSupportBrightness={props.isSupportBrightness}
|
|
87
|
+
isSupportTemperature={props.isSupportTemperature}
|
|
88
|
+
isColorMode={deviceData.isColorMode}
|
|
89
|
+
setIsColorMode={mode => {
|
|
90
|
+
state.deviceData = {
|
|
91
|
+
...state.deviceData,
|
|
92
|
+
isColorMode: mode,
|
|
93
|
+
};
|
|
94
|
+
state.manualFlag = Symbol()
|
|
95
|
+
}}
|
|
96
|
+
reserveSV={true}
|
|
97
|
+
h={deviceData.h}
|
|
98
|
+
s={deviceData.s}
|
|
99
|
+
v={deviceData.v}
|
|
100
|
+
brightness={deviceData.brightness}
|
|
101
|
+
colorTemp={deviceData.temperature}
|
|
102
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
103
|
+
state.deviceData = {
|
|
104
|
+
...state.deviceData,
|
|
105
|
+
h,
|
|
106
|
+
s,
|
|
107
|
+
v,
|
|
108
|
+
};
|
|
109
|
+
state.manualFlag = Symbol()
|
|
110
|
+
}}
|
|
111
|
+
onBrightnessChangeComplete={bright => {
|
|
112
|
+
state.deviceData = {
|
|
113
|
+
...state.deviceData,
|
|
114
|
+
brightness: bright
|
|
115
|
+
}
|
|
116
|
+
state.manualFlag = Symbol()
|
|
117
|
+
}}
|
|
118
|
+
onCCTChangeComplete={cct => {
|
|
119
|
+
state.deviceData = {
|
|
120
|
+
...state.deviceData,
|
|
121
|
+
temperature: cct
|
|
122
|
+
}
|
|
123
|
+
state.manualFlag = Symbol()
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
</Card>
|
|
128
|
+
<Spacer />
|
|
129
|
+
</View>
|
|
130
|
+
))}
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
}, [state.deviceData, state.applyForList]);
|
|
134
|
+
|
|
135
|
+
const mixLightCard = useMemo(() => {
|
|
136
|
+
return (
|
|
137
|
+
<View>
|
|
138
|
+
{state.applyForList.map((item, idx) => (
|
|
139
|
+
<View key={item.dp}>
|
|
140
|
+
<Card style={{ marginHorizontal: cx(24) }}>
|
|
141
|
+
<LdvSwitch
|
|
142
|
+
title={item.key}
|
|
143
|
+
color={'#fff'}
|
|
144
|
+
colorAlpha={1}
|
|
145
|
+
enable={item.enable}
|
|
146
|
+
setEnable={(enable: boolean) => {
|
|
147
|
+
state.applyForList[idx].enable = enable;
|
|
148
|
+
state.applyFlag = Symbol()
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
{item.enable &&
|
|
152
|
+
(item.type === 'mainLight' ? (
|
|
153
|
+
<View>
|
|
154
|
+
<ColorTempAdjustView
|
|
155
|
+
isSupportBrightness={props.isSupportBrightness}
|
|
156
|
+
isSupportTemperature={props.isSupportTemperature}
|
|
157
|
+
colorTemp={state.deviceData.temperature}
|
|
158
|
+
brightness={state.deviceData.brightness}
|
|
159
|
+
onBrightnessChangeComplete={bright => {
|
|
160
|
+
state.deviceData.brightness = bright;
|
|
161
|
+
state.manualFlag = Symbol()
|
|
162
|
+
}}
|
|
163
|
+
onCCTChangeComplete={cct => {
|
|
164
|
+
state.deviceData.temperature = cct;
|
|
165
|
+
state.manualFlag = Symbol()
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
<Spacer height={cx(16)} />
|
|
169
|
+
</View>
|
|
170
|
+
) : (
|
|
171
|
+
<View>
|
|
172
|
+
<ColorAdjustView
|
|
173
|
+
h={state.deviceData.h}
|
|
174
|
+
s={state.deviceData.s}
|
|
175
|
+
v={state.deviceData.v}
|
|
176
|
+
reserveSV={true}
|
|
177
|
+
minSaturation={1}
|
|
178
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
179
|
+
state.deviceData.h = h;
|
|
180
|
+
state.deviceData.s = s;
|
|
181
|
+
state.deviceData.v = v;
|
|
182
|
+
state.manualFlag = Symbol()
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
<Spacer />
|
|
186
|
+
</View>
|
|
187
|
+
))}
|
|
188
|
+
</Card>
|
|
189
|
+
<Spacer />
|
|
190
|
+
</View>
|
|
191
|
+
))}
|
|
192
|
+
</View>
|
|
193
|
+
);
|
|
194
|
+
}, [state.deviceData, state.applyForList]);
|
|
195
|
+
|
|
196
|
+
const stripLightCard = useMemo(() => {
|
|
197
|
+
return (
|
|
198
|
+
<View>
|
|
199
|
+
<Card>
|
|
200
|
+
<LdvSwitch
|
|
201
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
202
|
+
color={'#fff'}
|
|
203
|
+
colorAlpha={1}
|
|
204
|
+
enable={state.applyForList[0]?.enable}
|
|
205
|
+
setEnable={(enable: boolean) => {
|
|
206
|
+
state.applyForList[0].enable = enable;
|
|
207
|
+
state.applyFlag = Symbol()
|
|
208
|
+
}}
|
|
209
|
+
/>
|
|
210
|
+
{state.applyForList[0]?.enable && (
|
|
211
|
+
<StripAdjustView
|
|
212
|
+
isSupportBrightness={props.isSupportBrightness}
|
|
213
|
+
isSupportTemperature={props.isSupportTemperature}
|
|
214
|
+
lampTabs={tabList}
|
|
215
|
+
reserveSV={true}
|
|
216
|
+
activeKey={0}
|
|
217
|
+
onActiveKeyChange={() => {}}
|
|
218
|
+
h={state.deviceData.h}
|
|
219
|
+
s={state.deviceData.s}
|
|
220
|
+
v={state.deviceData.v}
|
|
221
|
+
brightness={state.deviceData.brightness}
|
|
222
|
+
colorTemp={state.deviceData.temperature}
|
|
223
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
224
|
+
state.deviceData.h = h;
|
|
225
|
+
state.deviceData.s = s;
|
|
226
|
+
state.deviceData.v = v;
|
|
227
|
+
state.manualFlag = Symbol()
|
|
228
|
+
}}
|
|
229
|
+
onBrightnessChangeComplete={bright => {
|
|
230
|
+
state.deviceData.brightness = bright;
|
|
231
|
+
state.manualFlag = Symbol()
|
|
232
|
+
}}
|
|
233
|
+
onCCTChangeComplete={cct => {
|
|
234
|
+
state.deviceData.temperature = cct;
|
|
235
|
+
state.manualFlag = Symbol()
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
)}
|
|
239
|
+
</Card>
|
|
240
|
+
<Spacer />
|
|
241
|
+
</View>
|
|
242
|
+
);
|
|
243
|
+
}, [state.deviceData, state.applyForList]);
|
|
244
|
+
|
|
245
|
+
const componentRender = useMemo(() => {
|
|
246
|
+
const component =
|
|
247
|
+
props.manualData.type === DeviceType.MixLight
|
|
248
|
+
? mixLightCard
|
|
249
|
+
: props.manualData.type === DeviceType.StripLight
|
|
250
|
+
? stripLightCard
|
|
251
|
+
: lightSourceCard;
|
|
252
|
+
return component;
|
|
253
|
+
}, [props.manualData, state.applyForList, state.deviceData]);
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
return <View>{componentRender}</View>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export default memo(ManualSettings);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle, View, Text, StyleSheet } from "react-native";
|
|
3
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
4
|
+
import { SwitchButton, Utils } from 'tuya-panel-kit';
|
|
5
|
+
import { convertTo12HourFormat, loopText } from '@ledvance/base/src/utils/common';
|
|
6
|
+
import { Timer } from "./Interface";
|
|
7
|
+
import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
8
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
9
|
+
|
|
10
|
+
interface ScheduleCardProps {
|
|
11
|
+
item: Timer
|
|
12
|
+
style?: ViewStyle
|
|
13
|
+
onEnableChange: (enable: boolean) => void
|
|
14
|
+
onPress: (item: any) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ScheduleCard = (props: ScheduleCardProps) => {
|
|
18
|
+
const { item, style, onEnableChange, onPress } = props;
|
|
19
|
+
const is24HourClock = useSystemTimeFormate()
|
|
20
|
+
return (
|
|
21
|
+
<Card
|
|
22
|
+
style={styles.card}
|
|
23
|
+
containerStyle={[styles.container, style]}
|
|
24
|
+
onPress={() => {
|
|
25
|
+
onPress(item);
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<View style={styles.infoContainer}>
|
|
29
|
+
<Text style={styles.time}>{is24HourClock ? item.time : convertTo12HourFormat(item.time)}</Text>
|
|
30
|
+
<Text style={styles.loop}>
|
|
31
|
+
{loopText(item.loops.split('').map(loop => parseInt(loop)), item.time)}
|
|
32
|
+
</Text>
|
|
33
|
+
<Text style={styles.name}>{item.name}</Text>
|
|
34
|
+
{/* {showTags() && <View style={styles.typeContainer}>
|
|
35
|
+
{renderTag()}
|
|
36
|
+
</View>} */}
|
|
37
|
+
</View>
|
|
38
|
+
<View style={styles.switchContainer}>
|
|
39
|
+
<SwitchButton
|
|
40
|
+
value={item.enable}
|
|
41
|
+
thumbStyle={{ elevation: 0 }}
|
|
42
|
+
onValueChange={() => {
|
|
43
|
+
onEnableChange(!item.enable);
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
</View>
|
|
47
|
+
</Card>
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const styles = StyleSheet.create({
|
|
53
|
+
card: {
|
|
54
|
+
marginHorizontal: cx(24),
|
|
55
|
+
borderRadius: cx(8),
|
|
56
|
+
},
|
|
57
|
+
container: {
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
justifyContent: 'space-between',
|
|
60
|
+
},
|
|
61
|
+
infoContainer: {
|
|
62
|
+
flex: 1,
|
|
63
|
+
marginTop: cx(16),
|
|
64
|
+
marginBottom: cx(16),
|
|
65
|
+
flexDirection: 'column',
|
|
66
|
+
marginLeft: cx(16),
|
|
67
|
+
},
|
|
68
|
+
time: {
|
|
69
|
+
marginBottom: cx(5),
|
|
70
|
+
fontSize: 16,
|
|
71
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
72
|
+
fontWeight: 'bold',
|
|
73
|
+
},
|
|
74
|
+
loop: {
|
|
75
|
+
color: '#000',
|
|
76
|
+
fontSize: cx(14),
|
|
77
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
78
|
+
marginTop: cx(8),
|
|
79
|
+
},
|
|
80
|
+
name: {
|
|
81
|
+
color: '#000',
|
|
82
|
+
fontSize: cx(14),
|
|
83
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
84
|
+
marginTop: cx(8),
|
|
85
|
+
},
|
|
86
|
+
switchContainer: {
|
|
87
|
+
marginRight: cx(16),
|
|
88
|
+
// backgroundColor: 'red',
|
|
89
|
+
marginTop: cx(16),
|
|
90
|
+
},
|
|
91
|
+
switch: {},
|
|
92
|
+
typeContainer: {
|
|
93
|
+
flexDirection: 'row',
|
|
94
|
+
marginTop: cx(8),
|
|
95
|
+
},
|
|
96
|
+
typeWrap: {
|
|
97
|
+
backgroundColor: '#E6E7E8',
|
|
98
|
+
marginRight: cx(10),
|
|
99
|
+
borderRadius: cx(10),
|
|
100
|
+
},
|
|
101
|
+
typeText: {
|
|
102
|
+
fontSize: cx(12),
|
|
103
|
+
color: '#000',
|
|
104
|
+
paddingHorizontal: cx(8),
|
|
105
|
+
paddingVertical: cx(2)
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export default ScheduleCard
|