@ledvance/ui-biz-bundle 1.1.55 → 1.1.57
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 +2 -1
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTime/Router.ts +26 -0
- package/src/modules/flags/FlagActions.ts +12 -4
- package/src/modules/flags/FlagPage.tsx +31 -11
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/history/Router.ts +16 -0
- package/src/modules/mood/FantasyRouter.ts +35 -0
- package/src/modules/mood/MixMood/Router.ts +44 -0
- package/src/modules/mood/Router.ts +53 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/powerOnBehavior/Router.ts +16 -0
- package/src/modules/randomTime/Router.ts +25 -0
- package/src/modules/sleepWakeup/Router.ts +25 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.d.ts +0 -7
- package/src/navigation/Routers.ts +15 -304
- package/src/newModules/childLock/ChildLockPage.tsx +97 -0
- package/src/newModules/childLock/Router.ts +16 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
- package/src/newModules/energyConsumption/Router.ts +34 -0
- package/src/newModules/energyConsumption/co2Data.ts +23655 -0
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
- package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
- package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
- package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
- package/src/newModules/fixedTime/Router.ts +25 -0
- package/src/newModules/lightMode/LightModePage.tsx +204 -0
- package/src/newModules/lightMode/Router.ts +16 -0
- package/src/newModules/mood/AddMoodPage.tsx +178 -0
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
- package/src/newModules/mood/Interface.ts +219 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
- package/src/newModules/mood/MoodActions.ts +235 -0
- package/src/newModules/mood/MoodInfo.ts +2151 -0
- package/src/newModules/mood/MoodItem.tsx +148 -0
- package/src/newModules/mood/MoodPage.tsx +385 -0
- package/src/newModules/mood/MoodParse.ts +442 -0
- package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
- package/src/newModules/mood/Router.ts +53 -0
- package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
- package/src/newModules/mood/tools.ts +12 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
- package/src/newModules/overchargeSwitch/Router.ts +16 -0
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
- package/src/newModules/powerOnBehavior/Router.ts +16 -0
- package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
- package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
- package/src/newModules/randomTime/Router.ts +25 -0
- package/src/newModules/randomTime/Summary.tsx +116 -0
- package/src/newModules/swithInching/Router.ts +16 -0
- package/src/newModules/swithInching/SwithInching.tsx +231 -0
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
- package/src/newModules/swithInching/pickerView.tsx +91 -0
- package/src/newModules/timeSchedule/Interface.ts +111 -0
- package/src/newModules/timeSchedule/Router.ts +25 -0
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
3
|
+
import { getFeature, putFeature } from "@ledvance/base/src/api/native";
|
|
4
|
+
import { Result } from "@ledvance/base/src/models/modules/Result";
|
|
5
|
+
import { Utils } from "@tuya/tuya-panel-lamp-sdk"
|
|
6
|
+
import { padStart } from "lodash";
|
|
7
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
8
|
+
import { hex2Int, spliceByStep } from "@ledvance/base/src/utils/common";
|
|
9
|
+
import { parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
10
|
+
import { Buffer } from "buffer";
|
|
11
|
+
import { useUpdateEffect } from "ahooks";
|
|
12
|
+
|
|
13
|
+
const { to16 } = Utils
|
|
14
|
+
|
|
15
|
+
const fixedFeatureId = 'cycle_timing'
|
|
16
|
+
const plug_fixedFeatureId = 'cycle_time'
|
|
17
|
+
export interface FixedTimerData {
|
|
18
|
+
version: number
|
|
19
|
+
length: number
|
|
20
|
+
nodes: FixedTimer[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FixedTimer {
|
|
24
|
+
enable: boolean;
|
|
25
|
+
weeks: number[];
|
|
26
|
+
startTime: number;
|
|
27
|
+
endTime: number;
|
|
28
|
+
openTime: number;
|
|
29
|
+
closeTime: number;
|
|
30
|
+
color?: {
|
|
31
|
+
h: number;
|
|
32
|
+
s: number;
|
|
33
|
+
v: number;
|
|
34
|
+
brightness: number;
|
|
35
|
+
temperature: number;
|
|
36
|
+
};
|
|
37
|
+
isColorMode?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FixedTimerUiItem extends FixedTimer {
|
|
41
|
+
index?: number
|
|
42
|
+
name: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PlugFixedTimer {
|
|
46
|
+
power: boolean;
|
|
47
|
+
channel: number;
|
|
48
|
+
weeks: number[];
|
|
49
|
+
startTime: number;
|
|
50
|
+
endTime: number;
|
|
51
|
+
openTime: number;
|
|
52
|
+
closeTime: number;
|
|
53
|
+
}
|
|
54
|
+
let fixedTimer
|
|
55
|
+
type UseFixedTimeType = (dpKey: string, isPlug?: boolean) => [FixedTimerUiItem[], (fixedTimeList: FixedTimerUiItem[]) => Promise<{ success: boolean }>]
|
|
56
|
+
|
|
57
|
+
export const useFixedTime: UseFixedTimeType = (dpKey, isPlug) => {
|
|
58
|
+
const deviceId = useDeviceId()
|
|
59
|
+
const [fixedTimeDp, setFixedTimeDp]: [string, (v: string) => Promise<Result<any>>] = useDp(dpKey)
|
|
60
|
+
const [fixedTimeUiList, setFixedTimeUiList] = useState<FixedTimerUiItem[]>([])
|
|
61
|
+
const fixedTimeList: FixedTimer[] = useMemo(() => fixedTimeDp2Obj(fixedTimeDp, isPlug)?.nodes || [], [fixedTimeDp])
|
|
62
|
+
const formatterFn = useCallback(() => {
|
|
63
|
+
return fixedTimeList.map((item, idx) => ({
|
|
64
|
+
...item,
|
|
65
|
+
index: idx,
|
|
66
|
+
name: `${I18n.getLang('fixedTimeCycle_socket_headline')} ${idx + 1}`
|
|
67
|
+
}))
|
|
68
|
+
}, [fixedTimeList])
|
|
69
|
+
|
|
70
|
+
// 获取云端数据
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
fixedTimer = setTimeout(() => {
|
|
73
|
+
getFeatureFn()
|
|
74
|
+
}, 300)
|
|
75
|
+
return () => clearTimeout(fixedTimer)
|
|
76
|
+
}, [])
|
|
77
|
+
|
|
78
|
+
useUpdateEffect(() =>{
|
|
79
|
+
fixedTimer = setTimeout(() =>{
|
|
80
|
+
getFeatureFn()
|
|
81
|
+
}, 100)
|
|
82
|
+
return () => clearTimeout(fixedTimer)
|
|
83
|
+
}, [fixedTimeDp])
|
|
84
|
+
|
|
85
|
+
const getFeatureFn = () =>{
|
|
86
|
+
getFeature(deviceId, isPlug ? plug_fixedFeatureId : fixedFeatureId).then(res => {
|
|
87
|
+
if (res?.result) {
|
|
88
|
+
// 首次进入同步云端数据 (云端无数据)
|
|
89
|
+
if (!res.data) {
|
|
90
|
+
const cloudData = formatterFn()
|
|
91
|
+
setFixedTimeFn(cloudData).then()
|
|
92
|
+
} else {
|
|
93
|
+
const featureData = parseJSON(res.data)
|
|
94
|
+
if (fixedTimeList.length) {
|
|
95
|
+
const uiPlan = fixedTimeList?.map((item, idx: number) => {
|
|
96
|
+
const featureItem = featureData.find(feature => (isPlug ? parseJSON(feature?.v)?.dp : feature?.v) === fixedTimeToHex(item, isPlug))
|
|
97
|
+
return {
|
|
98
|
+
...item,
|
|
99
|
+
index: idx,
|
|
100
|
+
name: featureItem ? featureItem?.n : `${I18n.getLang('fixedTimeCycle_socket_headline')} ${idx + 1}`
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
setFixedTimeUiList(uiPlan)
|
|
104
|
+
} else {
|
|
105
|
+
setFixedTimeUiList([])
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const setFixedTimeFn = async (fixedTimeList: FixedTimerUiItem[]) => {
|
|
113
|
+
const fixedData = fixedTimeList.map(item => ({
|
|
114
|
+
n: item?.name || '',
|
|
115
|
+
v: isPlug ? JSON.stringify({dp: fixedTimeToHex(item, isPlug)}) : fixedTimeToHex(item, isPlug)
|
|
116
|
+
}))
|
|
117
|
+
const cloudStatus = await putFeatureFn(deviceId, isPlug ? plug_fixedFeatureId : fixedFeatureId, JSON.stringify(fixedData))
|
|
118
|
+
if (cloudStatus) {
|
|
119
|
+
const fixedTimerData = {
|
|
120
|
+
version: 0,
|
|
121
|
+
length: isPlug ? 10 : 16,
|
|
122
|
+
nodes: fixedTimeList
|
|
123
|
+
}
|
|
124
|
+
let hex = fixedTimeObj2Dp(fixedTimerData, isPlug)
|
|
125
|
+
if(isPlug) hex = Buffer.from(hex, 'hex').toString('base64')
|
|
126
|
+
const res = await setFixedTimeDp(hex)
|
|
127
|
+
if (res.success) {
|
|
128
|
+
return {
|
|
129
|
+
success: true
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
success: false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return [fixedTimeUiList, setFixedTimeFn];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let retryNumber = 0
|
|
142
|
+
|
|
143
|
+
const putFeatureFn = async (devId, featureId, data) => {
|
|
144
|
+
let status = false
|
|
145
|
+
await putFeature(devId, featureId, data).then(result => {
|
|
146
|
+
if (!result?.result && retryNumber < 3) {
|
|
147
|
+
retryNumber += 1
|
|
148
|
+
putFeatureFn(devId, featureId, data).then()
|
|
149
|
+
}
|
|
150
|
+
if (result?.result) {
|
|
151
|
+
retryNumber = 0
|
|
152
|
+
status = result.result
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
return status
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const fixedTimeDp2Obj = (fixedDp: string, isPlug?: boolean) => {
|
|
159
|
+
if (fixedDp?.length <= 4) return
|
|
160
|
+
if(isPlug){
|
|
161
|
+
fixedDp = Buffer.from(fixedDp, 'base64').toString('hex')
|
|
162
|
+
}
|
|
163
|
+
const version = hex2Int(fixedDp.slice(0, 2))
|
|
164
|
+
const length = hex2Int(fixedDp.slice(2, 4))
|
|
165
|
+
const s = isPlug ? 0 : 4
|
|
166
|
+
const n = isPlug ? 20 : 32
|
|
167
|
+
const nodes = spliceByStep(fixedDp.slice(s), n).map(plan => {
|
|
168
|
+
const enable = plan.slice(0, 2) === '01'
|
|
169
|
+
const weeks = parseInt(plan.slice(2, 4), 16).toString(2).padStart(8, '0')
|
|
170
|
+
.split('')
|
|
171
|
+
.reverse()
|
|
172
|
+
.map(v => parseInt(v, 10))
|
|
173
|
+
const startTime = hex2Int(plan.slice(4, 8))
|
|
174
|
+
const endTime = hex2Int(plan.slice(8, 12))
|
|
175
|
+
const openTime = hex2Int(plan.slice(12, 16))
|
|
176
|
+
const closeTime = hex2Int(plan.slice(16, 20))
|
|
177
|
+
const common = {
|
|
178
|
+
enable, weeks, startTime, endTime, openTime, closeTime
|
|
179
|
+
}
|
|
180
|
+
if (isPlug) {
|
|
181
|
+
return common
|
|
182
|
+
}
|
|
183
|
+
const h = hex2Int(plan.slice(20, 24))
|
|
184
|
+
const s = hex2Int(plan.slice(24, 26))
|
|
185
|
+
const v = hex2Int(plan.slice(26, 28))
|
|
186
|
+
const brightness = hex2Int(plan.slice(28, 30))
|
|
187
|
+
const temperature = hex2Int(plan.slice(30, 32))
|
|
188
|
+
return {
|
|
189
|
+
...common,
|
|
190
|
+
color: {
|
|
191
|
+
h, s, v,
|
|
192
|
+
brightness,
|
|
193
|
+
temperature
|
|
194
|
+
},
|
|
195
|
+
isColorMode: !!(h && s && v)
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
return {
|
|
199
|
+
version, length, nodes
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const fixedTimeObj2Dp = (randomTimerData: FixedTimerData, isPlug?: boolean) => {
|
|
204
|
+
const { version, nodes, length } = randomTimerData
|
|
205
|
+
const versionHex = isPlug ? '' : to16(version)
|
|
206
|
+
const numHex = isPlug ? '' : to16(length)
|
|
207
|
+
const nodeHex = nodes.map(node => {
|
|
208
|
+
return fixedTimeToHex(node, isPlug)
|
|
209
|
+
}).join('')
|
|
210
|
+
return versionHex + numHex + nodeHex
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
const fixedTimeToHex = (fixedTime: FixedTimer, isPlug?: boolean) => {
|
|
215
|
+
const { weeks, startTime, endTime, openTime, closeTime, enable } = fixedTime
|
|
216
|
+
const enableStr = enable ? '01' : '00'
|
|
217
|
+
const weeksValue: string = padStart([...weeks].reverse().join(''), 8, '0');
|
|
218
|
+
const weeksStr = to16(parseInt(weeksValue, 2), 2);
|
|
219
|
+
const startTimeStr = to16(startTime, 4);
|
|
220
|
+
const endTimeStr = to16(endTime, 4);
|
|
221
|
+
const openTimeStr = to16(openTime, 4);
|
|
222
|
+
const closeTimeStr = to16(closeTime, 4);
|
|
223
|
+
let colorHex = ''
|
|
224
|
+
if (!isPlug && fixedTime.color) {
|
|
225
|
+
const { h, s, v, brightness, temperature } = fixedTime.color
|
|
226
|
+
const hueStr = to16(h, 4);
|
|
227
|
+
const saturationStr = to16(s);
|
|
228
|
+
const valueStr = to16(v);
|
|
229
|
+
const brightnessStr = to16(brightness);
|
|
230
|
+
const temperatureStr = to16(temperature);
|
|
231
|
+
colorHex = hueStr + saturationStr + valueStr + brightnessStr + temperatureStr
|
|
232
|
+
}
|
|
233
|
+
return enableStr + weeksStr + startTimeStr + endTimeStr + openTimeStr + closeTimeStr + colorHex
|
|
234
|
+
}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import React, { 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 TextField from "@ledvance/base/src/components/TextField";
|
|
9
|
+
import LdvWeekView from '@ledvance/base/src/components/weekSelect'
|
|
10
|
+
import { TimerPicker, Utils } from "tuya-panel-kit";
|
|
11
|
+
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
12
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
13
|
+
import { convertMinutesTo12HourFormat, loopText, showDialog } from "@ledvance/base/src/utils/common";
|
|
14
|
+
import LdvPickerView from "@ledvance/base/src/components/ldvPickerView";
|
|
15
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
16
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
17
|
+
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
18
|
+
import { FixedTimerUiItem } from "./FixedTimeActions";
|
|
19
|
+
import { cloneDeep, isEqual } from "lodash";
|
|
20
|
+
import Summary from "../randomTime/Summary";
|
|
21
|
+
import { FixedTimePageParams } from "./FixedTimePage";
|
|
22
|
+
import { Result } from "@ledvance/base/src/models/modules/Result";
|
|
23
|
+
import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
24
|
+
|
|
25
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
26
|
+
const { toFixedString } = Utils.NumberUtils;
|
|
27
|
+
|
|
28
|
+
export interface FixedTimeDetailPageParams extends FixedTimePageParams {
|
|
29
|
+
mode: 'add' | 'edit'
|
|
30
|
+
scheduleItem: FixedTimerUiItem
|
|
31
|
+
onPost: (mode: 'add' | 'edit' | 'del', fixedTime: FixedTimerUiItem) => Promise<Result<any>>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const FixedTimeDetailPage = () => {
|
|
35
|
+
const navigation = useNavigation()
|
|
36
|
+
const params = useRoute().params as FixedTimeDetailPageParams
|
|
37
|
+
const is24Hour = useSystemTimeFormate()
|
|
38
|
+
const state = useReactive({
|
|
39
|
+
loading: false,
|
|
40
|
+
isColorMode: false,
|
|
41
|
+
selectedSkill: params.applyDps.length === 1 ? params.applyDps : [],
|
|
42
|
+
skillList: params.applyDps.length === 1 ? [] : params.applyDps,
|
|
43
|
+
fixedTime: cloneDeep(params.scheduleItem)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!params.isPlug && state.fixedTime.color) {
|
|
48
|
+
const { brightness, temperature, h, s, v } = state.fixedTime.color
|
|
49
|
+
const isColor = brightness === 0 && temperature === 0 && (h !== 0 || s !== 0 || v !== 0)
|
|
50
|
+
state.isColorMode = isColor
|
|
51
|
+
}
|
|
52
|
+
}, [])
|
|
53
|
+
|
|
54
|
+
useUpdateEffect(() => {
|
|
55
|
+
if (state.fixedTime.openTime === 0) state.fixedTime.openTime = 1
|
|
56
|
+
if (state.fixedTime.closeTime === 0) state.fixedTime.closeTime = 1
|
|
57
|
+
}, [state.fixedTime.openTime, state.fixedTime.closeTime])
|
|
58
|
+
|
|
59
|
+
const showClearIcon = useMemo(() => (
|
|
60
|
+
false
|
|
61
|
+
), [state.skillList])
|
|
62
|
+
|
|
63
|
+
const inRangeTime = useMemo(() => {
|
|
64
|
+
const { startTime, endTime, closeTime, openTime } = state.fixedTime
|
|
65
|
+
const poweredTime = openTime + closeTime
|
|
66
|
+
if (startTime <= endTime) {
|
|
67
|
+
return (endTime - startTime) >= poweredTime
|
|
68
|
+
} else {
|
|
69
|
+
return (1440 - endTime + startTime) >= poweredTime
|
|
70
|
+
}
|
|
71
|
+
}, [JSON.stringify(state.fixedTime)])
|
|
72
|
+
|
|
73
|
+
const canSubmit = useMemo(() => {
|
|
74
|
+
return state.fixedTime.name?.length > 0 && state.fixedTime.name?.length < 33 && !isEqual(state.fixedTime, params.scheduleItem) && inRangeTime
|
|
75
|
+
}, [JSON.stringify(state.fixedTime), inRangeTime])
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Page
|
|
79
|
+
backText={I18n.getLang('fixedTimeCycle_socket_headline')}
|
|
80
|
+
rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
|
|
81
|
+
loading={state.loading}
|
|
82
|
+
showBackDialog={canSubmit}
|
|
83
|
+
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
84
|
+
backDialogContent={I18n.getLang('cancel_dialog_leave_unsaved_fixedtimecycle_note')}
|
|
85
|
+
headlineText={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')}
|
|
86
|
+
rightButtonIconClick={async () => {
|
|
87
|
+
if (!canSubmit || state.loading) return
|
|
88
|
+
state.loading = true
|
|
89
|
+
const editFixedTime = {
|
|
90
|
+
...state.fixedTime,
|
|
91
|
+
enable: true
|
|
92
|
+
}
|
|
93
|
+
if (!params.isPlug && state.fixedTime.color) {
|
|
94
|
+
editFixedTime.color = {
|
|
95
|
+
h: state.isColorMode ? state.fixedTime.color?.h : 0,
|
|
96
|
+
s: state.isColorMode ? state.fixedTime.color?.s : 0,
|
|
97
|
+
v: state.isColorMode ? state.fixedTime.color?.v : 0,
|
|
98
|
+
temperature: state.isColorMode ? 0 : state.fixedTime.color?.temperature,
|
|
99
|
+
brightness: state.isColorMode ? 0 : state.fixedTime.color?.brightness
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const res = await params.onPost(params.mode, editFixedTime)
|
|
103
|
+
state.loading = false
|
|
104
|
+
if (res.success) {
|
|
105
|
+
navigation.goBack()
|
|
106
|
+
}
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
110
|
+
<TextField
|
|
111
|
+
style={styles.cardContainer}
|
|
112
|
+
value={state.fixedTime.name}
|
|
113
|
+
showError={state.fixedTime.name?.length > 32}
|
|
114
|
+
maxLength={33}
|
|
115
|
+
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
116
|
+
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
117
|
+
onChangeText={(t: string) => {
|
|
118
|
+
state.fixedTime.name = t;
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
{/* pick */}
|
|
122
|
+
<TimerPicker
|
|
123
|
+
itemTextColor='#aeadb5'
|
|
124
|
+
style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
|
|
125
|
+
is12Hours={!is24Hour}
|
|
126
|
+
startTime={state.fixedTime.startTime}
|
|
127
|
+
endTime={state.fixedTime.endTime}
|
|
128
|
+
onTimerChange={(startTime, endTime) => {
|
|
129
|
+
state.fixedTime.startTime = startTime
|
|
130
|
+
state.fixedTime.endTime = endTime
|
|
131
|
+
}} />
|
|
132
|
+
<LdvWeekView
|
|
133
|
+
value={state.fixedTime.weeks}
|
|
134
|
+
style={styles.cardContainer}
|
|
135
|
+
onSelect={(index: number) => {
|
|
136
|
+
const rawIndex = index - 1
|
|
137
|
+
state.fixedTime.weeks[rawIndex] = state.fixedTime.weeks[rawIndex] === 1 ? 0 : 1
|
|
138
|
+
}} />
|
|
139
|
+
<Spacer />
|
|
140
|
+
<Text style={styles.cardContainer}>{loopText(state.fixedTime.weeks)}</Text>
|
|
141
|
+
<Spacer />
|
|
142
|
+
{/* Apply for */}
|
|
143
|
+
<View style={styles.cardContainer}>
|
|
144
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
145
|
+
<Spacer height={cx(10)} />
|
|
146
|
+
<View style={styles.applyContent}>
|
|
147
|
+
{state.selectedSkill.length === 0 ?
|
|
148
|
+
<Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
149
|
+
state.selectedSkill.map((skill: any) => (
|
|
150
|
+
<View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]} key={skill.label}>
|
|
151
|
+
<Text style={{ color: '#000' }}>{skill.label}</Text>
|
|
152
|
+
{showClearIcon && <TouchableOpacity
|
|
153
|
+
onPress={() => { }}
|
|
154
|
+
style={{ paddingHorizontal: cx(5) }}>
|
|
155
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
|
|
156
|
+
</TouchableOpacity>}
|
|
157
|
+
</View>
|
|
158
|
+
))
|
|
159
|
+
}
|
|
160
|
+
</View>
|
|
161
|
+
{state.skillList.map((item: any) => {
|
|
162
|
+
return (
|
|
163
|
+
<TouchableOpacity style={styles.applyItem} key={item.label} onPress={() => { }}>
|
|
164
|
+
<Text style={{ color: '#000' }}>{item.label}</Text>
|
|
165
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
166
|
+
</TouchableOpacity>
|
|
167
|
+
)
|
|
168
|
+
})}
|
|
169
|
+
</View>
|
|
170
|
+
<Spacer />
|
|
171
|
+
{/* Devices */}
|
|
172
|
+
<View style={styles.cardContainer}>
|
|
173
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
|
|
174
|
+
<Spacer height={cx(10)} />
|
|
175
|
+
{state.fixedTime.color && !params.isPlug && <Card>
|
|
176
|
+
<LdvSwitch
|
|
177
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
178
|
+
color={'#fff'}
|
|
179
|
+
colorAlpha={1}
|
|
180
|
+
enable={true}
|
|
181
|
+
setEnable={() => { }}
|
|
182
|
+
showSwitch={false}
|
|
183
|
+
/>
|
|
184
|
+
<LampAdjustView
|
|
185
|
+
isSupportColor={params.isSupportColor}
|
|
186
|
+
isSupportBrightness={params.isSupportBrightness}
|
|
187
|
+
isSupportTemperature={params.isSupportTemperature}
|
|
188
|
+
isColorMode={state.isColorMode}
|
|
189
|
+
reserveSV={true}
|
|
190
|
+
setIsColorMode={(v) => state.isColorMode = v}
|
|
191
|
+
h={state.fixedTime.color.h}
|
|
192
|
+
s={state.fixedTime.color.s}
|
|
193
|
+
v={state.fixedTime.color.v}
|
|
194
|
+
colorTemp={state.fixedTime.color.temperature}
|
|
195
|
+
brightness={state.fixedTime.color.brightness}
|
|
196
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
197
|
+
state.fixedTime.color = {
|
|
198
|
+
...state.fixedTime.color,
|
|
199
|
+
h,
|
|
200
|
+
s,
|
|
201
|
+
v
|
|
202
|
+
}
|
|
203
|
+
}}
|
|
204
|
+
onCCTChangeComplete={(v) => {
|
|
205
|
+
state.fixedTime.color = {
|
|
206
|
+
...state.fixedTime.color,
|
|
207
|
+
temperature: v
|
|
208
|
+
}
|
|
209
|
+
}}
|
|
210
|
+
onBrightnessChangeComplete={(v) => {
|
|
211
|
+
state.fixedTime.color = {
|
|
212
|
+
...state.fixedTime.color,
|
|
213
|
+
brightness: v
|
|
214
|
+
}
|
|
215
|
+
}}
|
|
216
|
+
/>
|
|
217
|
+
</Card>}
|
|
218
|
+
<Spacer />
|
|
219
|
+
</View>
|
|
220
|
+
{/* Settings */}
|
|
221
|
+
<View style={styles.cardContainer}>
|
|
222
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}</Text>
|
|
223
|
+
<Spacer height={cx(10)} />
|
|
224
|
+
{!inRangeTime && <View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
225
|
+
<Image style={{ width: cx(16), height: cx(16), tintColor: 'rgb(255,149,0)' }} source={res.ic_warning_amber} />
|
|
226
|
+
<Text style={{ fontSize: cx(12), color: 'rgb(255,149,0)' }}>{I18n.getLang('addTimeCycle_warning_text')}</Text>
|
|
227
|
+
</View>}
|
|
228
|
+
<View >
|
|
229
|
+
<Text style={{ color: '#000', marginVertical: cx(10) }}>{I18n.getLang('addTimeCycle_settings_sec_text')}</Text>
|
|
230
|
+
<LdvPickerView
|
|
231
|
+
hour={toFixedString(Math.trunc(state.fixedTime.openTime / 60), 2)}
|
|
232
|
+
minute={toFixedString(state.fixedTime.openTime % 60, 2)}
|
|
233
|
+
setHour={(h) => {
|
|
234
|
+
state.fixedTime.openTime = Number(h) * 60 + state.fixedTime.openTime % 60
|
|
235
|
+
}}
|
|
236
|
+
setMinute={(m) => {
|
|
237
|
+
state.fixedTime.openTime = Math.trunc(state.fixedTime.openTime / 60) * 60 + Number(m)
|
|
238
|
+
}}
|
|
239
|
+
unit={['h', 'min']}
|
|
240
|
+
/>
|
|
241
|
+
</View>
|
|
242
|
+
<View>
|
|
243
|
+
<Text style={{ color: '#000', marginVertical: cx(10) }}>{I18n.getLang('addTimeCycle_settings_sec_text2')}</Text>
|
|
244
|
+
<LdvPickerView
|
|
245
|
+
hour={toFixedString(Math.trunc(state.fixedTime.closeTime / 60), 2)}
|
|
246
|
+
minute={toFixedString(state.fixedTime.closeTime % 60, 2)}
|
|
247
|
+
setHour={(h) => {
|
|
248
|
+
state.fixedTime.closeTime = Number(h) * 60 + state.fixedTime.closeTime % 60
|
|
249
|
+
}}
|
|
250
|
+
setMinute={(m) => {
|
|
251
|
+
state.fixedTime.closeTime = Math.trunc(state.fixedTime.closeTime / 60) * 60 + Number(m)
|
|
252
|
+
}}
|
|
253
|
+
unit={['h', 'min']}
|
|
254
|
+
/>
|
|
255
|
+
</View>
|
|
256
|
+
<Spacer />
|
|
257
|
+
</View>
|
|
258
|
+
{/* summary */}
|
|
259
|
+
<Summary
|
|
260
|
+
frequency={loopText(state.fixedTime.weeks)}
|
|
261
|
+
time={`${convertMinutesTo12HourFormat(state.fixedTime.startTime, is24Hour)} - ${convertMinutesTo12HourFormat(state.fixedTime.endTime, is24Hour)}`}
|
|
262
|
+
actions={(
|
|
263
|
+
<View style={{ flexDirection: 'column' }}>
|
|
264
|
+
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_4', `${Math.trunc(state.fixedTime.openTime / 60)}`, `${state.fixedTime.openTime % 60}`)}</Text>
|
|
265
|
+
<View style={styles.summaryTag}>
|
|
266
|
+
<Text style={{ color: '#000' }}>{state.selectedSkill[0]?.label || ''}</Text>
|
|
267
|
+
</View>
|
|
268
|
+
<Spacer height={cx(5)} />
|
|
269
|
+
<Text style={{ color: '#000' }}>{I18n.formatValue('feature_summary_action_txt_6', `${Math.trunc(state.fixedTime.closeTime / 60)}`, `${state.fixedTime.closeTime % 60}`)}</Text>
|
|
270
|
+
<View style={styles.summaryTag}>
|
|
271
|
+
<Text style={{ color: '#000' }}>{state.selectedSkill[0]?.label || ''}</Text>
|
|
272
|
+
</View>
|
|
273
|
+
</View>
|
|
274
|
+
)}
|
|
275
|
+
/>
|
|
276
|
+
<Spacer />
|
|
277
|
+
{params.mode === 'edit' &&
|
|
278
|
+
<View style={{ marginHorizontal: cx(24) }}>
|
|
279
|
+
<DeleteButton
|
|
280
|
+
text={I18n.getLang('edit_fixedtimecycle_bttn_text')}
|
|
281
|
+
onPress={() => {
|
|
282
|
+
showDialog({
|
|
283
|
+
method: 'confirm',
|
|
284
|
+
title: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_titel'),
|
|
285
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
286
|
+
onConfirm: async (_, { close }) => {
|
|
287
|
+
state.loading = true
|
|
288
|
+
close()
|
|
289
|
+
const res = await params.onPost('del', state.fixedTime)
|
|
290
|
+
state.loading = false
|
|
291
|
+
if (res.success) {
|
|
292
|
+
navigation.goBack()
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
}} />
|
|
297
|
+
<Spacer />
|
|
298
|
+
</View>
|
|
299
|
+
}
|
|
300
|
+
</ScrollView>
|
|
301
|
+
</Page>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
const styles = StyleSheet.create({
|
|
307
|
+
cardContainer: {
|
|
308
|
+
marginHorizontal: cx(24)
|
|
309
|
+
},
|
|
310
|
+
itemTitle: {
|
|
311
|
+
color: '#000',
|
|
312
|
+
fontSize: cx(16),
|
|
313
|
+
fontWeight: 'bold',
|
|
314
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
315
|
+
},
|
|
316
|
+
applyContent: {
|
|
317
|
+
backgroundColor: '#f6f6f6',
|
|
318
|
+
borderRadius: 4,
|
|
319
|
+
minHeight: cx(55),
|
|
320
|
+
flex: 1,
|
|
321
|
+
justifyContent: 'center',
|
|
322
|
+
paddingHorizontal: cx(10),
|
|
323
|
+
paddingTop: cx(10)
|
|
324
|
+
},
|
|
325
|
+
applyItem: {
|
|
326
|
+
paddingLeft: cx(5),
|
|
327
|
+
flexDirection: 'row',
|
|
328
|
+
justifyContent: 'space-between',
|
|
329
|
+
alignItems: 'center',
|
|
330
|
+
backgroundColor: '#fff',
|
|
331
|
+
height: cx(35),
|
|
332
|
+
},
|
|
333
|
+
summaryTag: {
|
|
334
|
+
backgroundColor: '#cbcbcb',
|
|
335
|
+
borderRadius: cx(16),
|
|
336
|
+
paddingHorizontal: cx(12),
|
|
337
|
+
alignSelf: 'flex-start'
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
export default FixedTimeDetailPage
|