@eohjsc/react-native-smart-city 0.3.68 → 0.3.69
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/assets/images/Device/inactive-icon.svg +22 -0
- package/package.json +3 -3
- package/src/commons/ActionGroup/ColorPickerTemplateStyles.js +1 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplateStyle.js +4 -6
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +3 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplateStyle.js +3 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplateStyle.js +1 -2
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -2
- package/src/commons/ActionGroup/OnOffTemplate/styles.js +7 -0
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +6 -1
- package/src/commons/ActionGroup/OneBigButtonTemplateStyle.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplateStyle.js +3 -4
- package/src/commons/ActionGroup/SliderRangeTemplate.js +15 -15
- package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +10 -10
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -13
- package/src/commons/ActionGroup/StatesGridActionTemplateStyle.js +23 -9
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +3 -3
- package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +9 -1
- package/src/commons/ActionGroup/TimerActionTemplateStyles.js +1 -1
- package/src/commons/ActionGroup/TwoButtonTemplate/TwoButtonTemplateStyles.js +1 -1
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +4 -14
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/index.test.js +1 -1
- package/src/commons/ActionGroup/index.js +3 -31
- package/src/commons/CameraDevice/CameraDeviceStyles.js +1 -2
- package/src/commons/DevMode/CardDevMode.js +9 -33
- package/src/commons/DevMode/Styles/CardStyles.js +3 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +15 -7
- package/src/commons/Device/WindDirection/Compass/index.js +1 -0
- package/src/commons/Device/WindSpeed/Anemometer/index.js +6 -2
- package/src/commons/IconComponent/index.js +17 -3
- package/src/commons/Processing/__test__/Connecting.test.js +38 -2
- package/src/commons/Processing/index.js +2 -6
- package/src/context/reducer.ts +9 -4
- package/src/screens/AddNewGateway/ConnectingDevice.js +14 -3
- package/src/screens/AllGateway/DetailConfigActionInternal/index.js +1 -1
- package/src/screens/AllGateway/DetailConfigActionModbus/index.js +2 -2
- package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +4 -4
- package/src/screens/AllGateway/DeviceGatewayInfo/__test__/index.test.js +2 -0
- package/src/screens/AllGateway/DeviceGatewayInfo/index.js +12 -3
- package/src/screens/AllGateway/components/GatewayItem/index.js +0 -5
- package/src/screens/AllGateway/components/GatewayItem/styles.js +0 -6
- package/src/screens/Device/__test__/detail.test.js +0 -1
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +143 -0
- package/src/screens/Device/components/DetailHistoryChart.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +51 -47
- package/src/screens/Device/detail.js +83 -116
- package/src/screens/Device/styles.js +6 -2
- package/src/screens/Template/utils/ValueEvaluation.test.js +21 -0
- package/src/screens/Unit/ManageUnit.js +9 -9
- package/src/screens/Unit/SelectAddress.js +1 -1
- package/src/screens/Unit/Summaries.js +1 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +60 -1
- package/src/screens/Unit/__test__/Summaries.test.js +21 -1
- package/src/screens/Unit/components/Header/index.js +13 -8
- package/src/utils/Apis/axios.js +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg width="44" height="43" viewBox="0 0 44 43" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_5351_7199)">
|
|
3
|
+
<path d="M23.1324 13.4136C18.9141 12.7994 14.9964 15.7213 14.3825 19.9399C13.7684 24.1583 16.6902 28.0756 20.9089 28.6898C25.1256 29.3037 29.0423 26.3837 29.6581 22.1673C30.2704 17.9486 27.3501 14.0313 23.1324 13.4136ZM16.7548 23.1361C16.3796 23.2335 15.9967 23.0083 15.8994 22.6331C15.0751 19.4398 16.8447 16.1495 19.9635 15.0772C20.3288 14.9477 20.73 15.1389 20.8594 15.5044C20.9889 15.8697 20.7974 16.2706 20.4322 16.4C20.4283 16.4013 20.4245 16.4029 20.4203 16.4042C17.9944 17.2378 16.6173 19.7967 17.2578 22.2807C17.3552 22.6559 17.13 23.0388 16.7548 23.1361ZM21.0448 26.625C20.9551 26.9205 20.6824 27.1225 20.3734 27.1225C20.3043 27.1225 20.2353 27.1123 20.1691 27.0917C19.1335 26.7756 18.1965 26.1981 17.4486 25.4146C17.1811 25.1342 17.1917 24.6899 17.4718 24.4223C17.7522 24.1547 18.1965 24.1653 18.464 24.4454C19.0445 25.0558 19.7724 25.5058 20.5777 25.7528C20.9468 25.8656 21.1556 26.2552 21.0448 26.625Z" fill="#262626"/>
|
|
4
|
+
<path d="M30.7895 15.1966L39.9143 9.94971L40.6136 11.1662L31.4892 16.4131L30.7895 15.1966Z" fill="#262626"/>
|
|
5
|
+
<path d="M21.3313 10.5253L21.3522 0L22.7556 0.00289103L22.7347 10.5282L21.3313 10.5253Z" fill="#262626"/>
|
|
6
|
+
<path d="M3.45079 11.1005L4.1546 9.88623L13.261 15.1649L12.5572 16.3788L3.45079 11.1005Z" fill="#262626"/>
|
|
7
|
+
<path d="M3.41579 30.9368L12.5393 25.689L13.2392 26.9055L4.11575 32.1533L3.41579 30.9368Z" fill="#262626"/>
|
|
8
|
+
<path d="M21.2757 42.1025L21.2966 31.5771L22.7001 31.5797L22.6792 42.1054L21.2757 42.1025Z" fill="#262626"/>
|
|
9
|
+
<path d="M30.7693 26.9359L31.4731 25.7217L40.5798 31.0001L39.876 32.2143L30.7693 26.9359Z" fill="#262626"/>
|
|
10
|
+
<path d="M26.6674 11.5841L29.8244 6.11426L31.0399 6.81582L27.8829 12.2857L26.6674 11.5841Z" fill="#262626"/>
|
|
11
|
+
<path d="M12.9838 6.81875L14.1984 6.11719L17.3573 11.5858L16.1428 12.2873L12.9838 6.81875Z" fill="#262626"/>
|
|
12
|
+
<path d="M5.17383 20.3521H11.4891V21.7555H5.17383V20.3521Z" fill="#262626"/>
|
|
13
|
+
<path d="M12.9893 35.2854L16.1463 29.8159L17.3618 30.5175L14.2048 35.987L12.9893 35.2854Z" fill="#262626"/>
|
|
14
|
+
<path d="M26.6715 30.5145L27.8861 29.813L31.045 35.2812L29.8305 35.9828L26.6715 30.5145Z" fill="#262626"/>
|
|
15
|
+
<path d="M32.5402 20.3477H38.8555V21.7511H32.5402V20.3477Z" fill="#262626"/>
|
|
16
|
+
</g>
|
|
17
|
+
<defs>
|
|
18
|
+
<clipPath id="clip0_5351_7199">
|
|
19
|
+
<rect width="42.1053" height="42.1053" fill="white" transform="translate(0.947388)"/>
|
|
20
|
+
</clipPath>
|
|
21
|
+
</defs>
|
|
22
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.69",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"querystring": "^0.2.0",
|
|
148
148
|
"react-content-loader": "^6.0.3",
|
|
149
149
|
"react-dom": "^17.0.1",
|
|
150
|
-
"react-hooks-global-state": "^
|
|
150
|
+
"react-hooks-global-state": "^2.0.0",
|
|
151
151
|
"react-i18next": "^11.8.12",
|
|
152
152
|
"react-native-alert-async": "^1.0.5",
|
|
153
153
|
"react-native-android-keyboard-adjust": "^1.2.0",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"react-native-animated-ellipsis": "^2.0.0",
|
|
157
157
|
"react-native-appearance": "^0.3.4",
|
|
158
158
|
"react-native-base64": "^0.1.0",
|
|
159
|
-
"react-native-ble-plx": "^2.0.
|
|
159
|
+
"react-native-ble-plx": "^2.0.3",
|
|
160
160
|
"react-native-bootsplash": "^2.2.5",
|
|
161
161
|
"react-native-calendars": "^1.1266.0",
|
|
162
162
|
"react-native-chart-kit": "^6.5.0",
|
|
@@ -3,15 +3,13 @@ import { Colors } from '../../configs';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
|
-
|
|
7
|
-
marginHorizontal:
|
|
8
|
-
|
|
6
|
+
padding: 16,
|
|
7
|
+
marginHorizontal: 16,
|
|
8
|
+
marginBottom: 16,
|
|
9
9
|
borderWidth: 1,
|
|
10
10
|
borderColor: Colors.Gray4,
|
|
11
11
|
borderRadius: 10,
|
|
12
12
|
flex: 1,
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
alignItems: 'center',
|
|
15
13
|
},
|
|
16
14
|
downButton: {
|
|
17
15
|
marginRight: 60,
|
|
@@ -31,7 +29,7 @@ export default StyleSheet.create({
|
|
|
31
29
|
controlPannel: {
|
|
32
30
|
flex: 1,
|
|
33
31
|
flexDirection: 'row',
|
|
34
|
-
justifyContent: '
|
|
32
|
+
justifyContent: 'space-between',
|
|
35
33
|
alignItems: 'center',
|
|
36
34
|
},
|
|
37
35
|
});
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { Colors
|
|
1
|
+
import { Colors } from '../../../configs';
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
|
-
import { standardizeCameraScreenSize } from '../../../utils/Utils';
|
|
4
|
-
|
|
5
|
-
const { standardizeHeight } = standardizeCameraScreenSize(
|
|
6
|
-
Device.screenWidth - 32
|
|
7
|
-
);
|
|
8
3
|
|
|
9
4
|
export default StyleSheet.create({
|
|
10
5
|
barrierControlContainer: {
|
|
11
|
-
|
|
12
|
-
width: '100%',
|
|
6
|
+
width: 'auto',
|
|
13
7
|
justifyContent: 'center',
|
|
14
8
|
alignItems: 'center',
|
|
15
9
|
padding: 20,
|
|
10
|
+
paddingVertical: 50,
|
|
16
11
|
},
|
|
17
12
|
bigCircle: {
|
|
18
13
|
backgroundColor: Colors.Gray2,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
2
3
|
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
3
4
|
|
|
4
5
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
@@ -6,6 +7,7 @@ import { useConfigGlobalState } from '../../../iot/states';
|
|
|
6
7
|
import { useUnwatchLGDeviceConfigControl } from '../../../hooks/IoT';
|
|
7
8
|
import OnOffButtonTemplate from './OnOffButtonTemplate';
|
|
8
9
|
import OnOffSimpleTemplate from './OnOffSimpleTemplate';
|
|
10
|
+
import styles from './styles';
|
|
9
11
|
|
|
10
12
|
let temp;
|
|
11
13
|
|
|
@@ -107,14 +109,14 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
107
109
|
}, [actionGroup]);
|
|
108
110
|
|
|
109
111
|
return (
|
|
110
|
-
|
|
112
|
+
<View style={styles.wrap}>
|
|
111
113
|
<Component
|
|
112
114
|
isOn={tempIsOn}
|
|
113
115
|
triggerAction={triggerAction}
|
|
114
116
|
actionGroup={actionGroup}
|
|
115
117
|
disabled={!action_on_data && !action_off_data}
|
|
116
118
|
/>
|
|
117
|
-
|
|
119
|
+
</View>
|
|
118
120
|
);
|
|
119
121
|
});
|
|
120
122
|
|
|
@@ -19,7 +19,12 @@ const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
19
19
|
<View style={styles.barrierControlContainer}>
|
|
20
20
|
<TouchableOpacity style={styles.bigCircle} onPress={onPressDoAction}>
|
|
21
21
|
<View style={styles.smallCircle}>
|
|
22
|
-
<IconComponent
|
|
22
|
+
<IconComponent
|
|
23
|
+
icon={icon}
|
|
24
|
+
iconSize={44}
|
|
25
|
+
size={44}
|
|
26
|
+
color={Colors.Green7}
|
|
27
|
+
/>
|
|
23
28
|
<Text style={styles.textBig}>{text}</Text>
|
|
24
29
|
</View>
|
|
25
30
|
</TouchableOpacity>
|
|
@@ -3,10 +3,9 @@ import { Colors } from '../../configs';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
marginTop: 20,
|
|
6
|
+
padding: 16,
|
|
7
|
+
marginHorizontal: 16,
|
|
8
|
+
marginBottom: 16,
|
|
10
9
|
borderWidth: 1,
|
|
11
10
|
borderColor: Colors.Gray4,
|
|
12
11
|
borderRadius: 10,
|
|
@@ -75,21 +75,21 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
75
75
|
</Text>
|
|
76
76
|
</View>
|
|
77
77
|
<View style={styles.RightBrightness}>
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
<SliderRange
|
|
79
|
+
style={styles.slider}
|
|
80
|
+
value={valueBrightness}
|
|
81
|
+
onSlidingComplete={onChangeBrightness}
|
|
82
|
+
onValueChange={setValueBrightness}
|
|
83
|
+
step={1}
|
|
84
|
+
minimumValue={0}
|
|
85
|
+
maximumValue={100}
|
|
86
|
+
thumbTintColor={Colors.Gray3}
|
|
87
|
+
minimumTrackTintColor={Colors.Primary}
|
|
88
|
+
maximumTrackTintColor={Colors.Gray4}
|
|
89
|
+
trackStyle={styles.trackSlider}
|
|
90
|
+
thumbStyle={styles.thumbSlider}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
93
|
<View style={styles.valuePercent}>
|
|
94
94
|
<Text type="Label" style={styles.textValuePercent}>
|
|
95
95
|
{`${valueBrightness}%`}
|
|
@@ -2,15 +2,16 @@ import { StyleSheet } from 'react-native';
|
|
|
2
2
|
import { Colors } from '../../configs';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
-
wrap: {
|
|
6
|
-
flexDirection: 'row',
|
|
7
|
-
justifyContent: 'space-around',
|
|
8
|
-
paddingVertical: 30,
|
|
9
|
-
},
|
|
10
5
|
viewBrightness: {
|
|
11
|
-
|
|
6
|
+
marginBottom: 16,
|
|
7
|
+
marginHorizontal: 16,
|
|
8
|
+
padding: 16,
|
|
12
9
|
flexDirection: 'row',
|
|
13
|
-
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'space-around',
|
|
12
|
+
borderWidth: 1,
|
|
13
|
+
borderColor: Colors.Gray4,
|
|
14
|
+
borderRadius: 10,
|
|
14
15
|
},
|
|
15
16
|
slider: {
|
|
16
17
|
width: 131,
|
|
@@ -25,12 +26,12 @@ export default StyleSheet.create({
|
|
|
25
26
|
height: 20,
|
|
26
27
|
},
|
|
27
28
|
valuePercent: {
|
|
28
|
-
width:
|
|
29
|
+
width: 45,
|
|
29
30
|
flexDirection: 'row',
|
|
30
31
|
paddingLeft: 16,
|
|
31
32
|
},
|
|
32
33
|
textValuePercent: {
|
|
33
|
-
width:
|
|
34
|
+
width: 45,
|
|
34
35
|
},
|
|
35
36
|
LeftBrightness: {
|
|
36
37
|
flex: 1,
|
|
@@ -42,7 +43,6 @@ export default StyleSheet.create({
|
|
|
42
43
|
paddingLeft: 8,
|
|
43
44
|
},
|
|
44
45
|
RightBrightness: {
|
|
45
|
-
flex: 1.2,
|
|
46
46
|
flexDirection: 'row',
|
|
47
47
|
alignItems: 'center',
|
|
48
48
|
},
|
|
@@ -25,7 +25,7 @@ const buttonStyle = {
|
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const GridItem = ({ item,
|
|
28
|
+
const GridItem = ({ item, doAction, sensor }) => {
|
|
29
29
|
const {
|
|
30
30
|
active,
|
|
31
31
|
text,
|
|
@@ -80,7 +80,10 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
|
|
|
80
80
|
}
|
|
81
81
|
}, [icon]);
|
|
82
82
|
return (
|
|
83
|
-
<View
|
|
83
|
+
<View
|
|
84
|
+
accessibilityLabel={AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM}
|
|
85
|
+
style={styles.viewButton}
|
|
86
|
+
>
|
|
84
87
|
<TouchableOpacity
|
|
85
88
|
style={[styles.button, buttonOnOffStyle]}
|
|
86
89
|
onPress={() => doActionAndWatchConfig(action_data)}
|
|
@@ -88,15 +91,14 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
|
|
|
88
91
|
{!checkIcon && (
|
|
89
92
|
<IconComponent
|
|
90
93
|
icon={iconKit || icon}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
color={'red'}
|
|
94
|
+
active={active}
|
|
95
|
+
color={Colors.White}
|
|
96
|
+
style={styles.iconComponent}
|
|
95
97
|
/>
|
|
96
98
|
)}
|
|
97
99
|
{checkIcon && <View>{iconSvg}</View>}
|
|
98
100
|
</TouchableOpacity>
|
|
99
|
-
<Text center color={Colors.Gray8}
|
|
101
|
+
<Text center color={Colors.Gray8}>
|
|
100
102
|
{text}
|
|
101
103
|
</Text>
|
|
102
104
|
</View>
|
|
@@ -127,18 +129,23 @@ const StatesGridActionTemplate = ({
|
|
|
127
129
|
|
|
128
130
|
return (
|
|
129
131
|
<View style={styles.wrap}>
|
|
130
|
-
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
{!!title && (
|
|
133
|
+
<Text type="H4" style={styles.textModeMargin}>
|
|
134
|
+
{title}
|
|
135
|
+
</Text>
|
|
136
|
+
)}
|
|
137
|
+
<View
|
|
138
|
+
style={[
|
|
139
|
+
styles.wrapOption,
|
|
140
|
+
options?.length < 4 && styles.justifyContentAround,
|
|
141
|
+
]}
|
|
142
|
+
>
|
|
134
143
|
{options.map((item, index) => (
|
|
135
144
|
<GridItem
|
|
136
145
|
item={item}
|
|
137
146
|
index={index}
|
|
138
|
-
length={options.length}
|
|
139
147
|
doAction={doAction}
|
|
140
148
|
sensor={sensor}
|
|
141
|
-
title={title}
|
|
142
149
|
/>
|
|
143
150
|
))}
|
|
144
151
|
</View>
|
|
@@ -3,16 +3,18 @@ import { Colors } from '../../configs';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
display: 'flex',
|
|
7
|
+
justifyContent: 'space-between',
|
|
8
|
+
paddingTop: 16,
|
|
9
|
+
paddingBottom: 10,
|
|
10
|
+
marginHorizontal: 16,
|
|
11
|
+
marginBottom: 16,
|
|
9
12
|
borderWidth: 1,
|
|
10
13
|
borderColor: Colors.Gray4,
|
|
11
14
|
borderTopRightRadius: 10,
|
|
12
15
|
borderTopLeftRadius: 10,
|
|
13
16
|
borderBottomRightRadius: 10,
|
|
14
17
|
borderBottomLeftRadius: 10,
|
|
15
|
-
marginTop: 20,
|
|
16
18
|
},
|
|
17
19
|
wrapOption: {
|
|
18
20
|
flex: 1,
|
|
@@ -21,20 +23,32 @@ export default StyleSheet.create({
|
|
|
21
23
|
flexWrap: 'wrap',
|
|
22
24
|
paddingHorizontal: 16,
|
|
23
25
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
justifyContentAround: {
|
|
27
|
+
justifyContent: 'space-around',
|
|
26
28
|
},
|
|
27
29
|
textModeMargin: {
|
|
28
30
|
marginBottom: 9,
|
|
29
31
|
marginLeft: 16,
|
|
30
32
|
},
|
|
33
|
+
viewButton: {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
},
|
|
31
38
|
button: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
padding: 10,
|
|
35
43
|
borderRadius: 5,
|
|
36
44
|
borderWidth: 1,
|
|
37
45
|
borderColor: Colors.Gray4,
|
|
38
46
|
backgroundColor: Colors.White,
|
|
47
|
+
marginBottom: 8,
|
|
48
|
+
},
|
|
49
|
+
iconComponent: {
|
|
50
|
+
fontSize: 28,
|
|
51
|
+
width: 28,
|
|
52
|
+
height: 28,
|
|
39
53
|
},
|
|
40
54
|
});
|
|
@@ -82,8 +82,8 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
|
-
|
|
86
|
-
<View style={styles.
|
|
85
|
+
<View style={styles.wrap}>
|
|
86
|
+
<View style={styles.threeButton}>
|
|
87
87
|
<TouchableOpacity
|
|
88
88
|
accessibilityLabel={AccessibilityLabel.BUTTON_TEMPLATE_1}
|
|
89
89
|
style={styles.buttonActionDoor}
|
|
@@ -125,7 +125,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
125
125
|
lock ? Colors.Primary : Colors.Gray6
|
|
126
126
|
)}
|
|
127
127
|
</View>
|
|
128
|
-
|
|
128
|
+
</View>
|
|
129
129
|
);
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -3,9 +3,17 @@ import { Colors } from '../../configs';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
marginBottom: 16,
|
|
8
|
+
},
|
|
9
|
+
threeButton: {
|
|
6
10
|
flexDirection: 'row',
|
|
7
11
|
justifyContent: 'space-around',
|
|
8
|
-
|
|
12
|
+
padding: 16,
|
|
13
|
+
margin: 20,
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderColor: Colors.Gray4,
|
|
16
|
+
borderRadius: 10,
|
|
9
17
|
},
|
|
10
18
|
imageButton: {
|
|
11
19
|
height: 32,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import OnOffTemplate from '../OnOffTemplate';
|
|
4
4
|
import { mockSCStore } from '../../../context/mockStore';
|
|
@@ -10,11 +10,6 @@ const wrapComponent = (actionGroup, mockDoAction) => (
|
|
|
10
10
|
</SCProvider>
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
jest.mock('react', () => ({
|
|
14
|
-
...jest.requireActual('react'),
|
|
15
|
-
useState: jest.fn(),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
13
|
jest.mock('@react-navigation/native', () => {
|
|
19
14
|
return {
|
|
20
15
|
...jest.requireActual('@react-navigation/native'),
|
|
@@ -58,11 +53,7 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
58
53
|
};
|
|
59
54
|
let wrapper;
|
|
60
55
|
|
|
61
|
-
const
|
|
62
|
-
useState.mockImplementation((init) => [init, setState]);
|
|
63
|
-
|
|
64
|
-
const assertRender = async (state, text) => {
|
|
65
|
-
useState.mockImplementationOnce((init) => [state, setState]);
|
|
56
|
+
const assertRender = async () => {
|
|
66
57
|
const mockDoAction = jest.fn();
|
|
67
58
|
|
|
68
59
|
await act(async () => {
|
|
@@ -71,8 +62,8 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
71
62
|
|
|
72
63
|
const renderJson = wrapper.toJSON();
|
|
73
64
|
|
|
74
|
-
expect(renderJson
|
|
75
|
-
expect(renderJson?.type).toEqual('Modal');
|
|
65
|
+
expect(renderJson[1].props?.visible).toEqual(false);
|
|
66
|
+
expect(renderJson[1]?.type).toEqual('Modal');
|
|
76
67
|
};
|
|
77
68
|
|
|
78
69
|
it('render state on', async () => {
|
|
@@ -84,7 +75,6 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
84
75
|
});
|
|
85
76
|
|
|
86
77
|
const assertActionCall = async (state, action_data) => {
|
|
87
|
-
useState.mockImplementationOnce((init) => [state, setState]);
|
|
88
78
|
const mockDoAction = jest.fn();
|
|
89
79
|
await act(async () => {
|
|
90
80
|
wrapper = create(wrapComponent(actionGroup, mockDoAction));
|
|
@@ -52,7 +52,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
52
52
|
});
|
|
53
53
|
const instance = tree.root;
|
|
54
54
|
const Texts = instance.findAllByType(Text);
|
|
55
|
-
expect(Texts).toHaveLength(1);
|
|
55
|
+
expect(Texts).not.toHaveLength(1);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('test render with params', async () => {
|
|
@@ -454,7 +454,7 @@ describe('Test ActionGroup', () => {
|
|
|
454
454
|
});
|
|
455
455
|
const instance = wrapper.root;
|
|
456
456
|
const texts = instance.findAllByType(Text);
|
|
457
|
-
expect(texts).toHaveLength(
|
|
457
|
+
expect(texts).toHaveLength(4);
|
|
458
458
|
});
|
|
459
459
|
|
|
460
460
|
it('render OptionsDropdownActionTemplate', async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo,
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
2
|
import Text from '../Text';
|
|
3
3
|
import OneBigButtonTemplate from './OneBigButtonTemplate';
|
|
4
4
|
import ThreeButtonTemplate from './ThreeButtonTemplate';
|
|
@@ -13,9 +13,6 @@ import ColorPickerTemplate from './ColorPickerTemplate';
|
|
|
13
13
|
import SliderRangeTemplate from './SliderRangeTemplate';
|
|
14
14
|
import OnOffSmartLock from './OnOffSmartLock/OnOffSmartLock';
|
|
15
15
|
import TwoButtonTemplate from './TwoButtonTemplate';
|
|
16
|
-
import { CardDevMode } from '../DevMode';
|
|
17
|
-
import t from '../../hooks/Common/useTranslations';
|
|
18
|
-
import { useSCContextSelector } from '../../context';
|
|
19
16
|
|
|
20
17
|
export const getActionComponent = (template) => {
|
|
21
18
|
switch (template) {
|
|
@@ -54,28 +51,9 @@ export const getActionComponent = (template) => {
|
|
|
54
51
|
}
|
|
55
52
|
};
|
|
56
53
|
|
|
57
|
-
const isWrap = (template) => {
|
|
58
|
-
switch (template) {
|
|
59
|
-
case 'OnOffSmartLockActionTemplate':
|
|
60
|
-
return true;
|
|
61
|
-
default:
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
54
|
const ActionGroup = (params = {}) => {
|
|
67
|
-
const { actionGroup = {}
|
|
55
|
+
const { actionGroup = {} } = params;
|
|
68
56
|
const { template } = actionGroup;
|
|
69
|
-
const { isEditingTemplate } = useSCContextSelector((state) => state.devMode);
|
|
70
|
-
|
|
71
|
-
const getTitle = useCallback(() => {
|
|
72
|
-
switch (template) {
|
|
73
|
-
case 'OnOffSmartLockActionTemplate':
|
|
74
|
-
return isEditingTemplate ? 'label' : 'controller';
|
|
75
|
-
default:
|
|
76
|
-
return 'label';
|
|
77
|
-
}
|
|
78
|
-
}, [template, isEditingTemplate]);
|
|
79
57
|
|
|
80
58
|
const ButtonGroupComponent = useMemo(() => {
|
|
81
59
|
return getActionComponent(template);
|
|
@@ -84,13 +62,7 @@ const ActionGroup = (params = {}) => {
|
|
|
84
62
|
return (
|
|
85
63
|
<>
|
|
86
64
|
{ButtonGroupComponent ? (
|
|
87
|
-
<
|
|
88
|
-
title={item?.label || t(getTitle())}
|
|
89
|
-
id={id}
|
|
90
|
-
isWrap={isWrap(template)}
|
|
91
|
-
>
|
|
92
|
-
<ButtonGroupComponent {...params} />
|
|
93
|
-
</CardDevMode>
|
|
65
|
+
<ButtonGroupComponent {...params} />
|
|
94
66
|
) : (
|
|
95
67
|
<Text
|
|
96
68
|
center
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Device } from '../../configs';
|
|
2
1
|
import { StyleSheet } from 'react-native';
|
|
3
2
|
import { Colors } from '../../configs';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ export default StyleSheet.create({
|
|
|
8
7
|
marginTop: 8,
|
|
9
8
|
marginBottom: 8,
|
|
10
9
|
overflow: 'hidden',
|
|
11
|
-
width:
|
|
10
|
+
width: '100%',
|
|
12
11
|
alignSelf: 'center',
|
|
13
12
|
},
|
|
14
13
|
image: {
|