@ledvance/group-ui-biz-bundle 1.0.92 → 1.0.94
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/biorhythm/BiorhythmBean.ts +1 -1
- package/src/modules/diyScene/DiyScenePage.tsx +6 -2
- package/src/modules/fixedTimeForPlug/FixedTimeForPlugPage.tsx +14 -0
- package/src/modules/fixedTimeForPlug/ItemCard.tsx +3 -2
- package/src/modules/fixedTimingForLight/FixedTimingForLightPage.tsx +14 -0
- package/src/modules/fixedTimingForLight/ItemCard.tsx +3 -2
- package/src/modules/flags/FlagActions.ts +3 -1
- package/src/modules/flags/FlagPage.tsx +4 -3
- package/src/modules/mood_new/Interface.ts +1 -0
- package/src/modules/mood_new/MoodActions.ts +12 -1
- package/src/modules/mood_new/MoodItem.tsx +2 -1
- package/src/modules/mood_new/MoodPage.tsx +34 -12
- package/src/modules/randomTimeForPlug/ItemCard.tsx +3 -2
- package/src/modules/randomTimeForPlug/RandomTimeForPlugPage.tsx +14 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightPage.tsx +14 -0
- package/src/modules/sleepWakeUp/SleepWakeUpPage.tsx +34 -5
- package/src/modules/timeSchedule/components/ScheduleCard.tsx +5 -6
- package/src/modules/timer/TimerAction.ts +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import React, {useCallback, useEffect, useMemo} from 'react';
|
|
|
2
2
|
import Page from '@ledvance/base/src/components/Page';
|
|
3
3
|
import {Utils} from 'tuya-panel-kit';
|
|
4
4
|
import {useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
5
|
-
import {useReactive} from 'ahooks';
|
|
5
|
+
import {useReactive, useUpdateEffect} from 'ahooks';
|
|
6
6
|
import I18n from '@ledvance/base/src/i18n';
|
|
7
7
|
import res from '@ledvance/base/src/res';
|
|
8
8
|
import {FlatList, Image, Platform, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
@@ -111,6 +111,10 @@ const DiyScenePage = (props: { theme?: ThemeType }) => {
|
|
|
111
111
|
[workMode, switchLed, sceneStatusId]
|
|
112
112
|
);
|
|
113
113
|
|
|
114
|
+
useUpdateEffect(() => {
|
|
115
|
+
state.originScenes = cloneDeep(scenes) as DiySceneInfo[];
|
|
116
|
+
}, [scenes]);
|
|
117
|
+
|
|
114
118
|
const nameRepeat = useCallback((scene: DiySceneInfo) => {
|
|
115
119
|
return !!state.originScenes.filter(m => m.id !== scene.id).find(m => m.name === scene.name)
|
|
116
120
|
}, [state.originScenes])
|
|
@@ -231,7 +235,7 @@ const DiyScenePage = (props: { theme?: ThemeType }) => {
|
|
|
231
235
|
subTitle: I18n.getLang('reset_mooddescription'),
|
|
232
236
|
onConfirm: async (_, { close }) => {
|
|
233
237
|
close()
|
|
234
|
-
resetMixScenes()
|
|
238
|
+
resetMixScenes().then();
|
|
235
239
|
}
|
|
236
240
|
})
|
|
237
241
|
}}
|
|
@@ -14,6 +14,7 @@ import {Utils} from "tuya-panel-kit";
|
|
|
14
14
|
import ItemCard from "./ItemCard";
|
|
15
15
|
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
16
16
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
17
|
+
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
17
18
|
|
|
18
19
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
19
20
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -114,6 +115,19 @@ const FixedTimeForPlugPage = (props: { theme?: ThemeType}) => {
|
|
|
114
115
|
onPress={() => {
|
|
115
116
|
onAddOrEditItem('edit', item)
|
|
116
117
|
}}
|
|
118
|
+
onLongPress={async () =>{
|
|
119
|
+
showDialog({
|
|
120
|
+
method: 'confirm',
|
|
121
|
+
title: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_titel'),
|
|
122
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
123
|
+
onConfirm: async (_, {close}) => {
|
|
124
|
+
close()
|
|
125
|
+
state.loading = true
|
|
126
|
+
await onPost('del', item)
|
|
127
|
+
state.loading = false
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}}
|
|
117
131
|
/>
|
|
118
132
|
)}
|
|
119
133
|
keyExtractor={(item: any) => `${item?.index}`}
|
|
@@ -18,10 +18,11 @@ export interface ItemCardProps {
|
|
|
18
18
|
is24Hour?: boolean,
|
|
19
19
|
onSwitch: (enable: boolean) => void
|
|
20
20
|
onPress: () => void
|
|
21
|
+
onLongPress: () => void
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const ItemCard = (props: ItemCardProps) => {
|
|
24
|
-
const {item, is24Hour, onSwitch, onPress} = props
|
|
25
|
+
const {item, is24Hour, onSwitch, onPress, onLongPress} = props
|
|
25
26
|
// 判断是否关闭
|
|
26
27
|
const closed = getIsClosed(item)
|
|
27
28
|
|
|
@@ -50,7 +51,7 @@ const ItemCard = (props: ItemCardProps) => {
|
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<Card style={styles.itemCard} onPress={onPress}>
|
|
54
|
+
<Card style={styles.itemCard} onPress={onPress} onLongPress={onLongPress}>
|
|
54
55
|
<Spacer height={cx(16)}/>
|
|
55
56
|
<View style={styles.switchLine}>
|
|
56
57
|
<Text style={styles.time}>
|
|
@@ -14,6 +14,7 @@ import ItemCard from "./ItemCard";
|
|
|
14
14
|
import {cloneDeep} from "lodash";
|
|
15
15
|
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
16
16
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
17
|
+
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
17
18
|
|
|
18
19
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
19
20
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -119,6 +120,19 @@ const FixedTimeForLightPage = (props: { theme?: ThemeType}) => {
|
|
|
119
120
|
onPress={() => {
|
|
120
121
|
onAddOrEditItem('edit', item)
|
|
121
122
|
}}
|
|
123
|
+
onLongPress={async () =>{
|
|
124
|
+
showDialog({
|
|
125
|
+
method: 'confirm',
|
|
126
|
+
title: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_titel'),
|
|
127
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
128
|
+
onConfirm: async (_, {close}) => {
|
|
129
|
+
close()
|
|
130
|
+
state.loading = true
|
|
131
|
+
await onPost('del', item)
|
|
132
|
+
state.loading = false
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}}
|
|
122
136
|
/>
|
|
123
137
|
)}
|
|
124
138
|
keyExtractor={(item: any) => `${item?.index}`}
|
|
@@ -18,10 +18,11 @@ export interface ItemCardProps {
|
|
|
18
18
|
is24Hour?: boolean,
|
|
19
19
|
onSwitch: (enable: boolean) => void
|
|
20
20
|
onPress: () => void
|
|
21
|
+
onLongPress: () => void
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const ItemCard = (props: ItemCardProps) => {
|
|
24
|
-
const {item, is24Hour, onSwitch, onPress} = props
|
|
25
|
+
const {item, is24Hour, onSwitch, onPress, onLongPress} = props
|
|
25
26
|
// 判断是否关闭
|
|
26
27
|
const closed = getIsClosed(item)
|
|
27
28
|
|
|
@@ -50,7 +51,7 @@ const ItemCard = (props: ItemCardProps) => {
|
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<Card style={styles.itemCard} onPress={onPress}>
|
|
54
|
+
<Card style={styles.itemCard} onPress={onPress} onLongPress={onLongPress}>
|
|
54
55
|
<Spacer height={cx(16)}/>
|
|
55
56
|
<View style={styles.switchLine}>
|
|
56
57
|
<Text style={styles.time}>
|
|
@@ -71,7 +71,9 @@ export const useFlag: UseFlagType = (params) => {
|
|
|
71
71
|
const dps = {}
|
|
72
72
|
const { flag } = flagData
|
|
73
73
|
if (!(params.isStripLight || params.isCeilingLight)){
|
|
74
|
-
const
|
|
74
|
+
const cloneFlag = cloneDeep(flag)
|
|
75
|
+
cloneFlag.colors = cloneFlag.colors.reverse()
|
|
76
|
+
const moodDp = obj2Dp(cloneFlag, params)
|
|
75
77
|
if (params.isStringLight){
|
|
76
78
|
dps[getGlobalParamsDp('rgbic_linerlight_scene')] = moodDp
|
|
77
79
|
}else{
|
|
@@ -49,6 +49,7 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
49
49
|
const state = useReactive({
|
|
50
50
|
loading: false,
|
|
51
51
|
flags: cloneDeep(flags) as FlagUiInfo[],
|
|
52
|
+
filterFlags: cloneDeep(flags) as FlagUiInfo[],
|
|
52
53
|
searchText: ''
|
|
53
54
|
})
|
|
54
55
|
|
|
@@ -57,8 +58,8 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
57
58
|
}, [])
|
|
58
59
|
|
|
59
60
|
useUpdateEffect(() => {
|
|
60
|
-
state.
|
|
61
|
-
}, [state.searchText, flags])
|
|
61
|
+
state.filterFlags = state.searchText !== '' ? cloneDeep(state.flags).filter(flag => (flag.name ?? '').toLowerCase().includes(state.searchText.toLowerCase())) : cloneDeep(state.flags)
|
|
62
|
+
}, [state.searchText, state.flags])
|
|
62
63
|
|
|
63
64
|
const getRemoteFlagInfo = async (isRefresh?: boolean) => {
|
|
64
65
|
const defNum = uaGroupInfo.groupDevices.filter(device => !(def2Pids.includes(device.tyPid) || def3Pids.includes(device.tyPid))).length
|
|
@@ -177,7 +178,7 @@ const FlagPage = (props: { theme?: ThemeType }) => {
|
|
|
177
178
|
</TouchableOpacity>
|
|
178
179
|
</View>
|
|
179
180
|
<FlatList
|
|
180
|
-
data={state.
|
|
181
|
+
data={state.filterFlags}
|
|
181
182
|
renderItem={({ item }) => <FlagItem
|
|
182
183
|
enable={flagMode?.flagId === item.id && flagMode?.flagMode && switch_led}
|
|
183
184
|
title={item.name}
|
|
@@ -205,6 +205,18 @@ export const getRemoteMoodList = async (
|
|
|
205
205
|
devId: string,
|
|
206
206
|
option: DefMoodOption,
|
|
207
207
|
) => {
|
|
208
|
+
const defaultScene = getDefMoodList(option);
|
|
209
|
+
if (option.isRefresh){
|
|
210
|
+
const res = await setRemoteMoodList(devId, defaultScene, SceneFeatureId)
|
|
211
|
+
if (res.success){
|
|
212
|
+
return {
|
|
213
|
+
success: true,
|
|
214
|
+
data: defaultScene.map((item, index) =>
|
|
215
|
+
remoteMoodInfo2MoodUIState(item, index, option)
|
|
216
|
+
),
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
208
220
|
const res = await NativeApi.getJson(devId, SceneFeatureId);
|
|
209
221
|
const isNormalData = Array.isArray(parseJSON(res?.data));
|
|
210
222
|
if (res.success && isNormalData) {
|
|
@@ -216,7 +228,6 @@ export const getRemoteMoodList = async (
|
|
|
216
228
|
};
|
|
217
229
|
} else {
|
|
218
230
|
if (res.msg?.includes('资源未找到') || !isNormalData) {
|
|
219
|
-
const defaultScene = getDefMoodList(option);
|
|
220
231
|
const res = await setRemoteMoodList(devId, defaultScene, SceneFeatureId);
|
|
221
232
|
if (res.success) {
|
|
222
233
|
return {
|
|
@@ -118,8 +118,9 @@ export default withTheme(MoodItem)
|
|
|
118
118
|
export function MixMoodColorsLine(props: { mixSubLight: MoodLampInfo; isMix: boolean, type: 'gradient' | 'separate' }) {
|
|
119
119
|
const { mixSubLight, isMix } = props;
|
|
120
120
|
const lightColors = !!(mixSubLight.enable && mixSubLight.nodes.length) ? mixSubLight.nodes?.map(n => {
|
|
121
|
+
const s = Math.round(mapFloatToRange(n.s / 100, 30, 100));
|
|
121
122
|
return n.isColorNode
|
|
122
|
-
? hsv2Hex(n.h,
|
|
123
|
+
? hsv2Hex(n.h, s, Math.round(mapFloatToRange(n.v / 100, 50, 100)))
|
|
123
124
|
: cctToColor(n.colorTemp.toFixed());
|
|
124
125
|
}) : ['#eee'];
|
|
125
126
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useReactive } from 'ahooks';
|
|
11
11
|
import Strings from '@ledvance/base/src/i18n';
|
|
12
12
|
import res from '@ledvance/base/src/res';
|
|
13
|
-
import { FlatList, StyleSheet, View, Platform } from 'react-native';
|
|
13
|
+
import { FlatList, StyleSheet, View, Platform, Image, TouchableOpacity } from 'react-native';
|
|
14
14
|
import Tag from '@ledvance/base/src/components/Tag';
|
|
15
15
|
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
16
16
|
import InfoText from '@ledvance/base/src/components/InfoText';
|
|
@@ -25,6 +25,8 @@ import { cloneDeep, filter, map } from 'lodash';
|
|
|
25
25
|
import { useFlagMode } from '../flags/FlagActions';
|
|
26
26
|
import { WorkMode } from '@ledvance/base/src/utils/interface';
|
|
27
27
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
28
|
+
import { showDialog } from '@ledvance/base/src/utils/common';
|
|
29
|
+
import I18n from '@ledvance/base/src/i18n';
|
|
28
30
|
|
|
29
31
|
const cx = Utils.RatioUtils.convertX;
|
|
30
32
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -63,17 +65,7 @@ const MoodPage = (props: {theme?: ThemeType}) => {
|
|
|
63
65
|
|
|
64
66
|
useEffect(() => {
|
|
65
67
|
state.timerId = setTimeout(() => {
|
|
66
|
-
|
|
67
|
-
getRemoteMoodList(
|
|
68
|
-
uaGroupInfo.tyGroupId.toString(),
|
|
69
|
-
params
|
|
70
|
-
).then(res => {
|
|
71
|
-
state.loading = false
|
|
72
|
-
if (res.success && Array.isArray(res.data)) {
|
|
73
|
-
state.originMoods = cloneDeep(res.data);
|
|
74
|
-
console.log(state.originMoods, '< --- originMoods')
|
|
75
|
-
}
|
|
76
|
-
});
|
|
68
|
+
getMoodList()
|
|
77
69
|
}, 250);
|
|
78
70
|
|
|
79
71
|
return () => {
|
|
@@ -93,6 +85,21 @@ const MoodPage = (props: {theme?: ThemeType}) => {
|
|
|
93
85
|
});
|
|
94
86
|
}, [state.staticTagChecked, state.dynamicTagChecked, state.originMoods]);
|
|
95
87
|
|
|
88
|
+
const getMoodList = (isRefresh?: boolean) =>{
|
|
89
|
+
state.loading = true
|
|
90
|
+
getRemoteMoodList(
|
|
91
|
+
uaGroupInfo.tyGroupId.toString(),
|
|
92
|
+
{...params, isRefresh}
|
|
93
|
+
).then(res => {
|
|
94
|
+
state.loading = false
|
|
95
|
+
if (res.success && Array.isArray(res.data)) {
|
|
96
|
+
state.originMoods = cloneDeep(res.data);
|
|
97
|
+
setMoods(cloneDeep(res.data));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
state.loading = false
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
const navigationRoute = (isStatic: boolean, mode: 'add' | 'edit', currentMood?: MoodUIInfo) => {
|
|
97
104
|
const path =
|
|
98
105
|
mode === 'add'
|
|
@@ -307,6 +314,21 @@ const MoodPage = (props: {theme?: ThemeType}) => {
|
|
|
307
314
|
}}
|
|
308
315
|
/>
|
|
309
316
|
</View>}
|
|
317
|
+
<TouchableOpacity style={{ alignItems: 'flex-end',paddingRight: cx(24) }}
|
|
318
|
+
onPress={() => {
|
|
319
|
+
showDialog({
|
|
320
|
+
method: 'confirm',
|
|
321
|
+
title: I18n.getLang('mood_resetbutton'),
|
|
322
|
+
subTitle: I18n.getLang('reset_mooddescription'),
|
|
323
|
+
onConfirm: (_, { close }) => {
|
|
324
|
+
close()
|
|
325
|
+
getMoodList(true)
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
<Image source={res.ic_refresh} style={{ width: cx(24), height: cx(24) }} />
|
|
331
|
+
</TouchableOpacity>
|
|
310
332
|
<Spacer height={cx(10)} />
|
|
311
333
|
{state.originMoods.length >= MAX_MOOD_COUNT && (
|
|
312
334
|
<View style={styles.infoLine}>
|
|
@@ -24,10 +24,11 @@ export interface ItemCardProps<T> {
|
|
|
24
24
|
is24Hour?: boolean,
|
|
25
25
|
onSwitch: (enable: boolean) => void
|
|
26
26
|
onPress: () => void
|
|
27
|
+
onLongPress: () => void
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
30
|
-
const {item, is24Hour, onSwitch, onPress} = props
|
|
31
|
+
const {item, is24Hour, onSwitch, onPress, onLongPress} = props
|
|
31
32
|
// 判断是否关闭
|
|
32
33
|
const closed = getIsClosed(item)
|
|
33
34
|
|
|
@@ -56,7 +57,7 @@ const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
|
56
57
|
},
|
|
57
58
|
})
|
|
58
59
|
return (
|
|
59
|
-
<Card style={styles.itemCard} onPress={onPress}>
|
|
60
|
+
<Card style={styles.itemCard} onPress={onPress} onLongPress={onLongPress}>
|
|
60
61
|
<Spacer height={cx(16)}/>
|
|
61
62
|
<View style={styles.switchLine}>
|
|
62
63
|
<Text style={styles.time}>
|
|
@@ -14,6 +14,7 @@ import ItemCard from "./ItemCard";
|
|
|
14
14
|
import {cloneDeep} from "lodash";
|
|
15
15
|
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
16
16
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
17
|
+
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
17
18
|
|
|
18
19
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
19
20
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -128,6 +129,19 @@ const RandomTimeForPlugPage = (props: { theme?: ThemeType}) => {
|
|
|
128
129
|
onPress={() => {
|
|
129
130
|
onAddOrEditItem('edit', item)
|
|
130
131
|
}}
|
|
132
|
+
onLongPress={async () =>{
|
|
133
|
+
showDialog({
|
|
134
|
+
method: 'confirm',
|
|
135
|
+
title: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_titel'),
|
|
136
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description'),
|
|
137
|
+
onConfirm: async (_, {close}) => {
|
|
138
|
+
close()
|
|
139
|
+
state.loading = true
|
|
140
|
+
await onPost('del', item)
|
|
141
|
+
state.loading = false
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}}
|
|
131
145
|
/>
|
|
132
146
|
)}
|
|
133
147
|
keyExtractor={(item: any) => `${item?.index}`}
|
|
@@ -14,6 +14,7 @@ import ItemCard from "./ItemCard";
|
|
|
14
14
|
import {cloneDeep} from "lodash";
|
|
15
15
|
import InfoText from "@ledvance/base/src/components/InfoText";
|
|
16
16
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
17
|
+
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
17
18
|
|
|
18
19
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
19
20
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -131,6 +132,19 @@ const RandomTimeForLightPage = (props: { theme?: ThemeType}) => {
|
|
|
131
132
|
onPress={() => {
|
|
132
133
|
onAddOrEditItem('edit', item)
|
|
133
134
|
}}
|
|
135
|
+
onLongPress={async () =>{
|
|
136
|
+
showDialog({
|
|
137
|
+
method: 'confirm',
|
|
138
|
+
title: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_titel'),
|
|
139
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description'),
|
|
140
|
+
onConfirm: async (_, {close}) => {
|
|
141
|
+
close()
|
|
142
|
+
state.loading = true
|
|
143
|
+
await onPost('del', item)
|
|
144
|
+
state.loading = false
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
}}
|
|
134
148
|
/>
|
|
135
149
|
)}
|
|
136
150
|
keyExtractor={(item: any) => `${item?.index}`}
|
|
@@ -10,7 +10,7 @@ import {useDeviceInfo, useSystemTimeFormate} from "@ledvance/base/src/models/mod
|
|
|
10
10
|
import {useReactive, useUpdateEffect} from "ahooks";
|
|
11
11
|
import CustomListDialog from "@ledvance/base/src/components/CustomListDialog";
|
|
12
12
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
13
|
-
import {convertMinutesTo12HourFormat, getIsClosed, loopText} from "@ledvance/base/src/utils/common";
|
|
13
|
+
import {convertMinutesTo12HourFormat, getIsClosed, loopText, showDialog} from "@ledvance/base/src/utils/common";
|
|
14
14
|
import TextButton from "@ledvance/base/src/components/TextButton";
|
|
15
15
|
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
16
16
|
import {cloneDeep} from "lodash";
|
|
@@ -49,6 +49,7 @@ const SleepWakeUpPage = (props: {theme?: ThemeType}) => {
|
|
|
49
49
|
sleepScheduleList: cloneDeep(sleepList),
|
|
50
50
|
wakeUpScheduleList: cloneDeep(wakeUpList),
|
|
51
51
|
filteredScheduleList: [] as any[],
|
|
52
|
+
loading: false
|
|
52
53
|
})
|
|
53
54
|
|
|
54
55
|
const isMaxNum = useMemo(() => {
|
|
@@ -192,7 +193,7 @@ const SleepWakeUpPage = (props: {theme?: ThemeType}) => {
|
|
|
192
193
|
alignItems: 'center'
|
|
193
194
|
},
|
|
194
195
|
emptyBtn: {
|
|
195
|
-
backgroundColor: props.theme?.button.
|
|
196
|
+
backgroundColor: props.theme?.button.active,
|
|
196
197
|
borderRadius: cx(5),
|
|
197
198
|
paddingHorizontal: cx(15),
|
|
198
199
|
paddingVertical: cx(10)
|
|
@@ -255,6 +256,7 @@ const SleepWakeUpPage = (props: {theme?: ThemeType}) => {
|
|
|
255
256
|
onHeadlineIconClick={() => {
|
|
256
257
|
state.showAddSchedulePopover = !state.showAddSchedulePopover
|
|
257
258
|
}}
|
|
259
|
+
loading={state.loading}
|
|
258
260
|
>
|
|
259
261
|
<View style={{ marginHorizontal: cx(24) }}>
|
|
260
262
|
<Text style={{ color: props.theme?.global.fontColor, fontSize: cx(12) }}>
|
|
@@ -302,6 +304,32 @@ const SleepWakeUpPage = (props: {theme?: ThemeType}) => {
|
|
|
302
304
|
settingTime: new Date().getTime()
|
|
303
305
|
})
|
|
304
306
|
}}
|
|
307
|
+
onLongPress={() =>{
|
|
308
|
+
showDialog({
|
|
309
|
+
method: 'confirm',
|
|
310
|
+
title: I18n.getLang(
|
|
311
|
+
item.isSleep
|
|
312
|
+
? 'cancel_dialog_delete_item_sleepschedule_titel'
|
|
313
|
+
: 'cancel_dialog_delete_item_wakeupschedule_titel'
|
|
314
|
+
),
|
|
315
|
+
subTitle: I18n.getLang(
|
|
316
|
+
item.isSleep
|
|
317
|
+
? 'cancel_dialog_delete_item_sleepschedule_description'
|
|
318
|
+
: 'cancel_dialog_delete_item_wakeupschedule_description'
|
|
319
|
+
),
|
|
320
|
+
onConfirm: async (_, { close }) => {
|
|
321
|
+
close();
|
|
322
|
+
if (state.loading) return;
|
|
323
|
+
state.loading = true;
|
|
324
|
+
await modDeleteTimeSchedule(
|
|
325
|
+
'del',
|
|
326
|
+
item.isSleep,
|
|
327
|
+
item
|
|
328
|
+
);
|
|
329
|
+
state.loading = false;
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
}}
|
|
305
333
|
/>
|
|
306
334
|
)}
|
|
307
335
|
ListHeaderComponent={() => (<Spacer height={cx(10)} />)}
|
|
@@ -374,16 +402,17 @@ const SleepWakeUpPage = (props: {theme?: ThemeType}) => {
|
|
|
374
402
|
)
|
|
375
403
|
}
|
|
376
404
|
|
|
377
|
-
const SleepWakeUpCard = ({ sleepWakeUp, is24HourClock, onSwitch, onPress, styles }: {
|
|
405
|
+
const SleepWakeUpCard = ({ sleepWakeUp, is24HourClock, onSwitch, onPress, onLongPress, styles }: {
|
|
378
406
|
sleepWakeUp: SleepWakeUpItem,
|
|
379
407
|
onSwitch: (enable: boolean) => void,
|
|
380
408
|
onPress: () => void
|
|
409
|
+
onLongPress: () => void
|
|
381
410
|
is24HourClock: boolean
|
|
382
411
|
styles: StyleSheet.NamedStyles<any>
|
|
383
412
|
}) => {
|
|
384
413
|
const closed = getIsClosed({weeks: sleepWakeUp.weeks, settingTime: sleepWakeUp.settingTime, endTime: getEndTime(sleepWakeUp)})
|
|
385
414
|
return (
|
|
386
|
-
<Card style={styles.randomTimingCard} onPress={onPress}>
|
|
415
|
+
<Card style={styles.randomTimingCard} onPress={onPress} onLongPress={onLongPress}>
|
|
387
416
|
<Spacer height={cx(16)} />
|
|
388
417
|
<View style={styles.switchLine}>
|
|
389
418
|
<Text style={styles.time}>
|
|
@@ -393,7 +422,7 @@ const SleepWakeUpCard = ({ sleepWakeUp, is24HourClock, onSwitch, onPress, styles
|
|
|
393
422
|
thumbStyle={{ elevation: 0 }}
|
|
394
423
|
onValueChange={onSwitch} />
|
|
395
424
|
</View>
|
|
396
|
-
<Text style={styles.loopText}>{loopText(sleepWakeUp.weeks, parseTimer(
|
|
425
|
+
<Text style={styles.loopText}>{loopText(sleepWakeUp.weeks, parseTimer(getEndTime(sleepWakeUp) * 60))}</Text>
|
|
397
426
|
<Spacer height={cx(5)} />
|
|
398
427
|
<Text style={styles.loopText}>{sleepWakeUp.name}</Text>
|
|
399
428
|
<Spacer height={cx(10)} />
|
|
@@ -15,11 +15,12 @@ interface ScheduleCardProps {
|
|
|
15
15
|
item: Timer
|
|
16
16
|
style?: ViewStyle
|
|
17
17
|
onEnableChange: (enable: boolean) => void
|
|
18
|
-
onPress: (
|
|
18
|
+
onPress: () => void
|
|
19
|
+
onLongPress: () => void
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const ScheduleCard = (props: ScheduleCardProps) => {
|
|
22
|
-
const { item, style, onEnableChange, onPress } = props;
|
|
23
|
+
const { item, style, onEnableChange, onPress, onLongPress } = props;
|
|
23
24
|
const is24HourClock = useSystemTimeFormate()
|
|
24
25
|
|
|
25
26
|
const styles = StyleSheet.create({
|
|
@@ -67,10 +68,8 @@ const ScheduleCard = (props: ScheduleCardProps) => {
|
|
|
67
68
|
<Card
|
|
68
69
|
style={styles.card}
|
|
69
70
|
containerStyle={[styles.container, style]}
|
|
70
|
-
onPress={
|
|
71
|
-
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
71
|
+
onPress={onPress}
|
|
72
|
+
onLongPress={onLongPress}>
|
|
74
73
|
<View style={styles.infoContainer}>
|
|
75
74
|
<Text style={styles.time}>{is24HourClock ? item.time : convertTo12HourFormat(item.time)}</Text>
|
|
76
75
|
<Text style={styles.loop}>
|
|
@@ -78,7 +78,7 @@ export function useTimerTasks(timerSettableDps: TimerSettableDp[], devIdGroup: s
|
|
|
78
78
|
dps[task.dp.code] = task.duration
|
|
79
79
|
const featureKey = timerSettableDps.find(timerSettableDp => timerSettableDp.dp.code === task.dp.code)?.cloudKey
|
|
80
80
|
devIdGroup.forEach(devId => {
|
|
81
|
-
NativeApi.putJson(devId, task.cloudKey ?? featureKey, JSON.stringify({ [getKey('Status', task.dp.code)]: !!task.duration, [getKey('StartTime', task.dp.code)]: task.startTime, progressAllNumber: task.duration }))
|
|
81
|
+
NativeApi.putJson(devId, task.cloudKey ?? featureKey, JSON.stringify({ [getKey('Status', task.dp.code)]: !!task.duration, [getKey('StartTime', task.dp.code)]: dayjs(task.startTime * 1000).format('YYYY-MM-DD HH:mm:ss'), progressAllNumber: task.duration }))
|
|
82
82
|
})
|
|
83
83
|
})
|
|
84
84
|
return dps
|