@ledvance/ui-biz-bundle 1.0.61 → 1.0.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/biorhythm/BiorhythmPage.tsx +2 -2
- package/src/modules/fixedTime/FixedTimeActions.ts +164 -0
- package/src/modules/fixedTime/FixedTimeDetailPage.tsx +372 -0
- package/src/modules/fixedTime/FixedTimePage.tsx +214 -0
- package/src/modules/history/HistoryPage.tsx +7 -2
- package/src/modules/mood/DynamicMoodEditorPage.tsx +2 -5
- package/src/modules/mood/MoodPage.tsx +17 -2
- package/src/modules/mood/StaticMoodEditorPage.tsx +2 -5
- package/src/modules/randomTime/RandomTimeActions.ts +149 -0
- package/src/modules/randomTime/RandomTimeDetailPage.tsx +337 -0
- package/src/modules/randomTime/RandomTimePage.tsx +215 -0
- package/src/modules/randomTime/Summary.tsx +123 -0
- package/src/modules/scene/SceneAction.ts +1 -1
- package/src/modules/sleepWakeup/DeviceState.tsx +6 -18
- package/src/modules/sleepWakeup/SleepWakeUpActions.ts +60 -50
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.tsx +4 -6
- package/src/modules/timeSchedule/DeviceState.tsx +2 -9
- package/src/modules/timeSchedule/ManualSetting.tsx +1 -8
- package/src/modules/timeSchedule/SingleLightView.tsx +5 -21
- package/src/modules/timeSchedule/TimeScheduleBean.ts +1 -0
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +3 -4
- package/src/navigation/Routers.ts +46 -0
package/package.json
CHANGED
|
@@ -61,8 +61,8 @@ const BiorhythmPage = () => {
|
|
|
61
61
|
const deviceInfo = useDeviceInfo()
|
|
62
62
|
const {productId} = deviceInfo
|
|
63
63
|
const devicesJudge = pIdList.some(val => val === productId)
|
|
64
|
-
const [sleepList, setSleepList] = useSleepPlan({sleep_mode: params.sleepPlanDp})
|
|
65
|
-
const [wakeUpList, setWakeUpList] = useWakeUpPlan({wakeup_mode: params.wakeUpPlanDp})
|
|
64
|
+
const [sleepList, setSleepList] = useSleepPlan({sleep_mode: params.sleepPlanDp}, true)
|
|
65
|
+
const [wakeUpList, setWakeUpList] = useWakeUpPlan({wakeup_mode: params.wakeUpPlanDp}, true)
|
|
66
66
|
const sleepWakeUpStatus = !![...sleepList, ...wakeUpList].filter(ele => ele.enable === 1).length
|
|
67
67
|
const state = useReactive<UIState>({
|
|
68
68
|
...biorhythm,
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useDeviceId, useSimpleDp } from "models/ldvModules/NativePropsSlice";
|
|
3
|
+
import { getFeature, putFeature } from "api/native";
|
|
4
|
+
import { Result } from "models/ldvModules/Result";
|
|
5
|
+
import { Formatter, Utils } from "@tuya/tuya-panel-lamp-sdk"
|
|
6
|
+
import { padStart } from "lodash";
|
|
7
|
+
import { useUpdateEffect } from "ahooks";
|
|
8
|
+
|
|
9
|
+
const { to16 } = Utils
|
|
10
|
+
|
|
11
|
+
const CycleTimer = new Formatter.CycleTimerFormatter()
|
|
12
|
+
|
|
13
|
+
const fixedFeatureId = 'cycle_timing'
|
|
14
|
+
|
|
15
|
+
export interface CycleTimer {
|
|
16
|
+
power: boolean;
|
|
17
|
+
channel: number;
|
|
18
|
+
weeks: number[];
|
|
19
|
+
startTime: number;
|
|
20
|
+
endTime: number;
|
|
21
|
+
openTime: number;
|
|
22
|
+
closeTime: number;
|
|
23
|
+
color: {
|
|
24
|
+
hue: number;
|
|
25
|
+
saturation: number;
|
|
26
|
+
value: number;
|
|
27
|
+
brightness: number;
|
|
28
|
+
temperature: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CycleTimerItem extends CycleTimer {
|
|
33
|
+
index: number | string
|
|
34
|
+
name: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
type UseFixedTimeType = (dpKey: string, disableFeature?: boolean) => [CycleTimerItem[], (fixedTimeList: CycleTimerItem[], manualEdit?: boolean) => Promise<{ success: boolean }>]
|
|
39
|
+
|
|
40
|
+
export const useFixedTime: UseFixedTimeType = (dpKey, disableFeature) => {
|
|
41
|
+
const deviceId = useDeviceId()
|
|
42
|
+
const [flag, setFlag] = useState(Symbol())
|
|
43
|
+
const [uiData, setUiData] = useState<CycleTimerItem[]>([])
|
|
44
|
+
const [fixedTime, setFixedTime]: [string, (v: string) => Promise<Result<any>>] = useSimpleDp(dpKey)
|
|
45
|
+
const fixedTimeList: CycleTimer[] = useMemo(() => CycleTimer.parse(fixedTime).nodes, [fixedTime])
|
|
46
|
+
const formatterFn = useCallback(() => {
|
|
47
|
+
return fixedTimeList.map((item, idx) => ({
|
|
48
|
+
...item,
|
|
49
|
+
index: idx,
|
|
50
|
+
name: `fixedPlan ${idx + 1}`
|
|
51
|
+
}))
|
|
52
|
+
}, [fixedTimeList])
|
|
53
|
+
// 获取云端数据
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
console.log('effect')
|
|
56
|
+
// 判断是否需要获取云端数据
|
|
57
|
+
if (disableFeature) {
|
|
58
|
+
const d = formatterFn()
|
|
59
|
+
setUiData(d)
|
|
60
|
+
} else {
|
|
61
|
+
getFeature(deviceId, fixedFeatureId).then(res => {
|
|
62
|
+
if (res?.result) {
|
|
63
|
+
// 首次进入同步云端数据 (云端无数据)
|
|
64
|
+
if (!res.data) {
|
|
65
|
+
const cloudData = fixedTimeList.map((item, idx) => ({
|
|
66
|
+
...item,
|
|
67
|
+
index: idx,
|
|
68
|
+
name: `fixedPlan ${idx + 1}`
|
|
69
|
+
}))
|
|
70
|
+
setFixedTimeFn(cloudData).then()
|
|
71
|
+
setUiData(cloudData)
|
|
72
|
+
} else {
|
|
73
|
+
const featureData = JSON.parse(res.data)
|
|
74
|
+
const mergeData = fixedTimeList.map((item, idx) => {
|
|
75
|
+
const getCloudItem = featureData.find(feature => feature?.v === fixedTimeToHex(item))
|
|
76
|
+
return ({
|
|
77
|
+
...item,
|
|
78
|
+
index: idx,
|
|
79
|
+
name: featureData[idx]?.v === fixedTimeToHex(item) ? featureData[idx]?.n : getCloudItem.n
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
setUiData(mergeData)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}, [fixedTimeList, flag])
|
|
88
|
+
|
|
89
|
+
useUpdateEffect(() => {
|
|
90
|
+
console.log('update effect')
|
|
91
|
+
}, [fixedTimeList])
|
|
92
|
+
|
|
93
|
+
const setFixedTimeFn = async (fixedTimeList: any[], manualEdit?: boolean) => {
|
|
94
|
+
const fixedData = fixedTimeList.map(item => ({
|
|
95
|
+
n: item?.name || '',
|
|
96
|
+
v: fixedTimeToHex(item)
|
|
97
|
+
}))
|
|
98
|
+
|
|
99
|
+
const cloudStatus = await putFeatureFn(deviceId, fixedFeatureId, JSON.stringify(fixedData))
|
|
100
|
+
if (cloudStatus) {
|
|
101
|
+
const fixedTimeFormatter = {
|
|
102
|
+
version: 0,
|
|
103
|
+
length: 16,
|
|
104
|
+
nodes: fixedTimeList
|
|
105
|
+
}
|
|
106
|
+
const hex = CycleTimer.format(fixedTimeFormatter)
|
|
107
|
+
const res = await setFixedTime(hex)
|
|
108
|
+
if (res.success) {
|
|
109
|
+
// 当只修改改名称时,需要手动刷新
|
|
110
|
+
if(manualEdit){
|
|
111
|
+
setFlag(Symbol())
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
success: true
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
return {
|
|
118
|
+
success: false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
return {
|
|
123
|
+
success: false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return [uiData, setFixedTimeFn];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let retryNumber = 0
|
|
132
|
+
|
|
133
|
+
const putFeatureFn = async (devId, featureId, data) => {
|
|
134
|
+
let status = false
|
|
135
|
+
await putFeature(devId, featureId, data).then(result => {
|
|
136
|
+
if (!result?.result && retryNumber < 3) {
|
|
137
|
+
retryNumber += 1
|
|
138
|
+
putFeatureFn(devId, featureId, data).then()
|
|
139
|
+
}
|
|
140
|
+
if (result?.result) {
|
|
141
|
+
retryNumber = 0
|
|
142
|
+
status = result.result
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
return status
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
const fixedTimeToHex = (fixedTime: CycleTimer) => {
|
|
150
|
+
const { weeks, startTime, endTime, openTime, closeTime } = fixedTime
|
|
151
|
+
const { hue, saturation, value, brightness, temperature } = fixedTime.color
|
|
152
|
+
const weeksValue: string = padStart([...weeks].reverse().join(''), 8, '0');
|
|
153
|
+
const weeksStr = to16(parseInt(weeksValue, 2), 2);
|
|
154
|
+
const startTimeStr = to16(startTime, 4);
|
|
155
|
+
const endTimeStr = to16(endTime, 4);
|
|
156
|
+
const openTimeStr = to16(openTime, 4);
|
|
157
|
+
const closeTimeStr = to16(closeTime, 4);
|
|
158
|
+
const hueStr = to16(hue, 4);
|
|
159
|
+
const saturationStr = to16(saturation);
|
|
160
|
+
const valueStr = to16(value);
|
|
161
|
+
const brightnessStr = to16(brightness);
|
|
162
|
+
const temperatureStr = to16(temperature);
|
|
163
|
+
return weeksStr + startTimeStr + endTimeStr + openTimeStr + closeTimeStr + hueStr + saturationStr + valueStr + brightnessStr + temperatureStr
|
|
164
|
+
}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet, View, Text, Image, TouchableOpacity } from "react-native";
|
|
3
|
+
import { useReactive, useUpdateEffect } from "ahooks";
|
|
4
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
5
|
+
import { useNavigation, useRoute } from '@react-navigation/core'
|
|
6
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
7
|
+
import res from "@ledvance/base/src/res";
|
|
8
|
+
import LdvTopName from "@ledvance/base/src/components/ldvTopName";
|
|
9
|
+
import TextField from "@ledvance/base/src/components/TextField";
|
|
10
|
+
import LdvWeekView from '@ledvance/base/src/components/weekSelect'
|
|
11
|
+
import { TimerPicker, Utils } from "tuya-panel-kit";
|
|
12
|
+
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
13
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
14
|
+
import { isTimeSpanValid, loopText, showDialog } from "@ledvance/base/src/utils/common";
|
|
15
|
+
import LdvPickerView from "@ledvance/base/src/components/ldvPickerView";
|
|
16
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
17
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
18
|
+
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
19
|
+
import { CycleTimerItem } from "./FixedTimeActions";
|
|
20
|
+
import { cloneDeep, isEqual } from "lodash";
|
|
21
|
+
import Summary from "pages/randomTime/Summary";
|
|
22
|
+
import { getSystemTimeFormat } from "@ledvance/base/src/api/native";
|
|
23
|
+
import { FixedTimePageParams } from "./FixedTimePage";
|
|
24
|
+
|
|
25
|
+
const { parseTimer } = Utils.TimeUtils
|
|
26
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
27
|
+
const { toFixedString } = Utils.NumberUtils;
|
|
28
|
+
|
|
29
|
+
export interface FixedTimeDetailPageParams extends FixedTimePageParams{
|
|
30
|
+
mode: 'add' | 'edit'
|
|
31
|
+
scheduleItem: CycleTimerItem
|
|
32
|
+
onPost: (mode: 'add' | 'edit' | 'del', fixedTime: CycleTimerItem, goBack?: boolean) => Promise<void>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const FixedTimeDetailPage = () => {
|
|
36
|
+
const navigation = useNavigation()
|
|
37
|
+
const params = useRoute().params as FixedTimeDetailPageParams
|
|
38
|
+
const state = useReactive({
|
|
39
|
+
loading: false,
|
|
40
|
+
isColorMode: false,
|
|
41
|
+
is24Hour: true,
|
|
42
|
+
selectedSkill: params.applyDps.length === 1 ? params.applyDps : [],
|
|
43
|
+
skillList: params.applyDps.length === 1 ? [] : params.applyDps,
|
|
44
|
+
fixedTime: params.mode === 'add' ? newFixedTime() : cloneDeep(params.scheduleItem)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const { brightness, temperature, hue, saturation, value } = state.fixedTime.color
|
|
49
|
+
const isColor = brightness === 0 && temperature === 0 && (hue !== 0 || saturation !== 0 || value !== 0)
|
|
50
|
+
state.isColorMode = isColor
|
|
51
|
+
}, [])
|
|
52
|
+
|
|
53
|
+
useEffect(() =>{
|
|
54
|
+
const getSystemTime = async () =>{
|
|
55
|
+
state.is24Hour = await getSystemTimeFormat() === 24
|
|
56
|
+
}
|
|
57
|
+
getSystemTime().then()
|
|
58
|
+
}, [])
|
|
59
|
+
|
|
60
|
+
useUpdateEffect(() => {
|
|
61
|
+
if (state.fixedTime.openTime === 0) state.fixedTime.openTime = 1
|
|
62
|
+
if (state.fixedTime.closeTime === 0) state.fixedTime.closeTime = 1
|
|
63
|
+
}, [state.fixedTime.openTime, state.fixedTime.closeTime])
|
|
64
|
+
|
|
65
|
+
const showClearIcon = useMemo(() => (
|
|
66
|
+
false
|
|
67
|
+
), [state.skillList])
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const maintenanceTime = () => {
|
|
72
|
+
const { startTime, endTime, closeTime, openTime } = state.fixedTime
|
|
73
|
+
const powered = openTime + closeTime
|
|
74
|
+
const compute = isTimeSpanValid({
|
|
75
|
+
startTime: [Math.trunc(startTime / 60), startTime % 60],
|
|
76
|
+
endTime: [Math.trunc(endTime / 60), endTime % 60]
|
|
77
|
+
})
|
|
78
|
+
return compute >= powered
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const showIcon = useCallback(() => {
|
|
82
|
+
return state.fixedTime.name?.length > 0 && state.fixedTime?.name.length <= 32 && maintenanceTime()
|
|
83
|
+
}, [state.fixedTime.name, maintenanceTime()])
|
|
84
|
+
|
|
85
|
+
const deleteDialog = () => {
|
|
86
|
+
return showDialog({
|
|
87
|
+
method: 'confirm',
|
|
88
|
+
title: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_titel'),
|
|
89
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
90
|
+
onConfirm: async (_, { close }) => {
|
|
91
|
+
close()
|
|
92
|
+
await params.onPost('del', state.fixedTime, true)
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const showBackDialog = useCallback(() => {
|
|
98
|
+
if (params.mode === 'add') return false
|
|
99
|
+
return !(state.fixedTime.name === params.scheduleItem.name &&
|
|
100
|
+
state.fixedTime.startTime === params.scheduleItem.startTime &&
|
|
101
|
+
state.fixedTime.endTime === params.scheduleItem.endTime &&
|
|
102
|
+
state.fixedTime.openTime === params.scheduleItem.openTime &&
|
|
103
|
+
state.fixedTime.closeTime === params.scheduleItem.closeTime &&
|
|
104
|
+
isEqual(state.fixedTime.color, params.scheduleItem.color)) &&
|
|
105
|
+
isEqual(state.fixedTime.weeks, params.scheduleItem.weeks)
|
|
106
|
+
}, [state.fixedTime, params.scheduleItem])
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Page
|
|
111
|
+
backText={I18n.getLang('fixedTimeCycle_socket_headline')}
|
|
112
|
+
onBackClick={!showBackDialog() ? navigation.goBack : undefined}
|
|
113
|
+
rightButtonIcon={showIcon() ? res.ic_check : res.ic_uncheck}
|
|
114
|
+
rightButtonDisabled={state.loading}
|
|
115
|
+
loading={state.loading}
|
|
116
|
+
showBackDialog={showBackDialog()}
|
|
117
|
+
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
118
|
+
backDialogContent={I18n.getLang('cancel_dialog_leave_unsaved_fixedtimecycle_note')}
|
|
119
|
+
rightButtonIconClick={async () => {
|
|
120
|
+
if (!showIcon()) return
|
|
121
|
+
state.loading = true
|
|
122
|
+
await params.onPost(params.mode, {
|
|
123
|
+
...state.fixedTime,
|
|
124
|
+
power: true,
|
|
125
|
+
color: {
|
|
126
|
+
hue: state.isColorMode ? state.fixedTime.color.hue : 0,
|
|
127
|
+
saturation: state.isColorMode ? state.fixedTime.color.saturation : 0,
|
|
128
|
+
value: state.isColorMode ? state.fixedTime.color.value : 0,
|
|
129
|
+
temperature: state.isColorMode ? 0 : state.fixedTime.color.temperature,
|
|
130
|
+
brightness: state.isColorMode ? 0 : state.fixedTime.color.brightness
|
|
131
|
+
}
|
|
132
|
+
}, true)
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
136
|
+
<LdvTopName title={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')} />
|
|
137
|
+
<TextField
|
|
138
|
+
style={styles.cardContainer}
|
|
139
|
+
value={state.fixedTime.name}
|
|
140
|
+
showError={state.fixedTime.name?.length > 32}
|
|
141
|
+
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
142
|
+
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
143
|
+
onChangeText={(t: string) => {
|
|
144
|
+
state.fixedTime.name = t;
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
{/* pick */}
|
|
148
|
+
<TimerPicker
|
|
149
|
+
itemTextColor='#aeadb5'
|
|
150
|
+
style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
|
|
151
|
+
is12Hours={!state.is24Hour}
|
|
152
|
+
startTime={state.fixedTime.startTime}
|
|
153
|
+
endTime={state.fixedTime.endTime}
|
|
154
|
+
onTimerChange={(startTime, endTime) => {
|
|
155
|
+
state.fixedTime.startTime = startTime
|
|
156
|
+
state.fixedTime.endTime = endTime
|
|
157
|
+
}} />
|
|
158
|
+
<LdvWeekView
|
|
159
|
+
value={state.fixedTime.weeks}
|
|
160
|
+
style={styles.cardContainer}
|
|
161
|
+
onSelect={(index: number) => {
|
|
162
|
+
const rawIndex = index - 1
|
|
163
|
+
state.fixedTime.weeks[rawIndex] = state.fixedTime.weeks[rawIndex] === 1 ? 0 : 1
|
|
164
|
+
}} />
|
|
165
|
+
<Spacer />
|
|
166
|
+
<Text style={styles.cardContainer}>{loopText(state.fixedTime.weeks)}</Text>
|
|
167
|
+
<Spacer />
|
|
168
|
+
{/* Apply for */}
|
|
169
|
+
<View style={styles.cardContainer}>
|
|
170
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
171
|
+
<Spacer height={cx(10)} />
|
|
172
|
+
<View style={styles.applyContent}>
|
|
173
|
+
{state.selectedSkill.length === 0 ?
|
|
174
|
+
<Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
175
|
+
state.selectedSkill.map((skill: any) => (
|
|
176
|
+
<View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]} key={skill.label}>
|
|
177
|
+
<Text style={{ color: '#000' }}>{skill.label}</Text>
|
|
178
|
+
{showClearIcon && <TouchableOpacity
|
|
179
|
+
onPress={() => { }}
|
|
180
|
+
style={{ paddingHorizontal: cx(5) }}>
|
|
181
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
|
|
182
|
+
</TouchableOpacity>}
|
|
183
|
+
</View>
|
|
184
|
+
))
|
|
185
|
+
}
|
|
186
|
+
</View>
|
|
187
|
+
{state.skillList.map((item: any) => {
|
|
188
|
+
return (
|
|
189
|
+
<TouchableOpacity style={styles.applyItem} key={item.label} onPress={() => { }}>
|
|
190
|
+
<Text style={{ color: '#000' }}>{item.label}</Text>
|
|
191
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
192
|
+
</TouchableOpacity>
|
|
193
|
+
)
|
|
194
|
+
})}
|
|
195
|
+
</View>
|
|
196
|
+
<Spacer />
|
|
197
|
+
{/* Devices */}
|
|
198
|
+
<View style={styles.cardContainer}>
|
|
199
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
|
|
200
|
+
<Spacer height={cx(10)} />
|
|
201
|
+
<Card>
|
|
202
|
+
<LdvSwitch
|
|
203
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
204
|
+
color={'#fff'}
|
|
205
|
+
colorAlpha={1}
|
|
206
|
+
enable={true}
|
|
207
|
+
setEnable={() => { }}
|
|
208
|
+
showSwitch={false}
|
|
209
|
+
/>
|
|
210
|
+
<LampAdjustView
|
|
211
|
+
isSupportColor={params.isSupportColor}
|
|
212
|
+
isSupportBrightness={params.isSupportBrightness}
|
|
213
|
+
isSupportTemperature={params.isSupportTemperature}
|
|
214
|
+
isColorMode={state.isColorMode}
|
|
215
|
+
reserveSV={true}
|
|
216
|
+
setIsColorMode={(v) => state.isColorMode = v}
|
|
217
|
+
h={state.fixedTime.color.hue}
|
|
218
|
+
s={state.fixedTime.color.saturation}
|
|
219
|
+
v={state.fixedTime.color.value}
|
|
220
|
+
colorTemp={state.fixedTime.color.temperature}
|
|
221
|
+
brightness={state.fixedTime.color.brightness}
|
|
222
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
223
|
+
state.fixedTime.color = {
|
|
224
|
+
...state.fixedTime.color,
|
|
225
|
+
hue: h,
|
|
226
|
+
saturation: s,
|
|
227
|
+
value: v
|
|
228
|
+
}
|
|
229
|
+
}}
|
|
230
|
+
onCCTChangeComplete={(v) => {
|
|
231
|
+
state.fixedTime.color = {
|
|
232
|
+
...state.fixedTime.color,
|
|
233
|
+
temperature: v
|
|
234
|
+
}
|
|
235
|
+
}}
|
|
236
|
+
onBrightnessChangeComplete={(v) => {
|
|
237
|
+
state.fixedTime.color = {
|
|
238
|
+
...state.fixedTime.color,
|
|
239
|
+
brightness: v
|
|
240
|
+
}
|
|
241
|
+
}}
|
|
242
|
+
/>
|
|
243
|
+
</Card>
|
|
244
|
+
<Spacer />
|
|
245
|
+
</View>
|
|
246
|
+
{/* Settings */}
|
|
247
|
+
<View style={styles.cardContainer}>
|
|
248
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}</Text>
|
|
249
|
+
<Spacer height={cx(10)} />
|
|
250
|
+
{!maintenanceTime() && <View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
251
|
+
<Image style={{ width: cx(16), height: cx(16), tintColor: 'rgb(255,149,0)' }} source={res.ic_warning_amber} />
|
|
252
|
+
<Text style={{ fontSize: cx(12), color: 'rgb(255,149,0)' }}>{I18n.getLang('addTimeCycle_warning_text')}</Text>
|
|
253
|
+
</View>}
|
|
254
|
+
<View >
|
|
255
|
+
<Text style={{ color: '#000', marginVertical: cx(10) }}>{I18n.getLang('addTimeCycle_settings_sec_text')}</Text>
|
|
256
|
+
<LdvPickerView
|
|
257
|
+
hour={toFixedString(Math.trunc(state.fixedTime.openTime / 60), 2)}
|
|
258
|
+
minute={toFixedString(state.fixedTime.openTime % 60, 2)}
|
|
259
|
+
setHour={(h) => {
|
|
260
|
+
state.fixedTime.openTime = Number(h) * 60 + state.fixedTime.openTime % 60
|
|
261
|
+
}}
|
|
262
|
+
setMinute={(m) => {
|
|
263
|
+
state.fixedTime.openTime = Math.trunc(state.fixedTime.openTime / 60) * 60 + Number(m)
|
|
264
|
+
}}
|
|
265
|
+
unit={['h', 'min']}
|
|
266
|
+
/>
|
|
267
|
+
</View>
|
|
268
|
+
<View>
|
|
269
|
+
<Text style={{ color: '#000', marginVertical: cx(10) }}>{I18n.getLang('addTimeCycle_settings_sec_text2')}</Text>
|
|
270
|
+
<LdvPickerView
|
|
271
|
+
hour={toFixedString(Math.trunc(state.fixedTime.closeTime / 60), 2)}
|
|
272
|
+
minute={toFixedString(state.fixedTime.closeTime % 60, 2)}
|
|
273
|
+
setHour={(h) => {
|
|
274
|
+
state.fixedTime.closeTime = Number(h) * 60 + state.fixedTime.closeTime % 60
|
|
275
|
+
}}
|
|
276
|
+
setMinute={(m) => {
|
|
277
|
+
state.fixedTime.closeTime = Math.trunc(state.fixedTime.closeTime / 60) * 60 + Number(m)
|
|
278
|
+
}}
|
|
279
|
+
unit={['h', 'min']}
|
|
280
|
+
/>
|
|
281
|
+
</View>
|
|
282
|
+
<Spacer />
|
|
283
|
+
</View>
|
|
284
|
+
{/* summary */}
|
|
285
|
+
<Summary
|
|
286
|
+
frequency={loopText(state.fixedTime.weeks)}
|
|
287
|
+
time={`${parseTimer(state.fixedTime.startTime * 60)} - ${parseTimer(state.fixedTime.endTime * 60)}`}
|
|
288
|
+
actions={(
|
|
289
|
+
<View style={{ flexDirection: 'column' }}>
|
|
290
|
+
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_4', `${Math.trunc(state.fixedTime.openTime / 60)}`, `${state.fixedTime.openTime % 60}`)}</Text>
|
|
291
|
+
<View style={styles.summaryTag}>
|
|
292
|
+
<Text style={{ color: '#000' }}>{I18n.getLang('timeschedule_add_schedule_nightlight_plug_selectionfield_text2')}</Text>
|
|
293
|
+
</View>
|
|
294
|
+
<Spacer height={cx(5)} />
|
|
295
|
+
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_6', `${Math.trunc(state.fixedTime.closeTime / 60)}`, `${state.fixedTime.closeTime % 60}`)}</Text>
|
|
296
|
+
<View style={styles.summaryTag}>
|
|
297
|
+
<Text style={{ color: '#000' }}>{I18n.getLang('timeschedule_add_schedule_nightlight_plug_selectionfield_text2')}</Text>
|
|
298
|
+
</View>
|
|
299
|
+
</View>
|
|
300
|
+
)}
|
|
301
|
+
/>
|
|
302
|
+
<Spacer />
|
|
303
|
+
{params.mode === 'edit' &&
|
|
304
|
+
<View style={{ marginHorizontal: cx(24) }}>
|
|
305
|
+
<DeleteButton
|
|
306
|
+
text={I18n.getLang('edit_fixedtimecycle_bttn_text')}
|
|
307
|
+
onPress={deleteDialog} />
|
|
308
|
+
</View>
|
|
309
|
+
}
|
|
310
|
+
<Spacer />
|
|
311
|
+
</ScrollView>
|
|
312
|
+
</Page>
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const newFixedTime = () => {
|
|
317
|
+
return {
|
|
318
|
+
name: '',
|
|
319
|
+
power: true,
|
|
320
|
+
weeks: [0, 0, 0, 0, 0, 0, 0],
|
|
321
|
+
startTime: 480,
|
|
322
|
+
endTime: 840,
|
|
323
|
+
closeTime: 1,
|
|
324
|
+
openTime: 1,
|
|
325
|
+
index: '',
|
|
326
|
+
channel: 1,
|
|
327
|
+
color: {
|
|
328
|
+
hue: 0,
|
|
329
|
+
saturation: 0,
|
|
330
|
+
value: 100,
|
|
331
|
+
brightness: 100,
|
|
332
|
+
temperature: 0,
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const styles = StyleSheet.create({
|
|
338
|
+
cardContainer: {
|
|
339
|
+
marginHorizontal: cx(24)
|
|
340
|
+
},
|
|
341
|
+
itemTitle: {
|
|
342
|
+
color: '#000',
|
|
343
|
+
fontSize: cx(16),
|
|
344
|
+
fontWeight: 'bold',
|
|
345
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
346
|
+
},
|
|
347
|
+
applyContent: {
|
|
348
|
+
backgroundColor: '#f6f6f6',
|
|
349
|
+
borderRadius: 4,
|
|
350
|
+
minHeight: cx(55),
|
|
351
|
+
flex: 1,
|
|
352
|
+
justifyContent: 'center',
|
|
353
|
+
paddingHorizontal: cx(10),
|
|
354
|
+
paddingTop: cx(10)
|
|
355
|
+
},
|
|
356
|
+
applyItem: {
|
|
357
|
+
paddingLeft: cx(5),
|
|
358
|
+
flexDirection: 'row',
|
|
359
|
+
justifyContent: 'space-between',
|
|
360
|
+
alignItems: 'center',
|
|
361
|
+
backgroundColor: '#fff',
|
|
362
|
+
height: cx(35),
|
|
363
|
+
},
|
|
364
|
+
summaryTag: {
|
|
365
|
+
backgroundColor: '#cbcbcb',
|
|
366
|
+
borderRadius: cx(16),
|
|
367
|
+
paddingHorizontal: cx(12),
|
|
368
|
+
alignSelf: 'flex-start'
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
export default FixedTimeDetailPage
|