@ledvance/ui-biz-bundle 1.1.62 → 1.1.63
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 +1 -1
- package/src/modules/timer/TimerPage.tsx +1 -1
- package/src/newModules/fixedTime/FixedTimeActions.ts +50 -44
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +40 -35
- package/src/newModules/fixedTime/FixedTimePage.tsx +158 -85
- package/src/newModules/randomTime/RandomTimeActions.ts +57 -49
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +33 -29
- package/src/newModules/randomTime/RandomTimePage.tsx +152 -84
- package/src/newModules/timeSchedule/Interface.ts +34 -4
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +118 -133
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +79 -49
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +209 -9
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +28 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { memo, useCallback } from "react";
|
|
1
|
+
import React, { memo, useCallback, useMemo } from "react";
|
|
2
2
|
import { FlatList, Image, ScrollView, StyleSheet, Text, View } from 'react-native'
|
|
3
3
|
import Page from "@ledvance/base/src/components/Page";
|
|
4
4
|
import { useDeviceInfo, useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
5
|
-
import { useNavigation
|
|
5
|
+
import { useNavigation } from '@react-navigation/core'
|
|
6
6
|
import I18n from "@ledvance/base/src/i18n";
|
|
7
7
|
import res from "@ledvance/base/src/res";
|
|
8
8
|
import { ui_biz_routerKey } from "../../navigation/Routers";
|
|
@@ -15,6 +15,10 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
15
15
|
import { convertMinutesTo12HourFormat, loopText } from "@ledvance/base/src/utils/common";
|
|
16
16
|
import { cloneDeep } from "lodash";
|
|
17
17
|
import dayjs from "dayjs";
|
|
18
|
+
import { ApplyForItem } from "@ledvance/ui-biz-bundle/src/newModules/timeSchedule/Interface";
|
|
19
|
+
import { useParams } from "@ledvance/base/src/hooks/Hooks";
|
|
20
|
+
import Tag from "@ledvance/base/src/components/Tag";
|
|
21
|
+
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
18
22
|
|
|
19
23
|
const { convertX: cx } = Utils.RatioUtils
|
|
20
24
|
const MAX_NUM = 10
|
|
@@ -28,30 +32,37 @@ export interface FixedTimePageParams {
|
|
|
28
32
|
}
|
|
29
33
|
isPlug?: boolean
|
|
30
34
|
showTags?: boolean
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
isSupportColor: boolean
|
|
36
|
-
isSupportTemperature: boolean
|
|
37
|
-
isSupportBrightness: boolean
|
|
35
|
+
applyForList: ApplyForItem[]
|
|
36
|
+
isSupportColor?: boolean
|
|
37
|
+
isSupportTemperature?: boolean
|
|
38
|
+
isSupportBrightness?: boolean
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const FixedTimePage = () => {
|
|
41
42
|
const navigation = useNavigation()
|
|
42
43
|
const devInfo = useDeviceInfo()
|
|
43
|
-
const params =
|
|
44
|
+
const params = useParams<FixedTimePageParams>()
|
|
44
45
|
const is24Hour = useSystemTimeFormate()
|
|
45
46
|
const [fixedTime, setFixedTime] = useFixedTime(params.fixedTimeDpCode, params.isPlug)
|
|
46
47
|
const state = useReactive({
|
|
47
48
|
loading: false,
|
|
48
|
-
|
|
49
|
+
originList: cloneDeep(fixedTime),
|
|
50
|
+
fixedTimeList: cloneDeep(fixedTime),
|
|
51
|
+
checkTags: params.applyForList.map(v => ({ ...v, enable: false }))
|
|
49
52
|
})
|
|
50
53
|
|
|
51
54
|
useUpdateEffect(() => {
|
|
52
|
-
state.
|
|
55
|
+
state.originList = cloneDeep(fixedTime)
|
|
53
56
|
}, [fixedTime])
|
|
54
57
|
|
|
58
|
+
useUpdateEffect(() => {
|
|
59
|
+
const isAll = state.checkTags.every(tag => tag.enable) || state.checkTags.every(tag => !tag.enable)
|
|
60
|
+
const checkedList = state.originList.filter(item => {
|
|
61
|
+
return isAll || state.checkTags[item.channel || 0]?.enable
|
|
62
|
+
})
|
|
63
|
+
state.fixedTimeList = cloneDeep(checkedList)
|
|
64
|
+
}, [JSON.stringify(state.checkTags), JSON.stringify(state.originList)])
|
|
65
|
+
|
|
55
66
|
const navigateToEdit = useCallback((mode: 'add' | 'edit', scheduleItem: FixedTimerUiItem) => {
|
|
56
67
|
navigation.navigate(ui_biz_routerKey.ui_biz_fixed_time_edit_new, {
|
|
57
68
|
...params,
|
|
@@ -62,19 +73,43 @@ const FixedTimePage = () => {
|
|
|
62
73
|
}, [])
|
|
63
74
|
|
|
64
75
|
const showMaxNumTip = useCallback(() => {
|
|
65
|
-
return state.
|
|
66
|
-
}, [state.
|
|
76
|
+
return state.originList.length >= MAX_NUM
|
|
77
|
+
}, [state.originList.length])
|
|
67
78
|
|
|
68
79
|
const onPost = useCallback(async (mode: 'add' | 'edit' | 'del', fixedTime: FixedTimerUiItem) => {
|
|
69
|
-
|
|
70
|
-
const
|
|
80
|
+
console.log(fixedTime, '< --- fixedTimeeeeee')
|
|
81
|
+
const cloneFixedTimeList = cloneDeep(state.originList)
|
|
82
|
+
const idx = state.originList.findIndex(f => f.index === fixedTime.index)
|
|
83
|
+
console.log(idx, '< --- idxxxxx')
|
|
71
84
|
if (mode === 'edit') {
|
|
72
85
|
cloneFixedTimeList.splice(idx, 1, fixedTime)
|
|
73
86
|
}
|
|
74
87
|
if (mode === 'del') cloneFixedTimeList.splice(idx, 1)
|
|
75
|
-
const newFixedTimeList = mode === 'add' ? [...state.
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
const newFixedTimeList = mode === 'add' ? [...state.originList, fixedTime] : cloneFixedTimeList
|
|
89
|
+
const res = await setFixedTime(newFixedTimeList)
|
|
90
|
+
console.log(res, '< ---== resss')
|
|
91
|
+
if (res.success) {
|
|
92
|
+
state.originList = cloneDeep(newFixedTimeList)
|
|
93
|
+
}
|
|
94
|
+
return res
|
|
95
|
+
}, [state.originList])
|
|
96
|
+
|
|
97
|
+
const showTags = useMemo(() => (
|
|
98
|
+
<View style={styles.categoryList}>
|
|
99
|
+
{state.checkTags.map((tag, idx) => (
|
|
100
|
+
<Tag
|
|
101
|
+
key={tag.key}
|
|
102
|
+
text={tag.key}
|
|
103
|
+
checked={tag.enable}
|
|
104
|
+
onCheckedChange={(v) => {
|
|
105
|
+
state.checkTags[idx].enable = v
|
|
106
|
+
state.checkTags = cloneDeep(state.checkTags)
|
|
107
|
+
}}
|
|
108
|
+
style={{ marginRight: cx(5), marginBottom: cx(5) }}
|
|
109
|
+
/>
|
|
110
|
+
))}
|
|
111
|
+
</View>
|
|
112
|
+
), [state.checkTags])
|
|
78
113
|
|
|
79
114
|
return (
|
|
80
115
|
<Page
|
|
@@ -87,71 +122,76 @@ const FixedTimePage = () => {
|
|
|
87
122
|
navigateToEdit('add', newFixedTime())
|
|
88
123
|
}}
|
|
89
124
|
>
|
|
90
|
-
{
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
126
|
+
<Text style={{
|
|
127
|
+
color: '#000',
|
|
128
|
+
marginLeft: cx(24),
|
|
129
|
+
fontSize: cx(12)
|
|
130
|
+
}}>{I18n.getLang('timeschedule_overview_description_text')}</Text>
|
|
131
|
+
<Spacer height={cx(10)} />
|
|
132
|
+
{showMaxNumTip() && <InfoText
|
|
133
|
+
style={{ marginHorizontal: cx(24), marginBottom: cx(5) }}
|
|
134
|
+
icon={res.ic_warning_amber}
|
|
135
|
+
iconStyle={{ width: cx(16), height: cx(16) }}
|
|
136
|
+
contentColor="#FF9500"
|
|
137
|
+
text={I18n.getLang('fixedtimecycle_warning_max_number_text')}
|
|
138
|
+
textStyle={{ fontSize: cx(12) }}
|
|
139
|
+
/>}
|
|
140
|
+
{params.showTags && !!state.originList.length && showTags}
|
|
141
|
+
{state.fixedTimeList.length > 0 ? <FlatList
|
|
142
|
+
data={state.fixedTimeList}
|
|
143
|
+
renderItem={({ item }) => (
|
|
144
|
+
<FixedTimeCard
|
|
145
|
+
is24Hour={is24Hour}
|
|
146
|
+
fixedTime={item}
|
|
147
|
+
showTags={params.showTags}
|
|
148
|
+
tags={params.applyForList}
|
|
149
|
+
onSwitch={async (v) => {
|
|
150
|
+
state.loading = true
|
|
151
|
+
await onPost('edit', {
|
|
152
|
+
...item,
|
|
153
|
+
enable: v
|
|
154
|
+
})
|
|
155
|
+
state.loading = false
|
|
156
|
+
}}
|
|
157
|
+
onPress={() => {
|
|
158
|
+
navigateToEdit('edit', item)
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
)}
|
|
162
|
+
keyExtractor={(item: any) => `${item?.index}`}
|
|
163
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
164
|
+
ListHeaderComponent={<Spacer height={cx(10)} />}
|
|
165
|
+
ListFooterComponent={<Spacer />}
|
|
166
|
+
/> :
|
|
167
|
+
<View style={{ flex: 1, marginTop: cx(60), alignItems: 'center', marginHorizontal: cx(24) }}>
|
|
132
168
|
<Image
|
|
133
|
-
|
|
134
|
-
|
|
169
|
+
style={{ width: cx(225), height: cx(198) }}
|
|
170
|
+
source={{ uri: res.ldv_timer_empty }}
|
|
171
|
+
resizeMode="contain" />
|
|
172
|
+
<InfoText
|
|
173
|
+
icon={res.device_panel_schedule_alert}
|
|
174
|
+
text={I18n.getLang(!state.originList.length ? 'fixedTimeCycle_information_text' : 'fixedTimeCycle_empty_filtering_information_text')}
|
|
175
|
+
style={{ width: 'auto', alignItems: 'center' }}
|
|
176
|
+
textStyle={{ color: '#000', fontSize: cx(12), flex: undefined }}
|
|
177
|
+
iconStyle={{ width: cx(16), height: cx(16), tintColor: '#000' }}
|
|
135
178
|
/>
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}} />
|
|
153
|
-
</View>
|
|
154
|
-
}
|
|
179
|
+
<Spacer />
|
|
180
|
+
{!state.originList.length && <TextButton
|
|
181
|
+
text={I18n.getLang('fixedTimeCycle_bttn_text')}
|
|
182
|
+
style={{
|
|
183
|
+
backgroundColor: '#f60',
|
|
184
|
+
borderRadius: cx(6),
|
|
185
|
+
paddingVertical: cx(12),
|
|
186
|
+
paddingHorizontal: cx(24),
|
|
187
|
+
}}
|
|
188
|
+
textStyle={{ color: '#fff' }}
|
|
189
|
+
onPress={() => {
|
|
190
|
+
navigateToEdit('add', newFixedTime())
|
|
191
|
+
}} />}
|
|
192
|
+
</View>}
|
|
193
|
+
</ScrollView>
|
|
194
|
+
|
|
155
195
|
</Page>
|
|
156
196
|
)
|
|
157
197
|
}
|
|
@@ -159,10 +199,12 @@ const FixedTimePage = () => {
|
|
|
159
199
|
const FixedTimeCard = memo((props: {
|
|
160
200
|
is24Hour: boolean
|
|
161
201
|
fixedTime: FixedTimerUiItem,
|
|
202
|
+
tags: ApplyForItem[]
|
|
203
|
+
showTags?: boolean,
|
|
162
204
|
onSwitch: (enable: boolean) => void,
|
|
163
205
|
onPress: () => void
|
|
164
206
|
}) => {
|
|
165
|
-
const { is24Hour, fixedTime, onSwitch, onPress } = props
|
|
207
|
+
const { is24Hour, fixedTime, tags, showTags, onSwitch, onPress } = props
|
|
166
208
|
return (
|
|
167
209
|
<Card style={styles.randomTimingCard} onPress={onPress}>
|
|
168
210
|
<Spacer height={cx(16)} />
|
|
@@ -178,7 +220,14 @@ const FixedTimeCard = memo((props: {
|
|
|
178
220
|
<Text style={styles.loopText}>{loopText(fixedTime.weeks)}</Text>
|
|
179
221
|
<Spacer height={cx(5)} />
|
|
180
222
|
<Text style={styles.loopText}>{fixedTime.name}</Text>
|
|
181
|
-
<Spacer />
|
|
223
|
+
<Spacer height={cx(showTags ? 5 : 20)} />
|
|
224
|
+
{showTags && <View style={styles.tagContainer}>
|
|
225
|
+
<View style={styles.tag}>
|
|
226
|
+
<Text style={styles.tagTitle}>
|
|
227
|
+
{tags[fixedTime.channel || 0]?.key}
|
|
228
|
+
</Text>
|
|
229
|
+
</View>
|
|
230
|
+
</View>}
|
|
182
231
|
</Card>
|
|
183
232
|
)
|
|
184
233
|
})
|
|
@@ -193,7 +242,7 @@ const newFixedTime = () => {
|
|
|
193
242
|
endTime: startTime + 60,
|
|
194
243
|
closeTime: 1,
|
|
195
244
|
openTime: 1,
|
|
196
|
-
channel:
|
|
245
|
+
channel: 0,
|
|
197
246
|
color: {
|
|
198
247
|
h: 0,
|
|
199
248
|
s: 100,
|
|
@@ -226,6 +275,30 @@ const styles = StyleSheet.create({
|
|
|
226
275
|
fontSize: cx(14),
|
|
227
276
|
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
228
277
|
},
|
|
278
|
+
categoryList: {
|
|
279
|
+
display: 'flex',
|
|
280
|
+
flexDirection: 'row',
|
|
281
|
+
flexWrap: 'wrap',
|
|
282
|
+
marginHorizontal: cx(24),
|
|
283
|
+
alignSelf: 'flex-start'
|
|
284
|
+
},
|
|
285
|
+
tagContainer: {
|
|
286
|
+
flexDirection: 'row',
|
|
287
|
+
marginBottom: cx(15)
|
|
288
|
+
},
|
|
289
|
+
tag: {
|
|
290
|
+
borderRadius: cx(16),
|
|
291
|
+
height: cx(16),
|
|
292
|
+
backgroundColor: '#E6E7E8',
|
|
293
|
+
marginRight: cx(10),
|
|
294
|
+
paddingHorizontal: cx(12)
|
|
295
|
+
},
|
|
296
|
+
tagTitle: {
|
|
297
|
+
fontSize: cx(10),
|
|
298
|
+
textAlign: 'center',
|
|
299
|
+
fontFamily: 'PingFangSC-Medium',
|
|
300
|
+
color: '#000'
|
|
301
|
+
},
|
|
229
302
|
})
|
|
230
303
|
|
|
231
304
|
export default FixedTimePage
|
|
@@ -7,7 +7,6 @@ import { padStart } from "lodash";
|
|
|
7
7
|
import { hex2Int, spliceByStep } from "@ledvance/base/src/utils/common";
|
|
8
8
|
import I18n from "@ledvance/base/src/i18n";
|
|
9
9
|
import { parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
10
|
-
import { useUpdateEffect } from "ahooks";
|
|
11
10
|
import { Buffer } from "buffer";
|
|
12
11
|
const { to16 } = Utils
|
|
13
12
|
|
|
@@ -21,6 +20,7 @@ export interface RandomTimerData {
|
|
|
21
20
|
|
|
22
21
|
export interface RandomTimer {
|
|
23
22
|
enable: boolean;
|
|
23
|
+
channel?: number;
|
|
24
24
|
weeks: number[];
|
|
25
25
|
startTime: number;
|
|
26
26
|
endTime: number;
|
|
@@ -52,9 +52,9 @@ export interface PlugRandomTimerItem extends PlugRandomTimer {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
let randomTimer
|
|
55
|
-
type UseFixedTimeType = (dpKey: string, isPlug?: boolean) => [RandomTimerUiItem[], (randomTimeList: RandomTimerUiItem[], manualEdit?: boolean) => Promise<{ success: boolean }>]
|
|
55
|
+
type UseFixedTimeType = (dpKey: string, isPlug?: boolean, disableFeature?: boolean) => [RandomTimerUiItem[], (randomTimeList: RandomTimerUiItem[], manualEdit?: boolean) => Promise<{ success: boolean }>]
|
|
56
56
|
|
|
57
|
-
export const useRandomTime: UseFixedTimeType = (dpKey, isPlug) => {
|
|
57
|
+
export const useRandomTime: UseFixedTimeType = (dpKey: string, isPlug?: boolean, disableFeature?: boolean) => {
|
|
58
58
|
const deviceId = useDeviceId()
|
|
59
59
|
const [randomTimeDp, setRandomTimeDp]: [string, (v: string) => Promise<Result<any>>] = useDp(dpKey)
|
|
60
60
|
const [randomTimeUiList, setRandomTimeUiList] = useState<RandomTimerUiItem[]>([])
|
|
@@ -69,53 +69,55 @@ export const useRandomTime: UseFixedTimeType = (dpKey, isPlug) => {
|
|
|
69
69
|
|
|
70
70
|
// 获取云端数据
|
|
71
71
|
useEffect(() => {
|
|
72
|
+
// 不获取名称
|
|
73
|
+
if(disableFeature) {
|
|
74
|
+
setRandomTimeUiList(formatterFn())
|
|
75
|
+
return
|
|
76
|
+
}
|
|
72
77
|
randomTimer = setTimeout(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
getFeature(deviceId, isPlug ? plug_randomFeatureId : randomFeatureId).then(res => {
|
|
79
|
+
if (res?.result) {
|
|
80
|
+
// 首次进入同步云端数据 (云端无数据)
|
|
81
|
+
if (!res.data) {
|
|
82
|
+
const cloudData = formatterFn()
|
|
83
|
+
setRandomTimeFn(cloudData).then()
|
|
84
|
+
} else {
|
|
85
|
+
const featureData = parseJSON(res.data)
|
|
86
|
+
if (randomTimeList.length) {
|
|
87
|
+
const uiPlan = randomTimeList?.map((item, idx: number) => {
|
|
88
|
+
const dp = randomTimeToHex(item, isPlug, true)
|
|
89
|
+
const random = featureData[idx]
|
|
90
|
+
const featureItem = random?.v && (isPlug ? parseJSON(random?.v)?.dp : random?.v)?.includes(dp) ? (isPlug ? parseJSON(random) : random) : featureData.find(feature => (isPlug ? parseJSON(feature?.v)?.dp : feature?.v).includes(dp))
|
|
91
|
+
return {
|
|
92
|
+
...item,
|
|
93
|
+
index: idx,
|
|
94
|
+
name: featureItem ? featureItem?.n : `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
setRandomTimeUiList(uiPlan)
|
|
98
|
+
} else {
|
|
99
|
+
setRandomTimeUiList([])
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}, 250)
|
|
77
106
|
|
|
78
|
-
useUpdateEffect(() =>{
|
|
79
|
-
randomTimer = setTimeout(() => {
|
|
80
|
-
getFeatureFn()
|
|
81
|
-
}, 100)
|
|
82
107
|
return () => clearTimeout(randomTimer)
|
|
83
108
|
}, [randomTimeDp])
|
|
84
109
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
setRandomTimeFn(cloudData).then()
|
|
92
|
-
} else {
|
|
93
|
-
const featureData = parseJSON(res.data)
|
|
94
|
-
if (randomTimeList.length) {
|
|
95
|
-
const uiPlan = randomTimeList?.map((item, idx: number) => {
|
|
96
|
-
const featureItem = featureData.find(feature => (isPlug ? parseJSON(feature?.v)?.dp : feature?.v) === randomTimeToHex(item, isPlug))
|
|
97
|
-
return {
|
|
98
|
-
...item,
|
|
99
|
-
index: idx,
|
|
100
|
-
name: featureItem ? featureItem?.n : `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
setRandomTimeUiList(uiPlan)
|
|
104
|
-
} else {
|
|
105
|
-
setRandomTimeUiList([])
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
}
|
|
110
|
+
const setRandomTimeFn = async (randomTimeList: RandomTimerUiItem[]) => {
|
|
111
|
+
const randomData = randomTimeList.map(item => {
|
|
112
|
+
const randomHex = randomTimeToHex(item, isPlug)
|
|
113
|
+
return {
|
|
114
|
+
n: item?.name || '',
|
|
115
|
+
v: isPlug ? JSON.stringify({dp: randomHex}) : randomHex
|
|
109
116
|
}
|
|
110
117
|
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const setRandomTimeFn = async (randomTimeList: RandomTimerUiItem[]) => {
|
|
114
|
-
const randomData = randomTimeList.map(item => ({
|
|
115
|
-
n: item?.name || '',
|
|
116
|
-
v: isPlug ? JSON.stringify({dp: randomTimeToHex(item, isPlug)}) : randomTimeToHex(item, isPlug)
|
|
117
|
-
}))
|
|
118
|
+
console.log(randomData, '< --- randomData')
|
|
118
119
|
const cloudStatus = await putFeatureFn(deviceId, isPlug ? plug_randomFeatureId : randomFeatureId, JSON.stringify(randomData))
|
|
120
|
+
console.log(cloudStatus, '< --- cloudStatus')
|
|
119
121
|
if (cloudStatus) {
|
|
120
122
|
const randomTimerData = {
|
|
121
123
|
version: 0,
|
|
@@ -157,7 +159,7 @@ const putFeatureFn = async (devId, featureId, data) => {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
const randomTimeDp2Obj = (randomDp: string, isPlug?: boolean) => {
|
|
160
|
-
if (randomDp?.length <=
|
|
162
|
+
if (!randomDp || randomDp?.length <= 6) return
|
|
161
163
|
if(isPlug){
|
|
162
164
|
randomDp = Buffer.from(randomDp, 'base64').toString('hex')
|
|
163
165
|
}
|
|
@@ -166,7 +168,11 @@ const randomTimeDp2Obj = (randomDp: string, isPlug?: boolean) => {
|
|
|
166
168
|
const s = isPlug ? 0 : 4
|
|
167
169
|
const n = isPlug ? 12 : 24
|
|
168
170
|
const nodes = spliceByStep(randomDp.slice(s), n).map(plan => {
|
|
169
|
-
const
|
|
171
|
+
const powerInfo = padStart(parseInt(`${plan.slice(0, 2)}`, 16).toString(2), 8, '0');
|
|
172
|
+
const powerBits = powerInfo.split('');
|
|
173
|
+
const enable = !!Number(powerBits[powerBits.length - 1]);
|
|
174
|
+
// 通道号
|
|
175
|
+
const channel = parseInt(powerBits.slice(1, powerBits.length - 1).join(''), 2);
|
|
170
176
|
const weeks = parseInt(plan.slice(2, 4), 16).toString(2).padStart(8, '0')
|
|
171
177
|
.split('')
|
|
172
178
|
.reverse()
|
|
@@ -174,7 +180,7 @@ const randomTimeDp2Obj = (randomDp: string, isPlug?: boolean) => {
|
|
|
174
180
|
const startTime = hex2Int(plan.slice(4, 8))
|
|
175
181
|
const endTime = hex2Int(plan.slice(8, 12))
|
|
176
182
|
const common = {
|
|
177
|
-
enable, weeks, startTime, endTime
|
|
183
|
+
enable, channel, weeks, startTime, endTime
|
|
178
184
|
}
|
|
179
185
|
if (isPlug) {
|
|
180
186
|
return common
|
|
@@ -210,9 +216,11 @@ const randomTimeObj2Dp = (randomTimerData: RandomTimerData, isPlug?: boolean) =>
|
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
|
|
213
|
-
const randomTimeToHex = (randomTime: RandomTimer, isPlug?: boolean) => {
|
|
214
|
-
const { weeks, startTime, endTime, enable } = randomTime
|
|
215
|
-
const
|
|
219
|
+
const randomTimeToHex = (randomTime: RandomTimer, isPlug?: boolean, isFeatureData?: boolean) => {
|
|
220
|
+
const { weeks, startTime, endTime, channel, enable } = randomTime
|
|
221
|
+
const channelStr = padStart((channel ?? 0).toString(2), 7, '0');
|
|
222
|
+
const powerChannel = parseInt(`${channelStr}${enable ? 1 : 0}`, 2);
|
|
223
|
+
const powerChannelStr = to16(powerChannel, 2);
|
|
216
224
|
const weeksValue: string = padStart([...weeks].reverse().join(''), 8, '0');
|
|
217
225
|
const weeksStr = to16(parseInt(weeksValue, 2), 2);
|
|
218
226
|
const startTimeStr = to16(startTime, 4);
|
|
@@ -227,6 +235,6 @@ const randomTimeToHex = (randomTime: RandomTimer, isPlug?: boolean) => {
|
|
|
227
235
|
const temperatureStr = to16(temperature);
|
|
228
236
|
colorHex = hueStr + saturationStr + valueStr + brightnessStr + temperatureStr
|
|
229
237
|
}
|
|
230
|
-
return
|
|
238
|
+
return (isFeatureData ? '' : powerChannelStr) + weeksStr + startTimeStr + endTimeStr + colorHex
|
|
231
239
|
}
|
|
232
240
|
|
|
@@ -36,8 +36,6 @@ const RandomTimeDetailPage = () => {
|
|
|
36
36
|
const state = useReactive({
|
|
37
37
|
loading: false,
|
|
38
38
|
isColorMode: false,
|
|
39
|
-
selectedSkill: params.applyDps.length === 1 ? params.applyDps : [],
|
|
40
|
-
skillList: params.applyDps.length === 1 ? [] : params.applyDps,
|
|
41
39
|
randomTime: cloneDeep(params.scheduleItem)
|
|
42
40
|
})
|
|
43
41
|
|
|
@@ -49,20 +47,20 @@ const RandomTimeDetailPage = () => {
|
|
|
49
47
|
}
|
|
50
48
|
}, [])
|
|
51
49
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const checkItemChanged = useMemo(() =>{
|
|
51
|
+
return isEqual(state.randomTime, params.scheduleItem)
|
|
52
|
+
}, [params.scheduleItem, JSON.stringify(state.randomTime)])
|
|
55
53
|
|
|
56
54
|
const canSubmit = useMemo(() => {
|
|
57
|
-
return state.randomTime.name?.length > 0 && state.randomTime.name?.length < 33 && !
|
|
58
|
-
}, [JSON.stringify(state.randomTime)])
|
|
55
|
+
return state.randomTime.name?.length > 0 && state.randomTime.name?.length < 33 && !checkItemChanged && state.randomTime.channel !== undefined
|
|
56
|
+
}, [JSON.stringify(state.randomTime), checkItemChanged])
|
|
59
57
|
|
|
60
58
|
return (
|
|
61
59
|
<Page
|
|
62
60
|
backText={I18n.getLang('randomtimecycle_sockets_headline_text')}
|
|
63
61
|
rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
|
|
64
62
|
loading={state.loading}
|
|
65
|
-
showBackDialog={
|
|
63
|
+
showBackDialog={!checkItemChanged}
|
|
66
64
|
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
67
65
|
backDialogContent={I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description')}
|
|
68
66
|
headlineText={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')}
|
|
@@ -138,25 +136,31 @@ const RandomTimeDetailPage = () => {
|
|
|
138
136
|
<View style={styles.cardContainer}>
|
|
139
137
|
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
140
138
|
<Spacer height={cx(10)} />
|
|
141
|
-
<View style={styles.applyContent}>
|
|
142
|
-
{state.
|
|
139
|
+
<View style={[styles.applyContent, { paddingTop: state.randomTime.channel === undefined ? 0 : cx(10) }]}>
|
|
140
|
+
{state.randomTime.channel === undefined ?
|
|
143
141
|
<Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
</
|
|
153
|
-
|
|
142
|
+
<View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]}>
|
|
143
|
+
<Text style={{ color: '#000', fontSize: cx(12) }}>{params.applyForList[state.randomTime.channel]?.key}</Text>
|
|
144
|
+
{params.applyForList.length > 1 && <TouchableOpacity
|
|
145
|
+
onPress={() => {
|
|
146
|
+
state.randomTime.channel = undefined
|
|
147
|
+
}}
|
|
148
|
+
style={{ paddingHorizontal: cx(5) }}>
|
|
149
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
|
|
150
|
+
</TouchableOpacity>}
|
|
151
|
+
</View>
|
|
154
152
|
}
|
|
155
153
|
</View>
|
|
156
|
-
{
|
|
154
|
+
{params.applyForList.map((item, index) => {
|
|
155
|
+
if (state.randomTime.channel === index) return null
|
|
157
156
|
return (
|
|
158
|
-
<TouchableOpacity
|
|
159
|
-
|
|
157
|
+
<TouchableOpacity
|
|
158
|
+
style={styles.applyItem}
|
|
159
|
+
key={item.key}
|
|
160
|
+
onPress={() => {
|
|
161
|
+
state.randomTime.channel = index
|
|
162
|
+
}}>
|
|
163
|
+
<Text style={{ color: '#000', fontSize: cx(12) }}>{item.key}</Text>
|
|
160
164
|
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
161
165
|
</TouchableOpacity>
|
|
162
166
|
)
|
|
@@ -177,9 +181,9 @@ const RandomTimeDetailPage = () => {
|
|
|
177
181
|
showSwitch={false}
|
|
178
182
|
/>
|
|
179
183
|
<LampAdjustView
|
|
180
|
-
isSupportColor={params.isSupportColor}
|
|
181
|
-
isSupportBrightness={params.isSupportBrightness}
|
|
182
|
-
isSupportTemperature={params.isSupportTemperature}
|
|
184
|
+
isSupportColor={!!params.isSupportColor}
|
|
185
|
+
isSupportBrightness={!!params.isSupportBrightness}
|
|
186
|
+
isSupportTemperature={!!params.isSupportTemperature}
|
|
183
187
|
isColorMode={state.isColorMode}
|
|
184
188
|
reserveSV={true}
|
|
185
189
|
setIsColorMode={(v) => state.isColorMode = v}
|
|
@@ -226,11 +230,11 @@ const RandomTimeDetailPage = () => {
|
|
|
226
230
|
onPress={() => {
|
|
227
231
|
showDialog({
|
|
228
232
|
method: 'confirm',
|
|
229
|
-
title: I18n.getLang('
|
|
233
|
+
title: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_titel'),
|
|
230
234
|
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
231
235
|
onConfirm: async (_, { close }) => {
|
|
232
|
-
state.loading = true
|
|
233
236
|
close()
|
|
237
|
+
state.loading = true
|
|
234
238
|
const res = await params.onPost('del', state.randomTime)
|
|
235
239
|
state.loading = false
|
|
236
240
|
if (res.success) {
|
|
@@ -319,4 +323,4 @@ const styles = StyleSheet.create({
|
|
|
319
323
|
}
|
|
320
324
|
})
|
|
321
325
|
|
|
322
|
-
export default RandomTimeDetailPage
|
|
326
|
+
export default RandomTimeDetailPage
|