@ledvance/ui-biz-bundle 1.1.56 → 1.1.58
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/FlagInfo.tsx +25 -25
- package/src/modules/flags/FlagPage.tsx +1 -1
- 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,232 @@
|
|
|
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 { hex2Int, spliceByStep } from "@ledvance/base/src/utils/common";
|
|
8
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
9
|
+
import { parseJSON } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
10
|
+
import { useUpdateEffect } from "ahooks";
|
|
11
|
+
import { Buffer } from "buffer";
|
|
12
|
+
const { to16 } = Utils
|
|
13
|
+
|
|
14
|
+
const randomFeatureId = 'random_timing'
|
|
15
|
+
const plug_randomFeatureId = 'random_time'
|
|
16
|
+
export interface RandomTimerData {
|
|
17
|
+
version: number
|
|
18
|
+
length: number
|
|
19
|
+
nodes: RandomTimer[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RandomTimer {
|
|
23
|
+
enable: boolean;
|
|
24
|
+
weeks: number[];
|
|
25
|
+
startTime: number;
|
|
26
|
+
endTime: number;
|
|
27
|
+
color?: {
|
|
28
|
+
h: number;
|
|
29
|
+
s: number;
|
|
30
|
+
v: number;
|
|
31
|
+
brightness: number;
|
|
32
|
+
temperature: number;
|
|
33
|
+
}
|
|
34
|
+
isColorMode?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface RandomTimerUiItem extends RandomTimer {
|
|
38
|
+
name: string
|
|
39
|
+
index?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PlugRandomTimer {
|
|
43
|
+
power: boolean;
|
|
44
|
+
weeks: number[];
|
|
45
|
+
startTime: number;
|
|
46
|
+
endTime: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface PlugRandomTimerItem extends PlugRandomTimer {
|
|
50
|
+
index: number | string
|
|
51
|
+
name: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let randomTimer
|
|
55
|
+
type UseFixedTimeType = (dpKey: string, isPlug?: boolean) => [RandomTimerUiItem[], (randomTimeList: RandomTimerUiItem[], manualEdit?: boolean) => Promise<{ success: boolean }>]
|
|
56
|
+
|
|
57
|
+
export const useRandomTime: UseFixedTimeType = (dpKey, isPlug) => {
|
|
58
|
+
const deviceId = useDeviceId()
|
|
59
|
+
const [randomTimeDp, setRandomTimeDp]: [string, (v: string) => Promise<Result<any>>] = useDp(dpKey)
|
|
60
|
+
const [randomTimeUiList, setRandomTimeUiList] = useState<RandomTimerUiItem[]>([])
|
|
61
|
+
const randomTimeList: RandomTimer[] = useMemo(() => randomTimeDp2Obj(randomTimeDp, isPlug)?.nodes || [], [randomTimeDp])
|
|
62
|
+
const formatterFn = useCallback(() => {
|
|
63
|
+
return randomTimeList.map((item, idx) => ({
|
|
64
|
+
...item,
|
|
65
|
+
index: idx,
|
|
66
|
+
name: `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
|
|
67
|
+
}))
|
|
68
|
+
}, [randomTimeList])
|
|
69
|
+
|
|
70
|
+
// 获取云端数据
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
randomTimer = setTimeout(() => {
|
|
73
|
+
getFeatureFn()
|
|
74
|
+
}, 400)
|
|
75
|
+
return () => clearTimeout(randomTimer)
|
|
76
|
+
}, [])
|
|
77
|
+
|
|
78
|
+
useUpdateEffect(() =>{
|
|
79
|
+
randomTimer = setTimeout(() => {
|
|
80
|
+
getFeatureFn()
|
|
81
|
+
}, 100)
|
|
82
|
+
return () => clearTimeout(randomTimer)
|
|
83
|
+
}, [randomTimeDp])
|
|
84
|
+
|
|
85
|
+
const getFeatureFn = () => {
|
|
86
|
+
getFeature(deviceId, isPlug ? plug_randomFeatureId : randomFeatureId).then(res => {
|
|
87
|
+
if (res?.result) {
|
|
88
|
+
// 首次进入同步云端数据 (云端无数据)
|
|
89
|
+
if (!res.data) {
|
|
90
|
+
const cloudData = formatterFn()
|
|
91
|
+
setRandomTimeFn(cloudData).then()
|
|
92
|
+
} else {
|
|
93
|
+
const featureData = parseJSON(res.data)
|
|
94
|
+
if (randomTimeList.length) {
|
|
95
|
+
const uiPlan = randomTimeList?.map((item, idx: number) => {
|
|
96
|
+
const featureItem = featureData.find(feature => (isPlug ? parseJSON(feature?.v)?.dp : feature?.v) === randomTimeToHex(item, isPlug))
|
|
97
|
+
return {
|
|
98
|
+
...item,
|
|
99
|
+
index: idx,
|
|
100
|
+
name: featureItem ? featureItem?.n : `${I18n.getLang('randomtimecycle_sockets_headline_text')} ${idx + 1}`
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
setRandomTimeUiList(uiPlan)
|
|
104
|
+
} else {
|
|
105
|
+
setRandomTimeUiList([])
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const setRandomTimeFn = async (randomTimeList: RandomTimerUiItem[]) => {
|
|
114
|
+
const randomData = randomTimeList.map(item => ({
|
|
115
|
+
n: item?.name || '',
|
|
116
|
+
v: isPlug ? JSON.stringify({dp: randomTimeToHex(item, isPlug)}) : randomTimeToHex(item, isPlug)
|
|
117
|
+
}))
|
|
118
|
+
const cloudStatus = await putFeatureFn(deviceId, isPlug ? plug_randomFeatureId : randomFeatureId, JSON.stringify(randomData))
|
|
119
|
+
if (cloudStatus) {
|
|
120
|
+
const randomTimerData = {
|
|
121
|
+
version: 0,
|
|
122
|
+
length: isPlug ? 6 : 12,
|
|
123
|
+
nodes: randomTimeList
|
|
124
|
+
}
|
|
125
|
+
let hex = randomTimeObj2Dp(randomTimerData, isPlug)
|
|
126
|
+
if(isPlug) hex = Buffer.from(hex, 'hex').toString('base64')
|
|
127
|
+
const res = await setRandomTimeDp(hex)
|
|
128
|
+
if (res.success) {
|
|
129
|
+
return {
|
|
130
|
+
success: true
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
success: false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return [randomTimeUiList, setRandomTimeFn];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let retryNumber = 0
|
|
143
|
+
|
|
144
|
+
const putFeatureFn = async (devId, featureId, data) => {
|
|
145
|
+
let status = false
|
|
146
|
+
await putFeature(devId, featureId, data).then(result => {
|
|
147
|
+
if (!result?.result && retryNumber < 3) {
|
|
148
|
+
retryNumber += 1
|
|
149
|
+
putFeatureFn(devId, featureId, data).then()
|
|
150
|
+
}
|
|
151
|
+
if (result?.result) {
|
|
152
|
+
retryNumber = 0
|
|
153
|
+
status = result.result
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
return status
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const randomTimeDp2Obj = (randomDp: string, isPlug?: boolean) => {
|
|
160
|
+
if (randomDp?.length <= 4) return
|
|
161
|
+
if(isPlug){
|
|
162
|
+
randomDp = Buffer.from(randomDp, 'base64').toString('hex')
|
|
163
|
+
}
|
|
164
|
+
const version = hex2Int(randomDp.slice(0, 2))
|
|
165
|
+
const length = hex2Int(randomDp.slice(2, 4))
|
|
166
|
+
const s = isPlug ? 0 : 4
|
|
167
|
+
const n = isPlug ? 12 : 24
|
|
168
|
+
const nodes = spliceByStep(randomDp.slice(s), n).map(plan => {
|
|
169
|
+
const enable = plan.slice(0, 2) === '01'
|
|
170
|
+
const weeks = parseInt(plan.slice(2, 4), 16).toString(2).padStart(8, '0')
|
|
171
|
+
.split('')
|
|
172
|
+
.reverse()
|
|
173
|
+
.map(v => parseInt(v, 10))
|
|
174
|
+
const startTime = hex2Int(plan.slice(4, 8))
|
|
175
|
+
const endTime = hex2Int(plan.slice(8, 12))
|
|
176
|
+
const common = {
|
|
177
|
+
enable, weeks, startTime, endTime
|
|
178
|
+
}
|
|
179
|
+
if (isPlug) {
|
|
180
|
+
return common
|
|
181
|
+
}
|
|
182
|
+
const h = hex2Int(plan.slice(12, 16))
|
|
183
|
+
const s = hex2Int(plan.slice(16, 18))
|
|
184
|
+
const v = hex2Int(plan.slice(18, 20))
|
|
185
|
+
const brightness = hex2Int(plan.slice(20, 22))
|
|
186
|
+
const temperature = hex2Int(plan.slice(22, 24))
|
|
187
|
+
return {
|
|
188
|
+
...common,
|
|
189
|
+
color: {
|
|
190
|
+
h, s, v,
|
|
191
|
+
brightness,
|
|
192
|
+
temperature
|
|
193
|
+
},
|
|
194
|
+
isColorMode: !!(h && s && v)
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
return {
|
|
198
|
+
version, length, nodes
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const randomTimeObj2Dp = (randomTimerData: RandomTimerData, isPlug?: boolean) => {
|
|
203
|
+
const { version, nodes, length } = randomTimerData
|
|
204
|
+
const versionHex = isPlug ? '' : to16(version)
|
|
205
|
+
const numHex = isPlug ? '' : to16(length)
|
|
206
|
+
const nodeHex = nodes.map(node => {
|
|
207
|
+
return randomTimeToHex(node, isPlug)
|
|
208
|
+
}).join('')
|
|
209
|
+
return versionHex + numHex + nodeHex
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
const randomTimeToHex = (randomTime: RandomTimer, isPlug?: boolean) => {
|
|
214
|
+
const { weeks, startTime, endTime, enable } = randomTime
|
|
215
|
+
const enableStr = enable ? '01' : '00'
|
|
216
|
+
const weeksValue: string = padStart([...weeks].reverse().join(''), 8, '0');
|
|
217
|
+
const weeksStr = to16(parseInt(weeksValue, 2), 2);
|
|
218
|
+
const startTimeStr = to16(startTime, 4);
|
|
219
|
+
const endTimeStr = to16(endTime, 4);
|
|
220
|
+
let colorHex = ''
|
|
221
|
+
if (!isPlug && randomTime.color) {
|
|
222
|
+
const { h, s, v, brightness, temperature } = randomTime.color
|
|
223
|
+
const hueStr = to16(h, 4);
|
|
224
|
+
const saturationStr = to16(s);
|
|
225
|
+
const valueStr = to16(v);
|
|
226
|
+
const brightnessStr = to16(brightness);
|
|
227
|
+
const temperatureStr = to16(temperature);
|
|
228
|
+
colorHex = hueStr + saturationStr + valueStr + brightnessStr + temperatureStr
|
|
229
|
+
}
|
|
230
|
+
return enableStr + weeksStr + startTimeStr + endTimeStr + colorHex
|
|
231
|
+
}
|
|
232
|
+
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet, View, Text, Image, TouchableOpacity } from "react-native";
|
|
3
|
+
import { useReactive } 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 LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
15
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
16
|
+
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
17
|
+
import { RandomTimerUiItem } from "./RandomTimeActions";
|
|
18
|
+
import { cloneDeep, isEqual } from "lodash";
|
|
19
|
+
import Summary from "./Summary";
|
|
20
|
+
import { RandomTimePageParams } from "./RandomTimePage";
|
|
21
|
+
import { Result } from "@ledvance/base/src/models/modules/Result";
|
|
22
|
+
import { useSystemTimeFormate } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
23
|
+
|
|
24
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
25
|
+
|
|
26
|
+
export interface RandomTimeDetailPageParams extends RandomTimePageParams {
|
|
27
|
+
mode: 'add' | 'edit'
|
|
28
|
+
scheduleItem: RandomTimerUiItem
|
|
29
|
+
onPost: (mode: 'add' | 'edit' | 'del', randomTime: RandomTimerUiItem) => Promise<Result<any>>
|
|
30
|
+
}
|
|
31
|
+
const minTimeGap = 30
|
|
32
|
+
const RandomTimeDetailPage = () => {
|
|
33
|
+
const navigation = useNavigation()
|
|
34
|
+
const params = useRoute().params as RandomTimeDetailPageParams
|
|
35
|
+
const is24Hour = useSystemTimeFormate()
|
|
36
|
+
const state = useReactive({
|
|
37
|
+
loading: false,
|
|
38
|
+
isColorMode: false,
|
|
39
|
+
selectedSkill: params.applyDps.length === 1 ? params.applyDps : [],
|
|
40
|
+
skillList: params.applyDps.length === 1 ? [] : params.applyDps,
|
|
41
|
+
randomTime: cloneDeep(params.scheduleItem)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!params.isPlug && state.randomTime.color) {
|
|
46
|
+
const { brightness, temperature, h, s, v } = state.randomTime.color
|
|
47
|
+
const isColor = brightness === 0 && temperature === 0 && (h !== 0 || s !== 0 || v !== 0)
|
|
48
|
+
state.isColorMode = isColor
|
|
49
|
+
}
|
|
50
|
+
}, [])
|
|
51
|
+
|
|
52
|
+
const showClearIcon = useMemo(() => (
|
|
53
|
+
false
|
|
54
|
+
), [state.skillList])
|
|
55
|
+
|
|
56
|
+
const canSubmit = useMemo(() => {
|
|
57
|
+
return state.randomTime.name?.length > 0 && state.randomTime.name?.length < 33 && !isEqual(params.scheduleItem, state.randomTime)
|
|
58
|
+
}, [JSON.stringify(state.randomTime)])
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Page
|
|
62
|
+
backText={I18n.getLang('randomtimecycle_sockets_headline_text')}
|
|
63
|
+
rightButtonIcon={canSubmit ? res.ic_check : res.ic_uncheck}
|
|
64
|
+
loading={state.loading}
|
|
65
|
+
showBackDialog={canSubmit}
|
|
66
|
+
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
67
|
+
backDialogContent={I18n.getLang('cancel_dialog_delete_item_randomtimecycle_description')}
|
|
68
|
+
headlineText={I18n.getLang(params.mode === 'add' ? 'add_fixedtimecycle_headline_text' : 'edit_fixedtimecycle_headline_text')}
|
|
69
|
+
rightButtonIconClick={async () => {
|
|
70
|
+
if (!canSubmit || state.loading) return
|
|
71
|
+
const { startTime, endTime} = state.randomTime
|
|
72
|
+
if(startTime < endTime && (endTime - startTime) < minTimeGap){
|
|
73
|
+
return showDialog({
|
|
74
|
+
method: 'alert',
|
|
75
|
+
title: I18n.getLang('conflict_dialog_save_item_randomtimecycle_tips'),
|
|
76
|
+
subTitle: I18n.getLang('conflict_dialog_save_item_randomtimecycle_interval_description'),
|
|
77
|
+
confirmText: I18n.getLang('conflict_dialog_save_item_randomtimecycle_answer_confirm_text'),
|
|
78
|
+
onConfirm: (_, { close}) =>{
|
|
79
|
+
close()
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
state.loading = true
|
|
84
|
+
const editRandomTime = {
|
|
85
|
+
...state.randomTime,
|
|
86
|
+
enable: true
|
|
87
|
+
}
|
|
88
|
+
if (!params.isPlug && state.randomTime.color) {
|
|
89
|
+
editRandomTime.color = {
|
|
90
|
+
h: state.isColorMode ? state.randomTime.color?.h : 0,
|
|
91
|
+
s: state.isColorMode ? state.randomTime.color?.s : 0,
|
|
92
|
+
v: state.isColorMode ? state.randomTime.color?.v : 0,
|
|
93
|
+
temperature: state.isColorMode ? 0 : state.randomTime.color?.temperature,
|
|
94
|
+
brightness: state.isColorMode ? 0 : state.randomTime.color?.brightness
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const res = await params.onPost(params.mode, editRandomTime)
|
|
98
|
+
state.loading = false
|
|
99
|
+
if (res.success) {
|
|
100
|
+
navigation.goBack()
|
|
101
|
+
}
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
105
|
+
<TextField
|
|
106
|
+
style={styles.cardContainer}
|
|
107
|
+
value={state.randomTime.name}
|
|
108
|
+
showError={state.randomTime.name?.length > 32}
|
|
109
|
+
maxLength={33}
|
|
110
|
+
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
111
|
+
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
112
|
+
onChangeText={(t: string) => {
|
|
113
|
+
state.randomTime.name = t;
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
{/* pick */}
|
|
117
|
+
<TimerPicker
|
|
118
|
+
itemTextColor='#aeadb5'
|
|
119
|
+
style={{ paddingVertical: cx(0), marginVertical: cx(0) }}
|
|
120
|
+
is12Hours={!is24Hour}
|
|
121
|
+
startTime={state.randomTime.startTime}
|
|
122
|
+
endTime={state.randomTime.endTime}
|
|
123
|
+
onTimerChange={(startTime, endTime) => {
|
|
124
|
+
state.randomTime.startTime = startTime
|
|
125
|
+
state.randomTime.endTime = endTime
|
|
126
|
+
}} />
|
|
127
|
+
<LdvWeekView
|
|
128
|
+
value={state.randomTime.weeks}
|
|
129
|
+
style={styles.cardContainer}
|
|
130
|
+
onSelect={(index: number) => {
|
|
131
|
+
const rawIndex = index - 1
|
|
132
|
+
state.randomTime.weeks[rawIndex] = state.randomTime.weeks[rawIndex] === 1 ? 0 : 1
|
|
133
|
+
}} />
|
|
134
|
+
<Spacer />
|
|
135
|
+
<Text style={styles.cardContainer}>{loopText(state.randomTime.weeks)}</Text>
|
|
136
|
+
<Spacer />
|
|
137
|
+
{/* Apply for */}
|
|
138
|
+
<View style={styles.cardContainer}>
|
|
139
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
140
|
+
<Spacer height={cx(10)} />
|
|
141
|
+
<View style={styles.applyContent}>
|
|
142
|
+
{state.selectedSkill.length === 0 ?
|
|
143
|
+
<Text>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
144
|
+
state.selectedSkill.map((skill: any) => (
|
|
145
|
+
<View style={[styles.applyItem, { marginBottom: cx(10), borderRadius: 4 }]} key={skill.label}>
|
|
146
|
+
<Text style={{ color: '#000' }}>{skill.label}</Text>
|
|
147
|
+
{showClearIcon && <TouchableOpacity
|
|
148
|
+
onPress={() => { }}
|
|
149
|
+
style={{ paddingHorizontal: cx(5) }}>
|
|
150
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.ic_arrows_nav_clear} />
|
|
151
|
+
</TouchableOpacity>}
|
|
152
|
+
</View>
|
|
153
|
+
))
|
|
154
|
+
}
|
|
155
|
+
</View>
|
|
156
|
+
{state.skillList.map((item: any) => {
|
|
157
|
+
return (
|
|
158
|
+
<TouchableOpacity style={styles.applyItem} key={item.label} onPress={() => { }}>
|
|
159
|
+
<Text style={{ color: '#000' }}>{item.label}</Text>
|
|
160
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
161
|
+
</TouchableOpacity>
|
|
162
|
+
)
|
|
163
|
+
})}
|
|
164
|
+
</View>
|
|
165
|
+
<Spacer />
|
|
166
|
+
{/* Devices */}
|
|
167
|
+
<View style={styles.cardContainer}>
|
|
168
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
|
|
169
|
+
<Spacer height={cx(10)} />
|
|
170
|
+
{state.randomTime.color && !params.isPlug && <Card>
|
|
171
|
+
<LdvSwitch
|
|
172
|
+
title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
173
|
+
color={'#fff'}
|
|
174
|
+
colorAlpha={1}
|
|
175
|
+
enable={true}
|
|
176
|
+
setEnable={() => { }}
|
|
177
|
+
showSwitch={false}
|
|
178
|
+
/>
|
|
179
|
+
<LampAdjustView
|
|
180
|
+
isSupportColor={params.isSupportColor}
|
|
181
|
+
isSupportBrightness={params.isSupportBrightness}
|
|
182
|
+
isSupportTemperature={params.isSupportTemperature}
|
|
183
|
+
isColorMode={state.isColorMode}
|
|
184
|
+
reserveSV={true}
|
|
185
|
+
setIsColorMode={(v) => state.isColorMode = v}
|
|
186
|
+
h={state.randomTime.color.h}
|
|
187
|
+
s={state.randomTime.color.s}
|
|
188
|
+
v={state.randomTime.color.v}
|
|
189
|
+
colorTemp={state.randomTime.color.temperature}
|
|
190
|
+
brightness={state.randomTime.color.brightness}
|
|
191
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
192
|
+
state.randomTime.color = {
|
|
193
|
+
...state.randomTime.color,
|
|
194
|
+
h,
|
|
195
|
+
s,
|
|
196
|
+
v
|
|
197
|
+
}
|
|
198
|
+
}}
|
|
199
|
+
onCCTChangeComplete={(v) => {
|
|
200
|
+
state.randomTime.color = {
|
|
201
|
+
...state.randomTime.color,
|
|
202
|
+
temperature: v
|
|
203
|
+
}
|
|
204
|
+
}}
|
|
205
|
+
onBrightnessChangeComplete={(v) => {
|
|
206
|
+
state.randomTime.color = {
|
|
207
|
+
...state.randomTime.color,
|
|
208
|
+
brightness: v
|
|
209
|
+
}
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
</Card>}
|
|
213
|
+
<Spacer />
|
|
214
|
+
</View>
|
|
215
|
+
{/* summary */}
|
|
216
|
+
<Summary
|
|
217
|
+
frequency={loopText(state.randomTime.weeks)}
|
|
218
|
+
time={`${convertMinutesTo12HourFormat(state.randomTime.startTime, is24Hour)} - ${convertMinutesTo12HourFormat(state.randomTime.endTime, is24Hour)}`}
|
|
219
|
+
hideActions={true}
|
|
220
|
+
/>
|
|
221
|
+
<Spacer />
|
|
222
|
+
{params.mode === 'edit' &&
|
|
223
|
+
<View style={{ marginHorizontal: cx(24) }}>
|
|
224
|
+
<DeleteButton
|
|
225
|
+
text={I18n.getLang('edit_fixedtimecycle_bttn_text')}
|
|
226
|
+
onPress={() => {
|
|
227
|
+
showDialog({
|
|
228
|
+
method: 'confirm',
|
|
229
|
+
title: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_titel'),
|
|
230
|
+
subTitle: I18n.getLang('cancel_dialog_delete_item_fixedtimecycle_description'),
|
|
231
|
+
onConfirm: async (_, { close }) => {
|
|
232
|
+
state.loading = true
|
|
233
|
+
close()
|
|
234
|
+
const res = await params.onPost('del', state.randomTime)
|
|
235
|
+
state.loading = false
|
|
236
|
+
if (res.success) {
|
|
237
|
+
navigation.goBack()
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
}} />
|
|
242
|
+
</View>
|
|
243
|
+
}
|
|
244
|
+
<Spacer />
|
|
245
|
+
</ScrollView>
|
|
246
|
+
</Page>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
const styles = StyleSheet.create({
|
|
252
|
+
cardContainer: {
|
|
253
|
+
marginHorizontal: cx(24)
|
|
254
|
+
},
|
|
255
|
+
itemTitle: {
|
|
256
|
+
color: '#000',
|
|
257
|
+
fontSize: cx(16),
|
|
258
|
+
fontWeight: 'bold',
|
|
259
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
260
|
+
},
|
|
261
|
+
applyContent: {
|
|
262
|
+
backgroundColor: '#f6f6f6',
|
|
263
|
+
borderRadius: 4,
|
|
264
|
+
minHeight: cx(55),
|
|
265
|
+
flex: 1,
|
|
266
|
+
justifyContent: 'center',
|
|
267
|
+
paddingHorizontal: cx(10),
|
|
268
|
+
paddingTop: cx(10)
|
|
269
|
+
},
|
|
270
|
+
applyItem: {
|
|
271
|
+
paddingLeft: cx(5),
|
|
272
|
+
flexDirection: 'row',
|
|
273
|
+
justifyContent: 'space-between',
|
|
274
|
+
alignItems: 'center',
|
|
275
|
+
backgroundColor: '#fff',
|
|
276
|
+
height: cx(35),
|
|
277
|
+
},
|
|
278
|
+
summaryContainer: {
|
|
279
|
+
flexDirection: 'row',
|
|
280
|
+
justifyContent: 'flex-start',
|
|
281
|
+
marginBottom: cx(10)
|
|
282
|
+
},
|
|
283
|
+
summaryLeft: {
|
|
284
|
+
flexDirection: 'row',
|
|
285
|
+
justifyContent: 'flex-start',
|
|
286
|
+
alignItems: 'center',
|
|
287
|
+
},
|
|
288
|
+
summaryImg: {
|
|
289
|
+
width: cx(12),
|
|
290
|
+
height: cx(12),
|
|
291
|
+
marginRight: cx(6)
|
|
292
|
+
},
|
|
293
|
+
leftTitle: {
|
|
294
|
+
fontSize: cx(14),
|
|
295
|
+
color: '#000'
|
|
296
|
+
},
|
|
297
|
+
summaryRight: {
|
|
298
|
+
flexDirection: 'column',
|
|
299
|
+
marginLeft: cx(21),
|
|
300
|
+
borderRadius: cx(16),
|
|
301
|
+
backgroundColor: '#cbcbcb',
|
|
302
|
+
},
|
|
303
|
+
rightItem: {
|
|
304
|
+
paddingHorizontal: cx(12),
|
|
305
|
+
color: '#000',
|
|
306
|
+
},
|
|
307
|
+
rightTitle: {
|
|
308
|
+
paddingLeft: cx(12),
|
|
309
|
+
paddingRight: cx(12),
|
|
310
|
+
fontSize: cx(10),
|
|
311
|
+
textAlign: 'center',
|
|
312
|
+
alignSelf: 'flex-start'
|
|
313
|
+
},
|
|
314
|
+
filletCorner: {
|
|
315
|
+
flexDirection: 'row',
|
|
316
|
+
backgroundColor: '#cbcbcb',
|
|
317
|
+
borderRadius: cx(16),
|
|
318
|
+
alignSelf: 'flex-start'
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
export default RandomTimeDetailPage
|