@eohjsc/react-native-smart-city 0.3.26 → 0.3.29
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/index.js +2 -0
- package/package.json +1 -1
- package/src/Images/Common/device_icon.png +0 -0
- package/src/Images/DevMode/gateway.png +0 -0
- package/src/Images/DevMode/gateway@2x.png +0 -0
- package/src/Images/DevMode/gateway@3x.png +0 -0
- package/src/Images/DevMode/menu.png +0 -0
- package/src/Images/DevMode/menu@2x.png +0 -0
- package/src/Images/DevMode/menu@3x.png +0 -0
- package/src/Images/DevMode/search.png +0 -0
- package/src/Images/DevMode/search@2x.png +0 -0
- package/src/Images/DevMode/search@3x.png +0 -0
- package/src/Images/DevMode/smart.png +0 -0
- package/src/Images/DevMode/smart@2x.png +0 -0
- package/src/Images/DevMode/smart@3x.png +0 -0
- package/src/Images/DevMode/template.png +0 -0
- package/src/Images/DevMode/template@2x.png +0 -0
- package/src/Images/DevMode/template@3x.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -0
- package/src/commons/ActionTemplate/CurtainAction.js +60 -0
- package/src/commons/ActionTemplate/CurtainActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +44 -0
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +11 -0
- package/src/commons/ActionTemplate/index.js +18 -0
- package/src/commons/CameraDevice/index.js +1 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +20 -12
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +2 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +1 -1
- package/src/commons/ConnectingProcess/index.js +11 -0
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +55 -5
- package/src/commons/Dashboard/MyUnit/index.js +59 -12
- package/src/commons/DevMode/Label.js +10 -0
- package/src/commons/DevMode/Search.js +20 -0
- package/src/commons/DevMode/Styles/LabelStyles.js +8 -0
- package/src/commons/DevMode/Styles/SearchStyles.js +21 -0
- package/src/commons/DevMode/index.js +3 -0
- package/src/commons/Device/ItemDevice.js +1 -0
- package/src/commons/Form/TextInput.js +4 -0
- package/src/commons/HeaderAni/index.js +1 -0
- package/src/commons/MediaPlayerDetail/index.js +0 -20
- package/src/commons/MenuActionMore/index.js +12 -4
- package/src/commons/Modal/index.js +1 -2
- package/src/commons/NavBar/index.js +12 -1
- package/src/commons/Popover/index.js +26 -0
- package/src/commons/SubUnit/ShortDetail.js +1 -0
- package/src/commons/SummaryItem/index.js +2 -1
- package/src/commons/Tabbar/Styles/indexStyles.js +51 -0
- package/src/commons/Tabbar/index.js +110 -0
- package/src/commons/Unit/HeaderUnit/index.js +2 -0
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/WrapParallaxScrollView/index.js +16 -2
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +5 -0
- package/src/configs/Images.js +6 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +9 -2
- package/src/hooks/Common/usePopover.js +0 -8
- package/src/hooks/IoT/useGGHomeConnection.js +0 -1
- package/src/navigations/GatewayStack.js +23 -0
- package/src/navigations/Main.js +144 -0
- package/src/navigations/SmartStack.js +23 -0
- package/src/navigations/TemplateStack.js +23 -0
- package/src/navigations/UnitStack.js +10 -2
- package/src/screens/AddNewAction/SelectAction.js +6 -1
- package/src/screens/AllCamera/__test__/index.test.js +1 -8
- package/src/screens/AllCamera/index.js +0 -13
- package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +37 -0
- package/src/screens/Drawer/Drawer.test.js +24 -0
- package/src/screens/Drawer/index.js +198 -0
- package/src/screens/Gateway/__test__/index.test.js +16 -0
- package/src/screens/Gateway/index.js +8 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +79 -85
- package/src/screens/Notification/components/NotificationItem.js +37 -220
- package/src/screens/ScriptDetail/__test__/index.test.js +39 -3
- package/src/screens/ScriptDetail/index.js +7 -10
- package/src/screens/Smart/__test__/index.test.js +16 -0
- package/src/screens/Smart/index.js +8 -0
- package/src/screens/SubUnit/AddSubUnit.js +1 -1
- package/src/screens/SubUnit/EditSubUnit.js +4 -1
- package/src/screens/Template/Styles/indexStyles.js +51 -0
- package/src/screens/Template/__test__/index.test.js +16 -0
- package/src/screens/Template/index.js +84 -0
- package/src/screens/Unit/Detail.js +10 -27
- package/src/screens/Unit/MoreMenu.js +16 -1
- package/src/screens/Unit/SmartAccount.js +7 -6
- package/src/screens/Unit/Station/__test__/index.test.js +41 -0
- package/src/screens/Unit/Station/index.js +0 -1
- package/src/screens/Unit/Summaries.js +14 -2
- package/src/screens/Unit/__test__/Detail.test.js +1 -5
- package/src/screens/Unit/components/Header/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +29 -12
- package/src/screens/Unit/components/__test__/Header.test.js +1 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +6 -5
- package/src/utils/Converter/__test__/timer.test.js +99 -0
- package/src/utils/Functions/Search.js +17 -0
- package/src/utils/Functions/ShortEmail.js +4 -0
- package/src/utils/Functions/__test__/Search.test.js +6 -0
- package/src/utils/Functions/__test__/ShortEmail.test.js +6 -0
- package/src/utils/I18n/translations/en.json +32 -42
- package/src/utils/I18n/translations/vi.json +32 -44
- package/src/utils/Route/index.js +6 -0
- package/src/commons/Modal/ModalFullVideo.js +0 -48
- package/src/commons/Modal/Styles/ModalFullVideoStyles.js +0 -26
- package/src/screens/Unit/components/MyUnit/index.js +0 -136
- package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -35
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Image,
|
|
5
|
-
TouchableOpacity,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
Dimensions,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import Carousel from 'react-native-snap-carousel';
|
|
10
|
-
import { useNavigation } from '@react-navigation/native';
|
|
11
|
-
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
12
|
-
|
|
13
|
-
import { Colors, Images } from '../../../../configs';
|
|
14
|
-
import { TESTID } from '../../../../configs/Constants';
|
|
15
|
-
import Text from '../../../../commons/Text';
|
|
16
|
-
import MyUnitDevice from '../MyUnitDevice';
|
|
17
|
-
import Routes from '../../../../utils/Route';
|
|
18
|
-
import { colorOpacity } from '../../../../utils/Converter/color';
|
|
19
|
-
|
|
20
|
-
let screenWidth = Dimensions.get('window').width;
|
|
21
|
-
|
|
22
|
-
const MyUnit = ({ myUnits }) => {
|
|
23
|
-
const t = useTranslations();
|
|
24
|
-
const navigation = useNavigation();
|
|
25
|
-
const carouselItems = useMemo(() => myUnits, [myUnits]);
|
|
26
|
-
const goToDetail = useCallback(
|
|
27
|
-
(item) => {
|
|
28
|
-
navigation.navigate(Routes.UnitStack, {
|
|
29
|
-
screen: Routes.UnitDetail,
|
|
30
|
-
params: {
|
|
31
|
-
unitId: item.id,
|
|
32
|
-
unitData: item,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
[navigation]
|
|
37
|
-
);
|
|
38
|
-
const _renderItem = useCallback(
|
|
39
|
-
({ item, index }) => {
|
|
40
|
-
const paddingLeft = index === 0 ? 0 : 8;
|
|
41
|
-
const paddingRight = index === carouselItems.length - 1 ? 0 : 8;
|
|
42
|
-
return (
|
|
43
|
-
<View
|
|
44
|
-
style={{
|
|
45
|
-
paddingLeft: paddingLeft,
|
|
46
|
-
paddingRight: paddingRight,
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
<TouchableOpacity
|
|
50
|
-
onPress={() => goToDetail(item)}
|
|
51
|
-
style={styles.btnItem}
|
|
52
|
-
activeOpacity={0.75}
|
|
53
|
-
testID={TESTID.MY_UNIT_GO_TO_DETAIL}
|
|
54
|
-
>
|
|
55
|
-
<View style={styles.overlay} />
|
|
56
|
-
<Image
|
|
57
|
-
style={styles.bgMyUnit}
|
|
58
|
-
source={{ uri: item.background }}
|
|
59
|
-
defaultSource={Images.BgUnit}
|
|
60
|
-
resizeMode="cover"
|
|
61
|
-
/>
|
|
62
|
-
<Text style={styles.title}>{item.name}</Text>
|
|
63
|
-
</TouchableOpacity>
|
|
64
|
-
{item.abstract_sensors.map((sensor, indexSensor) => (
|
|
65
|
-
<MyUnitDevice key={indexSensor} sensor={sensor} />
|
|
66
|
-
))}
|
|
67
|
-
</View>
|
|
68
|
-
);
|
|
69
|
-
},
|
|
70
|
-
[carouselItems.length, goToDetail]
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<View style={styles.container}>
|
|
75
|
-
{carouselItems.length ? (
|
|
76
|
-
<Carousel
|
|
77
|
-
layout={'default'}
|
|
78
|
-
data={carouselItems}
|
|
79
|
-
sliderWidth={screenWidth}
|
|
80
|
-
itemWidth={screenWidth - 32}
|
|
81
|
-
renderItem={_renderItem}
|
|
82
|
-
inactiveSlideScale={1}
|
|
83
|
-
/>
|
|
84
|
-
) : (
|
|
85
|
-
<View>
|
|
86
|
-
<Text testID={TESTID.MY_UNIT_NO_UNIT}>{t('text_no_units')}</Text>
|
|
87
|
-
</View>
|
|
88
|
-
)}
|
|
89
|
-
</View>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const styles = StyleSheet.create({
|
|
94
|
-
container: {
|
|
95
|
-
flex: 1,
|
|
96
|
-
backgroundColor: Colors.White,
|
|
97
|
-
flexDirection: 'row',
|
|
98
|
-
justifyContent: 'center',
|
|
99
|
-
paddingBottom: 16,
|
|
100
|
-
},
|
|
101
|
-
overlay: {
|
|
102
|
-
backgroundColor: colorOpacity(Colors.Black, 0.4),
|
|
103
|
-
zIndex: 2,
|
|
104
|
-
left: 0,
|
|
105
|
-
top: 0,
|
|
106
|
-
position: 'absolute',
|
|
107
|
-
width: '100%',
|
|
108
|
-
height: '100%',
|
|
109
|
-
borderRadius: 10,
|
|
110
|
-
},
|
|
111
|
-
bgMyUnit: {
|
|
112
|
-
position: 'absolute',
|
|
113
|
-
left: 0,
|
|
114
|
-
top: 0,
|
|
115
|
-
right: 0,
|
|
116
|
-
width: '100%',
|
|
117
|
-
height: '100%',
|
|
118
|
-
borderRadius: 10,
|
|
119
|
-
},
|
|
120
|
-
title: {
|
|
121
|
-
position: 'absolute',
|
|
122
|
-
zIndex: 3,
|
|
123
|
-
fontWeight: 'bold',
|
|
124
|
-
fontSize: 20,
|
|
125
|
-
lineHeight: 28,
|
|
126
|
-
color: Colors.White,
|
|
127
|
-
bottom: 16,
|
|
128
|
-
left: 16,
|
|
129
|
-
},
|
|
130
|
-
btnItem: {
|
|
131
|
-
height: 121,
|
|
132
|
-
marginBottom: 16,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
export default MyUnit;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Carousel from 'react-native-snap-carousel';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import MyUnit from '../MyUnit';
|
|
5
|
-
import { SCProvider } from '../../../../context';
|
|
6
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
-
|
|
8
|
-
const wrapComponent = (units) => (
|
|
9
|
-
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<MyUnit myUnits={units} />
|
|
11
|
-
</SCProvider>
|
|
12
|
-
);
|
|
13
|
-
jest.mock('react', () => {
|
|
14
|
-
return {
|
|
15
|
-
...jest.requireActual('react'),
|
|
16
|
-
memo: (x) => x,
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('Test MyUnit', () => {
|
|
21
|
-
let tree;
|
|
22
|
-
|
|
23
|
-
it('render MyUnit carousel', async () => {
|
|
24
|
-
const units = [
|
|
25
|
-
{ id: 1, name: '', abstract_sensors: [{ id: 1, name: '' }] },
|
|
26
|
-
{ id: 2, name: '', abstract_sensors: [{ id: 1, name: '' }] },
|
|
27
|
-
];
|
|
28
|
-
await act(() => {
|
|
29
|
-
tree = create(wrapComponent(units));
|
|
30
|
-
});
|
|
31
|
-
const instance = tree.root;
|
|
32
|
-
const carousel = instance.findAllByType(Carousel);
|
|
33
|
-
expect(carousel).toHaveLength(1);
|
|
34
|
-
});
|
|
35
|
-
});
|