@ledvance/ui-biz-bundle 1.1.125 → 1.1.127
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/hooks/DeviceDpStateHooks.ts +6 -4
- package/src/modules/flags/FlagEditPage.tsx +7 -8
- package/src/newModules/energyConsumption/component/NewBarChart.tsx +7 -0
- package/src/newModules/swithInching/SwithInching.tsx +140 -96
- package/src/newModules/swithInching/SwithInchingAction.ts +56 -35
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +32 -29
package/package.json
CHANGED
|
@@ -153,10 +153,12 @@ export const useConflictTask = (conflictDps: ConflictDps, isPlug?: boolean): [(v
|
|
|
153
153
|
newState[conflictDps.wakeUpDpCode] = newItems
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
if (conflictDps.switchIngCode
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
if (conflictDps.switchIngCode) {
|
|
157
|
+
const targetItem = switchInching.find(item => item.channel === conflictItem.channel && item.enable);
|
|
158
|
+
if (targetItem) {
|
|
159
|
+
newState[conflictDps.switchIngCode] = switchInching.map(item =>
|
|
160
|
+
item.channel === conflictItem.channel && item.enable ? { ...item, enable: false } : item
|
|
161
|
+
);
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
state.conflictTask = cloneDeep(newState)
|
|
@@ -213,7 +213,7 @@ const FlagEditPage = (props: { theme?: ThemeType }) => {
|
|
|
213
213
|
maxLength={33}
|
|
214
214
|
showError={state.mood.name.length > 32 || nameRepeat}
|
|
215
215
|
tipColor={nameRepeat ? props.theme?.global.error : undefined}
|
|
216
|
-
tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
|
|
216
|
+
tipIcon={nameRepeat ? { uri: res.ic_text_field_input_error } : undefined}
|
|
217
217
|
errorText={I18n.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')} />
|
|
218
218
|
{(params.moduleParams.isSupportMixScene || params.moduleParams.isCeilingLight) && <><Card style={styles.adjustCard}>
|
|
219
219
|
<Spacer height={cx(16)} />
|
|
@@ -387,11 +387,10 @@ const FlagEditPage = (props: { theme?: ThemeType }) => {
|
|
|
387
387
|
state.mood.colors = state.mood.colors.map(() => (
|
|
388
388
|
{ h, s, v }
|
|
389
389
|
))
|
|
390
|
-
} else {
|
|
391
|
-
state.currentNode.h = h
|
|
392
|
-
state.currentNode.s = s
|
|
393
|
-
state.currentNode.v = v
|
|
394
390
|
}
|
|
391
|
+
state.currentNode.h = h
|
|
392
|
+
state.currentNode.s = s
|
|
393
|
+
state.currentNode.v = v
|
|
395
394
|
}}
|
|
396
395
|
onHSVChangeComplete={(h, s, v) => {
|
|
397
396
|
if (state.colorPaintBucketSelected) {
|
|
@@ -399,9 +398,6 @@ const FlagEditPage = (props: { theme?: ThemeType }) => {
|
|
|
399
398
|
{ h, s, v }
|
|
400
399
|
))
|
|
401
400
|
} else {
|
|
402
|
-
state.currentNode.h = h
|
|
403
|
-
state.currentNode.s = s
|
|
404
|
-
state.currentNode.v = v
|
|
405
401
|
state.mood.colors = state.mood.colors.map((item, idx) => {
|
|
406
402
|
if (idx === state.colorPaintBucketIdx) {
|
|
407
403
|
return { h, s, v }
|
|
@@ -409,6 +405,9 @@ const FlagEditPage = (props: { theme?: ThemeType }) => {
|
|
|
409
405
|
return item
|
|
410
406
|
})
|
|
411
407
|
}
|
|
408
|
+
state.currentNode.h = h
|
|
409
|
+
state.currentNode.s = s
|
|
410
|
+
state.currentNode.v = v
|
|
412
411
|
}}
|
|
413
412
|
/>
|
|
414
413
|
<Spacer height={cx(16)} />
|
|
@@ -42,6 +42,10 @@ const BarChartWithTouch = (props: BarChartProps) => {
|
|
|
42
42
|
}
|
|
43
43
|
return max
|
|
44
44
|
}, [dataKwhY]);
|
|
45
|
+
const gridRight = useMemo(() => {
|
|
46
|
+
const max = Math.max(...dataPriceY.map(it => Number(it)))
|
|
47
|
+
return max > 999 ? '12%' : '10%'
|
|
48
|
+
}, [dataPriceY])
|
|
45
49
|
const option = {
|
|
46
50
|
tooltip: {
|
|
47
51
|
show: true,
|
|
@@ -55,6 +59,9 @@ const BarChartWithTouch = (props: BarChartProps) => {
|
|
|
55
59
|
color: theme?.global.fontColor,
|
|
56
60
|
}
|
|
57
61
|
},
|
|
62
|
+
grid: {
|
|
63
|
+
right: gridRight,
|
|
64
|
+
},
|
|
58
65
|
xAxis: {
|
|
59
66
|
data: dataX,
|
|
60
67
|
axisTick: {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet, Text, View } from "react-native";
|
|
3
3
|
import Page from "@ledvance/base/src/components/Page";
|
|
4
4
|
import { useDeviceInfo } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
5
5
|
import { useNavigation } from '@react-navigation/native'
|
|
6
6
|
import { SwitchButton, Utils, Dialog } from "tuya-panel-kit";
|
|
7
7
|
import LdvPickerView from "@ledvance/base/src/components/ldvPickerView";
|
|
8
8
|
import I18n from '@ledvance/base/src/i18n'
|
|
9
|
-
import {
|
|
10
|
-
import { SwitchInchingPageParams, useCountdown1, useSwitchInching } from "./SwithInchingAction";
|
|
9
|
+
import { SwitchInchingItem, SwitchInchingPageParams, useSwitchInching, defSwitchInching, useCountdowns } from "./SwithInchingAction";
|
|
11
10
|
import { useParams } from "@ledvance/base/src/hooks/Hooks";
|
|
12
11
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
13
12
|
import { useConflictTask } from "../../hooks/DeviceDpStateHooks";
|
|
14
13
|
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
14
|
+
import Segmented from "@ledvance/base/src/components/Segmented";
|
|
15
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
15
16
|
|
|
16
17
|
const { convertX: cx } = Utils.RatioUtils
|
|
17
18
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -21,48 +22,66 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
|
|
|
21
22
|
const deviceInfo = useDeviceInfo()
|
|
22
23
|
const navigation = useNavigation()
|
|
23
24
|
const [switchInching, setSwitchInching] = useSwitchInching(params.switchIngCode)
|
|
24
|
-
const [countdown1, setCountDown1] = useCountdown1(params.countdownCode)
|
|
25
25
|
const [checkConflict, resolveConflict] = useConflictTask(params.conflictDps, true)
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const [countdowns, setCountdowns] = useCountdowns(params.countdownCode || params.channelConfig.map(item => item.countdownCode))
|
|
27
|
+
const timeRef = useRef({
|
|
28
28
|
minute: '00',
|
|
29
29
|
second: '00',
|
|
30
|
-
|
|
30
|
+
})
|
|
31
|
+
const [state, setState] = useState({
|
|
32
|
+
loading: false,
|
|
33
|
+
channel: 0,
|
|
34
|
+
switchInchingItem: defSwitchInching[0]
|
|
31
35
|
})
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
state.second = formateValue('second')
|
|
37
|
-
}, [JSON.stringify(switchInching)])
|
|
38
|
-
|
|
39
|
-
const requestSwitchInching = async () => {
|
|
40
|
-
const enable = state.enable
|
|
41
|
-
const time = Number(state.minute) * 60 + Number(state.second)
|
|
42
|
-
if (enable && countdown1){
|
|
43
|
-
setCountDown1(0)
|
|
44
|
-
}
|
|
45
|
-
await setSwitchInching({ enable, time })
|
|
46
|
-
}
|
|
37
|
+
const updateState = (newState: Partial<typeof state>) => {
|
|
38
|
+
setState(prev => ({ ...prev, ...newState }));
|
|
39
|
+
};
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
41
|
+
const updateTime = (minute?: string, second?: string) => {
|
|
42
|
+
if (minute !== undefined) timeRef.current.minute = minute;
|
|
43
|
+
if (second !== undefined) timeRef.current.second = second;
|
|
44
|
+
|
|
45
|
+
if (!Number(timeRef.current.minute) && Number(timeRef.current.second) < 1) {
|
|
46
|
+
timeRef.current.second = '01';
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
|
|
49
|
+
if (Number(timeRef.current.minute) === 60) {
|
|
50
|
+
timeRef.current.second = '00';
|
|
54
51
|
}
|
|
55
|
-
|
|
52
|
+
|
|
53
|
+
const time = Number(timeRef.current.minute) * 60 + Number(timeRef.current.second);
|
|
54
|
+
const newSwitchInchingItem = {
|
|
55
|
+
...state.switchInchingItem,
|
|
56
|
+
time
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
updateState({ switchInchingItem: newSwitchInchingItem });
|
|
60
|
+
|
|
61
|
+
};
|
|
56
62
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const switchInchingItem = useMemo(() => {
|
|
64
|
+
return switchInching.find(item => item.channel === state.channel) ?? { ...defSwitchInching[0], channel: state.channel }
|
|
65
|
+
}, [state.channel, JSON.stringify(switchInching)])
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const { minute, second } = formateValue(switchInchingItem)
|
|
69
|
+
timeRef.current = { minute, second }
|
|
70
|
+
updateState({ switchInchingItem })
|
|
71
|
+
}, [switchInchingItem])
|
|
72
|
+
|
|
73
|
+
const saveInchingConfig = async (item: SwitchInchingItem) => {
|
|
74
|
+
const updatedSwitchInching = [...switchInching];
|
|
75
|
+
const existingItemIndex = updatedSwitchInching.findIndex(item => item.channel === state.channel);
|
|
76
|
+
updatedSwitchInching[existingItemIndex] = item;
|
|
77
|
+
console.log('updatedSwitchInching', updatedSwitchInching)
|
|
78
|
+
await setSwitchInching(updatedSwitchInching)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const formateValue = (switchInchingItem: SwitchInchingItem) => {
|
|
82
|
+
const minute = Math.floor((switchInchingItem.time || 0) / 60).toString().padStart(2, '0')
|
|
83
|
+
const second = ((switchInchingItem.time || 0) % 60).toString().padStart(2, '0')
|
|
84
|
+
return { minute, second }
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
const styles = StyleSheet.create({
|
|
@@ -120,71 +139,96 @@ const SwitchInching = (props: { theme?: ThemeType }) => {
|
|
|
120
139
|
<Page
|
|
121
140
|
backText={deviceInfo.name}
|
|
122
141
|
onBackClick={navigation.goBack}
|
|
123
|
-
headlineText={I18n.getLang('
|
|
142
|
+
headlineText={I18n.getLang('sockets_specific_settings_switch_inching')}
|
|
124
143
|
>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
<
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
145
|
+
{params.channelConfig && params.channelConfig.length > 1 && <>
|
|
146
|
+
<Segmented
|
|
147
|
+
style={{ marginHorizontal: cx(24) }}
|
|
148
|
+
options={params.channelConfig.map(item => ({
|
|
149
|
+
label: item.channelTitle,
|
|
150
|
+
value: item.channel
|
|
151
|
+
}))}
|
|
152
|
+
value={state.channel}
|
|
153
|
+
onChange={v => {
|
|
154
|
+
updateState({ channel: Number(v) })
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
<Spacer />
|
|
158
|
+
</>}
|
|
159
|
+
<View style={styles.switchContainer}>
|
|
160
|
+
<View style={styles.switchCardContainer}>
|
|
161
|
+
<Text style={styles.switchCardTitle}>
|
|
162
|
+
{I18n.getLang('socket_settings_switch_off_firstbox_text')}
|
|
163
|
+
</Text>
|
|
164
|
+
<SwitchButton
|
|
165
|
+
value={state.switchInchingItem.enable}
|
|
166
|
+
onValueChange={async v => {
|
|
167
|
+
const time = Number(timeRef.current.minute) * 60 + Number(timeRef.current.second)
|
|
168
|
+
const newSwitchInchingItem = {
|
|
169
|
+
...state.switchInchingItem,
|
|
135
170
|
enable: v,
|
|
136
|
-
|
|
137
|
-
endTime: 1440,
|
|
138
|
-
weeks: [1, 1, 1, 1, 1, 1, 1],
|
|
171
|
+
time
|
|
139
172
|
}
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
if (v) {
|
|
174
|
+
const switchingTask = {
|
|
175
|
+
channel: state.channel,
|
|
176
|
+
enable: v,
|
|
177
|
+
startTime: 0,
|
|
178
|
+
endTime: 1440,
|
|
179
|
+
weeks: [1, 1, 1, 1, 1, 1, 1],
|
|
180
|
+
}
|
|
181
|
+
const countdown = params.countdownCode ? countdowns[params.countdownCode] : countdowns[params.channelConfig[state.channel].countdownCode]
|
|
182
|
+
if (countdown) {
|
|
183
|
+
setCountdowns(params.countdownCode || params.channelConfig[state.channel].countdownCode, 0).then()
|
|
184
|
+
}
|
|
185
|
+
if (checkConflict(switchingTask)) {
|
|
186
|
+
return showDialog({
|
|
187
|
+
method: 'confirm',
|
|
188
|
+
title: I18n.getLang('conflict_dialog_save_item_inching_titel'),
|
|
189
|
+
subTitle: I18n.getLang('conflict_dialog_save_item_inching_description'),
|
|
190
|
+
onConfirm: async (_, { close }) => {
|
|
191
|
+
resolveConflict()
|
|
192
|
+
close()
|
|
193
|
+
state.loading = true
|
|
194
|
+
updateState({ switchInchingItem: newSwitchInchingItem })
|
|
195
|
+
setTimeout(async () => {
|
|
196
|
+
await saveInchingConfig(newSwitchInchingItem)
|
|
197
|
+
}, 0)
|
|
198
|
+
},
|
|
199
|
+
onCancel: () => {
|
|
200
|
+
Dialog.close()
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
}
|
|
156
204
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
205
|
+
updateState({ switchInchingItem: newSwitchInchingItem })
|
|
206
|
+
await saveInchingConfig(newSwitchInchingItem)
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
</View>
|
|
210
|
+
<Text style={styles.switchDescription}>
|
|
211
|
+
{I18n.getLang('switchinching_overview_description_text')}
|
|
212
|
+
</Text>
|
|
162
213
|
</View>
|
|
163
|
-
<Text style={styles.
|
|
164
|
-
{I18n.getLang('
|
|
214
|
+
<Text style={styles.secondTopic}>
|
|
215
|
+
{I18n.getLang('socket_settings_switch_off_secondtopic')}
|
|
165
216
|
</Text>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}}
|
|
182
|
-
setMinute={s => {
|
|
183
|
-
state.second = s;
|
|
184
|
-
}}
|
|
185
|
-
maxHour={61}
|
|
186
|
-
/>
|
|
187
|
-
</View>
|
|
217
|
+
<View style={styles.pickContainer}>
|
|
218
|
+
{state.switchInchingItem.enable && <View style={styles.disabledCover} />}
|
|
219
|
+
<LdvPickerView
|
|
220
|
+
hour={timeRef.current.minute}
|
|
221
|
+
minute={timeRef.current.second}
|
|
222
|
+
unit={[
|
|
223
|
+
I18n.getLang('socket_settings_switch_off_min'),
|
|
224
|
+
I18n.getLang('socket_settings_switch_off_s'),
|
|
225
|
+
]}
|
|
226
|
+
setHour={m => updateTime(m, undefined)}
|
|
227
|
+
setMinute={s => updateTime(undefined, s)}
|
|
228
|
+
maxHour={61}
|
|
229
|
+
/>
|
|
230
|
+
</View>
|
|
231
|
+
</ScrollView>
|
|
188
232
|
</Page>
|
|
189
233
|
);
|
|
190
234
|
};
|
|
@@ -1,61 +1,82 @@
|
|
|
1
|
-
import {Buffer} from 'buffer'
|
|
2
|
-
import {Result} from "@ledvance/base/src/models/modules/Result"
|
|
3
|
-
import {useDp} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
1
|
+
import { Buffer } from 'buffer'
|
|
2
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
3
|
+
import { useDp } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
4
|
+
import { spliceByStep } from '@ledvance/base/src/utils/common';
|
|
5
|
+
import { Utils } from '@tuya/tuya-panel-lamp-sdk'
|
|
4
6
|
|
|
7
|
+
const { to16 } = Utils
|
|
5
8
|
export interface SwitchInchingPageParams {
|
|
6
9
|
switchIngCode: string
|
|
7
|
-
countdownCode
|
|
10
|
+
countdownCode?: string
|
|
11
|
+
channelConfig?: {
|
|
12
|
+
countdownCode: string
|
|
13
|
+
channelTitle: string
|
|
14
|
+
channel: number
|
|
15
|
+
}[]
|
|
8
16
|
conflictDps: {
|
|
9
17
|
randomTimeDpCode?: string
|
|
10
18
|
fixedTimeDpCode?: string
|
|
11
19
|
}
|
|
12
20
|
}
|
|
13
21
|
|
|
14
|
-
interface
|
|
22
|
+
export interface SwitchInchingItem {
|
|
23
|
+
channel: number,
|
|
15
24
|
enable: boolean,
|
|
16
25
|
time: number
|
|
17
26
|
}
|
|
18
27
|
|
|
19
|
-
function format(number: string, code: number) {
|
|
20
|
-
const l = number.length; //获取要格式化数字的长度,如二进制1的话长度为1
|
|
21
|
-
if (l < code) { //补全位数 0000,这里我要显示4位
|
|
22
|
-
for (let i = 0; i < code - l; i++) {
|
|
23
|
-
number = "0" + number; //不够的就在前面补0
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return number;
|
|
27
|
-
}
|
|
28
28
|
|
|
29
|
-
type SwitchInchingResult = (switchInchingCode: string) => [SwitchInchingModel, (v: SwitchInchingModel) => Promise<Result<any>>]
|
|
30
29
|
|
|
31
|
-
export function
|
|
32
|
-
|
|
30
|
+
export function useCountdowns(countdownCodes: string | string[]): [Record<string, number>, (countdownCode: string, value: number) => Promise<Result<any>>] {
|
|
31
|
+
const codes = Array.isArray(countdownCodes) ? countdownCodes : [countdownCodes];
|
|
32
|
+
const countdownValues: Record<string, number> = {};
|
|
33
|
+
const dpSetters: Record<string, (value: number) => Promise<Result<any>>> = {};
|
|
34
|
+
|
|
35
|
+
for (const code of codes) {
|
|
36
|
+
const [value, setDp] = useDp<number, any>(code);
|
|
37
|
+
countdownValues[code] = value;
|
|
38
|
+
dpSetters[code] = setDp;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const setCountdown = async (countdownCode: string, value: number) => {
|
|
42
|
+
if (dpSetters[countdownCode]) {
|
|
43
|
+
return await dpSetters[countdownCode](value);
|
|
44
|
+
}
|
|
45
|
+
return { success: false, msg: 'Countdown code not found' } as Result<any>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return [countdownValues, setCountdown];
|
|
33
49
|
}
|
|
34
50
|
|
|
35
51
|
export function useSwitchInchingHex(switchInchingCode: string): [string, (switchInching: string) => Promise<Result<any>>] {
|
|
36
52
|
return useDp(switchInchingCode)
|
|
37
53
|
}
|
|
38
54
|
|
|
39
|
-
export const
|
|
55
|
+
export const defSwitchInching = [{ enable: false, channel: 0, time: 1 }]
|
|
56
|
+
|
|
57
|
+
export const useSwitchInching = (switchInchingCode: string) => {
|
|
40
58
|
const [hex, setHex] = useSwitchInchingHex(switchInchingCode)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
59
|
+
const switching = hex ? spliceByStep(Buffer.from(hex, 'base64').toString('hex'), 6).map(item => {
|
|
60
|
+
const powerInfo = parseInt(`${item.slice(0, 2)}`, 16).toString(2).padStart(8, '0');
|
|
61
|
+
const powerBits = powerInfo.split('');
|
|
62
|
+
const enable = !!Number(powerBits[powerBits.length - 1]);
|
|
63
|
+
// 通道号
|
|
64
|
+
const channel = parseInt(powerBits.slice(1, powerBits.length - 1).join(''), 2);
|
|
65
|
+
const time = parseInt(item.slice(2, 6), 16)
|
|
66
|
+
return { enable, channel, time }
|
|
67
|
+
}) : defSwitchInching
|
|
68
|
+
|
|
69
|
+
const setSwitchInching = (switching: SwitchInchingItem[]) => {
|
|
70
|
+
const inchingString = switching.map(item => {
|
|
71
|
+
const channelStr = item.channel.toString(2).padStart(7, '0')
|
|
72
|
+
const powerChannel = parseInt(`${channelStr}${item.enable ? 1 : 0}`, 2);
|
|
73
|
+
const powerChannelStr = to16(powerChannel, 2);
|
|
74
|
+
const timeHex = item.time?.toString(16).padStart(4, '0')
|
|
75
|
+
return powerChannelStr + timeHex
|
|
76
|
+
}).join('')
|
|
77
|
+
const inchingHex = Buffer.from(inchingString, 'hex').toString('base64')
|
|
53
78
|
return setHex(inchingHex)
|
|
54
79
|
}
|
|
55
|
-
return [
|
|
80
|
+
return [switching, setSwitchInching] as const
|
|
56
81
|
}
|
|
57
82
|
|
|
58
|
-
const hexToBase64 = (hex: string) => {
|
|
59
|
-
const buffer = Buffer.from(hex, 'hex');
|
|
60
|
-
return buffer.toString('base64');
|
|
61
|
-
}
|
|
@@ -40,7 +40,6 @@ const ScheduleCard = (props: ScheduleCardProps) => {
|
|
|
40
40
|
infoContainer: {
|
|
41
41
|
flex: 1,
|
|
42
42
|
marginTop: cx(16),
|
|
43
|
-
marginBottom: cx(16),
|
|
44
43
|
flexDirection: 'column',
|
|
45
44
|
marginLeft: cx(16),
|
|
46
45
|
},
|
|
@@ -65,20 +64,22 @@ const ScheduleCard = (props: ScheduleCardProps) => {
|
|
|
65
64
|
},
|
|
66
65
|
switchContainer: {
|
|
67
66
|
marginRight: cx(16),
|
|
68
|
-
// backgroundColor: 'red',
|
|
69
67
|
marginTop: cx(16),
|
|
70
68
|
},
|
|
71
69
|
switch: {},
|
|
72
70
|
typeContainer: {
|
|
73
71
|
flexDirection: 'row',
|
|
74
|
-
|
|
72
|
+
flexWrap: 'wrap',
|
|
73
|
+
marginVertical: cx(8),
|
|
74
|
+
marginHorizontal: cx(16),
|
|
75
75
|
},
|
|
76
76
|
tag: {
|
|
77
77
|
borderRadius: cx(16),
|
|
78
78
|
height: cx(16),
|
|
79
79
|
backgroundColor: '#E6E7E8',
|
|
80
80
|
marginRight: cx(10),
|
|
81
|
-
|
|
81
|
+
marginBottom: cx(6),
|
|
82
|
+
paddingHorizontal: cx(10)
|
|
82
83
|
},
|
|
83
84
|
tagTitle: {
|
|
84
85
|
fontSize: cx(10),
|
|
@@ -90,7 +91,7 @@ const ScheduleCard = (props: ScheduleCardProps) => {
|
|
|
90
91
|
return (
|
|
91
92
|
<Card
|
|
92
93
|
style={styles.card}
|
|
93
|
-
containerStyle={[
|
|
94
|
+
containerStyle={[style]}
|
|
94
95
|
onPress={() => {
|
|
95
96
|
onPress(item);
|
|
96
97
|
}}
|
|
@@ -98,31 +99,33 @@ const ScheduleCard = (props: ScheduleCardProps) => {
|
|
|
98
99
|
onLongPress && onLongPress(item)
|
|
99
100
|
}}
|
|
100
101
|
>
|
|
101
|
-
<View style={styles.
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<SwitchButton
|
|
119
|
-
value={item.enable}
|
|
120
|
-
thumbStyle={{ elevation: 0 }}
|
|
121
|
-
onValueChange={() => {
|
|
122
|
-
onEnableChange(!item.enable);
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
102
|
+
<View style={styles.container}>
|
|
103
|
+
<View style={styles.infoContainer}>
|
|
104
|
+
<Text style={styles.time}>{is24HourClock ? item.time : convertTo12HourFormat(item.time)}</Text>
|
|
105
|
+
<Text style={styles.loop}>
|
|
106
|
+
{loopText(item.loops.split('').map(loop => parseInt(loop)), item.time)}
|
|
107
|
+
</Text>
|
|
108
|
+
<Text style={styles.name}>{item.name}</Text>
|
|
109
|
+
</View>
|
|
110
|
+
<View style={styles.switchContainer}>
|
|
111
|
+
<SwitchButton
|
|
112
|
+
value={item.enable}
|
|
113
|
+
thumbStyle={{ elevation: 0 }}
|
|
114
|
+
onValueChange={() => {
|
|
115
|
+
onEnableChange(!item.enable);
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
125
119
|
</View>
|
|
120
|
+
{showTag && <View style={styles.typeContainer}>
|
|
121
|
+
{showTags.map(tag => (
|
|
122
|
+
<View style={styles.tag} key={tag.dp}>
|
|
123
|
+
<Text style={styles.tagTitle}>
|
|
124
|
+
{tag.key}
|
|
125
|
+
</Text>
|
|
126
|
+
</View>
|
|
127
|
+
))}
|
|
128
|
+
</View>}
|
|
126
129
|
</Card>
|
|
127
130
|
)
|
|
128
131
|
|