@eohjsc/react-native-smart-city 0.3.24 → 0.3.27

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
  3. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +55 -5
  4. package/src/commons/Dashboard/MyUnit/index.js +58 -11
  5. package/src/commons/MenuActionMore/index.js +1 -3
  6. package/src/commons/Popover/index.js +26 -0
  7. package/src/configs/Constants.js +4 -0
  8. package/src/context/actionType.ts +2 -0
  9. package/src/context/reducer.ts +10 -0
  10. package/src/hooks/Common/useGGHomeDeviceConnected.js +9 -2
  11. package/src/hooks/Common/usePopover.js +0 -8
  12. package/src/hooks/IoT/useGGHomeConnection.js +0 -1
  13. package/src/navigations/UnitStack.js +10 -2
  14. package/src/screens/GuestInfo/index.js +11 -4
  15. package/src/screens/GuestInfo/styles/indexStyles.js +7 -0
  16. package/src/screens/ManageAccess/index.js +14 -5
  17. package/src/screens/ManageAccess/styles/ManageAccessStyles.js +9 -0
  18. package/src/screens/PlayBackCamera/Timer.js +3 -0
  19. package/src/screens/PlayBackCamera/__test__/index.test.js +8 -1
  20. package/src/screens/PlayBackCamera/index.js +67 -46
  21. package/src/screens/ScriptDetail/__test__/index.test.js +0 -3
  22. package/src/screens/ScriptDetail/index.js +7 -10
  23. package/src/screens/Unit/Detail.js +16 -10
  24. package/src/screens/Unit/SmartAccount.js +7 -6
  25. package/src/screens/Unit/Summaries.js +8 -1
  26. package/src/screens/Unit/components/Header/index.js +1 -1
  27. package/src/screens/Unit/components/MyUnitDevice/index.js +29 -12
  28. package/src/screens/Unit/components/__test__/AutomateScript.test.js +116 -0
  29. package/src/screens/Unit/components/__test__/Header.test.js +1 -1
  30. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  31. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +6 -5
  32. package/src/screens/Unit/components/MyUnit/index.js +0 -136
  33. 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
- });