@eohjsc/react-native-smart-city 0.2.84 → 0.2.85
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/brightness.svg +12 -0
- package/package.json +3 -1
- package/src/Images/Common/SuccessfullyConnected.svg +4 -0
- package/src/Images/Common/eye-closed.png +0 -0
- package/src/Images/Common/eye-closed@2x.png +0 -0
- package/src/Images/Common/eye-closed@3x.png +0 -0
- package/src/Images/Common/eye.png +0 -0
- package/src/Images/Common/eye@2x.png +0 -0
- package/src/Images/Common/eye@3x.png +0 -0
- package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
- package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/CardShadow/index.js +5 -2
- package/src/commons/CardShadow/styles.js +2 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
- package/src/commons/ConnectingProcess/index.js +202 -0
- package/src/commons/ConnectingProcess/styles.js +69 -0
- package/src/commons/Device/LinearChart.js +1 -0
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/configs/API.js +2 -0
- package/src/configs/Constants.js +15 -0
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useBlockBackAndroid.js +3 -1
- package/src/navigations/AddDeviceStack.js +10 -0
- package/src/screens/AddCommon/SelectSubUnit.js +29 -6
- package/src/screens/AddCommon/SelectUnit.js +24 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +45 -15
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +52 -23
- package/src/screens/AddNewGateway/SelectGateway.js +132 -0
- package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
- package/src/screens/Device/detail.js +6 -6
- package/src/screens/Notification/__test__/NotificationItem.test.js +12 -2
- package/src/screens/Notification/components/NotificationItem.js +60 -12
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +10 -7
- package/src/screens/ScanChipQR/hooks/index.js +46 -22
- package/src/screens/Unit/Detail.js +23 -1
- package/src/utils/I18n/translations/en.json +8 -0
- package/src/utils/I18n/translations/vi.json +8 -1
- package/src/utils/Route/index.js +2 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M10.0001 3.90845C8.79471 3.90824 7.61636 4.26551 6.61406 4.93507C5.61177 5.60463 4.83056 6.55639 4.36924 7.66998C3.90791 8.78357 3.78721 10.009 4.02239 11.1912C4.25757 12.3734 4.83807 13.4593 5.69046 14.3115C6.54286 15.1638 7.62885 15.7441 8.81109 15.979C9.99333 16.214 11.2187 16.0931 12.3322 15.6316C13.4457 15.1701 14.3974 14.3887 15.0667 13.3863C15.7361 12.3839 16.0932 11.2055 16.0928 10.0001C16.0922 8.38449 15.4501 6.83522 14.3076 5.6929C13.1651 4.55058 11.6157 3.90872 10.0001 3.90845ZM10.0001 14.6376C9.08332 14.6378 8.18709 14.3662 7.4247 13.8571C6.66232 13.3479 6.06802 12.6242 5.71696 11.7773C5.36589 10.9304 5.27383 9.99847 5.4524 9.09928C5.63097 8.20008 6.07216 7.37403 6.72019 6.72557C7.36821 6.07711 8.19397 5.63536 9.09304 5.45618C9.99212 5.277 10.9241 5.36844 11.7712 5.71893C12.6184 6.06943 13.3425 6.66324 13.8522 7.42528C14.3618 8.18731 14.634 9.08336 14.6344 10.0001C14.6336 11.2293 14.1452 12.4079 13.2763 13.2773C12.4075 14.1467 11.2292 14.636 10.0001 14.6376Z" fill="#BFBFBF"/>
|
|
3
|
+
<path d="M9.37419 0.866699H10.6242C10.6936 0.866699 10.7284 0.901421 10.7284 0.970866V2.96774C10.7284 3.03719 10.6936 3.07191 10.6242 3.07191H9.37419C9.30474 3.07191 9.27002 3.03719 9.27002 2.96774V0.970866C9.27002 0.901421 9.30474 0.866699 9.37419 0.866699Z" fill="#BFBFBF"/>
|
|
4
|
+
<path d="M3.09933 3.98419L3.98321 3.10031C4.03232 3.0512 4.08142 3.0512 4.13053 3.10031L5.54253 4.51231C5.59164 4.56141 5.59164 4.61052 5.54253 4.65962L4.65865 5.54351C4.60954 5.59261 4.56044 5.59261 4.51133 5.54351L3.09933 4.1315C3.05022 4.0824 3.05022 4.03329 3.09933 3.98419Z" fill="#BFBFBF"/>
|
|
5
|
+
<path d="M0.970866 9.27197H2.96774C3.03719 9.27197 3.07191 9.3067 3.07191 9.37614V10.6261C3.07191 10.6956 3.03719 10.7303 2.96774 10.7303H0.970866C0.901421 10.7303 0.866699 10.6956 0.866699 10.6261V9.37614C0.866699 9.3067 0.901421 9.27197 0.970866 9.27197Z" fill="#BFBFBF"/>
|
|
6
|
+
<path d="M3.10079 15.8697L4.5128 14.4577C4.5619 14.4086 4.61101 14.4086 4.66011 14.4577L5.54399 15.3416C5.5931 15.3907 5.5931 15.4398 5.54399 15.4889L4.13199 16.9009C4.08289 16.95 4.03378 16.95 3.98468 16.9009L3.10079 16.017C3.05169 15.9679 3.05169 15.9188 3.10079 15.8697Z" fill="#BFBFBF"/>
|
|
7
|
+
<path d="M9.37614 16.9282H10.6261C10.6956 16.9282 10.7303 16.9629 10.7303 17.0324V19.0293C10.7303 19.0987 10.6956 19.1334 10.6261 19.1334H9.37614C9.3067 19.1334 9.27197 19.0987 9.27197 19.0293V17.0324C9.27197 16.9629 9.3067 16.9282 9.37614 16.9282Z" fill="#BFBFBF"/>
|
|
8
|
+
<path d="M14.4572 15.3404L15.3411 14.4565C15.3902 14.4074 15.4393 14.4074 15.4884 14.4565L16.9004 15.8685C16.9496 15.9176 16.9496 15.9667 16.9004 16.0158L16.0166 16.8997C15.9675 16.9488 15.9184 16.9488 15.8692 16.8997L14.4572 15.4877C14.4081 15.4386 14.4081 15.3895 14.4572 15.3404Z" fill="#BFBFBF"/>
|
|
9
|
+
<path d="M17.0324 9.26978H19.0293C19.0987 9.26978 19.1334 9.3045 19.1334 9.37394V10.6239C19.1334 10.6934 19.0987 10.7281 19.0293 10.7281H17.0324C16.9629 10.7281 16.9282 10.6934 16.9282 10.6239V9.37394C16.9282 9.3045 16.9629 9.26978 17.0324 9.26978Z" fill="#BFBFBF"/>
|
|
10
|
+
<path d="M14.4558 4.51109L15.8678 3.09908C15.9169 3.04998 15.966 3.04998 16.0151 3.09908L16.899 3.98297C16.9481 4.03207 16.9481 4.08118 16.899 4.13028L15.487 5.54229C15.4379 5.59139 15.3888 5.59139 15.3397 5.54229L14.4558 4.6584C14.4067 4.6093 14.4067 4.56019 14.4558 4.51109Z" fill="#BFBFBF"/>
|
|
11
|
+
<path d="M9.89605 6.07715C8.87128 6.10077 7.89643 6.52444 7.18002 7.25756C6.4636 7.99068 6.0625 8.97503 6.0625 10.0001C6.0625 11.0251 6.4636 12.0095 7.18002 12.7426C7.89643 13.4757 8.87128 13.8994 9.89605 13.923C9.92367 13.923 9.95017 13.912 9.9697 13.8925C9.98924 13.8729 10.0002 13.8464 10.0002 13.8188V6.18132C10.0002 6.15369 9.98924 6.12719 9.9697 6.10766C9.95017 6.08812 9.92367 6.07715 9.89605 6.07715Z" fill="#BFBFBF"/>
|
|
12
|
+
</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.2.
|
|
4
|
+
"version": "0.2.85",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -174,6 +174,7 @@
|
|
|
174
174
|
"react-native-parsed-text": "^0.0.22",
|
|
175
175
|
"react-native-permissions": "^2.1.5",
|
|
176
176
|
"react-native-popover-view": "^4.0.3",
|
|
177
|
+
"react-native-progress": "^5.0.0",
|
|
177
178
|
"react-native-reanimated": "1.10.1",
|
|
178
179
|
"react-native-responsive-fontsize": "^0.5.1",
|
|
179
180
|
"react-native-safe-area-context": "^3.1.1",
|
|
@@ -188,6 +189,7 @@
|
|
|
188
189
|
"react-native-version-check": "^3.4.2",
|
|
189
190
|
"react-native-vlc-media-player": "^1.0.39",
|
|
190
191
|
"react-native-webview": "^10.9.3",
|
|
192
|
+
"react-native-wheel-color-picker": "^1.2.0",
|
|
191
193
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
192
194
|
"react-native-wifi-reborn": "^4.5.0",
|
|
193
195
|
"react-navigation": "^2.2.0",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M21.8437 11.0312H20.3781C20.0593 11.0312 19.7562 11.1844 19.5687 11.4469L14.6562 18.2594L12.4312 15.1719C12.2437 14.9125 11.9437 14.7563 11.6218 14.7563H10.1562C9.95303 14.7563 9.83428 14.9875 9.95303 15.1531L13.8468 20.5531C13.9388 20.6815 14.06 20.7861 14.2005 20.8583C14.341 20.9305 14.4967 20.9681 14.6546 20.9681C14.8125 20.9681 14.9682 20.9305 15.1087 20.8583C15.2492 20.7861 15.3704 20.6815 15.4624 20.5531L22.0437 11.4281C22.1656 11.2625 22.0468 11.0312 21.8437 11.0312V11.0312Z" fill="#52C41A"/>
|
|
3
|
+
<path d="M16 2C8.26875 2 2 8.26875 2 16C2 23.7312 8.26875 30 16 30C23.7312 30 30 23.7312 30 16C30 8.26875 23.7312 2 16 2ZM16 27.625C9.58125 27.625 4.375 22.4187 4.375 16C4.375 9.58125 9.58125 4.375 16 4.375C22.4187 4.375 27.625 9.58125 27.625 16C27.625 22.4187 22.4187 27.625 16 27.625Z" fill="#52C41A"/>
|
|
4
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { memo, useCallback, useState, useMemo } from 'react';
|
|
2
|
+
import { Alert, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
+
import styles from './LightActionTemplateStyles';
|
|
5
|
+
import Text from '../Text';
|
|
6
|
+
import { Colors } from '../../configs';
|
|
7
|
+
import { Card } from '../CardShadow';
|
|
8
|
+
import ColorPicker from 'react-native-wheel-color-picker';
|
|
9
|
+
import SvgBrightness from '../../../assets/images/brightness.svg';
|
|
10
|
+
import Slider from 'react-native-slider';
|
|
11
|
+
import OnOffButtonTemplate from './OnOffTemplate/OnOffButtonTemplate';
|
|
12
|
+
|
|
13
|
+
const LightActionTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
14
|
+
const t = useTranslations();
|
|
15
|
+
const { configuration, title } = actionGroup;
|
|
16
|
+
const dataColor = useMemo(() => {
|
|
17
|
+
return configuration?.config_color;
|
|
18
|
+
}, [configuration]);
|
|
19
|
+
|
|
20
|
+
const dataBrightness = useMemo(() => {
|
|
21
|
+
return configuration?.config_brightness;
|
|
22
|
+
}, [configuration]);
|
|
23
|
+
|
|
24
|
+
const [valueComplete, setValueComplete] = useState(dataBrightness || 0);
|
|
25
|
+
const [value, setValue] = useState(dataBrightness || 0);
|
|
26
|
+
const [color, setColor] = useState(dataColor || '');
|
|
27
|
+
const [isOn] = useState(true);
|
|
28
|
+
|
|
29
|
+
const onChangeColor = useCallback(
|
|
30
|
+
(color) => {
|
|
31
|
+
setColor(color);
|
|
32
|
+
Alert.alert(t('feature_under_development'));
|
|
33
|
+
},
|
|
34
|
+
[t]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const onChangeBrightness = useCallback(
|
|
38
|
+
(value) => {
|
|
39
|
+
setValueComplete(value);
|
|
40
|
+
Alert.alert(t('feature_under_development'));
|
|
41
|
+
},
|
|
42
|
+
[t]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const triggerAction = useCallback(() => {
|
|
46
|
+
Alert.alert(t('feature_under_development'));
|
|
47
|
+
}, [t]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View>
|
|
51
|
+
<OnOffButtonTemplate
|
|
52
|
+
isOn={isOn}
|
|
53
|
+
triggerAction={triggerAction}
|
|
54
|
+
actionGroup={actionGroup}
|
|
55
|
+
isLight={true}
|
|
56
|
+
/>
|
|
57
|
+
<Card title={!!title && t(title)}>
|
|
58
|
+
<View style={styles.viewPickColor}>
|
|
59
|
+
<ColorPicker
|
|
60
|
+
style={styles.colorPicker}
|
|
61
|
+
sliderHidden={true}
|
|
62
|
+
swatches={false}
|
|
63
|
+
color={color}
|
|
64
|
+
onColorChangeComplete={(color) => onChangeColor(color)}
|
|
65
|
+
thumbSize={16}
|
|
66
|
+
/>
|
|
67
|
+
</View>
|
|
68
|
+
<View style={styles.viewBrightness}>
|
|
69
|
+
<View style={styles.LeftBrightness}>
|
|
70
|
+
<SvgBrightness />
|
|
71
|
+
<Text type="H4" style={styles.LeftTextBrightness}>
|
|
72
|
+
{t('brightness')}
|
|
73
|
+
</Text>
|
|
74
|
+
</View>
|
|
75
|
+
<View style={styles.RightBrightness}>
|
|
76
|
+
<View style={styles.slider}>
|
|
77
|
+
<Slider
|
|
78
|
+
value={valueComplete}
|
|
79
|
+
onSlidingComplete={(value) => onChangeBrightness(value)}
|
|
80
|
+
onValueChange={(value) => setValue(value)}
|
|
81
|
+
step={1}
|
|
82
|
+
minimumValue={0}
|
|
83
|
+
maximumValue={100}
|
|
84
|
+
thumbTintColor={Colors.Gray3}
|
|
85
|
+
minimumTrackTintColor={Colors.Primary}
|
|
86
|
+
maximumTrackTintColor={Colors.Gray4}
|
|
87
|
+
trackStyle={styles.trackSlider}
|
|
88
|
+
thumbStyle={styles.thumbSlider}
|
|
89
|
+
/>
|
|
90
|
+
</View>
|
|
91
|
+
<View style={styles.valuePercent}>
|
|
92
|
+
<Text type="Label" style={styles.textValuePercent}>
|
|
93
|
+
{`${value || 0}%`}
|
|
94
|
+
</Text>
|
|
95
|
+
</View>
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
</Card>
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export default LightActionTemplate;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrap: {
|
|
6
|
+
flexDirection: 'row',
|
|
7
|
+
justifyContent: 'space-around',
|
|
8
|
+
paddingVertical: 30,
|
|
9
|
+
},
|
|
10
|
+
viewPickColor: {
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
},
|
|
14
|
+
viewBrightness: {
|
|
15
|
+
paddingTop: 16,
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
},
|
|
19
|
+
slider: {
|
|
20
|
+
width: 131,
|
|
21
|
+
},
|
|
22
|
+
trackSlider: {
|
|
23
|
+
height: 8,
|
|
24
|
+
borderRadius: 30,
|
|
25
|
+
},
|
|
26
|
+
thumbSlider: {
|
|
27
|
+
backgroundColor: Colors.Primary,
|
|
28
|
+
width: 20,
|
|
29
|
+
height: 20,
|
|
30
|
+
},
|
|
31
|
+
colorPicker: {
|
|
32
|
+
width: '100%',
|
|
33
|
+
height: 'auto',
|
|
34
|
+
},
|
|
35
|
+
valuePercent: {
|
|
36
|
+
width: 40,
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
paddingLeft: 16,
|
|
39
|
+
},
|
|
40
|
+
textValuePercent: {
|
|
41
|
+
width: 50,
|
|
42
|
+
},
|
|
43
|
+
LeftBrightness: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
},
|
|
48
|
+
LeftTextBrightness: {
|
|
49
|
+
paddingTop: 4,
|
|
50
|
+
paddingLeft: 8,
|
|
51
|
+
},
|
|
52
|
+
RightBrightness: {
|
|
53
|
+
flex: 1.2,
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -6,37 +6,39 @@ import { TouchableOpacity, View } from 'react-native';
|
|
|
6
6
|
import { Colors } from '../../../configs';
|
|
7
7
|
import styles from './OnOffButtonTemplateStyle';
|
|
8
8
|
|
|
9
|
-
const OnOffButtonTemplate = memo(
|
|
10
|
-
|
|
9
|
+
const OnOffButtonTemplate = memo(
|
|
10
|
+
({ isOn, triggerAction, actionGroup, isLight = false }) => {
|
|
11
|
+
const { configuration } = actionGroup;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<View style={styles.barrierControlContainer}>
|
|
16
|
+
<TouchableOpacity style={styles.bigCircle} onPress={triggerAction}>
|
|
17
|
+
<View style={styles.smallCircle}>
|
|
18
|
+
<Icon
|
|
19
|
+
name={isOn ? configuration.icon_on : configuration.icon_off}
|
|
20
|
+
size={44}
|
|
21
|
+
color={isOn ? Colors.Green7 : Colors.Gray6}
|
|
22
|
+
/>
|
|
23
|
+
<Text
|
|
24
|
+
style={[
|
|
25
|
+
styles.textBig,
|
|
26
|
+
{ color: isOn ? Colors.Gray8 : Colors.Gray6 },
|
|
27
|
+
]}
|
|
28
|
+
>
|
|
29
|
+
{isOn ? configuration.text_on : configuration.text_off}
|
|
30
|
+
</Text>
|
|
31
|
+
</View>
|
|
32
|
+
</TouchableOpacity>
|
|
33
|
+
</View>
|
|
34
|
+
{!!actionGroup.title && !isLight && (
|
|
35
|
+
<Text size={20} semibold center>
|
|
36
|
+
{actionGroup.title}
|
|
37
|
+
</Text>
|
|
38
|
+
)}
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
41
43
|
|
|
42
44
|
export default OnOffButtonTemplate;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import Slider from 'react-native-slider';
|
|
4
|
+
import ColorPicker from 'react-native-wheel-color-picker';
|
|
5
|
+
|
|
6
|
+
import LightActionTemplate from '../LightActionTemplate';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (actionGroup) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<LightActionTemplate actionGroup={actionGroup} doAction={jest.fn()} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
describe('Test CurtainButtonTemplate', () => {
|
|
17
|
+
const actionGroup = {
|
|
18
|
+
configuration: {
|
|
19
|
+
action: 'b1be40f2-f482-4796-8c1a-0431ab49ab5a',
|
|
20
|
+
action_data: {
|
|
21
|
+
color: '#00979D',
|
|
22
|
+
command_prefer_over_bluetooth: true,
|
|
23
|
+
command_prefer_over_googlehome: false,
|
|
24
|
+
command_prefer_over_internet: false,
|
|
25
|
+
googlehome_actions: [Array],
|
|
26
|
+
icon: '123231',
|
|
27
|
+
icon_kit: null,
|
|
28
|
+
id: 5,
|
|
29
|
+
key: 'b1be40f2-f482-4796-8c1a-0431ab49ab5a',
|
|
30
|
+
lg_actions: [Array],
|
|
31
|
+
name: 'change color',
|
|
32
|
+
},
|
|
33
|
+
config_brightness: 18,
|
|
34
|
+
config_color: 17,
|
|
35
|
+
},
|
|
36
|
+
id: 2,
|
|
37
|
+
template: 'light_action_template',
|
|
38
|
+
title: 'controller',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let wrapper;
|
|
42
|
+
|
|
43
|
+
test('render LightActionTemplate', async () => {
|
|
44
|
+
await act(() => {
|
|
45
|
+
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
46
|
+
});
|
|
47
|
+
const instance = wrapper.root;
|
|
48
|
+
const slider = instance.findAllByType(Slider);
|
|
49
|
+
const colorPicker = instance.findAllByType(ColorPicker);
|
|
50
|
+
expect(slider.length).toEqual(1);
|
|
51
|
+
expect(colorPicker.length).toEqual(1);
|
|
52
|
+
await act(async () => {
|
|
53
|
+
await slider[0].props.onSlidingComplete();
|
|
54
|
+
});
|
|
55
|
+
await act(async () => {
|
|
56
|
+
await colorPicker[0].props.onColorChangeComplete();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -10,6 +10,7 @@ import OnOffTemplate from './OnOffTemplate';
|
|
|
10
10
|
import TimerActionTemplate from './TimerActionTemplate';
|
|
11
11
|
import CurtainButtonTemplate from './CurtainButtonTemplate';
|
|
12
12
|
import SmartTiviActionTemplate from './SmartTiviActionTemplate/SmartTiviActionTemplate';
|
|
13
|
+
import LightActionTemplate from './LightActionTemplate';
|
|
13
14
|
|
|
14
15
|
export const getActionComponent = (template) => {
|
|
15
16
|
switch (template) {
|
|
@@ -35,6 +36,8 @@ export const getActionComponent = (template) => {
|
|
|
35
36
|
return CurtainButtonTemplate;
|
|
36
37
|
case 'SmartTiviActionTemplate':
|
|
37
38
|
return SmartTiviActionTemplate;
|
|
39
|
+
case 'light_action_template':
|
|
40
|
+
return LightActionTemplate;
|
|
38
41
|
default:
|
|
39
42
|
return null;
|
|
40
43
|
}
|
|
@@ -3,10 +3,13 @@ import { View } from 'react-native';
|
|
|
3
3
|
import Text from '../../commons/Text';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
|
|
6
|
-
const Card = memo(({ title, children, style }) => {
|
|
6
|
+
const Card = memo(({ title, children, style, rightHeaderComponent }) => {
|
|
7
7
|
return (
|
|
8
8
|
<View style={[styles.card, style]}>
|
|
9
|
-
|
|
9
|
+
<View style={styles.headerTitle}>
|
|
10
|
+
{!!title && <Text style={styles.headerLeft}>{title}</Text>}
|
|
11
|
+
{!!rightHeaderComponent && rightHeaderComponent}
|
|
12
|
+
</View>
|
|
10
13
|
{children}
|
|
11
14
|
</View>
|
|
12
15
|
);
|
|
@@ -17,9 +17,8 @@ export default StyleSheet.create({
|
|
|
17
17
|
shadowRadius: 3,
|
|
18
18
|
elevation: 6,
|
|
19
19
|
},
|
|
20
|
-
headerTitle: {
|
|
21
|
-
|
|
22
|
-
alignItems: 'flex-end',
|
|
20
|
+
headerTitle: { justifyContent: 'space-between', flexDirection: 'row' },
|
|
21
|
+
headerLeft: {
|
|
23
22
|
color: Colors.Gray8,
|
|
24
23
|
fontSize: 16,
|
|
25
24
|
lineHeight: 24,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import styles from './DeviceItemStyles';
|
|
4
|
+
import FImage from '../../FImage';
|
|
5
|
+
import Text from '../../Text';
|
|
6
|
+
|
|
7
|
+
const DeviceItem = memo(({ icon, name }) => {
|
|
8
|
+
return (
|
|
9
|
+
<View style={styles.container}>
|
|
10
|
+
{!!icon && <FImage source={{ uri: icon }} style={styles.iconSensor} />}
|
|
11
|
+
<Text style={styles.textItem}>{name}</Text>
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default DeviceItem;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Constants, Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 5;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 60;
|
|
8
|
+
|
|
9
|
+
export default StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
paddingHorizontal: 15,
|
|
12
|
+
borderRadius: 10,
|
|
13
|
+
width: 250,
|
|
14
|
+
height: heightItem,
|
|
15
|
+
borderWidth: 1,
|
|
16
|
+
borderColor: Colors.Gray4,
|
|
17
|
+
backgroundColor: Colors.White,
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginBottom: 16,
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
shadowColor: Colors.Shadow,
|
|
23
|
+
shadowOffset: {
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 2,
|
|
26
|
+
},
|
|
27
|
+
shadowOpacity: 0.1,
|
|
28
|
+
shadowRadius: 3,
|
|
29
|
+
elevation: 6,
|
|
30
|
+
paddingLeft: 30,
|
|
31
|
+
paddingRight: 30,
|
|
32
|
+
},
|
|
33
|
+
iconSensor: {
|
|
34
|
+
width: 32,
|
|
35
|
+
height: 32,
|
|
36
|
+
resizeMode: 'contain',
|
|
37
|
+
},
|
|
38
|
+
textItem: {
|
|
39
|
+
marginLeft: 15,
|
|
40
|
+
fontSize: 16,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import ConnectingProcess from '../index';
|
|
4
|
+
import { SafeAreaView } from 'react-native';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = (route) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ConnectingProcess route={route} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
describe('Test ConnectingProcess', () => {
|
|
14
|
+
let tree;
|
|
15
|
+
test('create ConnectingProcess', () => {
|
|
16
|
+
const scan_sensor_data = { imei: 'SENSOR-afasdfas' };
|
|
17
|
+
const gateway = { id: 1, name: 'gateway' };
|
|
18
|
+
const station = { id: 1, icon_kit: 'a', name: 'station' };
|
|
19
|
+
const route = { params: { scan_sensor_data, gateway, station } };
|
|
20
|
+
act(() => {
|
|
21
|
+
tree = renderer.create(wrapComponent(route));
|
|
22
|
+
});
|
|
23
|
+
const instance = tree.root;
|
|
24
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
25
|
+
expect(safeAreaView).toHaveLength(1);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import DeviceItem from '../DeviceItem/DeviceItem';
|
|
4
|
+
import FImage from '../../FImage';
|
|
5
|
+
import Text from '../../Text';
|
|
6
|
+
describe('Test DeviceItem button', () => {
|
|
7
|
+
let tree;
|
|
8
|
+
test('create DeviceItem button', () => {
|
|
9
|
+
act(() => {
|
|
10
|
+
tree = renderer.create(<DeviceItem />);
|
|
11
|
+
});
|
|
12
|
+
const instance = tree.root;
|
|
13
|
+
const image = instance.findAllByType(FImage);
|
|
14
|
+
const text = instance.findAllByType(Text);
|
|
15
|
+
expect(image).toHaveLength(0);
|
|
16
|
+
expect(text).toHaveLength(1);
|
|
17
|
+
});
|
|
18
|
+
});
|