@ledvance/ui-biz-bundle 1.1.61 → 1.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/biorhythm/BiorhythmPage.tsx +2 -0
- package/src/modules/flags/FlagActions.ts +1 -0
- package/src/modules/flags/FlagPage.tsx +2 -1
- package/src/modules/timer/TimerPage.tsx +1 -1
- package/src/newModules/fixedTime/FixedTimeActions.ts +50 -44
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +40 -35
- package/src/newModules/fixedTime/FixedTimePage.tsx +158 -85
- package/src/newModules/randomTime/RandomTimeActions.ts +57 -49
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +33 -29
- package/src/newModules/randomTime/RandomTimePage.tsx +152 -84
- package/src/newModules/timeSchedule/Interface.ts +34 -4
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +118 -133
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +79 -49
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +209 -9
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +28 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useCallback } from 'react'
|
|
1
|
+
import React, { useCallback, useMemo } from 'react'
|
|
2
2
|
import { FlatList, Image, ScrollView, StyleSheet, Text, View } from 'react-native'
|
|
3
3
|
import Page from '@ledvance/base/src/components/Page'
|
|
4
4
|
import { useDeviceInfo, useSystemTimeFormate } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
5
|
-
import { useNavigation
|
|
5
|
+
import { useNavigation } from '@react-navigation/core'
|
|
6
6
|
import I18n from '@ledvance/base/src/i18n'
|
|
7
7
|
import res from '@ledvance/base/src/res'
|
|
8
8
|
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
@@ -15,6 +15,10 @@ import Card from '@ledvance/base/src/components/Card'
|
|
|
15
15
|
import { convertMinutesTo12HourFormat, loopText } from '@ledvance/base/src/utils/common'
|
|
16
16
|
import { cloneDeep } from 'lodash'
|
|
17
17
|
import dayjs from 'dayjs'
|
|
18
|
+
import { ApplyForItem } from '@ledvance/ui-biz-bundle/src/newModules/timeSchedule/Interface'
|
|
19
|
+
import { useParams } from '@ledvance/base/src/hooks/Hooks'
|
|
20
|
+
import Tag from '@ledvance/base/src/components/Tag'
|
|
21
|
+
import InfoText from '@ledvance/base/src/components/InfoText'
|
|
18
22
|
|
|
19
23
|
const { convertX: cx } = Utils.RatioUtils
|
|
20
24
|
const { parseTimer } = Utils.TimeUtils
|
|
@@ -29,30 +33,37 @@ export interface RandomTimePageParams {
|
|
|
29
33
|
}
|
|
30
34
|
isPlug?: boolean
|
|
31
35
|
showTags?: boolean
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
isSupportColor: boolean
|
|
37
|
-
isSupportTemperature: boolean
|
|
38
|
-
isSupportBrightness: boolean
|
|
36
|
+
applyForList: ApplyForItem[]
|
|
37
|
+
isSupportColor?: boolean
|
|
38
|
+
isSupportTemperature?: boolean
|
|
39
|
+
isSupportBrightness?: boolean
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
const RandomTimePage = () => {
|
|
42
43
|
const navigation = useNavigation()
|
|
43
44
|
const devInfo = useDeviceInfo()
|
|
44
|
-
const params =
|
|
45
|
+
const params = useParams<RandomTimePageParams>()
|
|
45
46
|
const is24Hour = useSystemTimeFormate()
|
|
46
47
|
const [randomTime, setRandomTime] = useRandomTime(params.randomTimeDpCode, params.isPlug)
|
|
47
48
|
const state = useReactive({
|
|
48
49
|
loading: false,
|
|
50
|
+
originList: cloneDeep(randomTime),
|
|
49
51
|
randomTimeList: cloneDeep(randomTime),
|
|
52
|
+
checkTags: params.applyForList.map(v => ({ ...v, enable: false }))
|
|
50
53
|
})
|
|
51
54
|
|
|
52
55
|
useUpdateEffect(() => {
|
|
53
|
-
state.
|
|
56
|
+
state.originList = cloneDeep(randomTime)
|
|
54
57
|
}, [randomTime])
|
|
55
58
|
|
|
59
|
+
useUpdateEffect(() => {
|
|
60
|
+
const isAll = state.checkTags.every(tag => tag.enable) || state.checkTags.every(tag => !tag.enable)
|
|
61
|
+
const checkedList = state.originList.filter(item => {
|
|
62
|
+
return isAll || state.checkTags[item.channel || 0]?.enable
|
|
63
|
+
})
|
|
64
|
+
state.randomTimeList = cloneDeep(checkedList)
|
|
65
|
+
}, [JSON.stringify(state.checkTags), JSON.stringify(state.originList)])
|
|
66
|
+
|
|
56
67
|
const navigateToEdit = useCallback((mode: 'add' | 'edit', scheduleItem?: RandomTimerUiItem) => {
|
|
57
68
|
navigation.navigate(ui_biz_routerKey.ui_biz_random_time_edit_new, {
|
|
58
69
|
...params,
|
|
@@ -63,19 +74,40 @@ const RandomTimePage = () => {
|
|
|
63
74
|
}, [])
|
|
64
75
|
|
|
65
76
|
const showMaxNumTip = useCallback(() => {
|
|
66
|
-
return state.
|
|
67
|
-
}, [state.
|
|
77
|
+
return state.originList.length >= MAX_NUM
|
|
78
|
+
}, [state.originList.length])
|
|
68
79
|
|
|
69
80
|
const onPost = useCallback(async (mode: 'add' | 'edit' | 'del', randomTime: RandomTimerUiItem) => {
|
|
70
|
-
const cloneRandomTime = cloneDeep(state.
|
|
71
|
-
const idx = state.
|
|
81
|
+
const cloneRandomTime = cloneDeep(state.originList)
|
|
82
|
+
const idx = state.originList.findIndex(f => f.index === randomTime.index)
|
|
72
83
|
if (mode === 'edit') {
|
|
73
84
|
cloneRandomTime.splice(idx, 1, randomTime)
|
|
74
85
|
}
|
|
75
86
|
if (mode === 'del') cloneRandomTime.splice(idx, 1)
|
|
76
|
-
const newRandomTimeList = mode === 'add' ? [...state.
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
const newRandomTimeList = mode === 'add' ? [...state.originList, randomTime] : cloneRandomTime
|
|
88
|
+
const res = await setRandomTime(newRandomTimeList)
|
|
89
|
+
if(res.success){
|
|
90
|
+
state.originList = cloneDeep(newRandomTimeList)
|
|
91
|
+
}
|
|
92
|
+
return res
|
|
93
|
+
}, [state.originList])
|
|
94
|
+
|
|
95
|
+
const showTags = useMemo(() => (
|
|
96
|
+
<View style={styles.categoryList}>
|
|
97
|
+
{state.checkTags.map((tag, idx) => (
|
|
98
|
+
<Tag
|
|
99
|
+
key={tag.key}
|
|
100
|
+
text={tag.key}
|
|
101
|
+
checked={tag.enable}
|
|
102
|
+
onCheckedChange={(v) => {
|
|
103
|
+
state.checkTags[idx].enable = v
|
|
104
|
+
state.checkTags = cloneDeep(state.checkTags)
|
|
105
|
+
}}
|
|
106
|
+
style={{ marginRight: cx(5), marginBottom: cx(5) }}
|
|
107
|
+
/>
|
|
108
|
+
))}
|
|
109
|
+
</View>
|
|
110
|
+
), [state.checkTags])
|
|
79
111
|
|
|
80
112
|
return (
|
|
81
113
|
<Page
|
|
@@ -88,71 +120,74 @@ const RandomTimePage = () => {
|
|
|
88
120
|
navigateToEdit('add', newRandomTime())
|
|
89
121
|
}}
|
|
90
122
|
>
|
|
91
|
-
{
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<View style={{
|
|
123
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
124
|
+
<Text style={{
|
|
125
|
+
color: '#000',
|
|
126
|
+
marginLeft: cx(24),
|
|
127
|
+
}}>{I18n.getLang('timeschedule_overview_description_text')}</Text>
|
|
128
|
+
<Spacer height={cx(10)} />
|
|
129
|
+
{showMaxNumTip() && <InfoText
|
|
130
|
+
style={{ marginHorizontal: cx(24), marginBottom: cx(5) }}
|
|
131
|
+
icon={res.ic_warning_amber}
|
|
132
|
+
iconStyle={{width: cx(16), height: cx(16)}}
|
|
133
|
+
contentColor="#FF9500"
|
|
134
|
+
text={I18n.getLang('randomtimecycle_warning_max_number_text')}
|
|
135
|
+
textStyle={{fontSize: cx(12)}}
|
|
136
|
+
/>}
|
|
137
|
+
{params.showTags && !!state.originList.length && showTags}
|
|
138
|
+
{state.randomTimeList.length > 0 ? <FlatList
|
|
139
|
+
data={state.randomTimeList}
|
|
140
|
+
renderItem={({ item }) => (
|
|
141
|
+
<RandomTimeCard
|
|
142
|
+
is24Hour={is24Hour}
|
|
143
|
+
randomTime={item}
|
|
144
|
+
showTags={params.showTags}
|
|
145
|
+
tags={params.applyForList}
|
|
146
|
+
onSwitch={async (v) => {
|
|
147
|
+
state.loading = true
|
|
148
|
+
await onPost('edit', {
|
|
149
|
+
...item,
|
|
150
|
+
enable: v,
|
|
151
|
+
})
|
|
152
|
+
state.loading = false
|
|
153
|
+
}}
|
|
154
|
+
onPress={() => {
|
|
155
|
+
navigateToEdit('edit', item)
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
keyExtractor={(item: any) => `${item?.index}`}
|
|
160
|
+
ItemSeparatorComponent={() => <Spacer />}
|
|
161
|
+
ListHeaderComponent={<Spacer height={cx(10)} />}
|
|
162
|
+
ListFooterComponent={<Spacer />}
|
|
163
|
+
/> :
|
|
164
|
+
<View style={{ flex: 1, marginTop: cx(60), alignItems: 'center', marginHorizontal: cx(24) }}>
|
|
133
165
|
<Image
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
style={{ width: cx(225), height: cx(198) }}
|
|
167
|
+
source={{ uri: res.ldv_timer_empty }}
|
|
168
|
+
resizeMode="contain" />
|
|
169
|
+
<InfoText
|
|
170
|
+
icon={res.device_panel_schedule_alert}
|
|
171
|
+
text={I18n.getLang(!state.originList.length ? 'timeschedule_overview_empty_information_text' : 'sleepwakeschedule_empty_filtering_information_text')}
|
|
172
|
+
style={{ width: 'auto', alignItems: 'center' }}
|
|
173
|
+
textStyle={{ color: '#000', fontSize: cx(12), flex: undefined }}
|
|
174
|
+
iconStyle={{ width: cx(16), height: cx(16), tintColor: '#000' }}
|
|
136
175
|
/>
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
navigateToEdit('add', newRandomTime())
|
|
153
|
-
}} />
|
|
154
|
-
</View>
|
|
155
|
-
}
|
|
176
|
+
<Spacer />
|
|
177
|
+
{!state.originList.length && <TextButton
|
|
178
|
+
text={I18n.getLang('randomtimecycle_empty_bttn_text')}
|
|
179
|
+
style={{
|
|
180
|
+
backgroundColor: '#f60',
|
|
181
|
+
borderRadius: cx(6),
|
|
182
|
+
paddingVertical: cx(12),
|
|
183
|
+
paddingHorizontal: cx(24),
|
|
184
|
+
}}
|
|
185
|
+
textStyle={{ color: '#fff' }}
|
|
186
|
+
onPress={() => {
|
|
187
|
+
navigateToEdit('add', newRandomTime())
|
|
188
|
+
}} />}
|
|
189
|
+
</View>}
|
|
190
|
+
</ScrollView>
|
|
156
191
|
</Page>
|
|
157
192
|
)
|
|
158
193
|
}
|
|
@@ -160,10 +195,12 @@ const RandomTimePage = () => {
|
|
|
160
195
|
const RandomTimeCard = (props: {
|
|
161
196
|
is24Hour: boolean
|
|
162
197
|
randomTime: RandomTimerUiItem,
|
|
198
|
+
tags: ApplyForItem[]
|
|
199
|
+
showTags?: boolean,
|
|
163
200
|
onSwitch: (enable: boolean) => void,
|
|
164
201
|
onPress: () => void
|
|
165
202
|
}) => {
|
|
166
|
-
const { is24Hour, randomTime, onSwitch, onPress } = props
|
|
203
|
+
const { is24Hour, randomTime, tags, showTags, onSwitch, onPress } = props
|
|
167
204
|
return (
|
|
168
205
|
<Card style={styles.randomTimingCard} onPress={onPress}>
|
|
169
206
|
<Spacer height={cx(16)} />
|
|
@@ -179,7 +216,14 @@ const RandomTimeCard = (props: {
|
|
|
179
216
|
<Text style={styles.loopText}>{loopText(randomTime.weeks, parseTimer(randomTime.startTime * 60))}</Text>
|
|
180
217
|
<Spacer height={cx(5)} />
|
|
181
218
|
<Text style={styles.loopText}>{randomTime.name}</Text>
|
|
182
|
-
<Spacer />
|
|
219
|
+
<Spacer height={cx(showTags ? 5 : 20)} />
|
|
220
|
+
{showTags && <View style={styles.tagContainer}>
|
|
221
|
+
<View style={styles.tag}>
|
|
222
|
+
<Text style={styles.tagTitle}>
|
|
223
|
+
{tags[randomTime.channel || 0]?.key}
|
|
224
|
+
</Text>
|
|
225
|
+
</View>
|
|
226
|
+
</View>}
|
|
183
227
|
</Card>
|
|
184
228
|
)
|
|
185
229
|
}
|
|
@@ -192,7 +236,7 @@ const newRandomTime = () => {
|
|
|
192
236
|
weeks: [0, 0, 0, 0, 0, 0, 0],
|
|
193
237
|
startTime: startTime,
|
|
194
238
|
endTime: startTime + 60,
|
|
195
|
-
channel:
|
|
239
|
+
channel: 0,
|
|
196
240
|
color: {
|
|
197
241
|
h: 0,
|
|
198
242
|
s: 100,
|
|
@@ -225,6 +269,30 @@ const styles = StyleSheet.create({
|
|
|
225
269
|
fontSize: cx(14),
|
|
226
270
|
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
227
271
|
},
|
|
272
|
+
categoryList: {
|
|
273
|
+
display: 'flex',
|
|
274
|
+
flexDirection: 'row',
|
|
275
|
+
flexWrap: 'wrap',
|
|
276
|
+
marginHorizontal: cx(24),
|
|
277
|
+
alignSelf: 'flex-start'
|
|
278
|
+
},
|
|
279
|
+
tagContainer: {
|
|
280
|
+
flexDirection: 'row',
|
|
281
|
+
marginBottom: cx(15)
|
|
282
|
+
},
|
|
283
|
+
tag: {
|
|
284
|
+
borderRadius: cx(16),
|
|
285
|
+
height: cx(16),
|
|
286
|
+
backgroundColor: '#E6E7E8',
|
|
287
|
+
marginRight: cx(10),
|
|
288
|
+
paddingHorizontal: cx(12)
|
|
289
|
+
},
|
|
290
|
+
tagTitle: {
|
|
291
|
+
fontSize: cx(10),
|
|
292
|
+
textAlign: 'center',
|
|
293
|
+
fontFamily: 'PingFangSC-Medium',
|
|
294
|
+
color: '#000'
|
|
295
|
+
},
|
|
228
296
|
})
|
|
229
297
|
|
|
230
298
|
export default RandomTimePage
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
1
2
|
import { MoodInfo, MoodUIInfo } from "../mood/Interface";
|
|
2
3
|
|
|
3
4
|
export interface Timer {
|
|
@@ -26,6 +27,8 @@ export interface HSV {
|
|
|
26
27
|
export type Category = 'light' | 'socket' | 'fan' | 'mainLight' | 'secondaryLight'
|
|
27
28
|
|
|
28
29
|
export interface ApplyForItem {
|
|
30
|
+
name?: string
|
|
31
|
+
index?: number
|
|
29
32
|
key: string;
|
|
30
33
|
dp: string;
|
|
31
34
|
type: Category;
|
|
@@ -40,6 +43,8 @@ interface judgmentSupport {
|
|
|
40
43
|
isStripLight?: boolean;
|
|
41
44
|
isStringLight?: boolean;
|
|
42
45
|
isMixLight?: boolean;
|
|
46
|
+
isFanLight?: boolean;
|
|
47
|
+
isUVCFan?: boolean;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
export interface ManualSettingProps extends judgmentSupport {
|
|
@@ -53,9 +58,12 @@ export interface ManualSettingProps extends judgmentSupport {
|
|
|
53
58
|
|
|
54
59
|
export enum DeviceType {
|
|
55
60
|
Plug = 'Plug',
|
|
61
|
+
PowerStrip = 'PowerStrip',
|
|
56
62
|
LightSource = 'lightSource',
|
|
57
63
|
MixLight = 'mixLight',
|
|
58
64
|
StripLight = 'stripLight',
|
|
65
|
+
CeilingLight = 'ceilingLight',
|
|
66
|
+
FanLight = 'fanLight'
|
|
59
67
|
}
|
|
60
68
|
// export type DeviceType = 'LightSource' | 'CeilingLight' | 'StringLight' | 'StripLight' | 'MixLight';
|
|
61
69
|
|
|
@@ -81,19 +89,32 @@ export interface MixLightData extends DeviceData {
|
|
|
81
89
|
export interface StripLightData extends DeviceData {
|
|
82
90
|
colors: string[];
|
|
83
91
|
activeKey: number;
|
|
92
|
+
colorDiskActiveKey: number
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface CeilingLightData extends DeviceData, StripLightData, MixLightData {
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface FanLightData extends DeviceData {
|
|
99
|
+
fanSpeed: number
|
|
100
|
+
direction: 'forward' | 'reverse'
|
|
101
|
+
mode: 'nature' | 'normal'
|
|
102
|
+
disinfect: boolean
|
|
84
103
|
}
|
|
85
104
|
|
|
86
105
|
export type ComponentConfig =
|
|
87
|
-
| { type: DeviceType.Plug; deviceData: PlugData }
|
|
88
106
|
| { type: DeviceType.LightSource; deviceData: DeviceData }
|
|
89
107
|
| { type: DeviceType.MixLight; deviceData: MixLightData }
|
|
90
|
-
| { type: DeviceType.StripLight; deviceData: StripLightData }
|
|
108
|
+
| { type: DeviceType.StripLight; deviceData: StripLightData }
|
|
109
|
+
| { type: DeviceType.CeilingLight; deviceData: CeilingLightData }
|
|
110
|
+
| { type: DeviceType.FanLight; deviceData: FanLightData }
|
|
111
|
+
| { type: DeviceType.PowerStrip; deviceData: DeviceData}
|
|
91
112
|
|
|
92
113
|
export interface TimeScheduleDetailState {
|
|
93
114
|
timeSchedule: Timer;
|
|
94
115
|
dps: Record<string, any>;
|
|
95
116
|
isManual: boolean;
|
|
96
|
-
initSelectedSkill: ApplyForItem[]
|
|
117
|
+
initSelectedSkill: ApplyForItem[],
|
|
97
118
|
selectedSkill: ApplyForItem[];
|
|
98
119
|
unSelectedSkill: ApplyForItem[];
|
|
99
120
|
loading: boolean;
|
|
@@ -104,9 +125,18 @@ export interface TimeScheduleDetailState {
|
|
|
104
125
|
timerId: any;
|
|
105
126
|
moodName: string;
|
|
106
127
|
}
|
|
107
|
-
|
|
108
128
|
export interface DeviceStateType {
|
|
109
129
|
deviceData: ComponentConfig
|
|
110
130
|
mood?: MoodInfo
|
|
111
131
|
isManual: boolean
|
|
112
132
|
}
|
|
133
|
+
|
|
134
|
+
export const directOptions = [
|
|
135
|
+
{label: I18n.getLang('ceiling_fan_tile_uvc_fan_direction_opt_1'), value: 'forward'},
|
|
136
|
+
{label: I18n.getLang('ceiling_fan_tile_uvc_fan_direction_opt_2'), value: 'reverse'}
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
export const modeOptions = [
|
|
140
|
+
{label: I18n.getLang('ceiling_fan_tile_uvc_fan_mode_opt_1'), value: 'normal'},
|
|
141
|
+
{label: I18n.getLang('ceiling_fan_tile_uvc_fan_mode_opt_2'), value: 'nature'},
|
|
142
|
+
]
|