@ledvance/ui-biz-bundle 1.1.69 → 1.1.71
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/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/package.json +74 -74
- package/rn-cli.config.js +8 -8
- package/src/hooks/DeviceDpStateHooks.d.ts +14 -14
- package/src/hooks/DeviceDpStateHooks.ts +50 -50
- package/src/modules/biorhythm/BiorhythmActions.d.ts +8 -8
- package/src/modules/biorhythm/BiorhythmActions.ts +324 -324
- package/src/modules/biorhythm/BiorhythmBean.d.ts +58 -58
- package/src/modules/biorhythm/BiorhythmBean.ts +230 -230
- package/src/modules/biorhythm/BiorhythmEditPage.d.ts +14 -14
- package/src/modules/biorhythm/BiorhythmEditPage.tsx +324 -324
- package/src/modules/biorhythm/BiorhythmPage.d.ts +10 -10
- package/src/modules/biorhythm/BiorhythmPage.tsx +796 -796
- package/src/modules/biorhythm/IconSelect.d.ts +2 -2
- package/src/modules/biorhythm/IconSelect.tsx +81 -81
- package/src/modules/biorhythm/Router.ts +34 -34
- package/src/modules/biorhythm/circular/ItemIcon.d.ts +22 -22
- package/src/modules/biorhythm/circular/ItemIcon.tsx +172 -172
- package/src/modules/biorhythm/circular/Progress.d.ts +24 -24
- package/src/modules/biorhythm/circular/Progress.tsx +411 -411
- package/src/modules/biorhythm/circular/TimeCircular.d.ts +11 -11
- package/src/modules/biorhythm/circular/TimeCircular.tsx +70 -70
- package/src/modules/biorhythm/iconListData.d.ts +7 -7
- package/src/modules/biorhythm/iconListData.ts +29 -29
- package/src/modules/biorhythm/pIdList.d.ts +2 -2
- package/src/modules/biorhythm/pIdList.ts +35 -35
- package/src/modules/biorhythm/res/BiologicalRes.d.ts +43 -43
- package/src/modules/biorhythm/res/BiologicalRes.ts +41 -41
- package/src/modules/config/ldvConfig.d.ts +2 -2
- package/src/modules/config/ldvConfig.tsx +18 -18
- package/src/modules/fixedTime/FixedTimeActions.ts +173 -173
- package/src/modules/fixedTime/FixedTimeDetailPage.tsx +372 -372
- package/src/modules/fixedTime/FixedTimePage.tsx +213 -213
- package/src/modules/fixedTime/Router.ts +26 -26
- package/src/modules/flags/FlagActions.ts +267 -267
- package/src/modules/flags/FlagEditPage.tsx +441 -441
- package/src/modules/flags/FlagInfo.tsx +563 -563
- package/src/modules/flags/FlagItem.tsx +90 -90
- package/src/modules/flags/FlagPage.tsx +277 -277
- package/src/modules/flags/Router.ts +25 -25
- package/src/modules/history/HistoryPage.d.ts +2 -2
- package/src/modules/history/HistoryPage.tsx +261 -261
- package/src/modules/history/Router.ts +16 -16
- package/src/modules/history/SwitchHistoryPageActions.d.ts +14 -14
- package/src/modules/history/SwitchHistoryPageActions.ts +76 -76
- package/src/modules/mood/AddMoodPage.d.ts +10 -10
- package/src/modules/mood/AddMoodPage.tsx +792 -792
- package/src/modules/mood/DynamicMoodEditorPage.d.ts +6 -6
- package/src/modules/mood/DynamicMoodEditorPage.tsx +561 -561
- package/src/modules/mood/FantasyMood.tsx +176 -176
- package/src/modules/mood/FantasyMoodEditPage.tsx +582 -582
- package/src/modules/mood/FantasyMoodItem.tsx +104 -104
- package/src/modules/mood/FantasyRouter.ts +35 -35
- package/src/modules/mood/MixMood/AddMixMoodPage.tsx +247 -247
- package/src/modules/mood/MixMood/MixMoodActions.ts +128 -128
- package/src/modules/mood/MixMood/MixMoodEditPage.tsx +721 -721
- package/src/modules/mood/MixMood/MixMoodItem.tsx +134 -134
- package/src/modules/mood/MixMood/MixMoodPage.tsx +326 -326
- package/src/modules/mood/MixMood/MixSceneBeans.ts +364 -364
- package/src/modules/mood/MixMood/RecommendMixMoodItem.tsx +69 -69
- package/src/modules/mood/MixMood/Router.ts +44 -44
- package/src/modules/mood/MoodItem.d.ts +11 -11
- package/src/modules/mood/MoodItem.tsx +114 -114
- package/src/modules/mood/MoodPage.d.ts +16 -16
- package/src/modules/mood/MoodPage.tsx +296 -296
- package/src/modules/mood/RecommendMoodItem.d.ts +13 -13
- package/src/modules/mood/RecommendMoodItem.tsx +74 -74
- package/src/modules/mood/Router.ts +53 -53
- package/src/modules/mood/StaticMoodEditorPage.d.ts +16 -16
- package/src/modules/mood/StaticMoodEditorPage.tsx +320 -320
- package/src/modules/mood/tools.d.ts +3 -3
- package/src/modules/mood/tools.ts +11 -11
- package/src/modules/music/MusicDataBean.d.ts +47 -47
- package/src/modules/music/MusicDataBean.ts +167 -167
- package/src/modules/music/MusicManager.d.ts +27 -27
- package/src/modules/music/MusicManager.ts +207 -207
- package/src/modules/music/MusicPage.d.ts +10 -10
- package/src/modules/music/MusicPage.tsx +347 -347
- package/src/modules/music/MusicPageActions.d.ts +35 -35
- package/src/modules/music/MusicPageActions.ts +317 -317
- package/src/modules/music/Router.ts +16 -16
- package/src/modules/music/SelecetGenre.d.ts +7 -7
- package/src/modules/music/SelecetGenre.tsx +63 -63
- package/src/modules/music/color.d.ts +2 -2
- package/src/modules/music/color.ts +73 -73
- package/src/modules/music/res/index.d.ts +10 -10
- package/src/modules/music/res/index.ts +9 -9
- package/src/modules/powerOnBehavior/PowerOnBehaviorActions.ts +11 -11
- package/src/modules/powerOnBehavior/PowerOnBehaviorPage.tsx +173 -173
- package/src/modules/powerOnBehavior/Router.ts +16 -16
- package/src/modules/randomTime/RandomTimeActions.ts +160 -160
- package/src/modules/randomTime/RandomTimeDetailPage.tsx +337 -337
- package/src/modules/randomTime/RandomTimePage.tsx +214 -214
- package/src/modules/randomTime/Router.ts +25 -25
- package/src/modules/randomTime/Summary.tsx +122 -122
- package/src/modules/scene/SceneAction.d.ts +13 -13
- package/src/modules/scene/SceneAction.ts +473 -473
- package/src/modules/scene/SceneDetailPage.d.ts +1 -1
- package/src/modules/scene/SceneDetailPage.tsx +421 -421
- package/src/modules/scene/SceneInfo.d.ts +72 -72
- package/src/modules/scene/SceneInfo.ts +1059 -1059
- package/src/modules/scene/ScenePage.d.ts +7 -7
- package/src/modules/scene/ScenePage.tsx +147 -147
- package/src/modules/select/SelectPage.d.ts +12 -12
- package/src/modules/select/SelectPage.tsx +137 -137
- package/src/modules/sleepWakeup/DeviceState.d.ts +9 -9
- package/src/modules/sleepWakeup/DeviceState.tsx +99 -99
- package/src/modules/sleepWakeup/LdvScheduleItem.d.ts +15 -15
- package/src/modules/sleepWakeup/LdvScheduleItem.tsx +176 -176
- package/src/modules/sleepWakeup/Router.ts +25 -25
- package/src/modules/sleepWakeup/SleepWakeUpActions.d.ts +2 -2
- package/src/modules/sleepWakeup/SleepWakeUpActions.ts +180 -180
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.d.ts +2 -2
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.tsx +616 -616
- package/src/modules/sleepWakeup/SleepWakeUpPage.d.ts +13 -13
- package/src/modules/sleepWakeup/SleepWakeUpPage.tsx +424 -424
- package/src/modules/sleepWakeup/utils.d.ts +44 -44
- package/src/modules/sleepWakeup/utils.ts +253 -253
- package/src/modules/timeSchedule/DeviceState.d.ts +17 -17
- package/src/modules/timeSchedule/DeviceState.tsx +94 -94
- package/src/modules/timeSchedule/LdvScheduleItem.d.ts +15 -15
- package/src/modules/timeSchedule/LdvScheduleItem.tsx +130 -130
- package/src/modules/timeSchedule/ManualSetting.d.ts +14 -14
- package/src/modules/timeSchedule/ManualSetting.tsx +219 -219
- package/src/modules/timeSchedule/MoodSetting.d.ts +11 -11
- package/src/modules/timeSchedule/MoodSetting.tsx +228 -228
- package/src/modules/timeSchedule/Router.ts +25 -25
- package/src/modules/timeSchedule/ScheduleScene.d.ts +6 -6
- package/src/modules/timeSchedule/ScheduleScene.tsx +144 -144
- package/src/modules/timeSchedule/SingleLightView.d.ts +12 -12
- package/src/modules/timeSchedule/SingleLightView.tsx +175 -175
- package/src/modules/timeSchedule/TimeScheduleBean.d.ts +14 -14
- package/src/modules/timeSchedule/TimeScheduleBean.ts +18 -18
- package/src/modules/timeSchedule/TimeScheduleEditpage.d.ts +6 -6
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +765 -765
- package/src/modules/timeSchedule/TimeSchedulePage.d.ts +13 -13
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +358 -358
- package/src/modules/timeSchedule/components/ColorList.ts +23 -23
- package/src/modules/timeSchedule/components/LampSwitchCard.tsx +106 -106
- package/src/modules/timeSchedule/mix/MixLightActions.d.ts +3 -3
- package/src/modules/timeSchedule/mix/MixLightActions.ts +49 -49
- package/src/modules/timeSchedule/mix/MixLightBean.d.ts +10 -10
- package/src/modules/timeSchedule/mix/MixLightBean.ts +9 -9
- package/src/modules/timeSchedule/mix/MixLightView.d.ts +7 -7
- package/src/modules/timeSchedule/mix/MixLightView.tsx +197 -197
- package/src/modules/timeSchedule/utils.d.ts +1 -1
- package/src/modules/timeSchedule/utils.ts +6 -6
- package/src/modules/timer/Router.ts +16 -16
- package/src/modules/timer/TimerPage.d.ts +11 -11
- package/src/modules/timer/TimerPage.tsx +384 -384
- package/src/modules/timer/TimerPageAction.d.ts +22 -22
- package/src/modules/timer/TimerPageAction.ts +131 -131
- package/src/navigation/Routers.d.ts +15 -15
- package/src/navigation/Routers.ts +46 -46
- package/src/navigation/tools.d.ts +9 -9
- package/src/navigation/tools.ts +21 -21
- package/src/newModules/biorhythm/BiorhythmActions.ts +62 -11
- package/src/newModules/biorhythm/BiorhythmPage.tsx +1 -4
- package/src/newModules/childLock/ChildLockPage.tsx +97 -97
- package/src/newModules/childLock/Router.ts +16 -16
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -23
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -84
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +322 -322
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +393 -393
- package/src/newModules/energyConsumption/Router.ts +34 -34
- package/src/newModules/energyConsumption/co2Data.ts +23655 -23655
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -93
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +284 -284
- package/src/newModules/energyConsumption/component/Overview.tsx +118 -118
- package/src/newModules/fixedTime/FixedTimeActions.ts +241 -241
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +345 -345
- package/src/newModules/fixedTime/FixedTimePage.tsx +302 -302
- package/src/newModules/fixedTime/Router.ts +25 -25
- package/src/newModules/lightMode/LightModePage.tsx +204 -204
- package/src/newModules/lightMode/Router.ts +16 -16
- package/src/newModules/mood/Interface.ts +5 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +8 -5
- package/src/newModules/mood/MoodActions.ts +32 -20
- package/src/newModules/mood/MoodItem.tsx +3 -3
- package/src/newModules/mood/MoodPage.tsx +31 -15
- package/src/newModules/mood/MoodParse.ts +5 -6
- package/src/newModules/mood/RecommendMoodItem.tsx +3 -3
- package/src/newModules/mood/Router.ts +9 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -96
- package/src/newModules/overchargeSwitch/Router.ts +16 -16
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -266
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -173
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -106
- package/src/newModules/powerOnBehavior/Router.ts +27 -27
- package/src/newModules/randomTime/RandomTimeActions.ts +238 -238
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +325 -325
- package/src/newModules/randomTime/RandomTimePage.tsx +299 -299
- package/src/newModules/randomTime/Router.ts +25 -25
- package/src/newModules/randomTime/Summary.tsx +116 -116
- package/src/newModules/remoteControl/RemoteControlActions.ts +5 -5
- package/src/newModules/remoteControl/RemoteControlPage.tsx +51 -51
- package/src/newModules/remoteControl/Router.ts +15 -15
- package/src/newModules/select/Route.ts +16 -16
- package/src/newModules/select/SelectPage.d.ts +12 -12
- package/src/newModules/select/SelectPage.tsx +137 -137
- package/src/newModules/sleepWakeUp/Interface.ts +69 -69
- package/src/newModules/sleepWakeUp/Router.ts +24 -24
- package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +317 -317
- package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +661 -661
- package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +455 -455
- package/src/newModules/sleepWakeUp/utils.ts +253 -253
- package/src/newModules/swithInching/Router.ts +16 -16
- package/src/newModules/swithInching/SwithInching.tsx +231 -231
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -55
- package/src/newModules/swithInching/pickerView.tsx +91 -91
- package/src/newModules/timeSchedule/Interface.ts +142 -142
- package/src/newModules/timeSchedule/Router.ts +25 -25
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -53
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +648 -648
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +253 -253
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +460 -460
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +125 -125
- package/tsconfig.json +50 -50
|
@@ -1,617 +1,617 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from "react";
|
|
2
|
-
import { FlatList, ScrollView, StyleSheet, Text, View, TouchableOpacity, Image } from "react-native";
|
|
3
|
-
import { useNavigation, useRoute } from '@react-navigation/native'
|
|
4
|
-
import Page from "@ledvance/base/src/components/Page";
|
|
5
|
-
import I18n from "@ledvance/base/src/i18n";
|
|
6
|
-
import res from "@ledvance/base/src/res";
|
|
7
|
-
import { Utils } from "tuya-panel-kit";
|
|
8
|
-
import { useReactive, useUpdateEffect } from "ahooks";
|
|
9
|
-
import TextField from "@ledvance/base/src/components/TextField";
|
|
10
|
-
import LdvTopName from "@ledvance/base/src/components/ldvTopName";
|
|
11
|
-
import LdvPickerView from "@ledvance/base/src/components/ldvPickerView";
|
|
12
|
-
import LdvWeekView from '@ledvance/base/src/components/weekSelect'
|
|
13
|
-
import { loopText, toFixed } from "@ledvance/base/src/utils/common";
|
|
14
|
-
import DeviceState from "./DeviceState";
|
|
15
|
-
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
16
|
-
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
17
|
-
import { SleepWakeUpPageRouteParams } from "./SleepWakeUpPage";
|
|
18
|
-
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
19
|
-
import { cloneDeep, isEqual } from "lodash";
|
|
20
|
-
import dayjs from "dayjs";
|
|
21
|
-
|
|
22
|
-
const { convertX: cx } = Utils.RatioUtils;
|
|
23
|
-
|
|
24
|
-
interface SleepWakeUpDetailPageProps extends SleepWakeUpPageRouteParams {
|
|
25
|
-
mode: 'add' | 'edit'
|
|
26
|
-
isSleep: boolean
|
|
27
|
-
scheduleItem: any
|
|
28
|
-
setSleepPlan: (plan: any[]) => void
|
|
29
|
-
setWakeUpPlan: (plan: any[]) => void
|
|
30
|
-
conflictFn: (item: any, editList: any[], goback: boolean) => void
|
|
31
|
-
deleteDialog: (item: any) => Promise<any>
|
|
32
|
-
sleepPlan: any[]
|
|
33
|
-
wakeUpPlan: any[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const SleepWakeUpDetailPage = () => {
|
|
37
|
-
const navigation = useNavigation()
|
|
38
|
-
const props = useRoute().params as SleepWakeUpDetailPageProps
|
|
39
|
-
const { scheduleItem } = props
|
|
40
|
-
const state = useReactive({
|
|
41
|
-
name: '',
|
|
42
|
-
hour: '00',
|
|
43
|
-
minute: '01',
|
|
44
|
-
loop: [0, 0, 0, 0, 0, 0, 0],
|
|
45
|
-
selectedSkill: props.dps,
|
|
46
|
-
skillList: [] as any[],
|
|
47
|
-
fadeOut: 5,
|
|
48
|
-
fadeIn: 5,
|
|
49
|
-
duration: 5,
|
|
50
|
-
fadeOutHour: '00',
|
|
51
|
-
fadeOutMinute: '05',
|
|
52
|
-
fadeInHour: '00',
|
|
53
|
-
fadeInMinute: '05',
|
|
54
|
-
durationHour: '00',
|
|
55
|
-
durationMinute: '05',
|
|
56
|
-
durationStatus: false,
|
|
57
|
-
mixActions: {
|
|
58
|
-
whiteLightSwitch: true,
|
|
59
|
-
colorLightSwitch: false,
|
|
60
|
-
mixRgbcwEnabled: true,
|
|
61
|
-
hue: 360,
|
|
62
|
-
sat: 100,
|
|
63
|
-
lightness: 100,
|
|
64
|
-
brightness: 100,
|
|
65
|
-
colorTempPercent: 100,
|
|
66
|
-
},
|
|
67
|
-
singleActions: {
|
|
68
|
-
isColor: false,
|
|
69
|
-
brightness: 100,
|
|
70
|
-
temperature: 100,
|
|
71
|
-
h: 0,
|
|
72
|
-
s: 100,
|
|
73
|
-
v: 100
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (props.mode === 'edit' && scheduleItem) {
|
|
79
|
-
console.log(scheduleItem, '< -- scheduleItem')
|
|
80
|
-
state.hour = scheduleItem.time[0].toString().padStart(2, '0')
|
|
81
|
-
state.minute = scheduleItem.time[1].toString().padStart(2, '0')
|
|
82
|
-
state.name = scheduleItem.name
|
|
83
|
-
state.loop = scheduleItem.loops
|
|
84
|
-
|
|
85
|
-
state.singleActions.isColor = scheduleItem.brightness === 0 && scheduleItem.temperature === 0
|
|
86
|
-
if (state.singleActions.isColor) {
|
|
87
|
-
state.singleActions.h = scheduleItem.hue
|
|
88
|
-
state.singleActions.s = scheduleItem.sat
|
|
89
|
-
state.singleActions.v = scheduleItem.value
|
|
90
|
-
} else {
|
|
91
|
-
state.singleActions.brightness = scheduleItem.brightness
|
|
92
|
-
state.singleActions.temperature = scheduleItem.temperature
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (props.isMixRGBWLamp) {
|
|
96
|
-
state.mixActions.hue = scheduleItem.hue
|
|
97
|
-
state.mixActions.sat = scheduleItem.sat
|
|
98
|
-
state.mixActions.lightness = scheduleItem.value
|
|
99
|
-
state.mixActions.colorLightSwitch = !scheduleItem.brightness && !scheduleItem.colorTempPercent
|
|
100
|
-
state.mixActions.brightness = scheduleItem.brightness
|
|
101
|
-
state.mixActions.colorTempPercent = scheduleItem.temperature
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const h = Math.trunc(scheduleItem.fade / 60)
|
|
105
|
-
const m = scheduleItem.fade % 60
|
|
106
|
-
|
|
107
|
-
if (props.isSleep) {
|
|
108
|
-
state.fadeOut = scheduleItem.fade
|
|
109
|
-
state.fadeOutHour = h.toString().padStart(2, '0')
|
|
110
|
-
state.fadeOutMinute = m.toString().padStart(2, '0')
|
|
111
|
-
} else {
|
|
112
|
-
state.fadeIn = scheduleItem.fade
|
|
113
|
-
state.fadeInHour = h.toString().padStart(2, '0')
|
|
114
|
-
state.fadeInMinute = m.toString().padStart(2, '0')
|
|
115
|
-
state.duration = scheduleItem.duration
|
|
116
|
-
state.durationStatus = scheduleItem.duration > 0
|
|
117
|
-
state.durationHour = Math.trunc(scheduleItem.duration / 60).toString().padStart(2, '0')
|
|
118
|
-
state.durationMinute = (scheduleItem.duration % 60).toString().padStart(2, '0')
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
const date = new Date()
|
|
122
|
-
state.hour = toFixed(date.getHours(), 2)
|
|
123
|
-
state.minute = toFixed(date.getMinutes(), 2)
|
|
124
|
-
state.singleActions.isColor = !!props.isGARDOT && !(props.isRGBLamp || props.isRGBWLamp)
|
|
125
|
-
}
|
|
126
|
-
}, [])
|
|
127
|
-
|
|
128
|
-
useUpdateEffect(() => {
|
|
129
|
-
const min = state.fadeOutHour === '02' ? '00' : (state.fadeOutHour === '00' && state.fadeOutMinute === '00') ? '05' : state.fadeOutMinute
|
|
130
|
-
state.fadeOutMinute = min
|
|
131
|
-
state.fadeOut = (Number(state.fadeOutHour) * 60) + Number(min)
|
|
132
|
-
}, [state.fadeOutHour, state.fadeOutMinute])
|
|
133
|
-
|
|
134
|
-
useUpdateEffect(() => {
|
|
135
|
-
const min = state.fadeInHour === '02' ? '00' : (state.fadeInHour === '00' && state.fadeInMinute === '00') ? '05' : state.fadeInMinute
|
|
136
|
-
state.fadeInMinute = min
|
|
137
|
-
state.fadeIn = (Number(state.fadeInHour) * 60) + Number(min)
|
|
138
|
-
}, [state.fadeInHour, state.fadeInMinute])
|
|
139
|
-
|
|
140
|
-
useUpdateEffect(() => {
|
|
141
|
-
const min = state.durationHour === '02' ? '00' : (state.durationHour === '00' && state.durationMinute === '00') ? '05' : state.durationMinute
|
|
142
|
-
state.durationMinute = min
|
|
143
|
-
state.duration = (Number(state.durationHour) * 60) + Number(min)
|
|
144
|
-
}, [state.durationHour, state.durationMinute])
|
|
145
|
-
|
|
146
|
-
const getNewItem = () =>{
|
|
147
|
-
return {
|
|
148
|
-
enable: 1,
|
|
149
|
-
loops: state.loop,
|
|
150
|
-
time: [parseInt(state.hour), parseInt(state.minute)],
|
|
151
|
-
hue: state.singleActions.isColor ? state.singleActions.h : 0,
|
|
152
|
-
sat: state.singleActions.isColor ? state.singleActions.s : 0,
|
|
153
|
-
value: state.singleActions.isColor ? state.singleActions.v : 0,
|
|
154
|
-
brightness: state.singleActions.isColor ? 0 : state.singleActions.brightness,
|
|
155
|
-
temperature: state.singleActions.isColor ? 0 : state.singleActions.temperature,
|
|
156
|
-
name: state.name,
|
|
157
|
-
isSleep: props.isSleep,
|
|
158
|
-
fade: props.isSleep ? state.fadeOut : state.fadeIn
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const postActions = async () => {
|
|
163
|
-
const baseItemData: any = getNewItem()
|
|
164
|
-
if (props.mode === 'edit') baseItemData.index = scheduleItem.index
|
|
165
|
-
|
|
166
|
-
if (props.isMixRGBWLamp) {
|
|
167
|
-
baseItemData.hue = state.mixActions.colorLightSwitch ? state.mixActions.hue : 0
|
|
168
|
-
baseItemData.sat = state.mixActions.colorLightSwitch ? state.mixActions.sat : 0
|
|
169
|
-
baseItemData.value = state.mixActions.colorLightSwitch ? state.mixActions.lightness : 0
|
|
170
|
-
baseItemData.brightness = state.mixActions.colorLightSwitch ? 0 : state.mixActions.brightness
|
|
171
|
-
baseItemData.temperature = state.mixActions.colorLightSwitch ? 0 : state.mixActions.colorTempPercent
|
|
172
|
-
}
|
|
173
|
-
if (!props.isSleep) {
|
|
174
|
-
baseItemData.duration = state.durationStatus && state.duration || 0
|
|
175
|
-
}
|
|
176
|
-
const baseList = props.isSleep ? props.sleepPlan : props.wakeUpPlan
|
|
177
|
-
if (props.mode === 'add') {
|
|
178
|
-
const newList = [...baseList, baseItemData]
|
|
179
|
-
props.conflictFn(baseItemData, newList, true)
|
|
180
|
-
} else {
|
|
181
|
-
const idx = baseList.findIndex(item => item.index === scheduleItem.index)
|
|
182
|
-
if (idx !== -1) {
|
|
183
|
-
baseList.splice(idx, 1, baseItemData)
|
|
184
|
-
}
|
|
185
|
-
props.conflictFn(baseItemData, baseList, true)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const selectWeekAction = useCallback((idx: number) => {
|
|
190
|
-
const newLoop = state.loop.map((item, tempIndex) => {
|
|
191
|
-
if (tempIndex === idx - 1) {
|
|
192
|
-
return item > 0 ? 0 : 1;
|
|
193
|
-
}
|
|
194
|
-
return item;
|
|
195
|
-
|
|
196
|
-
});
|
|
197
|
-
state.loop = newLoop;
|
|
198
|
-
}, [])
|
|
199
|
-
|
|
200
|
-
const showClearIcon = useCallback(() => {
|
|
201
|
-
return false
|
|
202
|
-
}, [])
|
|
203
|
-
|
|
204
|
-
const showSubmit = useCallback(() => {
|
|
205
|
-
return state?.name?.length > 0 && state?.name?.length <= 32 && hasSelected()
|
|
206
|
-
}, [state.name])
|
|
207
|
-
|
|
208
|
-
const handelSkill = (v, i) => {
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const hasSelected = () => {
|
|
213
|
-
return !!state.selectedSkill.length
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const renderItem = ({ item }) => {
|
|
219
|
-
return (
|
|
220
|
-
<View style={{
|
|
221
|
-
flexDirection: 'row',
|
|
222
|
-
justifyContent: 'space-between',
|
|
223
|
-
alignItems: 'center',
|
|
224
|
-
backgroundColor: '#fff',
|
|
225
|
-
marginBottom: cx(8)
|
|
226
|
-
}}>
|
|
227
|
-
<Text
|
|
228
|
-
style={{
|
|
229
|
-
color: '#000',
|
|
230
|
-
fontSize: 14,
|
|
231
|
-
marginHorizontal: cx(6),
|
|
232
|
-
marginVertical: cx(9),
|
|
233
|
-
}}
|
|
234
|
-
>
|
|
235
|
-
{item.label}
|
|
236
|
-
</Text>
|
|
237
|
-
{showClearIcon() && <TouchableOpacity onPress={() => handelSkill('lower', item)}>
|
|
238
|
-
<Image style={{ width: cx(16), height: cx(16), marginRight: cx(5) }} source={res.ic_arrows_nav_clear} />
|
|
239
|
-
</TouchableOpacity>}
|
|
240
|
-
</View>
|
|
241
|
-
);
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const editMixActions = (mix) => {
|
|
245
|
-
state.mixActions = cloneDeep(mix)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const editSingleActions = (single) => {
|
|
249
|
-
state.singleActions = cloneDeep(single)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const formateTime = (v, isSleep) => {
|
|
253
|
-
const date = dayjs().format('YYYY-MM-DD')
|
|
254
|
-
const time = dayjs(`${date} ${state.hour}:${state.minute}`)
|
|
255
|
-
return isSleep ? time.add(Number(v), 'm').format('HH:mm') : time.subtract(Number(v), 'm').format('HH:mm')
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const formateDurationTime = () => {
|
|
259
|
-
const duration = state.durationStatus && Number(state.duration) || 0
|
|
260
|
-
const date = dayjs().format('YYYY-MM-DD')
|
|
261
|
-
const time = dayjs(`${date} ${state.hour}:${state.minute}`)
|
|
262
|
-
const startTime = props.isSleep ? time.format('HH:mm') : time.subtract(state.fadeIn, 'm').format('HH:mm')
|
|
263
|
-
const data = props.isSleep ? Number(state.fadeOut) : duration
|
|
264
|
-
const endTime = time.add(data, 'm').format('HH:mm')
|
|
265
|
-
return {
|
|
266
|
-
durationTime: `${startTime} - ${endTime}`,
|
|
267
|
-
endTime
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const showBackDialog = () =>{
|
|
272
|
-
const newItem:any = {
|
|
273
|
-
...getNewItem(),
|
|
274
|
-
index: props.scheduleItem?.index,
|
|
275
|
-
enable: props.scheduleItem?.enable
|
|
276
|
-
}
|
|
277
|
-
if(!props.isSleep){
|
|
278
|
-
newItem.duration = state.durationStatus && state.duration || 0
|
|
279
|
-
}
|
|
280
|
-
return props.mode === 'edit' && !isEqual(props.scheduleItem, newItem)
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return (
|
|
286
|
-
<Page
|
|
287
|
-
backText={I18n.getLang('add_sleepschedule_one_source_system_back_text')}
|
|
288
|
-
showBackDialog={showBackDialog()}
|
|
289
|
-
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
290
|
-
backDialogContent={I18n.getLang(props.isSleep ? 'cancel_dialog_leave_unsaved_sleepschedule_note' : 'cancel_dialog_leave_unsaved_wakeupschedule_note')}
|
|
291
|
-
rightButtonIcon={showSubmit() ? res.ic_check : res.ic_uncheck}
|
|
292
|
-
rightButtonIconClick={showSubmit() && postActions || undefined}
|
|
293
|
-
>
|
|
294
|
-
<ScrollView
|
|
295
|
-
nestedScrollEnabled={true}
|
|
296
|
-
showsHorizontalScrollIndicator={false}
|
|
297
|
-
showsVerticalScrollIndicator={false}
|
|
298
|
-
>
|
|
299
|
-
<LdvTopName title={I18n.getLang(props.isSleep ? (props.mode === 'add' ? 'add_sleepschedule_one_source_headline_text' : 'edit_sleepschedule_headline_text') : (props.mode === 'add' ? 'add_wakeupschedule_one_source_headline_text' : 'edit_wakeupschedule_headline_text'))} />
|
|
300
|
-
<TextField
|
|
301
|
-
style={styles.cardContainer}
|
|
302
|
-
value={state.name}
|
|
303
|
-
showError={state.name?.length > 32}
|
|
304
|
-
maxLength={33}
|
|
305
|
-
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
306
|
-
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
307
|
-
onChangeText={(t: string) => {
|
|
308
|
-
state.name = t;
|
|
309
|
-
}}
|
|
310
|
-
/>
|
|
311
|
-
{/* pick */}
|
|
312
|
-
<LdvPickerView
|
|
313
|
-
style={styles.picker}
|
|
314
|
-
hour={state.hour}
|
|
315
|
-
minute={state.minute}
|
|
316
|
-
setHour={v => (state.hour = v)}
|
|
317
|
-
setMinute={v => (state.minute = v)}
|
|
318
|
-
// unit={['h', 'min']}
|
|
319
|
-
/>
|
|
320
|
-
|
|
321
|
-
{/* week */}
|
|
322
|
-
<View style={styles.week}>
|
|
323
|
-
<LdvWeekView style={{}} value={state.loop} onSelect={selectWeekAction} />
|
|
324
|
-
<Spacer />
|
|
325
|
-
<Text style={{ marginHorizontal: cx(24) }}>{loopText(state.loop)}</Text>
|
|
326
|
-
<Spacer />
|
|
327
|
-
</View>
|
|
328
|
-
|
|
329
|
-
{/* Apply for */}
|
|
330
|
-
<View style={styles.cardContainer}>
|
|
331
|
-
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
332
|
-
<View
|
|
333
|
-
style={{
|
|
334
|
-
backgroundColor: '#f6f6f6',
|
|
335
|
-
borderRadius: 4,
|
|
336
|
-
minHeight: cx(50),
|
|
337
|
-
flex: 1,
|
|
338
|
-
justifyContent: 'center',
|
|
339
|
-
}}
|
|
340
|
-
>
|
|
341
|
-
{!hasSelected() ? <Text style={{ marginLeft: cx(10) }}>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
342
|
-
<View
|
|
343
|
-
style={{
|
|
344
|
-
marginHorizontal: cx(8),
|
|
345
|
-
marginTop: cx(8),
|
|
346
|
-
borderRadius: 4,
|
|
347
|
-
}}
|
|
348
|
-
>
|
|
349
|
-
<FlatList
|
|
350
|
-
data={state.selectedSkill}
|
|
351
|
-
renderItem={item => renderItem(item)}
|
|
352
|
-
keyExtractor={(item) => item.dpId + 'selected'}
|
|
353
|
-
/>
|
|
354
|
-
</View>}
|
|
355
|
-
</View>
|
|
356
|
-
{state.skillList.map((item) => {
|
|
357
|
-
return (
|
|
358
|
-
<TouchableOpacity style={styles.skillListItem} key={item.dpId + 'skill'} onPress={() => handelSkill('add', item)}>
|
|
359
|
-
<Text style={{ color: '#000' }}>{item.label}</Text>
|
|
360
|
-
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
361
|
-
</TouchableOpacity>
|
|
362
|
-
)
|
|
363
|
-
})}
|
|
364
|
-
<Spacer />
|
|
365
|
-
</View>
|
|
366
|
-
|
|
367
|
-
{/* Device state */}
|
|
368
|
-
<View>
|
|
369
|
-
<Text style={[styles.itemTitle, styles.cardContainer]}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
|
|
370
|
-
<DeviceState
|
|
371
|
-
mixActions={state.mixActions}
|
|
372
|
-
singleActions={state.singleActions}
|
|
373
|
-
editMixFn={editMixActions}
|
|
374
|
-
editSingleFn={editSingleActions}
|
|
375
|
-
isSupportColor={props.isSupportColor}
|
|
376
|
-
isSupportBrightness={true}
|
|
377
|
-
isSupportTemperature={true}
|
|
378
|
-
isMixRGBWLamp={props.isMixRGBWLamp}
|
|
379
|
-
/>
|
|
380
|
-
</View>
|
|
381
|
-
<Spacer />
|
|
382
|
-
{/* Settings */}
|
|
383
|
-
<View style={styles.cardContainer}>
|
|
384
|
-
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}</Text>
|
|
385
|
-
<Spacer />
|
|
386
|
-
<Text>{I18n.getLang(props.isSleep ? 'add_sleepschedule_one_source_settings_text' : 'add_wakeupschedule_settings_text')}</Text>
|
|
387
|
-
<LdvPickerView
|
|
388
|
-
style={styles.picker}
|
|
389
|
-
hour={props.isSleep ? state.fadeOutHour : state.fadeInHour}
|
|
390
|
-
minute={props.isSleep ? state.fadeOutMinute : state.fadeInMinute}
|
|
391
|
-
minutesStep={5}
|
|
392
|
-
setHour={v => {
|
|
393
|
-
if (props.isSleep) {
|
|
394
|
-
state.fadeOutHour = v
|
|
395
|
-
} else {
|
|
396
|
-
state.fadeInHour = v
|
|
397
|
-
}
|
|
398
|
-
}}
|
|
399
|
-
setMinute={v => {
|
|
400
|
-
if (props.isSleep) {
|
|
401
|
-
state.fadeOutMinute = v
|
|
402
|
-
} else {
|
|
403
|
-
state.fadeInMinute = v
|
|
404
|
-
}
|
|
405
|
-
}}
|
|
406
|
-
unit={['h', 'min']}
|
|
407
|
-
maxHour={3}
|
|
408
|
-
/>
|
|
409
|
-
<Text>{I18n.formatValue(props.isSleep ? 'add_sleepschedule_one_source_settings_text2' : 'add_wakeupschedule_settings_text2', `${formateTime(props.isSleep ? state.fadeOut : state.fadeIn, props.isSleep)}`)}</Text>
|
|
410
|
-
<Spacer />
|
|
411
|
-
{!props.isSleep &&
|
|
412
|
-
<View style={{ marginHorizontal: -cx(16), marginTop: -cx(20) }}>
|
|
413
|
-
<LdvSwitch
|
|
414
|
-
title={I18n.getLang('add_wakeupschedule_settings_text3')}
|
|
415
|
-
enable={state.durationStatus}
|
|
416
|
-
color="#fff"
|
|
417
|
-
colorAlpha={1}
|
|
418
|
-
setEnable={() => {
|
|
419
|
-
state.durationStatus = !state.durationStatus
|
|
420
|
-
state.duration = 5
|
|
421
|
-
state.durationHour = '00'
|
|
422
|
-
state.durationMinute = '05'
|
|
423
|
-
if (!state.durationStatus) {
|
|
424
|
-
state.duration = 0
|
|
425
|
-
}
|
|
426
|
-
}}
|
|
427
|
-
/>
|
|
428
|
-
</View>
|
|
429
|
-
}
|
|
430
|
-
{state.durationStatus && <>
|
|
431
|
-
<Text style={{ fontSize: cx(14) }}>{I18n.getLang('add_wakeupschedule_settings_text4')}</Text>
|
|
432
|
-
<LdvPickerView
|
|
433
|
-
style={styles.picker}
|
|
434
|
-
hour={state.durationHour}
|
|
435
|
-
minutesStep={5}
|
|
436
|
-
minute={state.durationMinute}
|
|
437
|
-
setHour={v => (state.durationHour = v)}
|
|
438
|
-
setMinute={v => (state.durationMinute = v)}
|
|
439
|
-
unit={['h', 'min']}
|
|
440
|
-
maxHour={3}
|
|
441
|
-
/>
|
|
442
|
-
<Text>{I18n.formatValue('add_wakeupschedule_settings_text5', `${formateTime(state.duration, !props.isSleep)}`)}</Text>
|
|
443
|
-
<Spacer />
|
|
444
|
-
</>}
|
|
445
|
-
</View>
|
|
446
|
-
{/* Summary */}
|
|
447
|
-
<View style={styles.cardContainer}>
|
|
448
|
-
<Text style={styles.itemTitle}>{I18n.getLang('add_randomtimecycle_subheadline_text')}</Text>
|
|
449
|
-
<View style={styles.summaryContainer}>
|
|
450
|
-
<View style={styles.summaryLeft}>
|
|
451
|
-
<Image
|
|
452
|
-
source={res.summary_icon1}
|
|
453
|
-
resizeMode="contain"
|
|
454
|
-
style={styles.summaryImg}
|
|
455
|
-
/>
|
|
456
|
-
<View>
|
|
457
|
-
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_frequency_headline')}</Text>
|
|
458
|
-
</View>
|
|
459
|
-
</View>
|
|
460
|
-
<View style={styles.summaryRight}>
|
|
461
|
-
<Text style={styles.rightItem}>{loopText(state.loop)}</Text>
|
|
462
|
-
</View>
|
|
463
|
-
</View>
|
|
464
|
-
<View style={styles.summaryContainer}>
|
|
465
|
-
<View style={styles.summaryLeft}>
|
|
466
|
-
<Image
|
|
467
|
-
source={res.summary_icon2}
|
|
468
|
-
resizeMode="contain"
|
|
469
|
-
style={styles.summaryImg}
|
|
470
|
-
/>
|
|
471
|
-
<View>
|
|
472
|
-
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_time_headline')}</Text>
|
|
473
|
-
</View>
|
|
474
|
-
</View>
|
|
475
|
-
<View style={styles.summaryRight}>
|
|
476
|
-
<Text style={styles.rightItem}>{formateDurationTime().durationTime}</Text>
|
|
477
|
-
</View>
|
|
478
|
-
</View>
|
|
479
|
-
<View style={[styles.summaryContainer, { alignItems: 'flex-start' }]}>
|
|
480
|
-
<View style={styles.summaryLeft}>
|
|
481
|
-
<Image
|
|
482
|
-
source={res.summary_icon3}
|
|
483
|
-
resizeMode="contain"
|
|
484
|
-
style={styles.summaryImg}
|
|
485
|
-
/>
|
|
486
|
-
<View>
|
|
487
|
-
<Text style={styles.leftTitle}>{I18n.getLang('motion_detection_add_time_schedule_actions_text1')}</Text>
|
|
488
|
-
</View>
|
|
489
|
-
</View>
|
|
490
|
-
<View style={{ marginLeft: cx(24), flex: 3 }}>
|
|
491
|
-
<Text style={{ fontSize: cx(12), color: '#000000' }}>{I18n.getLang(!props.isSleep ? 'feature_summary_action_txt_11' : 'feature_summary_action_txt_10')}</Text>
|
|
492
|
-
<View style={{ flexDirection: 'row' }}>
|
|
493
|
-
{
|
|
494
|
-
props.isMixRGBWLamp &&
|
|
495
|
-
<>
|
|
496
|
-
{
|
|
497
|
-
state.mixActions.whiteLightSwitch &&
|
|
498
|
-
<View style={styles.filletCorner}>
|
|
499
|
-
<Text style={styles.rightTitle}>{state.selectedSkill[0]?.label}</Text>
|
|
500
|
-
</View>
|
|
501
|
-
}
|
|
502
|
-
{
|
|
503
|
-
state.mixActions.colorLightSwitch &&
|
|
504
|
-
<View style={[styles.filletCorner, { marginLeft: cx(4) }]}>
|
|
505
|
-
<Text style={styles.rightTitle}>{state.selectedSkill[1]?.label}</Text>
|
|
506
|
-
</View>
|
|
507
|
-
}
|
|
508
|
-
</> ||
|
|
509
|
-
<View style={styles.filletCorner}>
|
|
510
|
-
<Text style={styles.rightTitle}>{state.selectedSkill[0]?.label}</Text>
|
|
511
|
-
</View>
|
|
512
|
-
}
|
|
513
|
-
</View>
|
|
514
|
-
<Text style={{ fontSize: cx(12), color: '#000000' }}>{I18n.getLang(
|
|
515
|
-
props.isSleep ? 'feature_summary_action_txt_2' :
|
|
516
|
-
(state.durationStatus ? 'feature_summary_action_txt_12' : 'feature_summary_action_txt_1')
|
|
517
|
-
)}</Text>
|
|
518
|
-
<View style={styles.filletCorner}>
|
|
519
|
-
<Text style={styles.rightTitle}>{formateDurationTime().endTime}</Text>
|
|
520
|
-
</View>
|
|
521
|
-
</View>
|
|
522
|
-
</View>
|
|
523
|
-
</View>
|
|
524
|
-
<Spacer />
|
|
525
|
-
{/* Delete btn */}
|
|
526
|
-
{props.mode === 'edit' &&
|
|
527
|
-
<View style={styles.cardContainer}>
|
|
528
|
-
<DeleteButton
|
|
529
|
-
text={I18n.getLang('edit_timeschedule_bttn_text')}
|
|
530
|
-
onPress={() => {
|
|
531
|
-
props.deleteDialog(scheduleItem).then(() => {
|
|
532
|
-
navigation.goBack()
|
|
533
|
-
})
|
|
534
|
-
}}
|
|
535
|
-
/>
|
|
536
|
-
</View>
|
|
537
|
-
}
|
|
538
|
-
<Spacer />
|
|
539
|
-
</ScrollView>
|
|
540
|
-
</Page>
|
|
541
|
-
)
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const styles = StyleSheet.create({
|
|
545
|
-
cardContainer: {
|
|
546
|
-
marginHorizontal: cx(24)
|
|
547
|
-
},
|
|
548
|
-
textField: {
|
|
549
|
-
marginHorizontal: cx(24)
|
|
550
|
-
},
|
|
551
|
-
picker: {
|
|
552
|
-
marginHorizontal: cx(24),
|
|
553
|
-
marginVertical: cx(15),
|
|
554
|
-
color: 'rgb(35,35,38)',
|
|
555
|
-
},
|
|
556
|
-
week: {
|
|
557
|
-
|
|
558
|
-
},
|
|
559
|
-
itemTitle: {
|
|
560
|
-
color: '#000',
|
|
561
|
-
fontSize: cx(16),
|
|
562
|
-
fontWeight: 'bold',
|
|
563
|
-
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
564
|
-
marginBottom: cx(10)
|
|
565
|
-
},
|
|
566
|
-
skillListItem: {
|
|
567
|
-
flexDirection: 'row',
|
|
568
|
-
justifyContent: 'space-between',
|
|
569
|
-
height: cx(30),
|
|
570
|
-
alignItems: 'center',
|
|
571
|
-
marginVertical: cx(5)
|
|
572
|
-
},
|
|
573
|
-
summaryContainer: {
|
|
574
|
-
flexDirection: 'row',
|
|
575
|
-
justifyContent: 'flex-start',
|
|
576
|
-
marginBottom: cx(10)
|
|
577
|
-
},
|
|
578
|
-
summaryImg: {
|
|
579
|
-
height: cx(12),
|
|
580
|
-
width: cx(12),
|
|
581
|
-
marginRight: cx(6)
|
|
582
|
-
},
|
|
583
|
-
summaryLeft: {
|
|
584
|
-
flexDirection: 'row',
|
|
585
|
-
alignItems: 'center',
|
|
586
|
-
minWidth: cx(90),
|
|
587
|
-
},
|
|
588
|
-
leftTitle: {
|
|
589
|
-
fontSize: cx(14),
|
|
590
|
-
color: '#000',
|
|
591
|
-
},
|
|
592
|
-
summaryRight: {
|
|
593
|
-
flexDirection: 'column',
|
|
594
|
-
marginLeft: cx(21),
|
|
595
|
-
borderRadius: cx(16),
|
|
596
|
-
backgroundColor: '#cbcbcb',
|
|
597
|
-
},
|
|
598
|
-
rightItem: {
|
|
599
|
-
paddingHorizontal: cx(12),
|
|
600
|
-
color: '#000',
|
|
601
|
-
},
|
|
602
|
-
rightTitle: {
|
|
603
|
-
paddingLeft: cx(12),
|
|
604
|
-
paddingRight: cx(12),
|
|
605
|
-
fontSize: cx(10),
|
|
606
|
-
textAlign: 'center',
|
|
607
|
-
alignSelf: 'flex-start'
|
|
608
|
-
},
|
|
609
|
-
filletCorner: {
|
|
610
|
-
flexDirection: 'row',
|
|
611
|
-
backgroundColor: '#cbcbcb',
|
|
612
|
-
borderRadius: cx(16),
|
|
613
|
-
alignSelf: 'flex-start'
|
|
614
|
-
}
|
|
615
|
-
})
|
|
616
|
-
|
|
1
|
+
import React, { useCallback, useEffect } from "react";
|
|
2
|
+
import { FlatList, ScrollView, StyleSheet, Text, View, TouchableOpacity, Image } from "react-native";
|
|
3
|
+
import { useNavigation, useRoute } from '@react-navigation/native'
|
|
4
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
5
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
6
|
+
import res from "@ledvance/base/src/res";
|
|
7
|
+
import { Utils } from "tuya-panel-kit";
|
|
8
|
+
import { useReactive, useUpdateEffect } from "ahooks";
|
|
9
|
+
import TextField from "@ledvance/base/src/components/TextField";
|
|
10
|
+
import LdvTopName from "@ledvance/base/src/components/ldvTopName";
|
|
11
|
+
import LdvPickerView from "@ledvance/base/src/components/ldvPickerView";
|
|
12
|
+
import LdvWeekView from '@ledvance/base/src/components/weekSelect'
|
|
13
|
+
import { loopText, toFixed } from "@ledvance/base/src/utils/common";
|
|
14
|
+
import DeviceState from "./DeviceState";
|
|
15
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
16
|
+
import DeleteButton from "@ledvance/base/src/components/DeleteButton";
|
|
17
|
+
import { SleepWakeUpPageRouteParams } from "./SleepWakeUpPage";
|
|
18
|
+
import LdvSwitch from "@ledvance/base/src/components/ldvSwitch";
|
|
19
|
+
import { cloneDeep, isEqual } from "lodash";
|
|
20
|
+
import dayjs from "dayjs";
|
|
21
|
+
|
|
22
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
23
|
+
|
|
24
|
+
interface SleepWakeUpDetailPageProps extends SleepWakeUpPageRouteParams {
|
|
25
|
+
mode: 'add' | 'edit'
|
|
26
|
+
isSleep: boolean
|
|
27
|
+
scheduleItem: any
|
|
28
|
+
setSleepPlan: (plan: any[]) => void
|
|
29
|
+
setWakeUpPlan: (plan: any[]) => void
|
|
30
|
+
conflictFn: (item: any, editList: any[], goback: boolean) => void
|
|
31
|
+
deleteDialog: (item: any) => Promise<any>
|
|
32
|
+
sleepPlan: any[]
|
|
33
|
+
wakeUpPlan: any[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SleepWakeUpDetailPage = () => {
|
|
37
|
+
const navigation = useNavigation()
|
|
38
|
+
const props = useRoute().params as SleepWakeUpDetailPageProps
|
|
39
|
+
const { scheduleItem } = props
|
|
40
|
+
const state = useReactive({
|
|
41
|
+
name: '',
|
|
42
|
+
hour: '00',
|
|
43
|
+
minute: '01',
|
|
44
|
+
loop: [0, 0, 0, 0, 0, 0, 0],
|
|
45
|
+
selectedSkill: props.dps,
|
|
46
|
+
skillList: [] as any[],
|
|
47
|
+
fadeOut: 5,
|
|
48
|
+
fadeIn: 5,
|
|
49
|
+
duration: 5,
|
|
50
|
+
fadeOutHour: '00',
|
|
51
|
+
fadeOutMinute: '05',
|
|
52
|
+
fadeInHour: '00',
|
|
53
|
+
fadeInMinute: '05',
|
|
54
|
+
durationHour: '00',
|
|
55
|
+
durationMinute: '05',
|
|
56
|
+
durationStatus: false,
|
|
57
|
+
mixActions: {
|
|
58
|
+
whiteLightSwitch: true,
|
|
59
|
+
colorLightSwitch: false,
|
|
60
|
+
mixRgbcwEnabled: true,
|
|
61
|
+
hue: 360,
|
|
62
|
+
sat: 100,
|
|
63
|
+
lightness: 100,
|
|
64
|
+
brightness: 100,
|
|
65
|
+
colorTempPercent: 100,
|
|
66
|
+
},
|
|
67
|
+
singleActions: {
|
|
68
|
+
isColor: false,
|
|
69
|
+
brightness: 100,
|
|
70
|
+
temperature: 100,
|
|
71
|
+
h: 0,
|
|
72
|
+
s: 100,
|
|
73
|
+
v: 100
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (props.mode === 'edit' && scheduleItem) {
|
|
79
|
+
console.log(scheduleItem, '< -- scheduleItem')
|
|
80
|
+
state.hour = scheduleItem.time[0].toString().padStart(2, '0')
|
|
81
|
+
state.minute = scheduleItem.time[1].toString().padStart(2, '0')
|
|
82
|
+
state.name = scheduleItem.name
|
|
83
|
+
state.loop = scheduleItem.loops
|
|
84
|
+
|
|
85
|
+
state.singleActions.isColor = scheduleItem.brightness === 0 && scheduleItem.temperature === 0
|
|
86
|
+
if (state.singleActions.isColor) {
|
|
87
|
+
state.singleActions.h = scheduleItem.hue
|
|
88
|
+
state.singleActions.s = scheduleItem.sat
|
|
89
|
+
state.singleActions.v = scheduleItem.value
|
|
90
|
+
} else {
|
|
91
|
+
state.singleActions.brightness = scheduleItem.brightness
|
|
92
|
+
state.singleActions.temperature = scheduleItem.temperature
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (props.isMixRGBWLamp) {
|
|
96
|
+
state.mixActions.hue = scheduleItem.hue
|
|
97
|
+
state.mixActions.sat = scheduleItem.sat
|
|
98
|
+
state.mixActions.lightness = scheduleItem.value
|
|
99
|
+
state.mixActions.colorLightSwitch = !scheduleItem.brightness && !scheduleItem.colorTempPercent
|
|
100
|
+
state.mixActions.brightness = scheduleItem.brightness
|
|
101
|
+
state.mixActions.colorTempPercent = scheduleItem.temperature
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const h = Math.trunc(scheduleItem.fade / 60)
|
|
105
|
+
const m = scheduleItem.fade % 60
|
|
106
|
+
|
|
107
|
+
if (props.isSleep) {
|
|
108
|
+
state.fadeOut = scheduleItem.fade
|
|
109
|
+
state.fadeOutHour = h.toString().padStart(2, '0')
|
|
110
|
+
state.fadeOutMinute = m.toString().padStart(2, '0')
|
|
111
|
+
} else {
|
|
112
|
+
state.fadeIn = scheduleItem.fade
|
|
113
|
+
state.fadeInHour = h.toString().padStart(2, '0')
|
|
114
|
+
state.fadeInMinute = m.toString().padStart(2, '0')
|
|
115
|
+
state.duration = scheduleItem.duration
|
|
116
|
+
state.durationStatus = scheduleItem.duration > 0
|
|
117
|
+
state.durationHour = Math.trunc(scheduleItem.duration / 60).toString().padStart(2, '0')
|
|
118
|
+
state.durationMinute = (scheduleItem.duration % 60).toString().padStart(2, '0')
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
const date = new Date()
|
|
122
|
+
state.hour = toFixed(date.getHours(), 2)
|
|
123
|
+
state.minute = toFixed(date.getMinutes(), 2)
|
|
124
|
+
state.singleActions.isColor = !!props.isGARDOT && !(props.isRGBLamp || props.isRGBWLamp)
|
|
125
|
+
}
|
|
126
|
+
}, [])
|
|
127
|
+
|
|
128
|
+
useUpdateEffect(() => {
|
|
129
|
+
const min = state.fadeOutHour === '02' ? '00' : (state.fadeOutHour === '00' && state.fadeOutMinute === '00') ? '05' : state.fadeOutMinute
|
|
130
|
+
state.fadeOutMinute = min
|
|
131
|
+
state.fadeOut = (Number(state.fadeOutHour) * 60) + Number(min)
|
|
132
|
+
}, [state.fadeOutHour, state.fadeOutMinute])
|
|
133
|
+
|
|
134
|
+
useUpdateEffect(() => {
|
|
135
|
+
const min = state.fadeInHour === '02' ? '00' : (state.fadeInHour === '00' && state.fadeInMinute === '00') ? '05' : state.fadeInMinute
|
|
136
|
+
state.fadeInMinute = min
|
|
137
|
+
state.fadeIn = (Number(state.fadeInHour) * 60) + Number(min)
|
|
138
|
+
}, [state.fadeInHour, state.fadeInMinute])
|
|
139
|
+
|
|
140
|
+
useUpdateEffect(() => {
|
|
141
|
+
const min = state.durationHour === '02' ? '00' : (state.durationHour === '00' && state.durationMinute === '00') ? '05' : state.durationMinute
|
|
142
|
+
state.durationMinute = min
|
|
143
|
+
state.duration = (Number(state.durationHour) * 60) + Number(min)
|
|
144
|
+
}, [state.durationHour, state.durationMinute])
|
|
145
|
+
|
|
146
|
+
const getNewItem = () =>{
|
|
147
|
+
return {
|
|
148
|
+
enable: 1,
|
|
149
|
+
loops: state.loop,
|
|
150
|
+
time: [parseInt(state.hour), parseInt(state.minute)],
|
|
151
|
+
hue: state.singleActions.isColor ? state.singleActions.h : 0,
|
|
152
|
+
sat: state.singleActions.isColor ? state.singleActions.s : 0,
|
|
153
|
+
value: state.singleActions.isColor ? state.singleActions.v : 0,
|
|
154
|
+
brightness: state.singleActions.isColor ? 0 : state.singleActions.brightness,
|
|
155
|
+
temperature: state.singleActions.isColor ? 0 : state.singleActions.temperature,
|
|
156
|
+
name: state.name,
|
|
157
|
+
isSleep: props.isSleep,
|
|
158
|
+
fade: props.isSleep ? state.fadeOut : state.fadeIn
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const postActions = async () => {
|
|
163
|
+
const baseItemData: any = getNewItem()
|
|
164
|
+
if (props.mode === 'edit') baseItemData.index = scheduleItem.index
|
|
165
|
+
|
|
166
|
+
if (props.isMixRGBWLamp) {
|
|
167
|
+
baseItemData.hue = state.mixActions.colorLightSwitch ? state.mixActions.hue : 0
|
|
168
|
+
baseItemData.sat = state.mixActions.colorLightSwitch ? state.mixActions.sat : 0
|
|
169
|
+
baseItemData.value = state.mixActions.colorLightSwitch ? state.mixActions.lightness : 0
|
|
170
|
+
baseItemData.brightness = state.mixActions.colorLightSwitch ? 0 : state.mixActions.brightness
|
|
171
|
+
baseItemData.temperature = state.mixActions.colorLightSwitch ? 0 : state.mixActions.colorTempPercent
|
|
172
|
+
}
|
|
173
|
+
if (!props.isSleep) {
|
|
174
|
+
baseItemData.duration = state.durationStatus && state.duration || 0
|
|
175
|
+
}
|
|
176
|
+
const baseList = props.isSleep ? props.sleepPlan : props.wakeUpPlan
|
|
177
|
+
if (props.mode === 'add') {
|
|
178
|
+
const newList = [...baseList, baseItemData]
|
|
179
|
+
props.conflictFn(baseItemData, newList, true)
|
|
180
|
+
} else {
|
|
181
|
+
const idx = baseList.findIndex(item => item.index === scheduleItem.index)
|
|
182
|
+
if (idx !== -1) {
|
|
183
|
+
baseList.splice(idx, 1, baseItemData)
|
|
184
|
+
}
|
|
185
|
+
props.conflictFn(baseItemData, baseList, true)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const selectWeekAction = useCallback((idx: number) => {
|
|
190
|
+
const newLoop = state.loop.map((item, tempIndex) => {
|
|
191
|
+
if (tempIndex === idx - 1) {
|
|
192
|
+
return item > 0 ? 0 : 1;
|
|
193
|
+
}
|
|
194
|
+
return item;
|
|
195
|
+
|
|
196
|
+
});
|
|
197
|
+
state.loop = newLoop;
|
|
198
|
+
}, [])
|
|
199
|
+
|
|
200
|
+
const showClearIcon = useCallback(() => {
|
|
201
|
+
return false
|
|
202
|
+
}, [])
|
|
203
|
+
|
|
204
|
+
const showSubmit = useCallback(() => {
|
|
205
|
+
return state?.name?.length > 0 && state?.name?.length <= 32 && hasSelected()
|
|
206
|
+
}, [state.name])
|
|
207
|
+
|
|
208
|
+
const handelSkill = (v, i) => {
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const hasSelected = () => {
|
|
213
|
+
return !!state.selectedSkill.length
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
const renderItem = ({ item }) => {
|
|
219
|
+
return (
|
|
220
|
+
<View style={{
|
|
221
|
+
flexDirection: 'row',
|
|
222
|
+
justifyContent: 'space-between',
|
|
223
|
+
alignItems: 'center',
|
|
224
|
+
backgroundColor: '#fff',
|
|
225
|
+
marginBottom: cx(8)
|
|
226
|
+
}}>
|
|
227
|
+
<Text
|
|
228
|
+
style={{
|
|
229
|
+
color: '#000',
|
|
230
|
+
fontSize: 14,
|
|
231
|
+
marginHorizontal: cx(6),
|
|
232
|
+
marginVertical: cx(9),
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
{item.label}
|
|
236
|
+
</Text>
|
|
237
|
+
{showClearIcon() && <TouchableOpacity onPress={() => handelSkill('lower', item)}>
|
|
238
|
+
<Image style={{ width: cx(16), height: cx(16), marginRight: cx(5) }} source={res.ic_arrows_nav_clear} />
|
|
239
|
+
</TouchableOpacity>}
|
|
240
|
+
</View>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const editMixActions = (mix) => {
|
|
245
|
+
state.mixActions = cloneDeep(mix)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const editSingleActions = (single) => {
|
|
249
|
+
state.singleActions = cloneDeep(single)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const formateTime = (v, isSleep) => {
|
|
253
|
+
const date = dayjs().format('YYYY-MM-DD')
|
|
254
|
+
const time = dayjs(`${date} ${state.hour}:${state.minute}`)
|
|
255
|
+
return isSleep ? time.add(Number(v), 'm').format('HH:mm') : time.subtract(Number(v), 'm').format('HH:mm')
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const formateDurationTime = () => {
|
|
259
|
+
const duration = state.durationStatus && Number(state.duration) || 0
|
|
260
|
+
const date = dayjs().format('YYYY-MM-DD')
|
|
261
|
+
const time = dayjs(`${date} ${state.hour}:${state.minute}`)
|
|
262
|
+
const startTime = props.isSleep ? time.format('HH:mm') : time.subtract(state.fadeIn, 'm').format('HH:mm')
|
|
263
|
+
const data = props.isSleep ? Number(state.fadeOut) : duration
|
|
264
|
+
const endTime = time.add(data, 'm').format('HH:mm')
|
|
265
|
+
return {
|
|
266
|
+
durationTime: `${startTime} - ${endTime}`,
|
|
267
|
+
endTime
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const showBackDialog = () =>{
|
|
272
|
+
const newItem:any = {
|
|
273
|
+
...getNewItem(),
|
|
274
|
+
index: props.scheduleItem?.index,
|
|
275
|
+
enable: props.scheduleItem?.enable
|
|
276
|
+
}
|
|
277
|
+
if(!props.isSleep){
|
|
278
|
+
newItem.duration = state.durationStatus && state.duration || 0
|
|
279
|
+
}
|
|
280
|
+
return props.mode === 'edit' && !isEqual(props.scheduleItem, newItem)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<Page
|
|
287
|
+
backText={I18n.getLang('add_sleepschedule_one_source_system_back_text')}
|
|
288
|
+
showBackDialog={showBackDialog()}
|
|
289
|
+
backDialogTitle={I18n.getLang('cancel_dialog_leave_unsaved_titel')}
|
|
290
|
+
backDialogContent={I18n.getLang(props.isSleep ? 'cancel_dialog_leave_unsaved_sleepschedule_note' : 'cancel_dialog_leave_unsaved_wakeupschedule_note')}
|
|
291
|
+
rightButtonIcon={showSubmit() ? res.ic_check : res.ic_uncheck}
|
|
292
|
+
rightButtonIconClick={showSubmit() && postActions || undefined}
|
|
293
|
+
>
|
|
294
|
+
<ScrollView
|
|
295
|
+
nestedScrollEnabled={true}
|
|
296
|
+
showsHorizontalScrollIndicator={false}
|
|
297
|
+
showsVerticalScrollIndicator={false}
|
|
298
|
+
>
|
|
299
|
+
<LdvTopName title={I18n.getLang(props.isSleep ? (props.mode === 'add' ? 'add_sleepschedule_one_source_headline_text' : 'edit_sleepschedule_headline_text') : (props.mode === 'add' ? 'add_wakeupschedule_one_source_headline_text' : 'edit_wakeupschedule_headline_text'))} />
|
|
300
|
+
<TextField
|
|
301
|
+
style={styles.cardContainer}
|
|
302
|
+
value={state.name}
|
|
303
|
+
showError={state.name?.length > 32}
|
|
304
|
+
maxLength={33}
|
|
305
|
+
errorText={I18n.getLang('add_new_dynamic_mood_alert_text')}
|
|
306
|
+
placeholder={I18n.getLang('add_new_trigger_time_inputfield_value_text')}
|
|
307
|
+
onChangeText={(t: string) => {
|
|
308
|
+
state.name = t;
|
|
309
|
+
}}
|
|
310
|
+
/>
|
|
311
|
+
{/* pick */}
|
|
312
|
+
<LdvPickerView
|
|
313
|
+
style={styles.picker}
|
|
314
|
+
hour={state.hour}
|
|
315
|
+
minute={state.minute}
|
|
316
|
+
setHour={v => (state.hour = v)}
|
|
317
|
+
setMinute={v => (state.minute = v)}
|
|
318
|
+
// unit={['h', 'min']}
|
|
319
|
+
/>
|
|
320
|
+
|
|
321
|
+
{/* week */}
|
|
322
|
+
<View style={styles.week}>
|
|
323
|
+
<LdvWeekView style={{}} value={state.loop} onSelect={selectWeekAction} />
|
|
324
|
+
<Spacer />
|
|
325
|
+
<Text style={{ marginHorizontal: cx(24) }}>{loopText(state.loop)}</Text>
|
|
326
|
+
<Spacer />
|
|
327
|
+
</View>
|
|
328
|
+
|
|
329
|
+
{/* Apply for */}
|
|
330
|
+
<View style={styles.cardContainer}>
|
|
331
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
|
|
332
|
+
<View
|
|
333
|
+
style={{
|
|
334
|
+
backgroundColor: '#f6f6f6',
|
|
335
|
+
borderRadius: 4,
|
|
336
|
+
minHeight: cx(50),
|
|
337
|
+
flex: 1,
|
|
338
|
+
justifyContent: 'center',
|
|
339
|
+
}}
|
|
340
|
+
>
|
|
341
|
+
{!hasSelected() ? <Text style={{ marginLeft: cx(10) }}>{I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}</Text> :
|
|
342
|
+
<View
|
|
343
|
+
style={{
|
|
344
|
+
marginHorizontal: cx(8),
|
|
345
|
+
marginTop: cx(8),
|
|
346
|
+
borderRadius: 4,
|
|
347
|
+
}}
|
|
348
|
+
>
|
|
349
|
+
<FlatList
|
|
350
|
+
data={state.selectedSkill}
|
|
351
|
+
renderItem={item => renderItem(item)}
|
|
352
|
+
keyExtractor={(item) => item.dpId + 'selected'}
|
|
353
|
+
/>
|
|
354
|
+
</View>}
|
|
355
|
+
</View>
|
|
356
|
+
{state.skillList.map((item) => {
|
|
357
|
+
return (
|
|
358
|
+
<TouchableOpacity style={styles.skillListItem} key={item.dpId + 'skill'} onPress={() => handelSkill('add', item)}>
|
|
359
|
+
<Text style={{ color: '#000' }}>{item.label}</Text>
|
|
360
|
+
<Image style={{ width: cx(16), height: cx(16) }} source={res.device_panel_timer_add} />
|
|
361
|
+
</TouchableOpacity>
|
|
362
|
+
)
|
|
363
|
+
})}
|
|
364
|
+
<Spacer />
|
|
365
|
+
</View>
|
|
366
|
+
|
|
367
|
+
{/* Device state */}
|
|
368
|
+
<View>
|
|
369
|
+
<Text style={[styles.itemTitle, styles.cardContainer]}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
|
|
370
|
+
<DeviceState
|
|
371
|
+
mixActions={state.mixActions}
|
|
372
|
+
singleActions={state.singleActions}
|
|
373
|
+
editMixFn={editMixActions}
|
|
374
|
+
editSingleFn={editSingleActions}
|
|
375
|
+
isSupportColor={props.isSupportColor}
|
|
376
|
+
isSupportBrightness={true}
|
|
377
|
+
isSupportTemperature={true}
|
|
378
|
+
isMixRGBWLamp={props.isMixRGBWLamp}
|
|
379
|
+
/>
|
|
380
|
+
</View>
|
|
381
|
+
<Spacer />
|
|
382
|
+
{/* Settings */}
|
|
383
|
+
<View style={styles.cardContainer}>
|
|
384
|
+
<Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline4_text')}</Text>
|
|
385
|
+
<Spacer />
|
|
386
|
+
<Text>{I18n.getLang(props.isSleep ? 'add_sleepschedule_one_source_settings_text' : 'add_wakeupschedule_settings_text')}</Text>
|
|
387
|
+
<LdvPickerView
|
|
388
|
+
style={styles.picker}
|
|
389
|
+
hour={props.isSleep ? state.fadeOutHour : state.fadeInHour}
|
|
390
|
+
minute={props.isSleep ? state.fadeOutMinute : state.fadeInMinute}
|
|
391
|
+
minutesStep={5}
|
|
392
|
+
setHour={v => {
|
|
393
|
+
if (props.isSleep) {
|
|
394
|
+
state.fadeOutHour = v
|
|
395
|
+
} else {
|
|
396
|
+
state.fadeInHour = v
|
|
397
|
+
}
|
|
398
|
+
}}
|
|
399
|
+
setMinute={v => {
|
|
400
|
+
if (props.isSleep) {
|
|
401
|
+
state.fadeOutMinute = v
|
|
402
|
+
} else {
|
|
403
|
+
state.fadeInMinute = v
|
|
404
|
+
}
|
|
405
|
+
}}
|
|
406
|
+
unit={['h', 'min']}
|
|
407
|
+
maxHour={3}
|
|
408
|
+
/>
|
|
409
|
+
<Text>{I18n.formatValue(props.isSleep ? 'add_sleepschedule_one_source_settings_text2' : 'add_wakeupschedule_settings_text2', `${formateTime(props.isSleep ? state.fadeOut : state.fadeIn, props.isSleep)}`)}</Text>
|
|
410
|
+
<Spacer />
|
|
411
|
+
{!props.isSleep &&
|
|
412
|
+
<View style={{ marginHorizontal: -cx(16), marginTop: -cx(20) }}>
|
|
413
|
+
<LdvSwitch
|
|
414
|
+
title={I18n.getLang('add_wakeupschedule_settings_text3')}
|
|
415
|
+
enable={state.durationStatus}
|
|
416
|
+
color="#fff"
|
|
417
|
+
colorAlpha={1}
|
|
418
|
+
setEnable={() => {
|
|
419
|
+
state.durationStatus = !state.durationStatus
|
|
420
|
+
state.duration = 5
|
|
421
|
+
state.durationHour = '00'
|
|
422
|
+
state.durationMinute = '05'
|
|
423
|
+
if (!state.durationStatus) {
|
|
424
|
+
state.duration = 0
|
|
425
|
+
}
|
|
426
|
+
}}
|
|
427
|
+
/>
|
|
428
|
+
</View>
|
|
429
|
+
}
|
|
430
|
+
{state.durationStatus && <>
|
|
431
|
+
<Text style={{ fontSize: cx(14) }}>{I18n.getLang('add_wakeupschedule_settings_text4')}</Text>
|
|
432
|
+
<LdvPickerView
|
|
433
|
+
style={styles.picker}
|
|
434
|
+
hour={state.durationHour}
|
|
435
|
+
minutesStep={5}
|
|
436
|
+
minute={state.durationMinute}
|
|
437
|
+
setHour={v => (state.durationHour = v)}
|
|
438
|
+
setMinute={v => (state.durationMinute = v)}
|
|
439
|
+
unit={['h', 'min']}
|
|
440
|
+
maxHour={3}
|
|
441
|
+
/>
|
|
442
|
+
<Text>{I18n.formatValue('add_wakeupschedule_settings_text5', `${formateTime(state.duration, !props.isSleep)}`)}</Text>
|
|
443
|
+
<Spacer />
|
|
444
|
+
</>}
|
|
445
|
+
</View>
|
|
446
|
+
{/* Summary */}
|
|
447
|
+
<View style={styles.cardContainer}>
|
|
448
|
+
<Text style={styles.itemTitle}>{I18n.getLang('add_randomtimecycle_subheadline_text')}</Text>
|
|
449
|
+
<View style={styles.summaryContainer}>
|
|
450
|
+
<View style={styles.summaryLeft}>
|
|
451
|
+
<Image
|
|
452
|
+
source={res.summary_icon1}
|
|
453
|
+
resizeMode="contain"
|
|
454
|
+
style={styles.summaryImg}
|
|
455
|
+
/>
|
|
456
|
+
<View>
|
|
457
|
+
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_frequency_headline')}</Text>
|
|
458
|
+
</View>
|
|
459
|
+
</View>
|
|
460
|
+
<View style={styles.summaryRight}>
|
|
461
|
+
<Text style={styles.rightItem}>{loopText(state.loop)}</Text>
|
|
462
|
+
</View>
|
|
463
|
+
</View>
|
|
464
|
+
<View style={styles.summaryContainer}>
|
|
465
|
+
<View style={styles.summaryLeft}>
|
|
466
|
+
<Image
|
|
467
|
+
source={res.summary_icon2}
|
|
468
|
+
resizeMode="contain"
|
|
469
|
+
style={styles.summaryImg}
|
|
470
|
+
/>
|
|
471
|
+
<View>
|
|
472
|
+
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_time_headline')}</Text>
|
|
473
|
+
</View>
|
|
474
|
+
</View>
|
|
475
|
+
<View style={styles.summaryRight}>
|
|
476
|
+
<Text style={styles.rightItem}>{formateDurationTime().durationTime}</Text>
|
|
477
|
+
</View>
|
|
478
|
+
</View>
|
|
479
|
+
<View style={[styles.summaryContainer, { alignItems: 'flex-start' }]}>
|
|
480
|
+
<View style={styles.summaryLeft}>
|
|
481
|
+
<Image
|
|
482
|
+
source={res.summary_icon3}
|
|
483
|
+
resizeMode="contain"
|
|
484
|
+
style={styles.summaryImg}
|
|
485
|
+
/>
|
|
486
|
+
<View>
|
|
487
|
+
<Text style={styles.leftTitle}>{I18n.getLang('motion_detection_add_time_schedule_actions_text1')}</Text>
|
|
488
|
+
</View>
|
|
489
|
+
</View>
|
|
490
|
+
<View style={{ marginLeft: cx(24), flex: 3 }}>
|
|
491
|
+
<Text style={{ fontSize: cx(12), color: '#000000' }}>{I18n.getLang(!props.isSleep ? 'feature_summary_action_txt_11' : 'feature_summary_action_txt_10')}</Text>
|
|
492
|
+
<View style={{ flexDirection: 'row' }}>
|
|
493
|
+
{
|
|
494
|
+
props.isMixRGBWLamp &&
|
|
495
|
+
<>
|
|
496
|
+
{
|
|
497
|
+
state.mixActions.whiteLightSwitch &&
|
|
498
|
+
<View style={styles.filletCorner}>
|
|
499
|
+
<Text style={styles.rightTitle}>{state.selectedSkill[0]?.label}</Text>
|
|
500
|
+
</View>
|
|
501
|
+
}
|
|
502
|
+
{
|
|
503
|
+
state.mixActions.colorLightSwitch &&
|
|
504
|
+
<View style={[styles.filletCorner, { marginLeft: cx(4) }]}>
|
|
505
|
+
<Text style={styles.rightTitle}>{state.selectedSkill[1]?.label}</Text>
|
|
506
|
+
</View>
|
|
507
|
+
}
|
|
508
|
+
</> ||
|
|
509
|
+
<View style={styles.filletCorner}>
|
|
510
|
+
<Text style={styles.rightTitle}>{state.selectedSkill[0]?.label}</Text>
|
|
511
|
+
</View>
|
|
512
|
+
}
|
|
513
|
+
</View>
|
|
514
|
+
<Text style={{ fontSize: cx(12), color: '#000000' }}>{I18n.getLang(
|
|
515
|
+
props.isSleep ? 'feature_summary_action_txt_2' :
|
|
516
|
+
(state.durationStatus ? 'feature_summary_action_txt_12' : 'feature_summary_action_txt_1')
|
|
517
|
+
)}</Text>
|
|
518
|
+
<View style={styles.filletCorner}>
|
|
519
|
+
<Text style={styles.rightTitle}>{formateDurationTime().endTime}</Text>
|
|
520
|
+
</View>
|
|
521
|
+
</View>
|
|
522
|
+
</View>
|
|
523
|
+
</View>
|
|
524
|
+
<Spacer />
|
|
525
|
+
{/* Delete btn */}
|
|
526
|
+
{props.mode === 'edit' &&
|
|
527
|
+
<View style={styles.cardContainer}>
|
|
528
|
+
<DeleteButton
|
|
529
|
+
text={I18n.getLang('edit_timeschedule_bttn_text')}
|
|
530
|
+
onPress={() => {
|
|
531
|
+
props.deleteDialog(scheduleItem).then(() => {
|
|
532
|
+
navigation.goBack()
|
|
533
|
+
})
|
|
534
|
+
}}
|
|
535
|
+
/>
|
|
536
|
+
</View>
|
|
537
|
+
}
|
|
538
|
+
<Spacer />
|
|
539
|
+
</ScrollView>
|
|
540
|
+
</Page>
|
|
541
|
+
)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
const styles = StyleSheet.create({
|
|
545
|
+
cardContainer: {
|
|
546
|
+
marginHorizontal: cx(24)
|
|
547
|
+
},
|
|
548
|
+
textField: {
|
|
549
|
+
marginHorizontal: cx(24)
|
|
550
|
+
},
|
|
551
|
+
picker: {
|
|
552
|
+
marginHorizontal: cx(24),
|
|
553
|
+
marginVertical: cx(15),
|
|
554
|
+
color: 'rgb(35,35,38)',
|
|
555
|
+
},
|
|
556
|
+
week: {
|
|
557
|
+
|
|
558
|
+
},
|
|
559
|
+
itemTitle: {
|
|
560
|
+
color: '#000',
|
|
561
|
+
fontSize: cx(16),
|
|
562
|
+
fontWeight: 'bold',
|
|
563
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
564
|
+
marginBottom: cx(10)
|
|
565
|
+
},
|
|
566
|
+
skillListItem: {
|
|
567
|
+
flexDirection: 'row',
|
|
568
|
+
justifyContent: 'space-between',
|
|
569
|
+
height: cx(30),
|
|
570
|
+
alignItems: 'center',
|
|
571
|
+
marginVertical: cx(5)
|
|
572
|
+
},
|
|
573
|
+
summaryContainer: {
|
|
574
|
+
flexDirection: 'row',
|
|
575
|
+
justifyContent: 'flex-start',
|
|
576
|
+
marginBottom: cx(10)
|
|
577
|
+
},
|
|
578
|
+
summaryImg: {
|
|
579
|
+
height: cx(12),
|
|
580
|
+
width: cx(12),
|
|
581
|
+
marginRight: cx(6)
|
|
582
|
+
},
|
|
583
|
+
summaryLeft: {
|
|
584
|
+
flexDirection: 'row',
|
|
585
|
+
alignItems: 'center',
|
|
586
|
+
minWidth: cx(90),
|
|
587
|
+
},
|
|
588
|
+
leftTitle: {
|
|
589
|
+
fontSize: cx(14),
|
|
590
|
+
color: '#000',
|
|
591
|
+
},
|
|
592
|
+
summaryRight: {
|
|
593
|
+
flexDirection: 'column',
|
|
594
|
+
marginLeft: cx(21),
|
|
595
|
+
borderRadius: cx(16),
|
|
596
|
+
backgroundColor: '#cbcbcb',
|
|
597
|
+
},
|
|
598
|
+
rightItem: {
|
|
599
|
+
paddingHorizontal: cx(12),
|
|
600
|
+
color: '#000',
|
|
601
|
+
},
|
|
602
|
+
rightTitle: {
|
|
603
|
+
paddingLeft: cx(12),
|
|
604
|
+
paddingRight: cx(12),
|
|
605
|
+
fontSize: cx(10),
|
|
606
|
+
textAlign: 'center',
|
|
607
|
+
alignSelf: 'flex-start'
|
|
608
|
+
},
|
|
609
|
+
filletCorner: {
|
|
610
|
+
flexDirection: 'row',
|
|
611
|
+
backgroundColor: '#cbcbcb',
|
|
612
|
+
borderRadius: cx(16),
|
|
613
|
+
alignSelf: 'flex-start'
|
|
614
|
+
}
|
|
615
|
+
})
|
|
616
|
+
|
|
617
617
|
export default SleepWakeUpDetailPage
|