@ledvance/group-ui-biz-bundle 1.0.43 → 1.0.45
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/BiorhythmPage.tsx +14 -22
- package/src/modules/fixedTimeForPlug/FixedTimeForPlugActon.ts +2 -0
- package/src/modules/fixedTimeForPlug/FixedTimeForPlugDetailPage.tsx +18 -3
- package/src/modules/fixedTimeForPlug/FixedTimeForPlugPage.tsx +1 -0
- package/src/modules/fixedTimeForPlug/ItemCard.tsx +5 -3
- package/src/modules/fixedTimingForLight/FixedTimingForLightAction.ts +1 -0
- package/src/modules/fixedTimingForLight/FixedTimingForLightDetailPage.tsx +19 -4
- package/src/modules/fixedTimingForLight/FixedTimingForLightPage.tsx +2 -1
- package/src/modules/fixedTimingForLight/ItemCard.tsx +5 -3
- package/src/modules/mood/AddMoodPage.tsx +2 -2
- package/src/modules/music/MusicActions.ts +1 -0
- package/src/modules/randomTimeForPlug/ItemCard.tsx +6 -3
- package/src/modules/randomTimeForPlug/RandomTimeForPlugAction.ts +2 -0
- package/src/modules/randomTimeForPlug/RandomTimeForPlugDetailPage.tsx +20 -3
- package/src/modules/randomTimeForPlug/RandomTimeForPlugPage.tsx +1 -0
- package/src/modules/randomTimingForLight/ItemCard.tsx +6 -3
- package/src/modules/randomTimingForLight/RandomTimingForLightAction.ts +1 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightDetailPage.tsx +27 -12
- package/src/modules/randomTimingForLight/RandomTimingForLightPage.tsx +2 -1
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ import { sortBy, cloneDeep } from 'lodash'
|
|
|
15
15
|
import iconList from './iconListData'
|
|
16
16
|
import pIdList from './pIdList'
|
|
17
17
|
import {
|
|
18
|
-
useDeviceId,
|
|
19
18
|
useDeviceInfo,
|
|
20
19
|
useGroupDevices,
|
|
21
20
|
} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
@@ -25,11 +24,10 @@ import res from '@ledvance/base/src/res'
|
|
|
25
24
|
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
26
25
|
import BiologicalRes from './res/BiologicalRes'
|
|
27
26
|
import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
|
|
28
|
-
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
29
27
|
import { setDataSource } from '@ledvance/base/src/components/weekSelect'
|
|
30
28
|
import { BiorhythmEditPageParams } from './BiorhythmDetailPage'
|
|
31
29
|
import { useBiorhythm } from './BiorhythmActions'
|
|
32
|
-
import { showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
|
|
30
|
+
import { showDialog as showCommonDialog, showDialog } from '@ledvance/base/src/utils/common'
|
|
33
31
|
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
34
32
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
35
33
|
import ApplyForDeviceList from '@ledvance/base/src/components/ApplyForDeviceList'
|
|
@@ -44,7 +42,6 @@ interface UIState extends BiorhythmBean {
|
|
|
44
42
|
showGradientTypeSelectModal: boolean;
|
|
45
43
|
flag: symbol;
|
|
46
44
|
weekString: string,
|
|
47
|
-
timeSchedule: any[]
|
|
48
45
|
loading: boolean
|
|
49
46
|
}
|
|
50
47
|
|
|
@@ -59,7 +56,6 @@ const BiorhythmPage = () => {
|
|
|
59
56
|
const navigation = useNavigation()
|
|
60
57
|
const params = useParams<BiorhythmPageParams>()
|
|
61
58
|
const [biorhythm, setBiorhythm] = useBiorhythm()
|
|
62
|
-
const deviceId = useDeviceId()
|
|
63
59
|
const deviceInfo = useDeviceInfo()
|
|
64
60
|
const [groupDevices] = useGroupDevices()
|
|
65
61
|
const { productId } = deviceInfo
|
|
@@ -70,7 +66,6 @@ const BiorhythmPage = () => {
|
|
|
70
66
|
showGradientTypeSelectModal: false,
|
|
71
67
|
flag: Symbol(),
|
|
72
68
|
weekString: '',
|
|
73
|
-
timeSchedule: [],
|
|
74
69
|
loading: false
|
|
75
70
|
})
|
|
76
71
|
|
|
@@ -257,21 +252,6 @@ const BiorhythmPage = () => {
|
|
|
257
252
|
return availableChart[randomIndex]
|
|
258
253
|
}
|
|
259
254
|
|
|
260
|
-
const reloadData = async () => {
|
|
261
|
-
const res: any = await NativeApi.getAllTaskTimer(deviceId)
|
|
262
|
-
console.log('reload data', res)
|
|
263
|
-
if (res.success && res.data) {
|
|
264
|
-
// 原生传过来的dps是json字符串。
|
|
265
|
-
if (Array.isArray(res.data) && res.data.length) {
|
|
266
|
-
state.timeSchedule = res.data
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
reloadData().then()
|
|
273
|
-
}, [])
|
|
274
|
-
|
|
275
255
|
return (
|
|
276
256
|
<>
|
|
277
257
|
<View style={{ flex: 1, flexDirection: 'column' }}>
|
|
@@ -305,7 +285,19 @@ const BiorhythmPage = () => {
|
|
|
305
285
|
thumbColor={'#f60'}
|
|
306
286
|
trackColor={{ false: '#00000026', true: '#ff660036' }}
|
|
307
287
|
onValueChange={async enable => {
|
|
308
|
-
|
|
288
|
+
if (enable) return showDialog({
|
|
289
|
+
method: 'confirm',
|
|
290
|
+
title: I18n.getLang('conflict_dialog_active_item_bio_rhythm_titel'),
|
|
291
|
+
subTitle: I18n.getLang('group_conflict_feature'),
|
|
292
|
+
confirmText: I18n.getLang('registration_dialog_button_yes'),
|
|
293
|
+
cancelText: I18n.getLang('registration_dialog_button_no'),
|
|
294
|
+
onConfirm: async (_, { close }) => {
|
|
295
|
+
state.loading = true
|
|
296
|
+
state.enable = enable
|
|
297
|
+
close()
|
|
298
|
+
state.flag = Symbol()
|
|
299
|
+
}
|
|
300
|
+
})
|
|
309
301
|
state.loading = true
|
|
310
302
|
state.enable = enable
|
|
311
303
|
state.flag = Symbol()
|
|
@@ -24,6 +24,7 @@ export interface FixedTimeItem {
|
|
|
24
24
|
weeks: number[]
|
|
25
25
|
startTime: number
|
|
26
26
|
endTime: number
|
|
27
|
+
settingTime: number
|
|
27
28
|
onTime: number
|
|
28
29
|
offTime: number
|
|
29
30
|
name?: string
|
|
@@ -72,6 +73,7 @@ const fixedTimeItemsFromBase64 = (base64Str: string): FixedTimeItem[] => {
|
|
|
72
73
|
endTime,
|
|
73
74
|
onTime,
|
|
74
75
|
offTime,
|
|
76
|
+
settingTime: new Date().getTime(),
|
|
75
77
|
name: `FixedTime ${items.length}`,
|
|
76
78
|
index: items.length
|
|
77
79
|
});
|
|
@@ -36,6 +36,7 @@ const newFixedTimeItem = (): FixedTimeItem => {
|
|
|
36
36
|
weeks: [0, 0, 0, 0, 0, 0, 0, 0],
|
|
37
37
|
startTime: startTime,
|
|
38
38
|
endTime: startTime + 60,
|
|
39
|
+
settingTime: new Date().getTime(),
|
|
39
40
|
onTime: 1,
|
|
40
41
|
offTime: 1
|
|
41
42
|
}
|
|
@@ -44,8 +45,9 @@ const newFixedTimeItem = (): FixedTimeItem => {
|
|
|
44
45
|
const FixedTimeForPlugDetailPage = () => {
|
|
45
46
|
const navigation = useNavigation()
|
|
46
47
|
const params = useRoute().params as FixedTimeDetailParam
|
|
48
|
+
const initItem = newFixedTimeItem();
|
|
47
49
|
const state = useReactive({
|
|
48
|
-
item: params.mode === 'add' ?
|
|
50
|
+
item: params.mode === 'add' ? cloneDeep(initItem) : cloneDeep(params.item),
|
|
49
51
|
onHour: '00',
|
|
50
52
|
onMinute: '01',
|
|
51
53
|
offHour: '00',
|
|
@@ -90,7 +92,7 @@ const FixedTimeForPlugDetailPage = () => {
|
|
|
90
92
|
}, [state.item.name, state.item.channel, isTimeEffective])
|
|
91
93
|
|
|
92
94
|
const showConfirm = useMemo(() => {
|
|
93
|
-
return params.mode === 'edit'
|
|
95
|
+
return !isEqual(state.item, params.mode === 'edit' ? params.item : initItem)
|
|
94
96
|
}, [JSON.stringify(state.item), JSON.stringify(params.item)])
|
|
95
97
|
|
|
96
98
|
const onSave = async () => {
|
|
@@ -100,7 +102,20 @@ const FixedTimeForPlugDetailPage = () => {
|
|
|
100
102
|
const item = cloneDeep(state.item)
|
|
101
103
|
item.onTime = parseTime(state.onHour, state.onMinute)
|
|
102
104
|
item.offTime = parseTime(state.offHour, state.offMinute)
|
|
103
|
-
|
|
105
|
+
item.settingTime = new Date().getTime()
|
|
106
|
+
showDialog({
|
|
107
|
+
method: 'confirm',
|
|
108
|
+
title: I18n.getLang('conflict_dialog_active_item_fixedtimecycle_titel'),
|
|
109
|
+
subTitle: I18n.getLang('group_conflict_feature'),
|
|
110
|
+
confirmText: I18n.getLang('registration_dialog_button_yes'),
|
|
111
|
+
cancelText: I18n.getLang('registration_dialog_button_no'),
|
|
112
|
+
onConfirm: async (_, { close }) => {
|
|
113
|
+
state.loading = true
|
|
114
|
+
close()
|
|
115
|
+
await params.onPost(params.mode, item, true);
|
|
116
|
+
state.loading = false
|
|
117
|
+
}
|
|
118
|
+
})
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
const onDelete = () => {
|
|
@@ -3,7 +3,7 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
3
3
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
4
4
|
import {StyleSheet, Text, View} from "react-native";
|
|
5
5
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
6
|
-
import {loopText} from "@ledvance/base/src/utils/common";
|
|
6
|
+
import {getIsClosed, loopText} from "@ledvance/base/src/utils/common";
|
|
7
7
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
8
8
|
import {FixedTimeItem} from "./FixedTimeForPlugActon";
|
|
9
9
|
|
|
@@ -19,6 +19,8 @@ export interface ItemCardProps {
|
|
|
19
19
|
|
|
20
20
|
const ItemCard = (props: ItemCardProps) => {
|
|
21
21
|
const {item, is24Hour, onSwitch, onPress} = props
|
|
22
|
+
// 判断是否关闭
|
|
23
|
+
const closed = getIsClosed(item)
|
|
22
24
|
return (
|
|
23
25
|
<Card style={styles.itemCard} onPress={onPress}>
|
|
24
26
|
<Spacer height={cx(16)}/>
|
|
@@ -32,11 +34,11 @@ const ItemCard = (props: ItemCardProps) => {
|
|
|
32
34
|
</Text>
|
|
33
35
|
<SwitchButton
|
|
34
36
|
style={styles.switchBtn}
|
|
35
|
-
value={item.enable}
|
|
37
|
+
value={item.enable && closed}
|
|
36
38
|
thumbStyle={{elevation: 0}}
|
|
37
39
|
onValueChange={onSwitch}/>
|
|
38
40
|
</View>
|
|
39
|
-
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.
|
|
41
|
+
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.endTime * 60))}</Text>
|
|
40
42
|
<Spacer height={cx(5)}/>
|
|
41
43
|
<Text style={styles.loopText}>{item.name}</Text>
|
|
42
44
|
<Spacer/>
|
|
@@ -39,6 +39,7 @@ const newFixedTimingItem = (): FixedTimingItem => {
|
|
|
39
39
|
weeks: [0, 0, 0, 0, 0, 0, 0],
|
|
40
40
|
startTime: startTime,
|
|
41
41
|
endTime: startTime + 60,
|
|
42
|
+
settingTime: new Date().getTime(),
|
|
42
43
|
openTime: 1,
|
|
43
44
|
closeTime: 1,
|
|
44
45
|
color: {
|
|
@@ -54,8 +55,9 @@ const newFixedTimingItem = (): FixedTimingItem => {
|
|
|
54
55
|
const FixedTimingForLightDetailPage = () => {
|
|
55
56
|
const navigation = useNavigation()
|
|
56
57
|
const params = useRoute().params as FixedTimeDetailParam
|
|
58
|
+
const initItem = newFixedTimingItem();
|
|
57
59
|
const state = useReactive({
|
|
58
|
-
item: params.mode === 'add' ?
|
|
60
|
+
item: params.mode === 'add' ? cloneDeep(initItem) : cloneDeep(params.item),
|
|
59
61
|
onHour: '00',
|
|
60
62
|
onMinute: '01',
|
|
61
63
|
offHour: '00',
|
|
@@ -106,7 +108,7 @@ const FixedTimingForLightDetailPage = () => {
|
|
|
106
108
|
}, [state.item.name, state.item.channel, isTimeEffective])
|
|
107
109
|
|
|
108
110
|
const showConfirm = useMemo(() => {
|
|
109
|
-
return params.mode === 'edit'
|
|
111
|
+
return !isEqual(state.item, params.mode === 'edit' ? params.item : initItem)
|
|
110
112
|
}, [JSON.stringify(state.item), JSON.stringify(params.item)])
|
|
111
113
|
|
|
112
114
|
const onSave = async () => {
|
|
@@ -123,11 +125,24 @@ const FixedTimingForLightDetailPage = () => {
|
|
|
123
125
|
value: state.isColorMode ? state.item.color.value : 0,
|
|
124
126
|
temperature: state.isColorMode ? 0 : state.item.color.temperature,
|
|
125
127
|
brightness: state.isColorMode ? 0 : state.item.color.brightness
|
|
126
|
-
}
|
|
128
|
+
},
|
|
129
|
+
settingTime: new Date().getTime()
|
|
127
130
|
};
|
|
128
131
|
item.openTime = parseTime(state.onHour, state.onMinute)
|
|
129
132
|
item.closeTime = parseTime(state.offHour, state.offMinute)
|
|
130
|
-
|
|
133
|
+
showDialog({
|
|
134
|
+
method: 'confirm',
|
|
135
|
+
title: I18n.getLang('conflict_dialog_active_item_fixedtimecycle_titel'),
|
|
136
|
+
subTitle: I18n.getLang('group_conflict_feature'),
|
|
137
|
+
confirmText: I18n.getLang('registration_dialog_button_yes'),
|
|
138
|
+
cancelText: I18n.getLang('registration_dialog_button_no'),
|
|
139
|
+
onConfirm: async (_, { close }) => {
|
|
140
|
+
state.loading = true
|
|
141
|
+
close()
|
|
142
|
+
await params.onPost(params.mode, item, true);
|
|
143
|
+
state.loading = false
|
|
144
|
+
}
|
|
145
|
+
})
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
const onDelete = () => {
|
|
@@ -14,7 +14,7 @@ import ItemCard from "./ItemCard";
|
|
|
14
14
|
import {cloneDeep} from "lodash";
|
|
15
15
|
|
|
16
16
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
17
|
-
const MAX_NUM =
|
|
17
|
+
const MAX_NUM = 4
|
|
18
18
|
|
|
19
19
|
const FixedTimeForLightPage = () => {
|
|
20
20
|
const devInfo = useDeviceInfo()
|
|
@@ -80,6 +80,7 @@ const FixedTimeForLightPage = () => {
|
|
|
80
80
|
await onPost('edit', {
|
|
81
81
|
...item,
|
|
82
82
|
power: v,
|
|
83
|
+
settingTime: new Date().getTime()
|
|
83
84
|
})
|
|
84
85
|
}}
|
|
85
86
|
onPress={() => {
|
|
@@ -3,7 +3,7 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
3
3
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
4
4
|
import {StyleSheet, Text, View} from "react-native";
|
|
5
5
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
6
|
-
import {loopText} from "@ledvance/base/src/utils/common";
|
|
6
|
+
import {getIsClosed, loopText} from "@ledvance/base/src/utils/common";
|
|
7
7
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
8
8
|
import {FixedTimingItem} from "./FixedTimingForLightAction";
|
|
9
9
|
|
|
@@ -19,6 +19,8 @@ export interface ItemCardProps {
|
|
|
19
19
|
|
|
20
20
|
const ItemCard = (props: ItemCardProps) => {
|
|
21
21
|
const {item, is24Hour, onSwitch, onPress} = props
|
|
22
|
+
// 判断是否关闭
|
|
23
|
+
const closed = getIsClosed(item)
|
|
22
24
|
return (
|
|
23
25
|
<Card style={styles.itemCard} onPress={onPress}>
|
|
24
26
|
<Spacer height={cx(16)}/>
|
|
@@ -32,11 +34,11 @@ const ItemCard = (props: ItemCardProps) => {
|
|
|
32
34
|
</Text>
|
|
33
35
|
<SwitchButton
|
|
34
36
|
style={styles.switchBtn}
|
|
35
|
-
value={item.power}
|
|
37
|
+
value={item.power && closed}
|
|
36
38
|
thumbStyle={{elevation: 0}}
|
|
37
39
|
onValueChange={onSwitch}/>
|
|
38
40
|
</View>
|
|
39
|
-
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.
|
|
41
|
+
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.endTime * 60))}</Text>
|
|
40
42
|
<Spacer height={cx(5)}/>
|
|
41
43
|
<Text style={styles.loopText}>{item.name}</Text>
|
|
42
44
|
<Spacer/>
|
|
@@ -76,7 +76,7 @@ const AddMoodPage = () => {
|
|
|
76
76
|
mode: 'add',
|
|
77
77
|
currentMood: index === 0 ? newMood(
|
|
78
78
|
id,
|
|
79
|
-
moduleParams.isSupportColor
|
|
79
|
+
moduleParams.isSupportColor,
|
|
80
80
|
routeParams.isStatic,
|
|
81
81
|
moduleParams
|
|
82
82
|
) : recommendMood2SceneUIState(item),
|
|
@@ -90,7 +90,7 @@ const AddMoodPage = () => {
|
|
|
90
90
|
mode: 'add',
|
|
91
91
|
currentMood: index === 0 ? newMood(
|
|
92
92
|
id,
|
|
93
|
-
moduleParams.isSupportColor
|
|
93
|
+
moduleParams.isSupportColor,
|
|
94
94
|
routeParams.isStatic,
|
|
95
95
|
moduleParams
|
|
96
96
|
) : recommendMood2SceneUIState(item),
|
|
@@ -44,6 +44,7 @@ export const useDreamMusicData = (musicOption: MusicPageParams) => {
|
|
|
44
44
|
dps[musicOption.musicDataDp] = v.phoneDpData
|
|
45
45
|
}
|
|
46
46
|
dps[musicOption.workModeDp] = WorkMode.Music
|
|
47
|
+
dps[musicOption.switchLedDp] = true
|
|
47
48
|
}else{
|
|
48
49
|
dps[musicOption.workModeDp] = v.lastWorkMode
|
|
49
50
|
}
|
|
@@ -3,7 +3,7 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
3
3
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
4
4
|
import {StyleSheet, Text, View} from "react-native";
|
|
5
5
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
6
|
-
import {loopText} from "@ledvance/base/src/utils/common";
|
|
6
|
+
import {getIsClosed, loopText} from "@ledvance/base/src/utils/common";
|
|
7
7
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
8
8
|
|
|
9
9
|
const {convertX: cx} = Utils.RatioUtils
|
|
@@ -14,6 +14,7 @@ export interface ItemCardProps<T> {
|
|
|
14
14
|
enable: boolean
|
|
15
15
|
startTime: number
|
|
16
16
|
endTime: number
|
|
17
|
+
settingTime: number
|
|
17
18
|
weeks: number[]
|
|
18
19
|
name?: string
|
|
19
20
|
},
|
|
@@ -24,6 +25,8 @@ export interface ItemCardProps<T> {
|
|
|
24
25
|
|
|
25
26
|
const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
26
27
|
const {item, is24Hour, onSwitch, onPress} = props
|
|
28
|
+
// 判断是否关闭
|
|
29
|
+
const closed = getIsClosed(item)
|
|
27
30
|
return (
|
|
28
31
|
<Card style={styles.itemCard} onPress={onPress}>
|
|
29
32
|
<Spacer height={cx(16)}/>
|
|
@@ -37,11 +40,11 @@ const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
|
37
40
|
</Text>
|
|
38
41
|
<SwitchButton
|
|
39
42
|
style={styles.switchBtn}
|
|
40
|
-
value={item.enable}
|
|
43
|
+
value={item.enable && closed}
|
|
41
44
|
thumbStyle={{elevation: 0}}
|
|
42
45
|
onValueChange={onSwitch}/>
|
|
43
46
|
</View>
|
|
44
|
-
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.
|
|
47
|
+
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.endTime * 60))}</Text>
|
|
45
48
|
<Spacer height={cx(5)}/>
|
|
46
49
|
<Text style={styles.loopText}>{item.name}</Text>
|
|
47
50
|
<Spacer/>
|
|
@@ -22,6 +22,7 @@ export interface RandomTimeItem {
|
|
|
22
22
|
weeks: number[]
|
|
23
23
|
startTime: number
|
|
24
24
|
endTime: number
|
|
25
|
+
settingTime: number
|
|
25
26
|
name?: string
|
|
26
27
|
index?: number
|
|
27
28
|
}
|
|
@@ -65,6 +66,7 @@ const randomTimeItemsFromBase64 = (base64Str: string): RandomTimeItem[] => {
|
|
|
65
66
|
weeks,
|
|
66
67
|
startTime,
|
|
67
68
|
endTime,
|
|
69
|
+
settingTime: new Date().getTime(),
|
|
68
70
|
name: `RandomTime ${items.length}`,
|
|
69
71
|
index: items.length
|
|
70
72
|
});
|
|
@@ -35,6 +35,7 @@ const newRandomTimeItem = (): RandomTimeItem => {
|
|
|
35
35
|
channel: 0,
|
|
36
36
|
weeks: [0, 0, 0, 0, 0, 0, 0, 0],
|
|
37
37
|
startTime: startTime,
|
|
38
|
+
settingTime: new Date().getTime(),
|
|
38
39
|
endTime: startTime + 30
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -42,8 +43,9 @@ const newRandomTimeItem = (): RandomTimeItem => {
|
|
|
42
43
|
const RandomTimeForPlugDetailPage = () => {
|
|
43
44
|
const navigation = useNavigation()
|
|
44
45
|
const params = useRoute().params as RandomTimeDetailParam
|
|
46
|
+
const initItem = newRandomTimeItem();
|
|
45
47
|
const state = useReactive({
|
|
46
|
-
item: params.mode === 'add' ?
|
|
48
|
+
item: params.mode === 'add' ? cloneDeep(initItem) : cloneDeep(params.item),
|
|
47
49
|
loading: false
|
|
48
50
|
})
|
|
49
51
|
|
|
@@ -52,7 +54,7 @@ const RandomTimeForPlugDetailPage = () => {
|
|
|
52
54
|
}, [state.item.name, state.item.channel])
|
|
53
55
|
|
|
54
56
|
const showConfirm = useMemo(() => {
|
|
55
|
-
return params.mode === 'edit'
|
|
57
|
+
return !isEqual(state.item, params.mode === 'edit' ? params.item : initItem)
|
|
56
58
|
}, [JSON.stringify(state.item), JSON.stringify(params.item)])
|
|
57
59
|
|
|
58
60
|
const onSave = async () => {
|
|
@@ -71,7 +73,22 @@ const RandomTimeForPlugDetailPage = () => {
|
|
|
71
73
|
})
|
|
72
74
|
return
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
showDialog({
|
|
77
|
+
method: 'confirm',
|
|
78
|
+
title: I18n.getLang('conflict_dialog_active_item_randomtimecycle_titel'),
|
|
79
|
+
subTitle: I18n.getLang('group_conflict_feature'),
|
|
80
|
+
confirmText: I18n.getLang('registration_dialog_button_yes'),
|
|
81
|
+
cancelText: I18n.getLang('registration_dialog_button_no'),
|
|
82
|
+
onConfirm: async (_, { close }) => {
|
|
83
|
+
state.loading = true
|
|
84
|
+
close()
|
|
85
|
+
await params.onPost(params.mode, cloneDeep({
|
|
86
|
+
...state.item,
|
|
87
|
+
settingTime: new Date().getTime()
|
|
88
|
+
}), true);
|
|
89
|
+
state.loading = false
|
|
90
|
+
}
|
|
91
|
+
})
|
|
75
92
|
}
|
|
76
93
|
|
|
77
94
|
const onDelete = () => {
|
|
@@ -3,7 +3,7 @@ import Card from "@ledvance/base/src/components/Card";
|
|
|
3
3
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
4
4
|
import {StyleSheet, Text, View} from "react-native";
|
|
5
5
|
import {SwitchButton, Utils} from "tuya-panel-kit";
|
|
6
|
-
import {loopText} from "@ledvance/base/src/utils/common";
|
|
6
|
+
import {getIsClosed, loopText} from "@ledvance/base/src/utils/common";
|
|
7
7
|
import {parseHour12} from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
8
8
|
|
|
9
9
|
const {convertX: cx} = Utils.RatioUtils
|
|
@@ -14,6 +14,7 @@ export interface ItemCardProps<T> {
|
|
|
14
14
|
power: boolean
|
|
15
15
|
startTime: number
|
|
16
16
|
endTime: number
|
|
17
|
+
settingTime: number
|
|
17
18
|
weeks: number[]
|
|
18
19
|
name?: string
|
|
19
20
|
},
|
|
@@ -24,6 +25,8 @@ export interface ItemCardProps<T> {
|
|
|
24
25
|
|
|
25
26
|
const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
26
27
|
const {item, is24Hour, onSwitch, onPress} = props
|
|
28
|
+
// 判断是否关闭
|
|
29
|
+
const closed = getIsClosed(item)
|
|
27
30
|
return (
|
|
28
31
|
<Card style={styles.itemCard} onPress={onPress}>
|
|
29
32
|
<Spacer height={cx(16)}/>
|
|
@@ -37,11 +40,11 @@ const ItemCard = <T, >(props: ItemCardProps<T>) => {
|
|
|
37
40
|
</Text>
|
|
38
41
|
<SwitchButton
|
|
39
42
|
style={styles.switchBtn}
|
|
40
|
-
value={item.power}
|
|
43
|
+
value={item.power && closed}
|
|
41
44
|
thumbStyle={{elevation: 0}}
|
|
42
45
|
onValueChange={onSwitch}/>
|
|
43
46
|
</View>
|
|
44
|
-
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.
|
|
47
|
+
<Text style={styles.loopText}>{loopText(item.weeks, parseTimer(item.endTime * 60))}</Text>
|
|
45
48
|
<Spacer height={cx(5)}/>
|
|
46
49
|
<Text style={styles.loopText}>{item.name}</Text>
|
|
47
50
|
<Spacer/>
|
|
@@ -38,6 +38,7 @@ const newRandomTimingItem = (): RandomTimingItem => {
|
|
|
38
38
|
weeks: [0, 0, 0, 0, 0, 0, 0],
|
|
39
39
|
startTime: startTime,
|
|
40
40
|
endTime: startTime + 60,
|
|
41
|
+
settingTime: new Date().getTime(),
|
|
41
42
|
color: {
|
|
42
43
|
hue: 0,
|
|
43
44
|
saturation: 100,
|
|
@@ -51,8 +52,9 @@ const newRandomTimingItem = (): RandomTimingItem => {
|
|
|
51
52
|
const RandomTimingForLightDetailPage = () => {
|
|
52
53
|
const navigation = useNavigation()
|
|
53
54
|
const params = useRoute().params as RandomTimeDetailParam
|
|
55
|
+
const initItem = newRandomTimingItem();
|
|
54
56
|
const state = useReactive({
|
|
55
|
-
item: params.mode === 'add' ?
|
|
57
|
+
item: params.mode === 'add' ? cloneDeep(initItem) : cloneDeep(params.item),
|
|
56
58
|
loading: false,
|
|
57
59
|
isColorMode: false
|
|
58
60
|
})
|
|
@@ -67,7 +69,7 @@ const RandomTimingForLightDetailPage = () => {
|
|
|
67
69
|
}, [state.item.name, state.item.channel])
|
|
68
70
|
|
|
69
71
|
const showConfirm = useMemo(() => {
|
|
70
|
-
return params.mode === 'edit'
|
|
72
|
+
return !isEqual(state.item, params.mode === 'edit' ? params.item : initItem)
|
|
71
73
|
}, [JSON.stringify(state.item), JSON.stringify(params.item)])
|
|
72
74
|
|
|
73
75
|
const onSave = async () => {
|
|
@@ -86,17 +88,30 @@ const RandomTimingForLightDetailPage = () => {
|
|
|
86
88
|
})
|
|
87
89
|
return
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
showDialog({
|
|
92
|
+
method: 'confirm',
|
|
93
|
+
title: I18n.getLang('conflict_dialog_active_item_randomtimecycle_titel'),
|
|
94
|
+
subTitle: I18n.getLang('group_conflict_feature'),
|
|
95
|
+
confirmText: I18n.getLang('registration_dialog_button_yes'),
|
|
96
|
+
cancelText: I18n.getLang('registration_dialog_button_no'),
|
|
97
|
+
onConfirm: async (_, { close }) => {
|
|
98
|
+
state.loading = true
|
|
99
|
+
close()
|
|
100
|
+
await params.onPost(params.mode, {
|
|
101
|
+
...state.item,
|
|
102
|
+
power: true,
|
|
103
|
+
color: {
|
|
104
|
+
hue: state.isColorMode ? state.item.color.hue : 0,
|
|
105
|
+
saturation: state.isColorMode ? state.item.color.saturation : 0,
|
|
106
|
+
value: state.isColorMode ? state.item.color.value : 0,
|
|
107
|
+
temperature: state.isColorMode ? 0 : state.item.color.temperature,
|
|
108
|
+
brightness: state.isColorMode ? 0 : state.item.color.brightness
|
|
109
|
+
},
|
|
110
|
+
settingTime: new Date().getTime()
|
|
111
|
+
}, true);
|
|
112
|
+
state.loading = false
|
|
98
113
|
}
|
|
99
|
-
}
|
|
114
|
+
})
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
const onDelete = () => {
|
|
@@ -14,7 +14,7 @@ import ItemCard from "./ItemCard";
|
|
|
14
14
|
import {cloneDeep} from "lodash";
|
|
15
15
|
|
|
16
16
|
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
17
|
-
const MAX_NUM =
|
|
17
|
+
const MAX_NUM = 4
|
|
18
18
|
|
|
19
19
|
const RandomTimeForLightPage = () => {
|
|
20
20
|
const devInfo = useDeviceInfo()
|
|
@@ -80,6 +80,7 @@ const RandomTimeForLightPage = () => {
|
|
|
80
80
|
await onPost('edit', {
|
|
81
81
|
...item,
|
|
82
82
|
power: v,
|
|
83
|
+
settingTime: new Date().getTime()
|
|
83
84
|
})
|
|
84
85
|
}}
|
|
85
86
|
onPress={() => {
|