@eohjsc/react-native-smart-city 0.2.57 → 0.2.61
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/Map/MarkerGeolocation.svg +4 -0
- package/package.json +4 -23
- package/src/Images/Common/buttonLeftCurtain.png +0 -0
- package/src/Images/Common/buttonPause-center-curtain.png +0 -0
- package/src/Images/Common/buttonRightCurtain.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +139 -0
- package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +58 -0
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +72 -0
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/Auth/__test__/AccountList.test.js +33 -0
- package/src/commons/CameraDevice/index.js +2 -0
- package/src/commons/CardShadow/index.js +1 -1
- package/src/commons/CardShadow/styles.js +1 -3
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +1 -1
- package/src/commons/Device/HistoryChart.js +78 -80
- package/src/commons/Device/HorizontalBarChart.js +46 -30
- package/src/commons/Device/LinearChart.js +0 -34
- package/src/commons/Form/CurrencyInput.js +7 -1
- package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +48 -0
- package/src/commons/FourButtonFilterHistory/index.js +72 -0
- package/src/commons/FourButtonFilterHistory/styles.js +22 -0
- package/src/commons/ImagePicker/index.js +27 -33
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +14 -0
- package/src/commons/MediaPlayerDetail/index.js +204 -161
- package/src/commons/SearchLocation/index.js +0 -1
- package/src/commons/Sharing/RowMember.js +4 -2
- package/src/commons/Sharing/__test__/RowMember.test.js +42 -0
- package/src/commons/SubUnit/ShortDetail.js +12 -6
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -1
- package/src/commons/UnitSummary/AirQuality/index.js +9 -7
- package/src/commons/UnitSummary/ConfigHistoryChart.js +2 -1
- package/src/configs/API.js +13 -3
- package/src/configs/Constants.js +12 -2
- package/src/configs/Images.js +3 -0
- package/src/configs/SCConfig.js +8 -0
- package/src/context/actionType.ts +5 -0
- package/src/context/mockStore.ts +3 -0
- package/src/context/reducer.ts +14 -0
- package/src/iot/RemoteControl/Bluetooth.js +14 -0
- package/src/iot/RemoteControl/GoogleHome.js +1 -1
- package/src/iot/RemoteControl/index.js +0 -1
- package/src/navigations/UnitStack.js +42 -4
- package/src/screens/ActivityLog/FilterPopup.js +1 -1
- package/src/screens/ActivityLog/ItemLog.js +3 -3
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +5 -2
- package/src/screens/ActivityLog/hooks/index.js +1 -0
- package/src/screens/ActivityLog/index.js +0 -1
- package/src/screens/AddCommon/SelectSubUnit.js +23 -1
- package/src/screens/AddCommon/SelectUnit.js +12 -0
- package/src/screens/AddLocationMaps/index.js +139 -44
- package/src/screens/AddLocationMaps/indexStyle.js +14 -12
- package/src/screens/AddNewAction/SelectAction.js +1 -0
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
- package/src/screens/Automate/__test__/index.test.js +2 -0
- package/src/screens/Automate/index.js +4 -2
- package/src/screens/Device/__test__/detail.test.js +3 -7
- package/src/screens/Device/components/SensorDisplayItem.js +10 -10
- package/src/screens/Device/detail.js +65 -15
- package/src/screens/Device/hooks/useDisconnectedDevice.js +32 -26
- package/src/screens/Device/styles.js +3 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +59 -0
- package/src/screens/EmergencySetting/__test__/index.test.js +27 -0
- package/src/screens/EmergencySetting/components/DropDownItem.js +54 -0
- package/src/screens/EmergencySetting/index.js +90 -0
- package/src/screens/EmergencySetting/styles/DropDownItem.js +38 -0
- package/src/screens/EmergencySetting/styles.js +19 -0
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +126 -0
- package/src/screens/MoveToAnotherSubUnit/index.js +88 -0
- package/src/screens/MoveToAnotherSubUnit/styles/MoveToAnotherSubUnitStyles.js +50 -0
- package/src/screens/Notification/__test__/Notification.test.js +3 -3
- package/src/screens/Notification/components/NotificationItem.js +3 -6
- package/src/screens/Notification/index.js +2 -2
- package/src/screens/ScriptDetail/Styles/indexStyles.js +0 -1
- package/src/screens/ScriptDetail/__test__/index.test.js +13 -0
- package/src/screens/ScriptDetail/index.js +20 -17
- package/src/screens/SelectUnit/index.js +2 -0
- package/src/screens/Sharing/MemberList.js +2 -9
- package/src/screens/SubUnit/AddSubUnit.js +7 -6
- package/src/screens/SubUnit/AddSubUnitStyles.js +0 -2
- package/src/screens/SubUnit/EditSubUnit.js +8 -6
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +4 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +2 -2
- package/src/screens/TDSGuide/index.js +6 -4
- package/src/screens/Unit/ChooseLocation.js +96 -0
- package/src/screens/Unit/ChooseLocationStyles.js +26 -0
- package/src/screens/Unit/Detail.js +8 -2
- package/src/screens/Unit/ManageUnit.js +12 -15
- package/src/screens/Unit/SelectAddress.js +240 -0
- package/src/screens/Unit/SelectAddressStyles.js +48 -0
- package/src/screens/Unit/__test__/ChooseLocation.test.js +112 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +216 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +21 -5
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +56 -58
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +25 -21
- package/src/screens/UnitSummary/components/Temperature/index.js +15 -14
- package/src/screens/UnitSummary/components/UvIndex/index.js +6 -5
- package/src/screens/UnitSummary/components/WaterQuality/index.js +9 -7
- package/src/screens/UnitSummary/index.js +11 -7
- package/src/screens/WaterQualityGuide/index.js +1 -0
- package/src/utils/Apis/axios.js +21 -9
- package/src/utils/I18n/translations/en.json +15 -4
- package/src/utils/I18n/translations/vi.json +18 -6
- package/src/utils/Route/index.js +4 -1
- package/src/utils/Utils.js +22 -2
- package/assets/images/AddLocationMaps/PinLocation.svg +0 -3
- package/assets/images/AddLocationMaps/Point.svg +0 -3
- package/src/commons/ThreeButtonHistory/CalendarHeader.js +0 -35
- package/src/commons/ThreeButtonHistory/CalendarHeaderStyles.js +0 -17
- package/src/commons/ThreeButtonHistory/SelectMonth.js +0 -53
- package/src/commons/ThreeButtonHistory/SelectMonthStyles.js +0 -29
- package/src/commons/ThreeButtonHistory/__test__/SelectMonth.test.js +0 -37
- package/src/commons/ThreeButtonHistory/__test__/ThreeButtonHistory.test.js +0 -240
- package/src/commons/ThreeButtonHistory/index.js +0 -310
- package/src/commons/ThreeButtonHistory/styles.js +0 -65
- package/src/screens/Unit/ManageUnit/index.js +0 -286
- package/src/screens/Unit/SelectLocation.js +0 -161
- package/src/screens/Unit/SelectLocationStyles.js +0 -114
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="39" viewBox="0 0 24 39" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M12 8.21875C11.0656 8.21875 10.1875 8.58125 9.525 9.24375C9.19945 9.56837 8.94129 9.95415 8.76538 10.3789C8.58947 10.8037 8.49928 11.259 8.5 11.7188C8.5 12.6531 8.86562 13.5312 9.525 14.1938C9.84962 14.5193 10.2354 14.7775 10.6602 14.9534C11.0849 15.1293 11.5403 15.2195 12 15.2188C12.9344 15.2188 13.8125 14.8531 14.475 14.1938C15.1375 13.5312 15.5 12.6531 15.5 11.7188C15.5 10.7844 15.1375 9.90625 14.475 9.24375C13.8125 8.58125 12.9344 8.21875 12 8.21875ZM22.7062 7.03438C22.1179 5.67775 21.2697 4.44944 20.2094 3.41875C19.1456 2.37875 17.8915 1.55331 16.5156 0.9875C15.0844 0.39375 13.5656 0.09375 12 0.09375C10.4344 0.09375 8.91562 0.39375 7.48438 0.984375C6.1 1.55625 4.85938 2.375 3.79063 3.41563C2.73101 4.44689 1.88286 5.67506 1.29375 7.03125C0.684375 8.4375 0.375 9.93125 0.375 11.4688C0.375 13.675 0.903125 15.8719 1.94063 17.9906C2.775 19.6938 3.94063 21.3531 5.40938 22.9312C7.91875 25.625 10.55 27.2719 11.2969 27.7125C11.5089 27.8377 11.7507 27.9036 11.9969 27.9031C12.2406 27.9031 12.4812 27.8406 12.6969 27.7125C13.4437 27.2719 16.075 25.625 18.5844 22.9312C20.0531 21.3562 21.2188 19.6938 22.0531 17.9906C23.0969 15.875 23.625 13.6812 23.625 11.4719C23.625 9.93437 23.3156 8.44063 22.7062 7.03438ZM12 17.2188C8.9625 17.2188 6.5 14.7563 6.5 11.7188C6.5 8.68125 8.9625 6.21875 12 6.21875C15.0375 6.21875 17.5 8.68125 17.5 11.7188C17.5 14.7563 15.0375 17.2188 12 17.2188Z" fill="#1890FF"/>
|
|
3
|
+
<path d="M16.6666 30.2735L15.7266 29.3335L12 33.0602L8.27331 29.3335L7.33331 30.2735L11.06 34.0002L7.33331 37.7268L8.27331 38.6668L12 34.9402L15.7266 38.6668L16.6666 37.7268L12.94 34.0002L16.6666 30.2735Z" fill="#262626"/>
|
|
4
|
+
</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.61",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -43,11 +43,7 @@
|
|
|
43
43
|
"pods": "cd example && pod-install --quiet",
|
|
44
44
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
45
45
|
"build": "sync-files ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
46
|
-
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src"
|
|
47
|
-
"test:code-formatter": "prettier src/**/**/*.js --write",
|
|
48
|
-
"test:code-formatter-step-1": "prettier --check src/**/*.js",
|
|
49
|
-
"test:code-formatter-step-2": "prettier --check src/**/**/*.js",
|
|
50
|
-
"test:code-formatter-step-3": "prettier --check src/**/**/**/*.js"
|
|
46
|
+
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src"
|
|
51
47
|
},
|
|
52
48
|
"repository": {
|
|
53
49
|
"type": "git",
|
|
@@ -85,7 +81,6 @@
|
|
|
85
81
|
"eslint-plugin-react": "^7.21.5",
|
|
86
82
|
"eslint-plugin-react-native": "^3.10.0",
|
|
87
83
|
"factory-girl": "^5.0.4",
|
|
88
|
-
"husky": "^2.7.0",
|
|
89
84
|
"jest": "^26.6.3",
|
|
90
85
|
"jest-circus": "^26.6.3",
|
|
91
86
|
"jetifier": "^1.6.6",
|
|
@@ -146,6 +141,7 @@
|
|
|
146
141
|
"react-hooks-global-state": "^1.0.1",
|
|
147
142
|
"react-i18next": "^11.8.12",
|
|
148
143
|
"react-native-alert-async": "^1.0.5",
|
|
144
|
+
"react-native-android-wifi": "^0.0.41",
|
|
149
145
|
"react-native-appearance": "^0.3.4",
|
|
150
146
|
"react-native-base64": "^0.1.0",
|
|
151
147
|
"react-native-ble-plx": "^2.0.1",
|
|
@@ -161,7 +157,7 @@
|
|
|
161
157
|
"react-native-geocoder": "^0.5.0",
|
|
162
158
|
"react-native-gesture-handler": "^1.7.0",
|
|
163
159
|
"react-native-get-location": "^2.0.0",
|
|
164
|
-
"react-native-image-picker": "^
|
|
160
|
+
"react-native-image-crop-picker": "^0.37.2",
|
|
165
161
|
"react-native-image-resizer": "^1.4.5",
|
|
166
162
|
"react-native-input-credit-card": "^0.5.5",
|
|
167
163
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
@@ -206,21 +202,6 @@
|
|
|
206
202
|
"validator": "^13.1.1",
|
|
207
203
|
"victory-native": "^35.0.1"
|
|
208
204
|
},
|
|
209
|
-
"husky": {
|
|
210
|
-
"hooks": {
|
|
211
|
-
"pre-commit": "lint-staged",
|
|
212
|
-
"pre-push": "yarn jest"
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
"lint-staged": {
|
|
216
|
-
"*.{js, ts}": [
|
|
217
|
-
"yarn lint",
|
|
218
|
-
"yarn test:code-formatter",
|
|
219
|
-
"yarn test:code-formatter-step-1",
|
|
220
|
-
"yarn test:code-formatter-step-2",
|
|
221
|
-
"yarn test:code-formatter-step-3"
|
|
222
|
-
]
|
|
223
|
-
},
|
|
224
205
|
"bugs": {
|
|
225
206
|
"url": "https://github.com/github_account/react-native-smart-city/issues"
|
|
226
207
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { TouchableOpacity, View, Switch, Image } from 'react-native';
|
|
3
|
+
import { Icon } from '@ant-design/react-native';
|
|
4
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
|
+
import styles from './CurtainButtonTemplateStyle';
|
|
6
|
+
import Text from '../Text';
|
|
7
|
+
import { TESTID } from '../../configs/Constants';
|
|
8
|
+
import { Colors, Images } from '../../configs';
|
|
9
|
+
import { Section } from '../../commons/Section';
|
|
10
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
11
|
+
|
|
12
|
+
const CurtainButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
13
|
+
const t = useTranslations();
|
|
14
|
+
const { configuration } = actionGroup;
|
|
15
|
+
const [lock, setLock] = useState(false);
|
|
16
|
+
|
|
17
|
+
const onButtonOpenPress = useCallback(
|
|
18
|
+
() => doAction(configuration.open_action_data),
|
|
19
|
+
[configuration.open_action_data, doAction]
|
|
20
|
+
);
|
|
21
|
+
const onButtonStopPress = useCallback(
|
|
22
|
+
() => doAction(configuration.stop_action_data),
|
|
23
|
+
[configuration.stop_action_data, doAction]
|
|
24
|
+
);
|
|
25
|
+
const onButtonClosePress = useCallback(
|
|
26
|
+
() => doAction(configuration.close_action_data),
|
|
27
|
+
[configuration.close_action_data, doAction]
|
|
28
|
+
);
|
|
29
|
+
const onChangeSwitch = useCallback(() => {
|
|
30
|
+
if (lock) {
|
|
31
|
+
setLock(false);
|
|
32
|
+
doAction(configuration.action_off_data);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
doAction(configuration.action_on_data);
|
|
36
|
+
setLock(true);
|
|
37
|
+
}, [
|
|
38
|
+
configuration.action_off_data,
|
|
39
|
+
configuration.action_on_data,
|
|
40
|
+
doAction,
|
|
41
|
+
lock,
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const RenderThreeButtonActions = () => {
|
|
45
|
+
const buttons = [
|
|
46
|
+
{
|
|
47
|
+
style: styles.buttonActionCurtain,
|
|
48
|
+
icon: Images.buttonLeftCurtain,
|
|
49
|
+
text: configuration.text1,
|
|
50
|
+
onPress: onButtonOpenPress,
|
|
51
|
+
testID: TESTID.BUTTON_TEMPLATE_1,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
style: styles.buttonActionCurtainCenter,
|
|
55
|
+
icon: Images.buttonPauseCurtain,
|
|
56
|
+
text: configuration.text2,
|
|
57
|
+
onPress: onButtonStopPress,
|
|
58
|
+
testID: TESTID.BUTTON_TEMPLATE_2,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
style: styles.buttonActionCurtain,
|
|
62
|
+
icon: Images.buttonRightCurtain,
|
|
63
|
+
text: configuration.text3,
|
|
64
|
+
onPress: onButtonClosePress,
|
|
65
|
+
testID: TESTID.BUTTON_TEMPLATE_3,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
{buttons.map((item, index) => (
|
|
72
|
+
<TouchableOpacity
|
|
73
|
+
testID={item.testID}
|
|
74
|
+
style={item.style}
|
|
75
|
+
onPress={item.onPress}
|
|
76
|
+
underlayColor={Colors.Gray2}
|
|
77
|
+
>
|
|
78
|
+
<Image source={item.icon} />
|
|
79
|
+
</TouchableOpacity>
|
|
80
|
+
))}
|
|
81
|
+
</>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
const itemLock = (icon, color) => {
|
|
85
|
+
return (
|
|
86
|
+
<>
|
|
87
|
+
<View style={styles.lockDoor}>
|
|
88
|
+
<Icon name={icon} size={15} color={color} style={styles.iconLock} />
|
|
89
|
+
<Text
|
|
90
|
+
style={styles.textLockDoor}
|
|
91
|
+
testID={TESTID.TEXT_DOOR_LOOK_ON_OFF}
|
|
92
|
+
>
|
|
93
|
+
{configuration.text_door_lock}{' '}
|
|
94
|
+
</Text>
|
|
95
|
+
</View>
|
|
96
|
+
<Switch
|
|
97
|
+
trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
|
|
98
|
+
thumbColor={Colors.White}
|
|
99
|
+
ios_backgroundColor={Colors.Gray4}
|
|
100
|
+
onValueChange={onChangeSwitch}
|
|
101
|
+
value={lock}
|
|
102
|
+
/>
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
return (
|
|
107
|
+
<>
|
|
108
|
+
<View style={styles.wrap}>
|
|
109
|
+
<RenderThreeButtonActions />
|
|
110
|
+
</View>
|
|
111
|
+
<View style={styles.lockSwitch}>
|
|
112
|
+
{configuration.is_display_lock &&
|
|
113
|
+
itemLock(
|
|
114
|
+
lock ? 'lock' : 'unlock',
|
|
115
|
+
lock ? Colors.Primary : Colors.Gray6
|
|
116
|
+
)}
|
|
117
|
+
</View>
|
|
118
|
+
<Section style={styles.section}>
|
|
119
|
+
<View style={styles.reminderOption}>
|
|
120
|
+
<Text type="H4" color={Colors.Gray8}>
|
|
121
|
+
{t('schedule')}
|
|
122
|
+
</Text>
|
|
123
|
+
<TouchableOpacity>
|
|
124
|
+
<IconOutline name="plus" size={20} />
|
|
125
|
+
</TouchableOpacity>
|
|
126
|
+
</View>
|
|
127
|
+
<View>
|
|
128
|
+
<TouchableOpacity style={styles.tapToAddSchedule}>
|
|
129
|
+
<Text type="Body" color={Colors.Gray6} center>
|
|
130
|
+
{t('tap_to_add_new_schedule')}
|
|
131
|
+
</Text>
|
|
132
|
+
</TouchableOpacity>
|
|
133
|
+
</View>
|
|
134
|
+
</Section>
|
|
135
|
+
</>
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export default CurtainButtonTemplate;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
wrap: {
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
justifyContent: 'space-around',
|
|
7
|
+
paddingVertical: 30,
|
|
8
|
+
},
|
|
9
|
+
text: {
|
|
10
|
+
fontSize: 14,
|
|
11
|
+
lineHeight: 22,
|
|
12
|
+
},
|
|
13
|
+
lockSwitch: {
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
marginBottom: 7,
|
|
17
|
+
},
|
|
18
|
+
iconLock: {
|
|
19
|
+
paddingBottom: 7,
|
|
20
|
+
},
|
|
21
|
+
textLockDoor: {
|
|
22
|
+
paddingLeft: 12,
|
|
23
|
+
height: 24,
|
|
24
|
+
fontSize: 16,
|
|
25
|
+
lineHeight: 24,
|
|
26
|
+
},
|
|
27
|
+
lockDoor: {
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
alignItems: 'flex-end',
|
|
30
|
+
paddingLeft: 5,
|
|
31
|
+
},
|
|
32
|
+
section: {
|
|
33
|
+
marginHorizontal: 20,
|
|
34
|
+
borderRadius: 10,
|
|
35
|
+
},
|
|
36
|
+
reminderOption: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
justifyContent: 'space-between',
|
|
40
|
+
},
|
|
41
|
+
tapToAddSchedule: {
|
|
42
|
+
paddingVertical: 50,
|
|
43
|
+
},
|
|
44
|
+
buttonActionCurtain: {
|
|
45
|
+
flex: 1,
|
|
46
|
+
aspectRatio: 1,
|
|
47
|
+
marginHorizontal: 4,
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
},
|
|
51
|
+
buttonActionCurtainCenter: {
|
|
52
|
+
flex: 1,
|
|
53
|
+
aspectRatio: 1,
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
marginTop: 15,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { TouchableOpacity } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import CurtainButtonTemplate from '../CurtainButtonTemplate';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (actionGroup) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<CurtainButtonTemplate actionGroup={actionGroup} doAction={jest.fn()} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
describe('Test CurtainButtonTemplate', () => {
|
|
16
|
+
const actionGroup = {
|
|
17
|
+
configuration: {
|
|
18
|
+
action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
19
|
+
action1_data: {
|
|
20
|
+
color: '#00979D',
|
|
21
|
+
command_prefer_over_bluetooth: true,
|
|
22
|
+
command_prefer_over_googlehome: false,
|
|
23
|
+
command_prefer_over_internet: false,
|
|
24
|
+
googlehome_actions: [],
|
|
25
|
+
icon: 'caret-up',
|
|
26
|
+
id: 9,
|
|
27
|
+
key: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
28
|
+
},
|
|
29
|
+
action2: '38347d5e-4418-4ab0-978c-c82f4c034897',
|
|
30
|
+
action2_data: {
|
|
31
|
+
color: '#00979D',
|
|
32
|
+
command_prefer_over_bluetooth: true,
|
|
33
|
+
command_prefer_over_googlehome: false,
|
|
34
|
+
command_prefer_over_internet: false,
|
|
35
|
+
googlehome_actions: [],
|
|
36
|
+
icon: 'stop',
|
|
37
|
+
id: 11,
|
|
38
|
+
key: '38347d5e-4418-4ab0-978c-c82f4c034897',
|
|
39
|
+
},
|
|
40
|
+
action3: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
|
|
41
|
+
action3_data: {
|
|
42
|
+
color: '#00979D',
|
|
43
|
+
command_prefer_over_bluetooth: true,
|
|
44
|
+
command_prefer_over_googlehome: false,
|
|
45
|
+
command_prefer_over_internet: false,
|
|
46
|
+
googlehome_actions: [],
|
|
47
|
+
icon: 'caret-down',
|
|
48
|
+
id: 10,
|
|
49
|
+
key: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
|
|
50
|
+
},
|
|
51
|
+
icon1: 'caret-up',
|
|
52
|
+
icon2: 'stop',
|
|
53
|
+
icon3: 'caret-down',
|
|
54
|
+
text1: 'UP',
|
|
55
|
+
text2: 'STOP/UNLOCK',
|
|
56
|
+
text3: 'DOWN',
|
|
57
|
+
id: 1,
|
|
58
|
+
template: 'curtain_button_action_template',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
let wrapper;
|
|
63
|
+
|
|
64
|
+
test('render CurtainButtonTemplate', async () => {
|
|
65
|
+
await act(() => {
|
|
66
|
+
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
67
|
+
});
|
|
68
|
+
const instance = wrapper.root;
|
|
69
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
70
|
+
expect(touchableOpacities.length).toEqual(5);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -8,6 +8,7 @@ import NumberUpDownActionTemplate from './NumberUpDownActionTemplate';
|
|
|
8
8
|
import OptionsDropdownActionTemplate from './OptionsDropdownActionTemplate';
|
|
9
9
|
import OnOffTemplate from './OnOffTemplate';
|
|
10
10
|
import TimerActionTemplate from './TimerActionTemplate';
|
|
11
|
+
import CurtainButtonTemplate from './CurtainButtonTemplate';
|
|
11
12
|
|
|
12
13
|
export const getActionComponent = (template) => {
|
|
13
14
|
switch (template) {
|
|
@@ -29,6 +30,8 @@ export const getActionComponent = (template) => {
|
|
|
29
30
|
return OptionsDropdownActionTemplate;
|
|
30
31
|
case 'TimerActionTemplate':
|
|
31
32
|
return TimerActionTemplate;
|
|
33
|
+
case 'curtain_action_template':
|
|
34
|
+
return CurtainButtonTemplate;
|
|
32
35
|
default:
|
|
33
36
|
return null;
|
|
34
37
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import AccountList from '../AccountList';
|
|
5
|
+
|
|
6
|
+
describe('Test AccountList', () => {
|
|
7
|
+
let tree;
|
|
8
|
+
const accounts = [
|
|
9
|
+
{
|
|
10
|
+
id: 1,
|
|
11
|
+
name: 'test',
|
|
12
|
+
phone_number: 123456677,
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
it('test render has data', async () => {
|
|
17
|
+
await act(() => {
|
|
18
|
+
tree = create(<AccountList accounts={accounts} />);
|
|
19
|
+
});
|
|
20
|
+
const instance = tree.root;
|
|
21
|
+
const scrollViews = instance.findAllByType(ScrollView);
|
|
22
|
+
expect(scrollViews).toHaveLength(1);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('test render has no data', async () => {
|
|
26
|
+
await act(() => {
|
|
27
|
+
tree = create(<AccountList accounts={[]} />);
|
|
28
|
+
});
|
|
29
|
+
const instance = tree.root;
|
|
30
|
+
const scrollViews = instance.findAllByType(ScrollView);
|
|
31
|
+
expect(scrollViews).toHaveLength(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -59,6 +59,8 @@ const CameraDevice = ({ station, handleFullScreen, goToPlayBack }) => {
|
|
|
59
59
|
cameraName={device.configuration.name}
|
|
60
60
|
handleFullScreen={handleFullScreen}
|
|
61
61
|
goToPlayBack={goToPlayBack(device, { uri: station?.background })}
|
|
62
|
+
width={standardizeWidth}
|
|
63
|
+
height={standardizeHeight}
|
|
62
64
|
/>
|
|
63
65
|
</View>
|
|
64
66
|
))}
|
|
@@ -3,11 +3,9 @@ import { StyleSheet } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
card: {
|
|
6
|
-
|
|
7
|
-
marginBottom: 14,
|
|
6
|
+
marginVertical: 14,
|
|
8
7
|
marginHorizontal: 16,
|
|
9
8
|
padding: 16,
|
|
10
|
-
flexDirection: 'column',
|
|
11
9
|
backgroundColor: Colors.White,
|
|
12
10
|
borderRadius: 10,
|
|
13
11
|
shadowColor: Colors.Shadow,
|
|
@@ -7,7 +7,7 @@ import Text from '../Text';
|
|
|
7
7
|
import { Colors } from '../../configs';
|
|
8
8
|
|
|
9
9
|
const DateTimeButton = memo(({ onPress, time, date, formatType, style }) => {
|
|
10
|
-
let format = 'DD.MM.YY
|
|
10
|
+
let format = 'DD.MM.YY HH:mm';
|
|
11
11
|
if (formatType === 'date') {
|
|
12
12
|
format = 'DD.MM.YY';
|
|
13
13
|
}
|
|
@@ -11,7 +11,7 @@ import DateTimeRangeChange from '../DateTimeRangeChange';
|
|
|
11
11
|
import HorizontalBarChart from './HorizontalBarChart';
|
|
12
12
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
13
13
|
import LinearChart from './LinearChart';
|
|
14
|
-
import
|
|
14
|
+
import FourButtonFilterHistory from '../FourButtonFilterHistory';
|
|
15
15
|
import { formatMoney } from '../../utils/Utils';
|
|
16
16
|
|
|
17
17
|
export const dateTimeType = {
|
|
@@ -33,98 +33,102 @@ const HistoryChart = memo(
|
|
|
33
33
|
endDate,
|
|
34
34
|
setEndDate,
|
|
35
35
|
setStartDate,
|
|
36
|
+
groupBy,
|
|
36
37
|
setGroupBy,
|
|
37
38
|
configuration,
|
|
38
39
|
}) => {
|
|
39
40
|
const t = useTranslations();
|
|
40
|
-
const dateNow = moment().valueOf();
|
|
41
41
|
const [chartOptions, setChartOptions] = useState({
|
|
42
42
|
index: -1,
|
|
43
43
|
showAll: true,
|
|
44
44
|
});
|
|
45
45
|
const [eventPicker, setEventPicker] = useState({
|
|
46
|
-
currentChangeTime: '',
|
|
47
46
|
showModalEnd: false,
|
|
48
47
|
showModalStart: false,
|
|
49
48
|
startTime: startDate ? startDate : moment().subtract(1, 'day').valueOf(),
|
|
50
|
-
endTime:
|
|
49
|
+
endTime: endDate ? endDate : moment().valueOf(),
|
|
51
50
|
});
|
|
52
51
|
const [price, setPrice] = useState(null);
|
|
53
52
|
|
|
54
53
|
const onStart = useCallback(() => {
|
|
55
|
-
setEventPicker({
|
|
56
|
-
...
|
|
57
|
-
currentChangeTime: 'start',
|
|
54
|
+
setEventPicker((state) => ({
|
|
55
|
+
...state,
|
|
58
56
|
showModalStart: true,
|
|
59
57
|
showModalEnd: false,
|
|
60
|
-
});
|
|
61
|
-
}, [
|
|
58
|
+
}));
|
|
59
|
+
}, []);
|
|
62
60
|
const onEnd = useCallback(() => {
|
|
63
|
-
setEventPicker({
|
|
64
|
-
...
|
|
65
|
-
currentChangeTime: 'end',
|
|
66
|
-
show: true,
|
|
61
|
+
setEventPicker((state) => ({
|
|
62
|
+
...state,
|
|
67
63
|
showModalStart: false,
|
|
68
64
|
showModalEnd: true,
|
|
69
|
-
});
|
|
70
|
-
}, [
|
|
71
|
-
const onConfirmStart = (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
}));
|
|
66
|
+
}, []);
|
|
67
|
+
const onConfirmStart = useCallback(
|
|
68
|
+
(date) => {
|
|
69
|
+
setEventPicker((state) => {
|
|
70
|
+
if (typeof date === 'number') {
|
|
71
|
+
onCancel();
|
|
72
|
+
return state;
|
|
73
|
+
}
|
|
74
|
+
if (moment(date).valueOf() < state.endTime) {
|
|
75
|
+
setStartDate(moment(date).valueOf());
|
|
76
|
+
return {
|
|
77
|
+
...state,
|
|
78
|
+
showModalStart: false,
|
|
79
|
+
startTime: moment(date).valueOf(),
|
|
80
|
+
};
|
|
81
|
+
} else {
|
|
82
|
+
setStartDate(moment(date).valueOf());
|
|
83
|
+
setEndDate(moment(date).add(1, 'day').valueOf());
|
|
84
|
+
return {
|
|
85
|
+
...state,
|
|
86
|
+
showModalStart: false,
|
|
87
|
+
startTime: moment(date).valueOf(),
|
|
88
|
+
endTime: moment(date).add(1, 'day').valueOf(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
90
91
|
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
92
|
+
},
|
|
93
|
+
[onCancel, setStartDate, setEndDate]
|
|
94
|
+
);
|
|
95
95
|
|
|
96
|
-
const onConfirmEnd = (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
const onConfirmEnd = useCallback(
|
|
97
|
+
(date) => {
|
|
98
|
+
setEventPicker((state) => {
|
|
99
|
+
if (typeof date === 'number') {
|
|
100
|
+
onCancel();
|
|
101
|
+
return state;
|
|
102
|
+
}
|
|
103
|
+
if (moment(date).valueOf() > state.startTime) {
|
|
104
|
+
setEndDate(moment(date).valueOf());
|
|
105
|
+
return {
|
|
106
|
+
...state,
|
|
107
|
+
showModalEnd: false,
|
|
108
|
+
endTime: moment(date).valueOf(),
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
setStartDate(moment(date).add(-1, 'day').valueOf());
|
|
112
|
+
setEndDate(moment(date).valueOf());
|
|
113
|
+
return {
|
|
114
|
+
...state,
|
|
115
|
+
showModalEnd: false,
|
|
116
|
+
startTime: moment(date).add(-1, 'day').valueOf(),
|
|
117
|
+
endTime: moment(date).valueOf(),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
107
120
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
currentChangeTime: 'start',
|
|
112
|
-
showModalEnd: false,
|
|
113
|
-
endTime: moment(date).valueOf(),
|
|
114
|
-
startTime: moment(date).subtract(1, 'day').valueOf(),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
setEndDate(moment(date).valueOf());
|
|
118
|
-
};
|
|
121
|
+
},
|
|
122
|
+
[onCancel, setStartDate, setEndDate]
|
|
123
|
+
);
|
|
119
124
|
|
|
120
125
|
const onCancel = useCallback(() => {
|
|
121
|
-
setEventPicker({
|
|
122
|
-
...
|
|
123
|
-
currentChangeTime: '',
|
|
126
|
+
setEventPicker((state) => ({
|
|
127
|
+
...state,
|
|
124
128
|
showModalEnd: false,
|
|
125
129
|
showModalStart: false,
|
|
126
|
-
});
|
|
127
|
-
}, [
|
|
130
|
+
}));
|
|
131
|
+
}, []);
|
|
128
132
|
const onShowOneChart = useCallback(
|
|
129
133
|
(index) => {
|
|
130
134
|
if (index === chartOptions.index) {
|
|
@@ -179,25 +183,19 @@ const HistoryChart = memo(
|
|
|
179
183
|
{t('history')}
|
|
180
184
|
</Text>
|
|
181
185
|
{configuration.type === 'horizontal_bar_chart' && (
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
setEndDate={setEndDate}
|
|
186
|
+
<FourButtonFilterHistory
|
|
187
|
+
groupBy={groupBy}
|
|
185
188
|
setGroupBy={setGroupBy}
|
|
186
|
-
startDate={startDate}
|
|
187
|
-
endDate={endDate}
|
|
188
189
|
/>
|
|
189
190
|
)}
|
|
190
191
|
</View>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
formatType={formatType}
|
|
199
|
-
/>
|
|
200
|
-
)}
|
|
192
|
+
<DateTimeRangeChange
|
|
193
|
+
startTime={eventPicker.startTime}
|
|
194
|
+
onStart={onStart}
|
|
195
|
+
onEnd={onEnd}
|
|
196
|
+
endTime={eventPicker.endTime}
|
|
197
|
+
formatType={formatType}
|
|
198
|
+
/>
|
|
201
199
|
</View>
|
|
202
200
|
{configuration.config === 'power_consumption' && (
|
|
203
201
|
<View style={styles.wrapCalculateCost}>
|