@ledvance/group-ui-biz-bundle 1.0.30 → 1.0.32
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/flags/FlagActions.ts +1 -1
- package/src/modules/mood/MoodPage.tsx +1 -0
- package/src/modules/randomTimeForPlug/ItemCard.tsx +76 -0
- package/src/modules/randomTimeForPlug/RandomTimeForPlugAction.ts +136 -0
- package/src/modules/randomTimeForPlug/RandomTimeForPlugDetailPage.tsx +268 -0
- package/src/modules/randomTimeForPlug/RandomTimeForPlugPage.tsx +192 -0
- package/src/modules/randomTimeForPlug/Summary.tsx +123 -0
- package/src/modules/randomTimingForLight/ItemCard.tsx +76 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightAction.ts +43 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightDetailPage.tsx +342 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightPage.tsx +192 -0
- package/src/modules/randomTimingForLight/Summary.tsx +123 -0
- package/src/modules/timer/TimerAction.ts +1 -1
- package/src/navigation/Routers.ts +46 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import Page from "@ledvance/base/src/components/Page";
|
|
2
|
+
import {useDeviceInfo} from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
3
|
+
import {useNavigation, useRoute} from '@react-navigation/native'
|
|
4
|
+
import I18n from "@ledvance/base/src/i18n/index";
|
|
5
|
+
import res from "@ledvance/base/src/res/index";
|
|
6
|
+
import {useReactive} from "ahooks";
|
|
7
|
+
import React, {useCallback, useMemo} from "react";
|
|
8
|
+
import {FlatList, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View} from "react-native";
|
|
9
|
+
import {Utils} from "tuya-panel-kit";
|
|
10
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
11
|
+
import {RandomTimingItem, RandomTimingParam, useRandomTiming} from "./RandomTimingForLightAction";
|
|
12
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
13
|
+
import ItemCard from "./ItemCard";
|
|
14
|
+
import {cloneDeep} from "lodash";
|
|
15
|
+
|
|
16
|
+
const {convertX: cx, topBarHeight} = Utils.RatioUtils;
|
|
17
|
+
const MAX_NUM = 16
|
|
18
|
+
|
|
19
|
+
const RandomTimeForLightPage = () => {
|
|
20
|
+
const devInfo = useDeviceInfo()
|
|
21
|
+
const navigation = useNavigation()
|
|
22
|
+
const params = useRoute().params as RandomTimingParam
|
|
23
|
+
const [randomTimingList, setRandomTimingList] = useRandomTiming()
|
|
24
|
+
const state = useReactive({
|
|
25
|
+
loading: false
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const isMaxNum = useMemo(() => {
|
|
29
|
+
return randomTimingList.length >= MAX_NUM
|
|
30
|
+
}, [randomTimingList])
|
|
31
|
+
|
|
32
|
+
const onAddOrEditItem = (mode: 'add' | 'edit', item?: RandomTimingItem) => {
|
|
33
|
+
const path = ui_biz_routerKey.group_ui_biz_random_timing_light_detail
|
|
34
|
+
navigation.navigate(path, {
|
|
35
|
+
...params,
|
|
36
|
+
mode,
|
|
37
|
+
item,
|
|
38
|
+
onPost
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const onPost = useCallback(async (mode: 'add' | 'edit' | 'del', randomTiming: RandomTimingItem, goBack?: boolean) => {
|
|
43
|
+
state.loading = true
|
|
44
|
+
const cloneRandomTimingList = cloneDeep(randomTimingList)
|
|
45
|
+
const idx = randomTimingList.findIndex(it => it.index === randomTiming.index)
|
|
46
|
+
if (mode === 'edit') {
|
|
47
|
+
cloneRandomTimingList.splice(idx, 1, randomTiming)
|
|
48
|
+
}
|
|
49
|
+
if (mode === 'del') cloneRandomTimingList.splice(idx, 1)
|
|
50
|
+
const newRandomTimingList = mode === 'add' ? [...randomTimingList, {
|
|
51
|
+
...randomTiming,
|
|
52
|
+
index: randomTimingList.length
|
|
53
|
+
}] : cloneRandomTimingList
|
|
54
|
+
const res = await setRandomTimingList(newRandomTimingList)
|
|
55
|
+
state.loading = false
|
|
56
|
+
if (res.success && goBack) {
|
|
57
|
+
navigation.goBack()
|
|
58
|
+
}
|
|
59
|
+
}, [randomTimingList])
|
|
60
|
+
|
|
61
|
+
const renderList = () => {
|
|
62
|
+
return (
|
|
63
|
+
<ScrollView nestedScrollEnabled={true}>
|
|
64
|
+
<Text style={{
|
|
65
|
+
color: '#000',
|
|
66
|
+
marginLeft: cx(24),
|
|
67
|
+
}}>{I18n.getLang('timeschedule_overview_description_text')}</Text>
|
|
68
|
+
<Spacer height={cx(10)}/>
|
|
69
|
+
{isMaxNum && <View style={{marginHorizontal: cx(24), flexDirection: 'row'}}>
|
|
70
|
+
<Image style={{width: cx(16), height: cx(16), tintColor: '#ff9500'}} source={res.ic_warning_amber}/>
|
|
71
|
+
<Text>{I18n.getLang('fixedtimecycle_warning_max_number_text')}</Text>
|
|
72
|
+
</View>}
|
|
73
|
+
<FlatList
|
|
74
|
+
data={randomTimingList}
|
|
75
|
+
renderItem={({item}) => (
|
|
76
|
+
<ItemCard
|
|
77
|
+
item={item}
|
|
78
|
+
is24Hour={params.is24Hour}
|
|
79
|
+
onSwitch={async (v) => {
|
|
80
|
+
await onPost('edit', {
|
|
81
|
+
...item,
|
|
82
|
+
enable: v,
|
|
83
|
+
})
|
|
84
|
+
}}
|
|
85
|
+
onPress={() => {
|
|
86
|
+
onAddOrEditItem('edit', item)
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
keyExtractor={(item: any) => `${item?.index}`}
|
|
91
|
+
ItemSeparatorComponent={() => <Spacer/>}
|
|
92
|
+
ListHeaderComponent={<Spacer height={cx(10)}/>}
|
|
93
|
+
ListFooterComponent={<Spacer/>}
|
|
94
|
+
/>
|
|
95
|
+
</ScrollView>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
const renderEmpty = () => {
|
|
99
|
+
return (
|
|
100
|
+
<View style={styles.emptyListCon}>
|
|
101
|
+
<Image
|
|
102
|
+
style={styles.emptyImage}
|
|
103
|
+
source={{uri: res.ldv_timer_empty}}
|
|
104
|
+
resizeMode="contain"/>
|
|
105
|
+
<View
|
|
106
|
+
style={{
|
|
107
|
+
marginHorizontal: cx(24),
|
|
108
|
+
marginTop: cx(30),
|
|
109
|
+
flexDirection: 'row',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
<Image
|
|
114
|
+
source={{uri: res.device_panel_schedule_alert}}
|
|
115
|
+
style={{width: cx(16), height: cx(16)}}
|
|
116
|
+
/>
|
|
117
|
+
<Text style={styles.emptyNoTime}>{I18n.getLang('randomtimecycle_empty_information_text')}</Text>
|
|
118
|
+
</View>
|
|
119
|
+
<View
|
|
120
|
+
style={{
|
|
121
|
+
height: cx(36),
|
|
122
|
+
width: cx(150),
|
|
123
|
+
marginVertical: cx(25),
|
|
124
|
+
marginHorizontal: cx(24),
|
|
125
|
+
borderRadius: cx(6),
|
|
126
|
+
backgroundColor: '#f60',
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<TouchableOpacity
|
|
130
|
+
style={{
|
|
131
|
+
flex: 1,
|
|
132
|
+
justifyContent: 'center',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
}}
|
|
135
|
+
onPress={() => onAddOrEditItem('add')}
|
|
136
|
+
>
|
|
137
|
+
<Text style={{fontSize: cx(12), fontWeight: 'bold', color: '#fff', textAlign: 'center'}}>
|
|
138
|
+
{I18n.getLang('randomtimecycle_empty_bttn_text')}
|
|
139
|
+
</Text>
|
|
140
|
+
</TouchableOpacity>
|
|
141
|
+
</View>
|
|
142
|
+
</View>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
return (
|
|
146
|
+
<Page
|
|
147
|
+
backText={devInfo.name}
|
|
148
|
+
headlineText={I18n.getLang('randomtimecycle_sockets_headline_text')}
|
|
149
|
+
headlineIcon={!isMaxNum && res.device_panel_schedule_add || undefined}
|
|
150
|
+
onHeadlineIconClick={() => onAddOrEditItem('add')}
|
|
151
|
+
loading={state.loading}
|
|
152
|
+
>
|
|
153
|
+
{randomTimingList.length > 0 ? renderList() : renderEmpty()}
|
|
154
|
+
</Page>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const styles = StyleSheet.create({
|
|
159
|
+
bg: {
|
|
160
|
+
marginTop: topBarHeight,
|
|
161
|
+
flex: 1,
|
|
162
|
+
},
|
|
163
|
+
emptyListCon: {
|
|
164
|
+
justifyContent: 'center',
|
|
165
|
+
alignItems: 'center',
|
|
166
|
+
marginTop: cx(30),
|
|
167
|
+
},
|
|
168
|
+
emptyImage: {
|
|
169
|
+
width: cx(225),
|
|
170
|
+
height: cx(198)
|
|
171
|
+
},
|
|
172
|
+
emptyNoTime: {
|
|
173
|
+
fontSize: cx(12),
|
|
174
|
+
color: '#000'
|
|
175
|
+
},
|
|
176
|
+
emptyTimeTip: {
|
|
177
|
+
fontSize: cx(12),
|
|
178
|
+
lineHeight: cx(17),
|
|
179
|
+
marginTop: cx(6),
|
|
180
|
+
width: '76%',
|
|
181
|
+
textAlign: 'center'
|
|
182
|
+
},
|
|
183
|
+
listContainer: {
|
|
184
|
+
bottom: cx(74)
|
|
185
|
+
},
|
|
186
|
+
categoryList: {
|
|
187
|
+
marginHorizontal: cx(24),
|
|
188
|
+
marginBottom: cx(12),
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
export default RandomTimeForLightPage
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { ReactElement, memo } from "react";
|
|
2
|
+
import { Text, Image, ViewStyle, View, StyleSheet } from 'react-native'
|
|
3
|
+
import res from "@ledvance/base/src/res"
|
|
4
|
+
import I18n from "@ledvance/base/src/i18n";
|
|
5
|
+
import { Utils } from "tuya-panel-kit";
|
|
6
|
+
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
7
|
+
|
|
8
|
+
const { convertX: cx } = Utils.RatioUtils;
|
|
9
|
+
|
|
10
|
+
interface SummaryProps {
|
|
11
|
+
style?: ViewStyle
|
|
12
|
+
frequency?: string | ReactElement
|
|
13
|
+
time?: string | ReactElement
|
|
14
|
+
actions?: ReactElement
|
|
15
|
+
hideActions?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Summary = (props: SummaryProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<View style={styles.cardContainer}>
|
|
21
|
+
<Text style={styles.itemTitle}>{I18n.getLang('add_randomtimecycle_subheadline_text')}</Text>
|
|
22
|
+
<Spacer height={cx(10)} />
|
|
23
|
+
<View style={{}}>
|
|
24
|
+
<View style={styles.summaryContainer}>
|
|
25
|
+
<View style={styles.summaryLeft}>
|
|
26
|
+
<Image
|
|
27
|
+
source={res.summary_icon1}
|
|
28
|
+
resizeMode="contain"
|
|
29
|
+
style={styles.summaryImg}
|
|
30
|
+
/>
|
|
31
|
+
<View>
|
|
32
|
+
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_frequency_headline')}</Text>
|
|
33
|
+
</View>
|
|
34
|
+
</View>
|
|
35
|
+
<View style={styles.summaryRight}>
|
|
36
|
+
<View style={styles.rightWrap}>
|
|
37
|
+
<Text style={styles.rightItem}>{props.frequency}</Text>
|
|
38
|
+
</View>
|
|
39
|
+
</View>
|
|
40
|
+
</View>
|
|
41
|
+
<View style={styles.summaryContainer}>
|
|
42
|
+
<View style={styles.summaryLeft}>
|
|
43
|
+
<Image
|
|
44
|
+
source={res.summary_icon2}
|
|
45
|
+
resizeMode="contain"
|
|
46
|
+
style={styles.summaryImg}
|
|
47
|
+
/>
|
|
48
|
+
<View>
|
|
49
|
+
<Text style={styles.leftTitle}>{I18n.getLang('feature_summary_time_headline')}</Text>
|
|
50
|
+
</View>
|
|
51
|
+
</View>
|
|
52
|
+
<View style={styles.summaryRight}>
|
|
53
|
+
<View style={styles.rightWrap}>
|
|
54
|
+
<Text style={styles.rightItem}>{props.time}</Text>
|
|
55
|
+
</View>
|
|
56
|
+
</View>
|
|
57
|
+
</View>
|
|
58
|
+
{!props.hideActions && <View style={[styles.summaryContainer, { alignItems: 'flex-start' }]}>
|
|
59
|
+
<View style={styles.summaryLeft}>
|
|
60
|
+
<Image
|
|
61
|
+
source={res.summary_icon3}
|
|
62
|
+
resizeMode="contain"
|
|
63
|
+
style={styles.summaryImg}
|
|
64
|
+
/>
|
|
65
|
+
<View>
|
|
66
|
+
<Text style={styles.leftTitle}>{I18n.getLang('motion_detection_add_time_schedule_actions_text1')}</Text>
|
|
67
|
+
</View>
|
|
68
|
+
</View>
|
|
69
|
+
<View style={styles.summaryRight}>
|
|
70
|
+
{props.actions}
|
|
71
|
+
</View>
|
|
72
|
+
</View>}
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const styles = StyleSheet.create({
|
|
79
|
+
cardContainer: {
|
|
80
|
+
marginHorizontal: cx(24),
|
|
81
|
+
},
|
|
82
|
+
itemTitle: {
|
|
83
|
+
color: '#000',
|
|
84
|
+
fontSize: cx(16),
|
|
85
|
+
fontWeight: 'bold',
|
|
86
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
87
|
+
},
|
|
88
|
+
summaryContainer: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
flexDirection: 'row',
|
|
91
|
+
marginBottom: cx(10),
|
|
92
|
+
},
|
|
93
|
+
summaryLeft: {
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
minWidth: cx(100)
|
|
97
|
+
},
|
|
98
|
+
summaryImg: {
|
|
99
|
+
width: cx(12),
|
|
100
|
+
height: cx(12),
|
|
101
|
+
marginRight: cx(6)
|
|
102
|
+
},
|
|
103
|
+
leftTitle: {
|
|
104
|
+
fontSize: cx(14),
|
|
105
|
+
color: '#000'
|
|
106
|
+
},
|
|
107
|
+
summaryRight: {
|
|
108
|
+
flex: 1,
|
|
109
|
+
flexDirection: 'column',
|
|
110
|
+
marginLeft: cx(15),
|
|
111
|
+
},
|
|
112
|
+
rightWrap: {
|
|
113
|
+
borderRadius: cx(16),
|
|
114
|
+
paddingHorizontal: cx(12),
|
|
115
|
+
alignSelf: 'flex-start',
|
|
116
|
+
backgroundColor: '#cbcbcb',
|
|
117
|
+
},
|
|
118
|
+
rightItem: {
|
|
119
|
+
color: '#000',
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
export default memo(Summary)
|
|
@@ -3,7 +3,7 @@ import {Result} from '@ledvance/base/src/models/modules/Result'
|
|
|
3
3
|
import dayjs from 'dayjs'
|
|
4
4
|
import {useCountDown, useReactive} from 'ahooks'
|
|
5
5
|
import {useEffect, useMemo} from 'react'
|
|
6
|
-
import {I18nKey} from "
|
|
6
|
+
import {I18nKey} from "@ledvance/base/src/i18n/index";
|
|
7
7
|
|
|
8
8
|
export interface TimerTask {
|
|
9
9
|
name: string
|
|
@@ -11,6 +11,10 @@ import FlagPage from '../modules/flags/FlagPage'
|
|
|
11
11
|
import FlagEditPage from '../modules/flags/FlagEditPage'
|
|
12
12
|
import RemoteSwitchPage from "../modules/remoteSwitch/RemoteSwitchPage";
|
|
13
13
|
import SwitchGradientPage from "../modules/switchGradient/SwitchGradientPage";
|
|
14
|
+
import RandomTimeForPlugPage from "../modules/randomTimeForPlug/RandomTimeForPlugPage";
|
|
15
|
+
import RandomTimeForPlugDetailPage from "../modules/randomTimeForPlug/RandomTimeForPlugDetailPage";
|
|
16
|
+
import RandomTimeForLightPage from "../modules/randomTimingForLight/RandomTimingForLightPage";
|
|
17
|
+
import RandomTimingForLightDetailPage from "../modules/randomTimingForLight/RandomTimingForLightDetailPage";
|
|
14
18
|
|
|
15
19
|
export const ui_biz_routerKey = {
|
|
16
20
|
'group_ui_biz_timer': 'group_ui_biz_timer',
|
|
@@ -25,6 +29,10 @@ export const ui_biz_routerKey = {
|
|
|
25
29
|
'group_ui_biz_flag_page_edit': 'group_ui_biz_flag_page_edit',
|
|
26
30
|
'group_ui_biz_remote_switch': 'group_ui_biz_remote_switch',
|
|
27
31
|
'group_ui_biz_switch_gradient': 'group_ui_biz_switch_gradient',
|
|
32
|
+
'group_ui_biz_random_time_plug': 'group_ui_biz_random_time_plug',
|
|
33
|
+
'group_ui_biz_random_time_plug_detail': 'group_ui_biz_random_time_plug_detail',
|
|
34
|
+
'group_ui_biz_random_timing_light': 'group_ui_biz_random_timing_light',
|
|
35
|
+
'group_ui_biz_random_timing_light_detail': 'group_ui_biz_random_timing_light_detail',
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
export const TimerRouters: NavigationRoute[] = [
|
|
@@ -144,3 +152,41 @@ export const SwitchGradientRouters: NavigationRoute[] = [
|
|
|
144
152
|
},
|
|
145
153
|
}
|
|
146
154
|
]
|
|
155
|
+
|
|
156
|
+
export const RandomTimeForPlugRouters: NavigationRoute[] = [
|
|
157
|
+
{
|
|
158
|
+
name: ui_biz_routerKey.group_ui_biz_random_time_plug,
|
|
159
|
+
component: RandomTimeForPlugPage,
|
|
160
|
+
options: {
|
|
161
|
+
hideTopbar: true,
|
|
162
|
+
showOfflineView: false,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: ui_biz_routerKey.group_ui_biz_random_time_plug_detail,
|
|
167
|
+
component: RandomTimeForPlugDetailPage,
|
|
168
|
+
options: {
|
|
169
|
+
hideTopbar: true,
|
|
170
|
+
showOfflineView: false,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
export const RandomTimingForLightRouters: NavigationRoute[] = [
|
|
176
|
+
{
|
|
177
|
+
name: ui_biz_routerKey.group_ui_biz_random_timing_light,
|
|
178
|
+
component: RandomTimeForLightPage,
|
|
179
|
+
options: {
|
|
180
|
+
hideTopbar: true,
|
|
181
|
+
showOfflineView: false,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: ui_biz_routerKey.group_ui_biz_random_timing_light_detail,
|
|
186
|
+
component: RandomTimingForLightDetailPage,
|
|
187
|
+
options: {
|
|
188
|
+
hideTopbar: true,
|
|
189
|
+
showOfflineView: false,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
]
|