@ledvance/group-ui-biz-bundle 1.0.0
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 -0
- package/.eslintignore +6 -0
- package/.eslintrc.js +27 -0
- package/.prettierignore +0 -0
- package/.prettierrc.js +1 -0
- package/.versionrc +5 -0
- package/package.json +73 -0
- package/rn-cli.config.js +8 -0
- package/src/modules/mood/AddMoodPage.tsx +826 -0
- package/src/modules/mood/DynamicMoodEditorPage.tsx +547 -0
- package/src/modules/mood/MoodItem.tsx +114 -0
- package/src/modules/mood/MoodPage.tsx +332 -0
- package/src/modules/mood/RecommendMoodItem.tsx +75 -0
- package/src/modules/mood/SceneAction.ts +459 -0
- package/src/modules/mood/SceneInfo.ts +886 -0
- package/src/modules/mood/StaticMoodEditorPage.tsx +251 -0
- package/src/modules/mood/tools.ts +12 -0
- package/src/modules/select/SelectPage.d.ts +12 -0
- package/src/modules/select/SelectPage.tsx +139 -0
- package/src/modules/time_schedule/Interface.ts +85 -0
- package/src/modules/time_schedule/ScheduleCard.tsx +111 -0
- package/src/modules/time_schedule/TimeScheduleActions.ts +81 -0
- package/src/modules/time_schedule/TimeScheduleDetailPage.tsx +704 -0
- package/src/modules/time_schedule/TimeSchedulePage.tsx +246 -0
- package/src/modules/timer/TimerAction.d.ts +12 -0
- package/src/modules/timer/TimerAction.ts +150 -0
- package/src/modules/timer/TimerPage.d.ts +2 -0
- package/src/modules/timer/TimerPage.tsx +351 -0
- package/src/navigation/Routers.d.ts +5 -0
- package/src/navigation/Routers.ts +97 -0
- package/src/navigation/tools.d.ts +0 -0
- package/src/navigation/tools.ts +0 -0
- package/src/res/GroupBizRes.ts +4 -0
- package/src/res/materialiconsFilledCancel.png +0 -0
- package/src/res/materialiconsFilledCancel@2x.png +0 -0
- package/src/res/materialiconsFilledCancel@3x.png +0 -0
- package/src/res/materialiconsOutlinedArrowsNavAddBox.png +0 -0
- package/src/res/materialiconsOutlinedArrowsNavAddBox@2x.png +0 -0
- package/src/res/materialiconsOutlinedArrowsNavAddBox@3x.png +0 -0
- package/tsconfig.json +51 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react'
|
|
2
|
+
import { ScrollView, StyleSheet, Text, View } from 'react-native'
|
|
3
|
+
import { cloneDeep, find, isEqual } from 'lodash'
|
|
4
|
+
import { useReactive } from 'ahooks'
|
|
5
|
+
import Page from '@ledvance/base/src/components/Page'
|
|
6
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
7
|
+
import { useNavigation, useRoute } from '@react-navigation/native'
|
|
8
|
+
import TextField from '@ledvance/base/src/components/TextField'
|
|
9
|
+
import { Utils } from 'tuya-panel-kit'
|
|
10
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
11
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
12
|
+
import res from '@ledvance/base/src/res'
|
|
13
|
+
import TextButton from '@ledvance/base/src/components/TextButton'
|
|
14
|
+
import { useFanMaxSpeed, useRole } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
15
|
+
import { SceneNodeInfo, SceneUIState } from './SceneInfo'
|
|
16
|
+
import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
|
|
17
|
+
import FanAdjustView from '@ledvance/base/src/components/FanAdjustView'
|
|
18
|
+
import { showDeleteMoodDialog } from './tools'
|
|
19
|
+
import { MoodPageProps } from './MoodPage'
|
|
20
|
+
import { Result } from '@ledvance/base/src/models/modules/Result'
|
|
21
|
+
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
22
|
+
|
|
23
|
+
const cx = Utils.RatioUtils.convertX
|
|
24
|
+
|
|
25
|
+
export interface StaticMoodEditorPageParams {
|
|
26
|
+
mode: 'add' | 'edit'
|
|
27
|
+
moods: SceneUIState[]
|
|
28
|
+
currentMood: SceneUIState
|
|
29
|
+
onSave: () => void
|
|
30
|
+
moduleParams: MoodPageProps
|
|
31
|
+
modDeleteMood: (mode: 'add' | 'edit' | 'del', currentMood: SceneUIState) => Promise<Result<any>>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface StaticMoodEditorPageState {
|
|
35
|
+
headline: string
|
|
36
|
+
mood: SceneUIState
|
|
37
|
+
currentNode: SceneNodeInfo
|
|
38
|
+
loading: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const StaticMoodEditorPage = () => {
|
|
42
|
+
const navigation = useNavigation()
|
|
43
|
+
const routeParams = useRoute().params as StaticMoodEditorPageParams
|
|
44
|
+
const params = cloneDeep(routeParams)
|
|
45
|
+
const moduleParams = params.moduleParams
|
|
46
|
+
const role = useRole()
|
|
47
|
+
|
|
48
|
+
const state = useReactive<StaticMoodEditorPageState>({
|
|
49
|
+
headline: '',
|
|
50
|
+
mood: params.currentMood,
|
|
51
|
+
currentNode: params.currentMood.nodes[0],
|
|
52
|
+
loading: false
|
|
53
|
+
})
|
|
54
|
+
const canDelete = useMemo(() => (role === 0 || role === 2), [role])
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
state.headline = I18n.getLang(params.mode === 'add' ? 'add_new_static_mood_headline_text' : 'edit_static_mood_headline_text')
|
|
57
|
+
}, [params.mode])
|
|
58
|
+
|
|
59
|
+
const getColorBlockColor = useCallback(() => {
|
|
60
|
+
return '#fff'
|
|
61
|
+
}, [state.currentNode.colorTemp])
|
|
62
|
+
|
|
63
|
+
const getButtonStatus = () => {
|
|
64
|
+
return (params.mode === 'edit' && isEqual(state.mood, routeParams.currentMood)) ||
|
|
65
|
+
!(!!state.mood.name) ||
|
|
66
|
+
nameRepeat ||
|
|
67
|
+
state.mood.name.length > 32
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const nameRepeat = useMemo(() => {
|
|
71
|
+
return !!find(params.moods, m => (m.id !== state.mood.id && m.name === state.mood.name))
|
|
72
|
+
}, [state.mood.name])
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Page
|
|
76
|
+
backText={I18n.getLang('mesh_device_detail_mode')}
|
|
77
|
+
showBackDialog={true}
|
|
78
|
+
backDialogTitle={
|
|
79
|
+
I18n.getLang(params.mode === 'add' ?
|
|
80
|
+
'string_light_pp_dialog_sm_add_headline_c' :
|
|
81
|
+
'manage_user_unsaved_changes_dialog_headline')
|
|
82
|
+
}
|
|
83
|
+
backDialogContent={
|
|
84
|
+
I18n.getLang(params.mode === 'add' ?
|
|
85
|
+
'strip_light_static_mood_add_step_2_dialog_text' :
|
|
86
|
+
'strip_light_static_mood_editor_step_2_dialog_text')
|
|
87
|
+
}
|
|
88
|
+
headlineText={state.headline}
|
|
89
|
+
rightButtonIcon={getButtonStatus() ? res.ic_uncheck : res.ic_check}
|
|
90
|
+
rightButtonDisabled={getButtonStatus()}
|
|
91
|
+
rightButtonIconClick={async () => {
|
|
92
|
+
if (state.loading) return
|
|
93
|
+
state.loading = true
|
|
94
|
+
const res = await params.modDeleteMood(params.mode, {
|
|
95
|
+
...state.mood,
|
|
96
|
+
nodes: [cloneDeep(state.currentNode)]
|
|
97
|
+
})
|
|
98
|
+
if (res.success) {
|
|
99
|
+
navigation.navigate(ui_biz_routerKey.group_ui_biz_mood)
|
|
100
|
+
}
|
|
101
|
+
state.loading = false
|
|
102
|
+
}}
|
|
103
|
+
loading={state.loading}
|
|
104
|
+
>
|
|
105
|
+
<ScrollView
|
|
106
|
+
style={{ flex: 1 }}
|
|
107
|
+
nestedScrollEnabled={true}>
|
|
108
|
+
<View style={styles.root}>
|
|
109
|
+
<TextField
|
|
110
|
+
style={styles.name}
|
|
111
|
+
value={state.mood.name}
|
|
112
|
+
placeholder={I18n.getLang('edit_static_mood_inputfield_topic_text')}
|
|
113
|
+
onChangeText={text => {
|
|
114
|
+
state.mood.name = text
|
|
115
|
+
}}
|
|
116
|
+
maxLength={33}
|
|
117
|
+
showError={state.mood.name.length > 32 || nameRepeat}
|
|
118
|
+
tipColor={nameRepeat ? '#f00' : undefined}
|
|
119
|
+
tipIcon={nameRepeat ? res.ic_text_field_input_error : undefined}
|
|
120
|
+
errorText={I18n.getLang(nameRepeat ? 'string_light_pp_field_sm_add_error1' : 'add_new_dynamic_mood_alert_text')} />
|
|
121
|
+
<Card style={styles.adjustCard}>
|
|
122
|
+
<Spacer height={cx(16)} />
|
|
123
|
+
<View style={styles.lightLine}>
|
|
124
|
+
<Text style={styles.light}>
|
|
125
|
+
{I18n.getLang('light_sources_tile_tw_lighting_headline')}
|
|
126
|
+
</Text>
|
|
127
|
+
<View style={[styles.preview, { backgroundColor: getColorBlockColor() }]} />
|
|
128
|
+
</View>
|
|
129
|
+
<Spacer />
|
|
130
|
+
<LampAdjustView
|
|
131
|
+
isSupportColor={moduleParams.isSupportColor}
|
|
132
|
+
isSupportBrightness={moduleParams.isSupportBrightness}
|
|
133
|
+
isSupportTemperature={moduleParams.isSupportTemperature}
|
|
134
|
+
isColorMode={state.currentNode.isColorNode}
|
|
135
|
+
reserveSV={true}
|
|
136
|
+
setIsColorMode={isColorMode => {
|
|
137
|
+
state.currentNode.isColorNode = isColorMode
|
|
138
|
+
}}
|
|
139
|
+
h={state.currentNode.h}
|
|
140
|
+
s={state.currentNode.s}
|
|
141
|
+
v={state.currentNode.v}
|
|
142
|
+
onHSVChange={(h, s, v) => {
|
|
143
|
+
state.currentNode.h = h
|
|
144
|
+
state.currentNode.s = s
|
|
145
|
+
state.currentNode.v = v
|
|
146
|
+
}}
|
|
147
|
+
onHSVChangeComplete={(h, s, v) => {
|
|
148
|
+
state.currentNode.h = h
|
|
149
|
+
state.currentNode.s = s
|
|
150
|
+
state.currentNode.v = v
|
|
151
|
+
}}
|
|
152
|
+
colorTemp={state.currentNode.colorTemp}
|
|
153
|
+
brightness={state.currentNode.brightness}
|
|
154
|
+
onCCTChange={cct => {
|
|
155
|
+
state.currentNode.colorTemp = cct
|
|
156
|
+
}}
|
|
157
|
+
onCCTChangeComplete={cct => {
|
|
158
|
+
state.currentNode.colorTemp = cct
|
|
159
|
+
}}
|
|
160
|
+
onBrightnessChange={brightness => {
|
|
161
|
+
state.currentNode.brightness = brightness
|
|
162
|
+
}}
|
|
163
|
+
onBrightnessChangeComplete={brightness => {
|
|
164
|
+
state.currentNode.brightness = brightness
|
|
165
|
+
}} />
|
|
166
|
+
</Card>
|
|
167
|
+
<Spacer />
|
|
168
|
+
{moduleParams.isSupportFan &&
|
|
169
|
+
<FanAdjustView
|
|
170
|
+
fanEnable={!!state.mood.fanEnable}
|
|
171
|
+
fanSpeed={state.mood.fanSpeed || 1}
|
|
172
|
+
maxFanSpeed={useFanMaxSpeed()}
|
|
173
|
+
onFanSwitch={fanEnable => {
|
|
174
|
+
state.mood.fanEnable = fanEnable
|
|
175
|
+
}}
|
|
176
|
+
onFanSpeedChange={fanSpeed => {
|
|
177
|
+
state.mood.fanSpeed = fanSpeed
|
|
178
|
+
}}
|
|
179
|
+
onFanSpeedChangeComplete={fanSpeed => {
|
|
180
|
+
state.mood.fanSpeed = fanSpeed
|
|
181
|
+
}}
|
|
182
|
+
style={styles.fanAdjustCard} />}
|
|
183
|
+
{params.mode === 'edit' && canDelete &&
|
|
184
|
+
<View style={{ marginTop: cx(20), marginHorizontal: cx(24) }}>
|
|
185
|
+
<TextButton
|
|
186
|
+
style={styles.deleteBtn}
|
|
187
|
+
textStyle={styles.deleteBtnText}
|
|
188
|
+
text={I18n.getLang('edit_static_mood_button_delete_text')}
|
|
189
|
+
onPress={() => {
|
|
190
|
+
showDeleteMoodDialog(async (_, { close }) => {
|
|
191
|
+
state.loading = true
|
|
192
|
+
close()
|
|
193
|
+
const res = await params.modDeleteMood('del', state.mood)
|
|
194
|
+
if (res.success) {
|
|
195
|
+
navigation.navigate(ui_biz_routerKey.group_ui_biz_mood)
|
|
196
|
+
}
|
|
197
|
+
state.loading = false
|
|
198
|
+
})
|
|
199
|
+
}} />
|
|
200
|
+
</View>}
|
|
201
|
+
<Spacer />
|
|
202
|
+
</View>
|
|
203
|
+
</ScrollView>
|
|
204
|
+
</Page>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const styles = StyleSheet.create({
|
|
209
|
+
root: {
|
|
210
|
+
flex: 1,
|
|
211
|
+
flexDirection: 'column',
|
|
212
|
+
},
|
|
213
|
+
name: {
|
|
214
|
+
marginHorizontal: cx(24),
|
|
215
|
+
},
|
|
216
|
+
adjustCard: {
|
|
217
|
+
marginTop: cx(12),
|
|
218
|
+
marginHorizontal: cx(24),
|
|
219
|
+
},
|
|
220
|
+
fanAdjustCard: {
|
|
221
|
+
marginHorizontal: cx(24),
|
|
222
|
+
},
|
|
223
|
+
lightLine: {
|
|
224
|
+
flexDirection: 'row',
|
|
225
|
+
marginHorizontal: cx(16),
|
|
226
|
+
},
|
|
227
|
+
light: {
|
|
228
|
+
color: '#000',
|
|
229
|
+
fontSize: cx(18),
|
|
230
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
231
|
+
},
|
|
232
|
+
preview: {
|
|
233
|
+
width: cx(20),
|
|
234
|
+
height: cx(20),
|
|
235
|
+
marginStart: cx(12),
|
|
236
|
+
borderRadius: cx(4),
|
|
237
|
+
},
|
|
238
|
+
deleteBtn: {
|
|
239
|
+
width: '100%',
|
|
240
|
+
height: cx(50),
|
|
241
|
+
backgroundColor: '#666',
|
|
242
|
+
borderRadius: cx(8),
|
|
243
|
+
},
|
|
244
|
+
deleteBtnText: {
|
|
245
|
+
color: '#fff',
|
|
246
|
+
fontSize: cx(16),
|
|
247
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
export default StaticMoodEditorPage
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dialog } from 'tuya-panel-kit'
|
|
2
|
+
import Strings from '@ledvance/base/src/i18n'
|
|
3
|
+
|
|
4
|
+
export const showDeleteMoodDialog = (onConfirm: (data: any, args: { close: () => void }) => void) => {
|
|
5
|
+
Dialog.confirm({
|
|
6
|
+
title: Strings.getLang('string_light_pp_dialog_sm_ed_headline_d'),
|
|
7
|
+
subTitle: Strings.getLang(`strip_light_static_mood_edit_dialog_text`),
|
|
8
|
+
cancelText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
|
|
9
|
+
confirmText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
|
|
10
|
+
onConfirm: onConfirm,
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SelectPageData<T> {
|
|
2
|
+
text: string;
|
|
3
|
+
selected: boolean;
|
|
4
|
+
value: T;
|
|
5
|
+
}
|
|
6
|
+
export interface SelectPageParams<T> {
|
|
7
|
+
title: string;
|
|
8
|
+
data: SelectPageData<T>[];
|
|
9
|
+
onSelect: (selectPageData: SelectPageData<T>) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const SelectPage: () => any;
|
|
12
|
+
export default SelectPage;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {FlatList, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {useNavigation, useRoute} from '@react-navigation/core'
|
|
4
|
+
import {Utils} from 'tuya-panel-kit'
|
|
5
|
+
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
6
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
7
|
+
import Card from '@ledvance/base/src/components/Card'
|
|
8
|
+
import res from '@ledvance/base/src/res'
|
|
9
|
+
|
|
10
|
+
const cx = Utils.RatioUtils.convertX
|
|
11
|
+
|
|
12
|
+
export interface SelectPageData<T> {
|
|
13
|
+
text: string
|
|
14
|
+
selected: boolean
|
|
15
|
+
value: T
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SelectPageParams<T> {
|
|
19
|
+
title: string
|
|
20
|
+
data: SelectPageData<T>[]
|
|
21
|
+
onSelect: (selectPageData: SelectPageData<T>) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const SelectPage = () => {
|
|
25
|
+
const params = useRoute().params as SelectPageParams<any>
|
|
26
|
+
const navigation = useNavigation()
|
|
27
|
+
return (
|
|
28
|
+
<View style={styles.root}>
|
|
29
|
+
<View style={styles.topBar}>
|
|
30
|
+
<Spacer height={cx(45)}/>
|
|
31
|
+
<View style={styles.topContent}>
|
|
32
|
+
<Text style={styles.title}>{params.title}</Text>
|
|
33
|
+
<TouchableOpacity
|
|
34
|
+
onPress={() => {
|
|
35
|
+
navigation.goBack()
|
|
36
|
+
}}>
|
|
37
|
+
<Text style={styles.cancel}>{I18n.getLang('auto_scan_system_cancel')}</Text>
|
|
38
|
+
</TouchableOpacity>
|
|
39
|
+
</View>
|
|
40
|
+
<View style={styles.line}/>
|
|
41
|
+
</View>
|
|
42
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
43
|
+
<View>
|
|
44
|
+
<Spacer height={cx(40)}/>
|
|
45
|
+
<Card style={styles.card}>
|
|
46
|
+
<FlatList
|
|
47
|
+
data={params.data}
|
|
48
|
+
renderItem={({item}) => {
|
|
49
|
+
return (
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
onPress={() => {
|
|
52
|
+
params.onSelect(item)
|
|
53
|
+
navigation.goBack()
|
|
54
|
+
}}>
|
|
55
|
+
<View style={styles.item}>
|
|
56
|
+
<Text style={styles.itemText}>{item.text}</Text>
|
|
57
|
+
<Image
|
|
58
|
+
style={[
|
|
59
|
+
styles.itemIcon,
|
|
60
|
+
{
|
|
61
|
+
opacity: item.selected ? 1 : 0,
|
|
62
|
+
},
|
|
63
|
+
]}
|
|
64
|
+
source={{uri: res.ic_check}}/>
|
|
65
|
+
</View>
|
|
66
|
+
</TouchableOpacity>
|
|
67
|
+
)
|
|
68
|
+
}}
|
|
69
|
+
ItemSeparatorComponent={() => <View style={styles.itemLine}/>}
|
|
70
|
+
keyExtractor={(_, index) => `${index}`}/>
|
|
71
|
+
</Card>
|
|
72
|
+
<Spacer height={cx(40)}/>
|
|
73
|
+
</View>
|
|
74
|
+
</ScrollView>
|
|
75
|
+
</View>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
root: {
|
|
81
|
+
flex: 1,
|
|
82
|
+
},
|
|
83
|
+
topBar: {
|
|
84
|
+
height: cx(91),
|
|
85
|
+
backgroundColor: '#eaeaea',
|
|
86
|
+
},
|
|
87
|
+
line: {
|
|
88
|
+
height: cx(1),
|
|
89
|
+
backgroundColor: '#d9d9d9',
|
|
90
|
+
},
|
|
91
|
+
topContent: {
|
|
92
|
+
height: cx(45),
|
|
93
|
+
flexDirection: 'row',
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
},
|
|
96
|
+
cancel: {
|
|
97
|
+
marginStart: cx(16),
|
|
98
|
+
color: '#f60',
|
|
99
|
+
fontSize: cx(17),
|
|
100
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
101
|
+
},
|
|
102
|
+
title: {
|
|
103
|
+
width: '100%',
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
start: 0,
|
|
106
|
+
textAlign: 'center',
|
|
107
|
+
color: '#000',
|
|
108
|
+
fontSize: cx(17),
|
|
109
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
110
|
+
},
|
|
111
|
+
card: {
|
|
112
|
+
marginHorizontal: cx(16),
|
|
113
|
+
},
|
|
114
|
+
item: {
|
|
115
|
+
height: cx(44),
|
|
116
|
+
flexDirection: 'row',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
},
|
|
119
|
+
itemText: {
|
|
120
|
+
flex: 1,
|
|
121
|
+
marginStart: cx(13),
|
|
122
|
+
color: '#000',
|
|
123
|
+
fontSize: cx(17),
|
|
124
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
125
|
+
},
|
|
126
|
+
itemLine: {
|
|
127
|
+
height: cx(1),
|
|
128
|
+
marginStart: cx(13),
|
|
129
|
+
backgroundColor: '#ccc',
|
|
130
|
+
},
|
|
131
|
+
itemIcon: {
|
|
132
|
+
width: cx(30),
|
|
133
|
+
height: cx(30),
|
|
134
|
+
marginEnd: cx(13),
|
|
135
|
+
tintColor: '#f60',
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
export default SelectPage
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface Timer {
|
|
2
|
+
status: number;
|
|
3
|
+
loops: string;
|
|
4
|
+
time: string;
|
|
5
|
+
id: number;
|
|
6
|
+
isAppPush: boolean;
|
|
7
|
+
dps: string;
|
|
8
|
+
groupOrder?: number;
|
|
9
|
+
groupId?: string;
|
|
10
|
+
aliasName: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IAddSingleTime {
|
|
14
|
+
bizId: string;
|
|
15
|
+
bizType?: string;
|
|
16
|
+
actions: any;
|
|
17
|
+
loops?: string;
|
|
18
|
+
category?: string;
|
|
19
|
+
status?: number;
|
|
20
|
+
isAppPush?: boolean;
|
|
21
|
+
aliasName?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IQueryTimerTasks {
|
|
25
|
+
bizId: string;
|
|
26
|
+
bizType?: string;
|
|
27
|
+
category?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type Timers = Array<{
|
|
31
|
+
/**
|
|
32
|
+
* 初始化状态,0:关闭;1:开启。
|
|
33
|
+
*/
|
|
34
|
+
status: number;
|
|
35
|
+
/**
|
|
36
|
+
* 在0000000基础上,把所选择日期对应位置的 0 改成 1,第一位表示周日。
|
|
37
|
+
*/
|
|
38
|
+
loops: string;
|
|
39
|
+
/**
|
|
40
|
+
* 定时时间。
|
|
41
|
+
*/
|
|
42
|
+
time: string;
|
|
43
|
+
/**
|
|
44
|
+
* 定时任务主键。
|
|
45
|
+
*/
|
|
46
|
+
id: number;
|
|
47
|
+
/**
|
|
48
|
+
* 是否发送执行通知。
|
|
49
|
+
*/
|
|
50
|
+
isAppPush: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* DP 值。
|
|
53
|
+
*/
|
|
54
|
+
dps: string;
|
|
55
|
+
/**
|
|
56
|
+
* 分组定时排序。
|
|
57
|
+
*/
|
|
58
|
+
groupOrder: number;
|
|
59
|
+
/**
|
|
60
|
+
* 分组定时 ID。
|
|
61
|
+
*/
|
|
62
|
+
groupId: string;
|
|
63
|
+
/**
|
|
64
|
+
* 分组定时定时备注。
|
|
65
|
+
*/
|
|
66
|
+
aliasName: string;
|
|
67
|
+
}>;
|
|
68
|
+
|
|
69
|
+
export interface IModifySingleTimer {
|
|
70
|
+
bizId: string;
|
|
71
|
+
bizType?: string;
|
|
72
|
+
id: string | number;
|
|
73
|
+
actions: any;
|
|
74
|
+
loops?: string;
|
|
75
|
+
status?: number;
|
|
76
|
+
isAppPush?: boolean;
|
|
77
|
+
aliasName?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IModDeleteTaskByIds {
|
|
81
|
+
bizId: string;
|
|
82
|
+
bizType?: string;
|
|
83
|
+
ids: string;
|
|
84
|
+
status?: number;
|
|
85
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewStyle, View, Text, StyleSheet } from "react-native";
|
|
3
|
+
import Card from "@ledvance/base/src/components/Card";
|
|
4
|
+
import { SwitchButton, Utils } from 'tuya-panel-kit';
|
|
5
|
+
import { loopText } from '@ledvance/base/src/utils/common';
|
|
6
|
+
import { Timer } from "./Interface";
|
|
7
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
8
|
+
|
|
9
|
+
interface ScheduleCardProps {
|
|
10
|
+
item: Timer
|
|
11
|
+
style?: ViewStyle
|
|
12
|
+
onEnableChange: (enable: boolean) => void
|
|
13
|
+
onPress: (item: any) => void
|
|
14
|
+
onLongPress: (item: any) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ScheduleCard = (props: ScheduleCardProps) => {
|
|
18
|
+
const { item, style, onEnableChange, onPress } = props;
|
|
19
|
+
return (
|
|
20
|
+
<Card
|
|
21
|
+
style={styles.card}
|
|
22
|
+
containerStyle={[styles.container, style]}
|
|
23
|
+
onPress={() => {
|
|
24
|
+
onPress(item);
|
|
25
|
+
}}
|
|
26
|
+
onLongPress={() => {
|
|
27
|
+
onPress(item);
|
|
28
|
+
// onLongPress(item);
|
|
29
|
+
}}>
|
|
30
|
+
<View style={styles.infoContainer}>
|
|
31
|
+
<Text style={styles.time}>{item.time}</Text>
|
|
32
|
+
<Text style={styles.loop}>
|
|
33
|
+
{loopText(item.loops.split('').map(loop => parseInt(loop)), item.time)}
|
|
34
|
+
</Text>
|
|
35
|
+
<Text style={styles.name}>{item.aliasName}</Text>
|
|
36
|
+
{/* {showTags() && <View style={styles.typeContainer}>
|
|
37
|
+
{renderTag()}
|
|
38
|
+
</View>} */}
|
|
39
|
+
</View>
|
|
40
|
+
<View style={styles.switchContainer}>
|
|
41
|
+
<SwitchButton
|
|
42
|
+
value={!!item.status}
|
|
43
|
+
thumbStyle={{ elevation: 0 }}
|
|
44
|
+
onValueChange={() => {
|
|
45
|
+
onEnableChange(!item.status);
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
</View>
|
|
49
|
+
</Card>
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
card: {
|
|
56
|
+
marginHorizontal: cx(24),
|
|
57
|
+
borderRadius: cx(8),
|
|
58
|
+
},
|
|
59
|
+
container: {
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
justifyContent: 'space-between',
|
|
62
|
+
},
|
|
63
|
+
infoContainer: {
|
|
64
|
+
flex: 1,
|
|
65
|
+
marginTop: cx(16),
|
|
66
|
+
marginBottom: cx(16),
|
|
67
|
+
flexDirection: 'column',
|
|
68
|
+
marginLeft: cx(16),
|
|
69
|
+
},
|
|
70
|
+
time: {
|
|
71
|
+
marginBottom: cx(5),
|
|
72
|
+
fontSize: 16,
|
|
73
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
74
|
+
fontWeight: 'bold',
|
|
75
|
+
},
|
|
76
|
+
loop: {
|
|
77
|
+
color: '#000',
|
|
78
|
+
fontSize: cx(14),
|
|
79
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
80
|
+
marginTop: cx(8),
|
|
81
|
+
},
|
|
82
|
+
name: {
|
|
83
|
+
color: '#000',
|
|
84
|
+
fontSize: cx(14),
|
|
85
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
86
|
+
marginTop: cx(8),
|
|
87
|
+
},
|
|
88
|
+
switchContainer: {
|
|
89
|
+
marginRight: cx(16),
|
|
90
|
+
// backgroundColor: 'red',
|
|
91
|
+
marginTop: cx(16),
|
|
92
|
+
},
|
|
93
|
+
switch: {},
|
|
94
|
+
typeContainer: {
|
|
95
|
+
flexDirection: 'row',
|
|
96
|
+
marginTop: cx(8),
|
|
97
|
+
},
|
|
98
|
+
typeWrap: {
|
|
99
|
+
backgroundColor: '#E6E7E8',
|
|
100
|
+
marginRight: cx(10),
|
|
101
|
+
borderRadius: cx(10),
|
|
102
|
+
},
|
|
103
|
+
typeText: {
|
|
104
|
+
fontSize: cx(12),
|
|
105
|
+
color: '#000',
|
|
106
|
+
paddingHorizontal: cx(8),
|
|
107
|
+
paddingVertical: cx(2)
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export default ScheduleCard
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { commonApi } from "@tuya/tuya-panel-api"
|
|
2
|
+
import { IAddSingleTime, IQueryTimerTasks, IModifySingleTimer, IModDeleteTaskByIds } from "./Interface"
|
|
3
|
+
import { flatMapDeep } from "lodash";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const addTimeSchedule = async (props: IAddSingleTime) => {
|
|
7
|
+
try{
|
|
8
|
+
const res = await commonApi.timerApi.addSingleTimer({
|
|
9
|
+
...props,
|
|
10
|
+
bizType: '1'
|
|
11
|
+
})
|
|
12
|
+
if (typeof res === 'number') {
|
|
13
|
+
return {
|
|
14
|
+
success: true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
success: false
|
|
19
|
+
}
|
|
20
|
+
}catch(err){
|
|
21
|
+
return {
|
|
22
|
+
success: false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getTimeSchedule = async (props: IQueryTimerTasks) => {
|
|
28
|
+
try{
|
|
29
|
+
const res = await commonApi.timerApi.queryTimerTasks({
|
|
30
|
+
...props,
|
|
31
|
+
bizType: '1',
|
|
32
|
+
category: 'category'
|
|
33
|
+
})
|
|
34
|
+
if (res.timers && res.timers.length) {
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
data: flatMapDeep(res.timers)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
success: false
|
|
42
|
+
}
|
|
43
|
+
}catch(err){
|
|
44
|
+
return {
|
|
45
|
+
success: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const modifyTimeSchedule = async (props: IModifySingleTimer) => {
|
|
51
|
+
try{
|
|
52
|
+
const status = await commonApi.timerApi.modifySingleTimer({
|
|
53
|
+
...props,
|
|
54
|
+
bizType: '1',
|
|
55
|
+
})
|
|
56
|
+
return {
|
|
57
|
+
success: status
|
|
58
|
+
}
|
|
59
|
+
}catch(err){
|
|
60
|
+
return {
|
|
61
|
+
success: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const modDelTimeSchedule = async (props: IModDeleteTaskByIds) =>{
|
|
67
|
+
try{
|
|
68
|
+
const status = await commonApi.timerApi.modDeleteTaskByIds({
|
|
69
|
+
...props,
|
|
70
|
+
bizType: '1',
|
|
71
|
+
status: props.status ?? 2
|
|
72
|
+
})
|
|
73
|
+
return {
|
|
74
|
+
success: status
|
|
75
|
+
}
|
|
76
|
+
}catch(err){
|
|
77
|
+
return {
|
|
78
|
+
success: false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|