@eohjsc/react-native-smart-city 0.2.45 → 0.2.49
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/README.md +9 -0
- package/index.js +6 -0
- package/package.json +23 -3
- package/src/Images/Common/logo.png +0 -0
- package/src/Images/Common/logo@2x.png +0 -0
- package/src/Images/Common/logo@3x.png +0 -0
- package/src/commons/ActionTemplate/index.js +40 -25
- package/src/commons/Automate/ItemAutomate.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +82 -0
- package/src/commons/Dashboard/MyPinnedSharedUnit/styles.js +78 -0
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +60 -0
- package/src/commons/Dashboard/MyUnit/index.js +111 -0
- package/src/commons/Dashboard/MyUnit/styles.js +61 -0
- package/src/commons/Device/ConnectedViewHeader.js +4 -1
- package/src/commons/Form/TextInput.js +1 -1
- package/src/commons/MediaPlayer/index.js +6 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +3 -3
- package/src/{screens/Unit/components → commons}/SearchLocation/RowLocation.js +2 -2
- package/src/{screens/Unit/components → commons}/SearchLocation/RowLocationStyles.js +1 -1
- package/src/{screens/Unit/components → commons}/SearchLocation/SearchBarLocationStyles.js +1 -1
- package/src/{screens/Unit/components → commons}/SearchLocation/__test__/RowLocation.test.js +2 -2
- package/src/{screens/Unit/components → commons}/SearchLocation/index.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -0
- package/src/commons/SubUnit/ShortDetail.js +1 -1
- package/src/commons/Unit/SharedUnit.js +2 -2
- package/src/configs/API.js +11 -4
- package/src/configs/Constants.js +19 -6
- package/src/configs/Images.js +1 -0
- package/src/iot/RemoteControl/Bluetooth.js +10 -1
- package/src/iot/RemoteControl/Internet.js +0 -2
- package/src/navigations/AddDeviceStack.js +5 -0
- package/src/navigations/AddUnitStack.js +2 -0
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/ActivityLog/FilterPopup.js +24 -17
- package/src/screens/ActivityLog/ItemLog.js +26 -22
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +1 -0
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +0 -20
- package/src/screens/ActivityLog/__test__/index.test.js +3 -0
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +8 -0
- package/src/screens/ActivityLog/hooks/index.js +5 -9
- package/src/screens/ActivityLog/index.js +4 -4
- package/src/screens/ActivityLog/styles/filterPopupStyles.js +3 -0
- package/src/screens/AddCommon/SelectSubUnit.js +10 -1
- package/src/screens/AddCommon/SelectUnit.js +11 -0
- package/src/screens/AddLocationMaps/index.js +124 -74
- package/src/screens/AddLocationMaps/indexStyle.js +58 -0
- package/src/screens/AddNewAction/SelectAction.js +59 -4
- package/src/screens/AddNewAction/SelectSensorDevices.js +27 -5
- package/src/screens/AddNewAction/SetupSensor.js +1 -6
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +6 -4
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -1
- package/src/screens/AddNewAutoSmart/index.js +24 -13
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -0
- package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +10 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -1
- package/src/screens/AddNewOneTap/index.js +11 -6
- package/src/screens/Automate/MultiUnits.js +14 -53
- package/src/screens/Automate/__test__/MultiUnits.test.js +5 -246
- package/src/screens/Automate/__test__/index.test.js +1 -0
- package/src/screens/Automate/index.js +1 -0
- package/src/screens/Device/__test__/detail.test.js +14 -0
- package/src/screens/Device/components/DetailHistoryChart.js +63 -0
- package/src/screens/Device/components/EmergencyCountdown.js +29 -0
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +57 -0
- package/src/screens/Device/components/SensorDisplayItem.js +127 -0
- package/src/screens/Device/detail.js +81 -294
- package/src/screens/Device/hooks/useDisconnectedDevice.js +63 -0
- package/src/screens/Device/styles.js +0 -10
- package/src/screens/GuestInfo/components/RecurringDetail.js +2 -2
- package/src/screens/Notification/components/NotificationItem.js +31 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +5 -0
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +12 -3
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +11 -2
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +12 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +83 -3
- package/src/screens/ScriptDetail/hooks/index.js +4 -0
- package/src/screens/ScriptDetail/index.js +65 -4
- package/src/screens/SetSchedule/__test__/SelectWeekday.test.js +2 -2
- package/src/screens/SetSchedule/__test__/index.test.js +8 -0
- package/src/screens/SetSchedule/components/SelectWeekday.js +13 -7
- package/src/screens/SetSchedule/index.js +28 -6
- package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +38 -0
- package/src/screens/SubUnit/AddSubUnit.js +113 -29
- package/src/screens/SubUnit/AddSubUnitStyles.js +10 -0
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +1 -0
- package/src/screens/TDSGuide/index.js +15 -19
- package/src/screens/Unit/MoreMenu.js +6 -1
- package/src/screens/Unit/SelectLocation.js +2 -3
- package/src/screens/Unit/SmartAccount.js +141 -0
- package/src/screens/Unit/SmartAccountItem.js +51 -0
- package/src/screens/Unit/SmartAccountStyles.js +46 -0
- package/src/screens/Unit/__test__/SmartAccount.test.js +58 -0
- package/src/screens/Unit/hook/useStateAlertRemove.js +36 -0
- package/src/utils/I18n/translations/en.json +26 -2
- package/src/utils/I18n/translations/vi.json +38 -14
- package/src/utils/Route/index.js +4 -0
- package/src/utils/Validation.js +3 -1
package/README.md
CHANGED
|
@@ -24,6 +24,15 @@ import SmartCity, {
|
|
|
24
24
|
AddUnitStack,
|
|
25
25
|
SharedStack,
|
|
26
26
|
Explore,
|
|
27
|
+
SCProvider,
|
|
28
|
+
SCContext,
|
|
29
|
+
AddLGDeviceStack,
|
|
30
|
+
initSCConfig,
|
|
31
|
+
AutomateStack,
|
|
32
|
+
NotificationStack,
|
|
33
|
+
MyPinnedSharedUnit,
|
|
34
|
+
SharedUnit,
|
|
35
|
+
MyUnit,
|
|
27
36
|
} from '@eohjsc/react-native-smart-city';
|
|
28
37
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
29
38
|
|
package/index.js
CHANGED
|
@@ -12,6 +12,9 @@ import { AddLGDeviceStack } from './src/navigations/AddLGDeviceStack';
|
|
|
12
12
|
import { initSCConfig } from './src/configs';
|
|
13
13
|
import AutomateStack from './src/navigations/AutomateStack';
|
|
14
14
|
import NotificationStack from './src/navigations/NotificationStack';
|
|
15
|
+
import MyPinnedSharedUnit from './src/commons/Dashboard/MyPinnedSharedUnit';
|
|
16
|
+
import MyUnit from './src/commons/Dashboard/MyUnit';
|
|
17
|
+
import SharedUnit from './src/commons/Unit/SharedUnit';
|
|
15
18
|
|
|
16
19
|
export {
|
|
17
20
|
AddSubUnitStack,
|
|
@@ -29,4 +32,7 @@ export {
|
|
|
29
32
|
initSCConfig,
|
|
30
33
|
AutomateStack,
|
|
31
34
|
NotificationStack,
|
|
35
|
+
MyPinnedSharedUnit,
|
|
36
|
+
SharedUnit,
|
|
37
|
+
MyUnit,
|
|
32
38
|
};
|
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.49",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -39,12 +39,16 @@
|
|
|
39
39
|
"reset-cache": "react-native start --reset-cache",
|
|
40
40
|
"merge_conflict": "yarn jest && yarn update_coverage_result && yarn check_coverage_config",
|
|
41
41
|
"jest": "jest --detectOpenHandles",
|
|
42
|
-
"postinstall": "
|
|
42
|
+
"postinstall": "npx husky install",
|
|
43
43
|
"example": "yarn --cwd example",
|
|
44
44
|
"pods": "cd example && pod-install --quiet",
|
|
45
45
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
46
46
|
"build": "sync-files ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
47
|
-
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src"
|
|
47
|
+
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
48
|
+
"test:code-formatter": "prettier src/**/**/*.js --write",
|
|
49
|
+
"test:code-formatter-step-1": "prettier --check src/**/*.js",
|
|
50
|
+
"test:code-formatter-step-2": "prettier --check src/**/**/*.js",
|
|
51
|
+
"test:code-formatter-step-3": "prettier --check src/**/**/**/*.js"
|
|
48
52
|
},
|
|
49
53
|
"repository": {
|
|
50
54
|
"type": "git",
|
|
@@ -159,6 +163,7 @@
|
|
|
159
163
|
"react-native-gesture-handler": "^1.7.0",
|
|
160
164
|
"react-native-get-location": "^2.0.0",
|
|
161
165
|
"react-native-image-picker": "^3.1.4",
|
|
166
|
+
"react-native-image-resizer": "^1.4.5",
|
|
162
167
|
"react-native-input-credit-card": "^0.5.5",
|
|
163
168
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
164
169
|
"react-native-keyboard-aware-scroll-view": "^0.9.2",
|
|
@@ -201,6 +206,21 @@
|
|
|
201
206
|
"validator": "^13.1.1",
|
|
202
207
|
"victory-native": "^35.0.1"
|
|
203
208
|
},
|
|
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
|
+
},
|
|
204
224
|
"bugs": {
|
|
205
225
|
"url": "https://github.com/github_account/react-native-smart-city/issues"
|
|
206
226
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useState, useCallback } from 'react';
|
|
1
|
+
import React, { memo, useState, useCallback, useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
@@ -31,29 +31,44 @@ const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
31
31
|
[onSelectAction]
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
const renderAction =
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
const renderAction = useMemo(() => {
|
|
35
|
+
return data.map((item, index) => {
|
|
36
|
+
switch (item.template) {
|
|
37
|
+
case 'on_off_button_action_template':
|
|
38
|
+
return (
|
|
39
|
+
<OnOffButtonAction
|
|
40
|
+
{...item}
|
|
41
|
+
onPress={onPressSelectAction}
|
|
42
|
+
key={index}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
case 'one_button_action_template':
|
|
46
|
+
return (
|
|
47
|
+
<OneButtonAction
|
|
48
|
+
{...item}
|
|
49
|
+
onPress={onPressSelectAction}
|
|
50
|
+
key={index}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
case 'three_button_action_template':
|
|
54
|
+
return (
|
|
55
|
+
<ThreeButtonAction
|
|
56
|
+
{...item}
|
|
57
|
+
onPress={onPressSelectAction}
|
|
58
|
+
key={index}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
case 'OnOffSimpleActionTemplate':
|
|
62
|
+
return (
|
|
63
|
+
<OnOffSimpleAction
|
|
64
|
+
{...item}
|
|
65
|
+
onPress={onPressSelectAction}
|
|
66
|
+
key={index}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}, [data, onPressSelectAction]);
|
|
57
72
|
|
|
58
73
|
return (
|
|
59
74
|
<>
|
|
@@ -69,7 +84,7 @@ const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
69
84
|
onBackdropPress={onClose}
|
|
70
85
|
>
|
|
71
86
|
<View style={styles.popoverStyle}>
|
|
72
|
-
<View style={styles.modalHeader}>{renderAction
|
|
87
|
+
<View style={styles.modalHeader}>{renderAction}</View>
|
|
73
88
|
</View>
|
|
74
89
|
</ModalCustom>
|
|
75
90
|
</>
|
|
@@ -24,7 +24,7 @@ const ItemAutomate = ({
|
|
|
24
24
|
} else if (isSelected && isItemOneTap) {
|
|
25
25
|
return t('quick_button_create_at_dashboard');
|
|
26
26
|
} else {
|
|
27
|
-
return item?.explanation;
|
|
27
|
+
return t(item?.explanation);
|
|
28
28
|
}
|
|
29
29
|
}, [isItemOneTap, isSelected, item?.explanation, t, textCondition]);
|
|
30
30
|
|
|
@@ -40,7 +40,7 @@ const ItemAutomate = ({
|
|
|
40
40
|
</View>
|
|
41
41
|
<View>
|
|
42
42
|
<Text type="H4" bold>
|
|
43
|
-
{item?.title}
|
|
43
|
+
{t(item?.title)}
|
|
44
44
|
</Text>
|
|
45
45
|
<Text type="Label" color={Colors.Gray8} numberOfLines={1}>
|
|
46
46
|
{renderText}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState, memo } from 'react';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
import { Section } from '../../Section';
|
|
6
|
+
import Text from '../../Text';
|
|
7
|
+
import { API, Colors } from '../../../configs';
|
|
8
|
+
import { useNavigation, useIsFocused } from '@react-navigation/native';
|
|
9
|
+
import Routes from '../../../utils/Route';
|
|
10
|
+
import { TESTID } from '../../../configs/Constants';
|
|
11
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
12
|
+
import SharedUnit from '../../Unit/SharedUnit';
|
|
13
|
+
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
14
|
+
|
|
15
|
+
const MyPinnedSharedUnit = () => {
|
|
16
|
+
const t = useTranslations();
|
|
17
|
+
const isFocused = useIsFocused();
|
|
18
|
+
const navigation = useNavigation();
|
|
19
|
+
const [sharedUnits, setSharedUnits] = useState([]);
|
|
20
|
+
|
|
21
|
+
const goToAllSharedUnits = () => {
|
|
22
|
+
navigation.navigate(Routes.SharedStack, {
|
|
23
|
+
screen: Routes.Shared,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const fetchSharedUnitDashboard = useCallback(async () => {
|
|
28
|
+
await fetchWithCache(API.UNIT.SHARED_UNITS(), {}, (response) => {
|
|
29
|
+
const { success, data } = response;
|
|
30
|
+
|
|
31
|
+
if (success) {
|
|
32
|
+
setSharedUnits(data);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}, [setSharedUnits]);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (isFocused) {
|
|
39
|
+
fetchSharedUnitDashboard();
|
|
40
|
+
}
|
|
41
|
+
}, [fetchSharedUnitDashboard, isFocused]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<Section>
|
|
46
|
+
<View style={styles.sharedUnitsHeading}>
|
|
47
|
+
<Text type="H5" color={Colors.Gray8}>
|
|
48
|
+
{t('text_shared_units')}
|
|
49
|
+
</Text>
|
|
50
|
+
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
onPress={goToAllSharedUnits}
|
|
53
|
+
testID={TESTID.DASHBOARD_VIEW_ALL_SHARED_UNITS}
|
|
54
|
+
>
|
|
55
|
+
<Text color={Colors.Primary} style={styles.viewAll}>
|
|
56
|
+
{t('view_all')}
|
|
57
|
+
</Text>
|
|
58
|
+
</TouchableOpacity>
|
|
59
|
+
</View>
|
|
60
|
+
{sharedUnits &&
|
|
61
|
+
Boolean(sharedUnits.length) &&
|
|
62
|
+
sharedUnits
|
|
63
|
+
.filter((sharedUnit) => sharedUnit.is_pin)
|
|
64
|
+
.map((item, index) => (
|
|
65
|
+
<View key={item.id}>
|
|
66
|
+
<SharedUnit
|
|
67
|
+
item={item}
|
|
68
|
+
index={index}
|
|
69
|
+
navigation={navigation}
|
|
70
|
+
isOptions={false}
|
|
71
|
+
/>
|
|
72
|
+
{index !== sharedUnits.length - 1 && (
|
|
73
|
+
<View style={styles.separator} />
|
|
74
|
+
)}
|
|
75
|
+
</View>
|
|
76
|
+
))}
|
|
77
|
+
</Section>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default memo(MyPinnedSharedUnit);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
const { width: widthScreen } = Dimensions.get('window');
|
|
5
|
+
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
wrap: {
|
|
8
|
+
backgroundColor: Colors.Gray2,
|
|
9
|
+
flex: 1,
|
|
10
|
+
paddingBottom: 20,
|
|
11
|
+
},
|
|
12
|
+
scrollViewContentContainerStyle: {
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
},
|
|
16
|
+
container: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
backgroundColor: Colors.White,
|
|
19
|
+
},
|
|
20
|
+
separator: {
|
|
21
|
+
height: 1,
|
|
22
|
+
width: '100%',
|
|
23
|
+
borderBottomWidth: 1,
|
|
24
|
+
borderColor: Colors.Gray4,
|
|
25
|
+
},
|
|
26
|
+
unitsHeading: {
|
|
27
|
+
flexDirection: 'row',
|
|
28
|
+
justifyContent: 'space-between',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
paddingHorizontal: 16,
|
|
31
|
+
paddingBottom: 8,
|
|
32
|
+
paddingTop: 16,
|
|
33
|
+
},
|
|
34
|
+
sharedUnitsHeading: {
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
paddingBottom: 8,
|
|
39
|
+
},
|
|
40
|
+
banner: {
|
|
41
|
+
marginTop: 8,
|
|
42
|
+
flex: 1,
|
|
43
|
+
width: widthScreen,
|
|
44
|
+
maxHeight: 140,
|
|
45
|
+
alignSelf: 'center',
|
|
46
|
+
},
|
|
47
|
+
btnLeftHeader: {
|
|
48
|
+
paddingRight: 16,
|
|
49
|
+
height: '100%',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
},
|
|
52
|
+
txtCopy: {
|
|
53
|
+
marginLeft: 16,
|
|
54
|
+
marginBottom: 10,
|
|
55
|
+
fontSize: 12,
|
|
56
|
+
color: Colors.Gray6,
|
|
57
|
+
},
|
|
58
|
+
boxTxtMyUnit: {
|
|
59
|
+
padding: 0,
|
|
60
|
+
paddingBottom: 30,
|
|
61
|
+
backgroundColor: Colors.White,
|
|
62
|
+
},
|
|
63
|
+
logo: {
|
|
64
|
+
marginLeft: 16,
|
|
65
|
+
marginTop: 24,
|
|
66
|
+
},
|
|
67
|
+
govSaleLogo: {
|
|
68
|
+
marginLeft: 16,
|
|
69
|
+
marginBottom: 8,
|
|
70
|
+
width: 120,
|
|
71
|
+
height: 40,
|
|
72
|
+
},
|
|
73
|
+
wrapCurrentLocationLoading: {
|
|
74
|
+
height: 170,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export default styles;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import MyUnit from '..';
|
|
4
|
+
import { TESTID } from '../../../../configs/Constants';
|
|
5
|
+
import { SCProvider } from '../../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
+
import axios from 'axios';
|
|
8
|
+
|
|
9
|
+
jest.mock('axios');
|
|
10
|
+
const mockedNavigate = jest.fn();
|
|
11
|
+
const mockUseIsFocused = jest.fn();
|
|
12
|
+
const mockedDispatch = jest.fn();
|
|
13
|
+
|
|
14
|
+
jest.mock('@react-navigation/native', () => {
|
|
15
|
+
return {
|
|
16
|
+
...jest.requireActual('@react-navigation/native'),
|
|
17
|
+
useNavigation: () => ({
|
|
18
|
+
navigate: mockedNavigate,
|
|
19
|
+
}),
|
|
20
|
+
useIsFocused: () => ({
|
|
21
|
+
isFocused: mockUseIsFocused,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
jest.mock('react-redux', () => ({
|
|
27
|
+
...jest.requireActual('react-redux'),
|
|
28
|
+
useDispatch: () => mockedDispatch,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const wrapComponent = () => (
|
|
32
|
+
<SCProvider initState={mockSCStore({})}>
|
|
33
|
+
<MyUnit />
|
|
34
|
+
</SCProvider>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
describe('Test MyUnit', () => {
|
|
38
|
+
let tree;
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
axios.get.mockClear();
|
|
41
|
+
});
|
|
42
|
+
const getElement = (instance) => {
|
|
43
|
+
const goToDetail = instance.findAll(
|
|
44
|
+
(item) => item.props.testID === TESTID.MY_UNIT_GO_TO_DETAIL
|
|
45
|
+
);
|
|
46
|
+
const textNoUnit = instance.findAll(
|
|
47
|
+
(item) => item.props.testID === TESTID.MY_UNIT_NO_UNIT
|
|
48
|
+
);
|
|
49
|
+
return { goToDetail, textNoUnit };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
test('create MyUnit no Unit', async () => {
|
|
53
|
+
await act(async () => {
|
|
54
|
+
tree = await renderer.create(wrapComponent());
|
|
55
|
+
});
|
|
56
|
+
const instance = tree.root;
|
|
57
|
+
const { textNoUnit } = getElement(instance);
|
|
58
|
+
expect(textNoUnit[0]).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { View, Image, TouchableOpacity, Dimensions } from 'react-native';
|
|
3
|
+
import { API, Colors, Images } from '../../../configs';
|
|
4
|
+
import Text from '../../Text';
|
|
5
|
+
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
6
|
+
|
|
7
|
+
import styles from './styles';
|
|
8
|
+
import { Section } from '../../Section';
|
|
9
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
10
|
+
import { useNavigation, useIsFocused } from '@react-navigation/native';
|
|
11
|
+
|
|
12
|
+
import Carousel from 'react-native-snap-carousel';
|
|
13
|
+
import { TESTID } from '../../../configs/Constants';
|
|
14
|
+
import Routes from '../../../utils/Route';
|
|
15
|
+
import MyUnitDevice from '../../../screens/Unit/components/MyUnitDevice';
|
|
16
|
+
|
|
17
|
+
let screenWidth = Dimensions.get('window').width;
|
|
18
|
+
const MyUnit = () => {
|
|
19
|
+
const t = useTranslations();
|
|
20
|
+
const isFocused = useIsFocused();
|
|
21
|
+
const navigation = useNavigation();
|
|
22
|
+
const [myUnits, setMyUnits] = useState([]);
|
|
23
|
+
|
|
24
|
+
const fetchMyUnitDashboard = useCallback(async () => {
|
|
25
|
+
await fetchWithCache(API.UNIT.MY_UNITS(), {}, (response) => {
|
|
26
|
+
const { success, data } = response;
|
|
27
|
+
if (success) {
|
|
28
|
+
setMyUnits(data);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}, [setMyUnits]);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (isFocused) {
|
|
35
|
+
fetchMyUnitDashboard();
|
|
36
|
+
}
|
|
37
|
+
}, [fetchMyUnitDashboard, isFocused]);
|
|
38
|
+
const goToDetail = useCallback(
|
|
39
|
+
(item) => {
|
|
40
|
+
navigation.navigate(Routes.UnitStack, {
|
|
41
|
+
screen: Routes.UnitDetail,
|
|
42
|
+
params: {
|
|
43
|
+
unitId: item.id,
|
|
44
|
+
unitData: item,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
[navigation]
|
|
49
|
+
);
|
|
50
|
+
const _renderItem = useCallback(
|
|
51
|
+
({ item, index }) => {
|
|
52
|
+
const paddingLeft = index === 0 ? 0 : 8;
|
|
53
|
+
const paddingRight = index === myUnits.length - 1 ? 0 : 8;
|
|
54
|
+
return (
|
|
55
|
+
<View
|
|
56
|
+
style={{
|
|
57
|
+
paddingLeft: paddingLeft,
|
|
58
|
+
paddingRight: paddingRight,
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<TouchableOpacity
|
|
62
|
+
onPress={() => goToDetail(item)}
|
|
63
|
+
style={styles.btnItem}
|
|
64
|
+
activeOpacity={0.75}
|
|
65
|
+
testID={TESTID.MY_UNIT_GO_TO_DETAIL}
|
|
66
|
+
>
|
|
67
|
+
<View style={styles.overlay} />
|
|
68
|
+
<Image
|
|
69
|
+
style={styles.bgMyUnit}
|
|
70
|
+
source={{ uri: item.background }}
|
|
71
|
+
defaultSource={Images.BgUnit}
|
|
72
|
+
resizeMode="cover"
|
|
73
|
+
/>
|
|
74
|
+
<Text style={styles.title}>{item.name}</Text>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
{item.abstract_sensors.map((sensor, indexSensor) => (
|
|
77
|
+
<MyUnitDevice key={indexSensor} sensor={sensor} unit={item} />
|
|
78
|
+
))}
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
[myUnits.length, goToDetail]
|
|
83
|
+
);
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<Section style={styles.boxTxtMyUnit}>
|
|
87
|
+
<Text style={styles.unitsHeading} type="H5" color={Colors.Gray8}>
|
|
88
|
+
{t('text_my_units')}
|
|
89
|
+
</Text>
|
|
90
|
+
<View style={styles.container}>
|
|
91
|
+
{myUnits.length ? (
|
|
92
|
+
<Carousel
|
|
93
|
+
layout={'default'}
|
|
94
|
+
data={myUnits}
|
|
95
|
+
sliderWidth={screenWidth}
|
|
96
|
+
itemWidth={screenWidth - 32}
|
|
97
|
+
renderItem={_renderItem}
|
|
98
|
+
inactiveSlideScale={1}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
<View>
|
|
102
|
+
<Text testID={TESTID.MY_UNIT_NO_UNIT}>{t('text_no_units')}</Text>
|
|
103
|
+
</View>
|
|
104
|
+
)}
|
|
105
|
+
</View>
|
|
106
|
+
</Section>
|
|
107
|
+
</>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default memo(MyUnit);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
import { colorOpacity } from '../../../utils/Converter/color';
|
|
4
|
+
|
|
5
|
+
const styles = StyleSheet.create({
|
|
6
|
+
boxTxtMyUnit: {
|
|
7
|
+
padding: 0,
|
|
8
|
+
paddingBottom: 30,
|
|
9
|
+
backgroundColor: Colors.White,
|
|
10
|
+
},
|
|
11
|
+
unitsHeading: {
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
justifyContent: 'space-between',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
paddingHorizontal: 16,
|
|
16
|
+
paddingBottom: 8,
|
|
17
|
+
paddingTop: 16,
|
|
18
|
+
},
|
|
19
|
+
container: {
|
|
20
|
+
flex: 1,
|
|
21
|
+
backgroundColor: Colors.White,
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
paddingBottom: 16,
|
|
25
|
+
},
|
|
26
|
+
overlay: {
|
|
27
|
+
backgroundColor: colorOpacity(Colors.Black, 0.4),
|
|
28
|
+
zIndex: 2,
|
|
29
|
+
left: 0,
|
|
30
|
+
top: 0,
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
width: '100%',
|
|
33
|
+
height: '100%',
|
|
34
|
+
borderRadius: 10,
|
|
35
|
+
},
|
|
36
|
+
bgMyUnit: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
left: 0,
|
|
39
|
+
top: 0,
|
|
40
|
+
right: 0,
|
|
41
|
+
width: '100%',
|
|
42
|
+
height: '100%',
|
|
43
|
+
borderRadius: 10,
|
|
44
|
+
},
|
|
45
|
+
title: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
zIndex: 3,
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
fontSize: 20,
|
|
50
|
+
lineHeight: 28,
|
|
51
|
+
color: Colors.White,
|
|
52
|
+
bottom: 16,
|
|
53
|
+
left: 16,
|
|
54
|
+
},
|
|
55
|
+
btnItem: {
|
|
56
|
+
height: 121,
|
|
57
|
+
marginBottom: 16,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default styles;
|
|
@@ -14,8 +14,11 @@ const DisplayTextConnected = memo(({ type }) => {
|
|
|
14
14
|
case 'GoogleHome':
|
|
15
15
|
text = t('ggHomeConnected');
|
|
16
16
|
break;
|
|
17
|
+
case 'Bluetooth':
|
|
18
|
+
text = t('connected_via_bluetooth');
|
|
19
|
+
break;
|
|
17
20
|
default:
|
|
18
|
-
text = t('
|
|
21
|
+
text = t('connected_via_internet');
|
|
19
22
|
break;
|
|
20
23
|
}
|
|
21
24
|
return <Text style={styles.greenStatus}>{text}</Text>;
|
|
@@ -105,6 +105,7 @@ const MediaPlayer = memo(
|
|
|
105
105
|
style,
|
|
106
106
|
ratioWidth = standardizeWidth,
|
|
107
107
|
ratioHeight = standardizeHeight,
|
|
108
|
+
background,
|
|
108
109
|
}) => {
|
|
109
110
|
const t = useTranslations();
|
|
110
111
|
const [started, setStarted] = useState(false);
|
|
@@ -116,7 +117,11 @@ const MediaPlayer = memo(
|
|
|
116
117
|
}, []);
|
|
117
118
|
|
|
118
119
|
const imageSource =
|
|
119
|
-
|
|
120
|
+
thumbnail || thumbnail?.uri
|
|
121
|
+
? thumbnail
|
|
122
|
+
: background
|
|
123
|
+
? background
|
|
124
|
+
: Images.BgDevice;
|
|
120
125
|
return (
|
|
121
126
|
<View style={styles.wrap}>
|
|
122
127
|
<View style={styles.loadingWrap}>
|
|
@@ -14,7 +14,7 @@ const OptionsDropdownActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
14
14
|
const t = useTranslations();
|
|
15
15
|
const [visible, setVisible] = useState(false);
|
|
16
16
|
const [actionName, setActionName] = useState(null);
|
|
17
|
-
const [activeAction, setActiveAction] = useState();
|
|
17
|
+
const [activeAction, setActiveAction] = useState(-1);
|
|
18
18
|
const onClose = () => setVisible(false);
|
|
19
19
|
const onPress = () => setVisible(true);
|
|
20
20
|
const { title, configuration, template } = data;
|
|
@@ -91,12 +91,12 @@ const OptionsDropdownActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
91
91
|
<TouchableOpacity
|
|
92
92
|
onPress={onPressDone}
|
|
93
93
|
testID={TESTID.OPTIONS_DROPDOWN_ACTION_DONE}
|
|
94
|
-
disabled={
|
|
94
|
+
disabled={activeAction < 0}
|
|
95
95
|
>
|
|
96
96
|
<Text
|
|
97
97
|
type="H4"
|
|
98
98
|
bold
|
|
99
|
-
color={activeAction ? Colors.Primary : Colors.Disabled}
|
|
99
|
+
color={activeAction >= 0 ? Colors.Primary : Colors.Disabled}
|
|
100
100
|
style={styles.textButton}
|
|
101
101
|
>
|
|
102
102
|
{t('done')}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { Colors } from '
|
|
5
|
-
import Text from '
|
|
4
|
+
import { Colors } from '../../configs';
|
|
5
|
+
import Text from '../Text';
|
|
6
6
|
import styles from './RowLocationStyles';
|
|
7
7
|
|
|
8
8
|
const RowLocation = memo(({ item, onPress }) => {
|