@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.
Files changed (40) hide show
  1. package/.babelrc +31 -0
  2. package/.eslintignore +6 -0
  3. package/.eslintrc.js +27 -0
  4. package/.prettierignore +0 -0
  5. package/.prettierrc.js +1 -0
  6. package/.versionrc +5 -0
  7. package/package.json +73 -0
  8. package/rn-cli.config.js +8 -0
  9. package/src/modules/mood/AddMoodPage.tsx +826 -0
  10. package/src/modules/mood/DynamicMoodEditorPage.tsx +547 -0
  11. package/src/modules/mood/MoodItem.tsx +114 -0
  12. package/src/modules/mood/MoodPage.tsx +332 -0
  13. package/src/modules/mood/RecommendMoodItem.tsx +75 -0
  14. package/src/modules/mood/SceneAction.ts +459 -0
  15. package/src/modules/mood/SceneInfo.ts +886 -0
  16. package/src/modules/mood/StaticMoodEditorPage.tsx +251 -0
  17. package/src/modules/mood/tools.ts +12 -0
  18. package/src/modules/select/SelectPage.d.ts +12 -0
  19. package/src/modules/select/SelectPage.tsx +139 -0
  20. package/src/modules/time_schedule/Interface.ts +85 -0
  21. package/src/modules/time_schedule/ScheduleCard.tsx +111 -0
  22. package/src/modules/time_schedule/TimeScheduleActions.ts +81 -0
  23. package/src/modules/time_schedule/TimeScheduleDetailPage.tsx +704 -0
  24. package/src/modules/time_schedule/TimeSchedulePage.tsx +246 -0
  25. package/src/modules/timer/TimerAction.d.ts +12 -0
  26. package/src/modules/timer/TimerAction.ts +150 -0
  27. package/src/modules/timer/TimerPage.d.ts +2 -0
  28. package/src/modules/timer/TimerPage.tsx +351 -0
  29. package/src/navigation/Routers.d.ts +5 -0
  30. package/src/navigation/Routers.ts +97 -0
  31. package/src/navigation/tools.d.ts +0 -0
  32. package/src/navigation/tools.ts +0 -0
  33. package/src/res/GroupBizRes.ts +4 -0
  34. package/src/res/materialiconsFilledCancel.png +0 -0
  35. package/src/res/materialiconsFilledCancel@2x.png +0 -0
  36. package/src/res/materialiconsFilledCancel@3x.png +0 -0
  37. package/src/res/materialiconsOutlinedArrowsNavAddBox.png +0 -0
  38. package/src/res/materialiconsOutlinedArrowsNavAddBox@2x.png +0 -0
  39. package/src/res/materialiconsOutlinedArrowsNavAddBox@3x.png +0 -0
  40. package/tsconfig.json +51 -0
@@ -0,0 +1,351 @@
1
+ import React, { useEffect, useMemo } from 'react'
2
+ import { FlatList, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
3
+ import I18n from '@ledvance/base/src/i18n'
4
+ import Page from '@ledvance/base/src/components/Page'
5
+ import { Utils } from 'tuya-panel-kit'
6
+ import { useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
7
+ import LdvPickerView from '@ledvance/base/src/components/ldvPickerView'
8
+ import { useReactive } from 'ahooks'
9
+ import Spacer from '@ledvance/base/src/components/Spacer'
10
+ import DeleteButton from '@ledvance/base/src/components/DeleteButton'
11
+ import { TaskStatus, timeFormat, TimerPageParams, TimerTask, useTimerTasks } from './TimerAction'
12
+ import { cloneDeep, groupBy } from 'lodash'
13
+ import { useParams } from '@ledvance/base/src/hooks/Hooks'
14
+ import GroupBizRes from '../../res/GroupBizRes'
15
+ import dayjs from 'dayjs'
16
+ import Card from '@ledvance/base/src/components/Card'
17
+ import TextButton from '@ledvance/base/src/components/TextButton'
18
+ import { CircularProgress } from '@ledvance/base/src/components/CircularProgress'
19
+
20
+ const { convertX: cx } = Utils.RatioUtils
21
+
22
+ const TimerPage = () => {
23
+ const devInfo = useDeviceInfo()
24
+
25
+ const params = useParams<TimerPageParams>()
26
+ const [timerTasks, setTimerTasks] = useTimerTasks(params.timerSettableDps)
27
+
28
+ const state = useReactive({
29
+ hour: '00',
30
+ min: '01',
31
+ tasks: cloneDeep(timerTasks),
32
+ loading: false,
33
+ })
34
+
35
+ useEffect(() => {
36
+ state.tasks = cloneDeep(timerTasks)
37
+ .map(task => {
38
+ const newStatus = timerTasks.length === 1 && task.status !== TaskStatus.Started
39
+ ? TaskStatus.Selected : task.status
40
+ return { ...task, status: newStatus }
41
+ })
42
+ }, [JSON.stringify(timerTasks)])
43
+
44
+ const tasksByStatus = useMemo(() => {
45
+ return groupBy(state.tasks, 'status')
46
+ }, [JSON.stringify(state.tasks)])
47
+
48
+ const noSelectedTasks = tasksByStatus[TaskStatus.NoSelected] || []
49
+ const selectedTasks = tasksByStatus[TaskStatus.Selected] || []
50
+ const startedTasks = tasksByStatus[TaskStatus.Started] || []
51
+ const startEnable = selectedTasks.length > 0
52
+
53
+ return (
54
+ <Page
55
+ backText={devInfo.name}
56
+ headlineText={I18n.getLang('timer_nightplug_headline_text')}
57
+ loading={state.loading}>
58
+ <ScrollView
59
+ style={styles.root}
60
+ nestedScrollEnabled={true}
61
+ showsHorizontalScrollIndicator={false}
62
+ showsVerticalScrollIndicator={false}>
63
+ <View>
64
+ {startedTasks.length !== state.tasks.length &&
65
+ <View style={styles.content}>
66
+ <LdvPickerView
67
+ hour={state.hour}
68
+ minute={state.min}
69
+ unit={['h', 'min']}
70
+ setHour={hour => {
71
+ state.hour = hour
72
+ }}
73
+ setMinute={min => {
74
+ state.min = min
75
+ }}/>
76
+ <Spacer height={cx(30)}/>
77
+ <Text style={styles.applyFor}>{I18n.getLang('timeschedule_add_schedule_subheadline_text')}</Text>
78
+ <Spacer height={cx(10)}/>
79
+ <FlatList
80
+ data={selectedTasks}
81
+ style={styles.taskList}
82
+ renderItem={({ item }) => {
83
+ return (
84
+ <View style={styles.taskItem}>
85
+ <Text style={styles.taskItemText}>{item.name}</Text>
86
+ {state.tasks.length > 1 &&
87
+ <TouchableOpacity
88
+ onPress={() => {
89
+ item.status = TaskStatus.NoSelected
90
+ }}>
91
+ <Image style={styles.taskItemIcon} source={GroupBizRes.ic_arrows_nav_clear}/>
92
+ </TouchableOpacity>}
93
+ </View>
94
+ )
95
+ }}
96
+ keyExtractor={item => item.dp.key}
97
+ ListEmptyComponent={() => <View style={styles.listEmptyView}>
98
+ <Text style={styles.listEmptyText}>
99
+ {I18n.getLang('timer_ceiling_fan_selectionfield_no_components_text')}
100
+ </Text>
101
+ </View>}/>
102
+ <Spacer height={cx(6)}/>
103
+ <FlatList
104
+ data={noSelectedTasks}
105
+ style={styles.noSelectTaskList}
106
+ renderItem={({ item }) => {
107
+ return (
108
+ <TouchableOpacity
109
+ style={styles.noSelectTaskItem}
110
+ onPress={() => {
111
+ item.status = TaskStatus.Selected
112
+ }}>
113
+ <Spacer width={cx(8)}/>
114
+ <Text style={styles.noSelectTaskText}>{item.name}</Text>
115
+ <Image style={styles.taskItemIcon} source={GroupBizRes.device_panel_timer_add}/>
116
+ </TouchableOpacity>
117
+ )
118
+ }}
119
+ keyExtractor={item => item.dp.key}/>
120
+ <Spacer/>
121
+ <DeleteButton
122
+ text={I18n.getLang('timer_sockets_button_text')}
123
+ onPress={async () => {
124
+ state.loading = true
125
+ const tasks = selectedTasks.map(task => {
126
+ return {
127
+ ...task,
128
+ startTime: dayjs().unix(),
129
+ duration: (parseInt(state.hour) * 60 + parseInt(state.min)) * 60,
130
+ status: TaskStatus.Started,
131
+ }
132
+ })
133
+ await setTimerTasks(cloneDeep(tasks))
134
+ state.loading = false
135
+ }}
136
+ textStyle={{ fontSize: cx(14) }}
137
+ style={{ backgroundColor: !startEnable ? '#FFE0D4' : '#f60' }}/>
138
+ </View>
139
+ }
140
+ {startedTasks.length > 0 && state.tasks.length > 1 &&
141
+ <>
142
+ <Spacer height={cx(30)}/>
143
+ <View style={styles.content}>
144
+ <Text style={styles.applyFor}>{
145
+ I18n.formatValue('timer_nightplug_active_timer_subheadline2_text', startedTasks.length.toString())
146
+ }</Text>
147
+ </View>
148
+ <FlatList
149
+ data={startedTasks}
150
+ renderItem={({ item }) => {
151
+ return ActiveTimerItem(item, () => {
152
+ item.status = TaskStatus.NoSelected
153
+ })
154
+ }}
155
+ keyExtractor={item => item.dp.key}
156
+ ListHeaderComponent={() => (<Spacer height={cx(10)}/>)}
157
+ ItemSeparatorComponent={() => (<Spacer height={cx(10)}/>)}
158
+ ListFooterComponent={() => (<Spacer height={cx(20)}/>)}/>
159
+ </>
160
+ }
161
+ {
162
+ startedTasks.length === 1 && state.tasks.length === 1 &&
163
+ <View style={{ justifyContent: 'center', marginHorizontal: cx(24) }}>
164
+ <Spacer height={cx(116)}/>
165
+ <View
166
+ style={{
167
+ justifyContent: 'center',
168
+ alignItems: 'center',
169
+ }}>
170
+ <CircularProgress
171
+ progress={(startedTasks[0].timeLeft / startedTasks[0].duration) * 100}
172
+ size={cx(172)}
173
+ strokeWidth={cx(14)}>
174
+ <Text style={styles.activeTaskTimeText2}>{timeFormat(startedTasks[0].timeLeft)}</Text>
175
+ </CircularProgress>
176
+ </View>
177
+ <Spacer height={cx(32)}/>
178
+ <Text
179
+ style={[styles.activeTaskDesc, { textAlign: 'center' }]}>{I18n.formatValue(startedTasks[0].stringOn, timeFormat(startedTasks[0].timeLeft))}</Text>
180
+ <Spacer height={cx(32)}/>
181
+ <TextButton
182
+ text={I18n.getLang('auto_scan_system_cancel')}
183
+ style={styles.activeTasBtn}
184
+ textStyle={styles.activeTaskBtnText}
185
+ onPress={async () => {
186
+ state.loading = true
187
+ const task = cloneDeep(startedTasks[0])
188
+ task.status = TaskStatus.NoSelected
189
+ task.startTime = 0
190
+ task.duration = 0
191
+ await setTimerTasks([task])
192
+ state.loading = false
193
+ }}/>
194
+ <Spacer width={cx(20)}/>
195
+ </View>
196
+ }
197
+ <Spacer/>
198
+ </View>
199
+ </ScrollView>
200
+ </Page>
201
+ )
202
+ }
203
+
204
+ function ActiveTimerItem(task: TimerTask, onCancel: () => void) {
205
+ return (
206
+ <Card style={{ marginHorizontal: cx(24) }}>
207
+ <Spacer/>
208
+ <View style={styles.activeTaskHeadLine}>
209
+ <Spacer width={cx(20)}/>
210
+ <Text style={styles.activeTaskHeadLineText}>{task.name}</Text>
211
+ <TextButton
212
+ text={I18n.getLang('auto_scan_system_cancel')}
213
+ style={styles.activeTaskHeadLineBtn}
214
+ textStyle={styles.activeTaskHeadLineBtnText}
215
+ onPress={onCancel}/>
216
+ <Spacer width={cx(12)}/>
217
+ </View>
218
+ <Spacer height={cx(12)}/>
219
+ <View style={styles.activeTaskHeadLine}>
220
+ <Spacer width={cx(20)}/>
221
+ <CircularProgress
222
+ progress={25}
223
+ size={cx(24)}
224
+ strokeWidth={cx(2)}/>
225
+ <Spacer width={cx(16)}/>
226
+ <Text style={styles.activeTaskTimeText}>{'2h 12 min'}</Text>
227
+ <Spacer width={cx(20)}/>
228
+ </View>
229
+ <Spacer/>
230
+ <View style={{ marginHorizontal: cx(20) }}>
231
+ <Text style={styles.activeTaskDesc}>{
232
+ I18n.getLang(task.stringOn)
233
+ }</Text>
234
+ </View>
235
+ <Spacer height={cx(22)}/>
236
+ </Card>
237
+ )
238
+ }
239
+
240
+ const styles = StyleSheet.create({
241
+ root: {
242
+ flex: 1,
243
+ },
244
+ content: {
245
+ marginHorizontal: cx(24),
246
+ },
247
+ applyFor: {
248
+ color: '#000',
249
+ fontSize: cx(16),
250
+ fontWeight: 'bold',
251
+ fontFamily: 'helvetica_neue_lt_std_bd',
252
+ },
253
+ taskList: {
254
+ backgroundColor: '#f6f6f6',
255
+ paddingTop: cx(8),
256
+ borderRadius: cx(4),
257
+ },
258
+ taskItem: {
259
+ marginHorizontal: cx(8),
260
+ marginBottom: cx(8),
261
+ flexDirection: 'row',
262
+ justifyContent: 'space-between',
263
+ alignItems: 'center',
264
+ backgroundColor: '#fff',
265
+ },
266
+ taskItemText: {
267
+ color: '#000',
268
+ fontSize: 14,
269
+ marginHorizontal: cx(8),
270
+ marginVertical: cx(9),
271
+ },
272
+ taskItemIcon: {
273
+ width: cx(16),
274
+ height: cx(16),
275
+ marginRight: cx(8),
276
+ },
277
+ listEmptyView: {
278
+ marginHorizontal: cx(8),
279
+ marginTop: cx(6),
280
+ marginBottom: cx(14),
281
+ },
282
+ listEmptyText: {
283
+ color: '#666',
284
+ fontSize: cx(14),
285
+ },
286
+ noSelectTaskList: {},
287
+ noSelectTaskItem: {
288
+ height: cx(30),
289
+ flexDirection: 'row',
290
+ alignItems: 'center',
291
+ },
292
+ noSelectTaskText: {
293
+ flex: 1,
294
+ color: '#000',
295
+ fontSize: cx(14),
296
+ },
297
+ activeTaskHeadLine: {
298
+ flexDirection: 'row',
299
+ alignItems: 'center',
300
+ },
301
+ activeTaskHeadLineText: {
302
+ flex: 1,
303
+ color: '#000',
304
+ fontSize: cx(14),
305
+ },
306
+ activeTaskHeadLineBtn: {
307
+ width: cx(50),
308
+ height: cx(24),
309
+ padding: 0,
310
+ backgroundColor: '#666',
311
+ borderRadius: cx(4),
312
+ },
313
+ activeTaskHeadLineBtnText: {
314
+ color: '#fff',
315
+ fontSize: cx(8.2),
316
+ },
317
+ activeTaskTimeText: {
318
+ flex: 1,
319
+ color: '#666',
320
+ fontSize: cx(24),
321
+ fontWeight: 'bold',
322
+ fontFamily: 'helvetica_neue_lt_std_bd',
323
+ },
324
+ activeTaskDesc: {
325
+ flex: 1,
326
+ color: '#666',
327
+ fontSize: cx(14),
328
+ },
329
+ activeTasBtn: {
330
+ width: cx(75),
331
+ height: cx(36),
332
+ padding: 0,
333
+ backgroundColor: '#666',
334
+ borderRadius: cx(4),
335
+ },
336
+ activeTaskBtnText: {
337
+ color: '#fff',
338
+ fontSize: cx(12.2),
339
+ },
340
+ activeTaskTimeText2: {
341
+ flex: 1,
342
+ marginHorizontal: cx(20),
343
+ color: '#666',
344
+ fontSize: cx(22),
345
+ textAlign: 'center',
346
+ fontWeight: 'bold',
347
+ fontFamily: 'helvetica_neue_lt_std_bd',
348
+ },
349
+ })
350
+
351
+ export default TimerPage
@@ -0,0 +1,5 @@
1
+ import { NavigationRoute } from 'tuya-panel-kit';
2
+ export declare const ui_biz_routerKey: {
3
+ group_ui_biz_timer: string;
4
+ };
5
+ export declare const TimerRouters: NavigationRoute[];
@@ -0,0 +1,97 @@
1
+ import { NavigationRoute, TransitionPresets } from 'tuya-panel-kit'
2
+ import TimerPage from '../modules/timer/TimerPage'
3
+ import TimeSchedulePage from '../modules/time_schedule/TimeSchedulePage'
4
+ import TimeScheduleDetailPage from '../modules/time_schedule/TimeScheduleDetailPage'
5
+ import MoodPage from '../modules/mood/MoodPage'
6
+ import AddMoodPage from '../modules/mood/AddMoodPage'
7
+ import DynamicMoodEditorPage from '../modules/mood/DynamicMoodEditorPage'
8
+ import StaticMoodEditorPage from '../modules/mood/StaticMoodEditorPage'
9
+ import SelectPage from '../modules/select/SelectPage'
10
+
11
+ export const ui_biz_routerKey = {
12
+ 'group_ui_biz_timer': 'group_ui_biz_timer',
13
+ 'group_ui_biz_time_schedule': 'group_ui_biz_time_schedule',
14
+ 'group_ui_biz_time_schedule_edit': 'group_ui_biz_time_schedule_edit',
15
+ 'group_ui_biz_mood': 'group_ui_biz_mood',
16
+ 'group_ui_biz_mood_add': 'group_ui_biz_mood_add',
17
+ 'group_ui_biz_static_mood_edit': 'group_ui_biz_static_mood_edit',
18
+ 'group_ui_biz_dynamic_mood_edit': 'group_ui_biz_dynamic_mood_edit',
19
+ 'group_ui_biz_select_page': 'group_ui_biz_select_page',
20
+ }
21
+
22
+ export const TimerRouters: NavigationRoute[] = [
23
+ {
24
+ name: ui_biz_routerKey.group_ui_biz_timer,
25
+ component: TimerPage,
26
+ options: {
27
+ hideTopbar: true,
28
+ showOfflineView: false,
29
+ },
30
+ }
31
+ ]
32
+
33
+ export const TimeScheduleRouters: NavigationRoute[] = [
34
+ {
35
+ name: ui_biz_routerKey.group_ui_biz_time_schedule,
36
+ component: TimeSchedulePage,
37
+ options: {
38
+ hideTopbar: true,
39
+ showOfflineView: false,
40
+ },
41
+ },
42
+ {
43
+ name: ui_biz_routerKey.group_ui_biz_time_schedule_edit,
44
+ component: TimeScheduleDetailPage,
45
+ options: {
46
+ hideTopbar: true,
47
+ showOfflineView: false,
48
+ },
49
+ },
50
+ ]
51
+
52
+ export const MoodRouters: NavigationRoute[] = [
53
+ {
54
+ name: ui_biz_routerKey.group_ui_biz_mood,
55
+ component: MoodPage,
56
+ options: {
57
+ hideTopbar: true,
58
+ showOfflineView: false,
59
+ },
60
+ },
61
+ {
62
+ name: ui_biz_routerKey.group_ui_biz_mood_add,
63
+ component: AddMoodPage,
64
+ options: {
65
+ hideTopbar: true,
66
+ showOfflineView: false,
67
+ },
68
+ },
69
+ {
70
+ name: ui_biz_routerKey.group_ui_biz_static_mood_edit,
71
+ component: StaticMoodEditorPage,
72
+ options: {
73
+ hideTopbar: true,
74
+ showOfflineView: false,
75
+ },
76
+ },
77
+ {
78
+ name: ui_biz_routerKey.group_ui_biz_dynamic_mood_edit,
79
+ component: DynamicMoodEditorPage,
80
+ options: {
81
+ hideTopbar: true,
82
+ showOfflineView: false,
83
+ },
84
+ },
85
+ ]
86
+
87
+ export const SelectPageRouters: NavigationRoute[] = [
88
+ {
89
+ name: ui_biz_routerKey.group_ui_biz_select_page,
90
+ component: SelectPage,
91
+ options: {
92
+ hideTopbar: true,
93
+ showOfflineView: false,
94
+ ...TransitionPresets.ModalPresentationIOS,
95
+ },
96
+ },
97
+ ]
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ export default {
2
+ ic_arrows_nav_clear: require('./materialiconsFilledCancel.png'),
3
+ device_panel_timer_add: require('./materialiconsOutlinedArrowsNavAddBox.png'),
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic Options */
4
+ "target": "ES2017",
5
+ /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
6
+ "module": "commonjs",
7
+ /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
8
+ "jsx": "react",
9
+ /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
10
+
11
+ /* Strict Type-Checking Options */
12
+ /* "strict": true /* Enable all strict type-checking options. */
13
+ "noImplicitAny": false,
14
+ /* Raise error on expressions and declarations with an implied 'any' type. */
15
+ "strictNullChecks": true,
16
+ /* Enable strict null checks. */
17
+
18
+ /* Additional Checks */
19
+ "noUnusedLocals": true,
20
+ /* Report errors on unused locals. */
21
+ "noUnusedParameters": true,
22
+ /* Report errors on unused parameters. */
23
+
24
+ /* .d.ts config */
25
+ "declaration": true,
26
+ "emitDeclarationOnly": true,
27
+
28
+ /* Module Resolution Options */
29
+ "moduleResolution": "node",
30
+ /* Specify module resolution strategy: 'node' (Node.js) or 'classic' */
31
+ "types": ["react", "react-native"],
32
+ /* Type declaration files to be included in compilation. */
33
+ "typeRoots": ["@types/*.d.ts"],
34
+ "allowSyntheticDefaultImports": true,
35
+ /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
36
+ "esModuleInterop": true,
37
+ /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
38
+ "baseUrl": "./src",
39
+ "paths": {
40
+ "@api": ["./api"],
41
+ "@components": ["./components"],
42
+ "@config": ["./config"],
43
+ "@i18n": ["./i18n"],
44
+ "@models": ["./models"],
45
+ "@res": ["./res"],
46
+ "@utils": ["./utils"]
47
+ }
48
+ },
49
+ "include": ["src/**/*.ts","src/**/*.tsx"],
50
+ "exclude": ["node_modules",".yalc"]
51
+ }