@eohjsc/react-native-smart-city 0.2.84 → 0.2.87

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 (128) hide show
  1. package/assets/images/Device/button-lock.svg +3 -0
  2. package/assets/images/Device/button-unlock.svg +3 -0
  3. package/assets/images/brightness.svg +12 -0
  4. package/assets/images/brightnessBlack.svg +12 -0
  5. package/index.js +4 -0
  6. package/package.json +3 -1
  7. package/src/Images/Common/SuccessfullyConnected.svg +4 -0
  8. package/src/Images/Common/eye-closed.png +0 -0
  9. package/src/Images/Common/eye-closed@2x.png +0 -0
  10. package/src/Images/Common/eye-closed@3x.png +0 -0
  11. package/src/Images/Common/eye.png +0 -0
  12. package/src/Images/Common/eye@2x.png +0 -0
  13. package/src/Images/Common/eye@3x.png +0 -0
  14. package/src/Images/SmartIr/AC.svg +14 -0
  15. package/src/Images/SmartIr/DIY.svg +3 -0
  16. package/src/Images/SmartIr/Fan.svg +10 -0
  17. package/src/Images/SmartIr/Fridge.svg +5 -0
  18. package/src/Images/SmartIr/TV.svg +10 -0
  19. package/src/Images/SmartIr/WM.svg +11 -0
  20. package/src/Images/SmartIr/index.js +7 -0
  21. package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
  22. package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
  23. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +40 -0
  24. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +65 -0
  25. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapperStyles.js +43 -0
  26. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +48 -0
  27. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +57 -0
  28. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +48 -0
  29. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +51 -0
  30. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +48 -0
  31. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscodeStyles.js +42 -0
  32. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/PasscodeListStyles.js +49 -0
  33. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +66 -0
  34. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +96 -0
  35. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +98 -0
  36. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +62 -0
  37. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +249 -0
  38. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
  39. package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -2
  40. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
  41. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +188 -186
  42. package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -1
  43. package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
  44. package/src/commons/ActionGroup/index.js +6 -0
  45. package/src/commons/CardShadow/index.js +5 -2
  46. package/src/commons/CardShadow/styles.js +2 -3
  47. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
  48. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
  49. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
  50. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
  51. package/src/commons/ConnectingProcess/index.js +205 -0
  52. package/src/commons/ConnectingProcess/styles.js +69 -0
  53. package/src/commons/Device/DisconnectedView.js +7 -1
  54. package/src/commons/Device/ItemDevice.js +8 -3
  55. package/src/commons/Device/LinearChart.js +3 -39
  56. package/src/commons/Device/__test__/DisconnectedView.test.js +13 -2
  57. package/src/commons/Form/TextInputPassword.js +1 -1
  58. package/src/commons/MediaPlayer/__test__/index.test.js +45 -0
  59. package/src/commons/RowItem/index.js +12 -7
  60. package/src/commons/SubUnit/ShortDetail.js +10 -22
  61. package/src/commons/SubUnit/__test__/ShortDetail.test.js +57 -48
  62. package/src/commons/WheelDateTimePicker/index.js +18 -4
  63. package/src/configs/API.js +4 -2
  64. package/src/configs/Colors.js +1 -0
  65. package/src/configs/Constants.js +39 -0
  66. package/src/configs/Images.js +2 -0
  67. package/src/context/actionType.ts +2 -0
  68. package/src/context/mockStore.ts +1 -0
  69. package/src/context/reducer.ts +10 -0
  70. package/src/hooks/Common/useBlockBackAndroid.js +3 -1
  71. package/src/iot/RemoteControl/Bluetooth.js +3 -3
  72. package/src/navigations/AddDeviceStack.js +10 -0
  73. package/src/navigations/SmartIrStack.js +31 -0
  74. package/src/navigations/SmartLockStack.js +51 -0
  75. package/src/navigations/UnitStack.js +12 -3
  76. package/src/screens/ActivityLog/hooks/index.js +18 -4
  77. package/src/screens/ActivityLog/index.js +3 -0
  78. package/src/screens/AddCommon/SelectSubUnit.js +30 -6
  79. package/src/screens/AddCommon/SelectUnit.js +24 -2
  80. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
  81. package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
  82. package/src/screens/AddNewAction/SelectSensorDevices.js +4 -2
  83. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +97 -37
  84. package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +4 -2
  85. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +178 -35
  86. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +58 -0
  87. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +26 -2
  88. package/src/screens/AddNewGateway/SelectGateway.js +132 -0
  89. package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
  90. package/src/screens/AddNewOneTap/index.js +32 -17
  91. package/src/screens/Automate/index.js +2 -2
  92. package/src/screens/Device/EditDevice/index.js +5 -3
  93. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +13 -2
  94. package/src/screens/Device/components/SensorDisplayItem.js +3 -0
  95. package/src/screens/Device/detail.js +56 -16
  96. package/src/screens/Device/hooks/useDisconnectedDevice.js +21 -5
  97. package/src/screens/GuestInfo/components/AccessScheduleItem.js +9 -2
  98. package/src/screens/GuestInfo/components/RecurringDetail.js +3 -2
  99. package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -2
  100. package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +3 -0
  101. package/src/screens/Notification/__test__/NotificationItem.test.js +28 -5
  102. package/src/screens/Notification/components/NotificationItem.js +128 -20
  103. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +11 -7
  104. package/src/screens/ScanChipQR/hooks/index.js +89 -19
  105. package/src/screens/ScriptDetail/index.js +1 -6
  106. package/src/screens/SelectUnit/index.js +1 -0
  107. package/src/screens/SharedUnit/index.js +1 -1
  108. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +54 -0
  109. package/src/screens/SmartIr/__test__/SelectBrand.test.js +74 -0
  110. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +64 -0
  111. package/src/screens/SmartIr/__test__/SmartIr.test.js +62 -0
  112. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +86 -0
  113. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByTypeStyles.js +76 -0
  114. package/src/screens/SmartIr/components/SelectBrand.js +61 -0
  115. package/src/screens/SmartIr/components/SelectBrandStyles.js +14 -0
  116. package/src/screens/SmartIr/components/SelectDeviceType.js +96 -0
  117. package/src/screens/SmartIr/components/SelectDeviceTypeStyles.js +30 -0
  118. package/src/screens/SmartIr/index.js +28 -0
  119. package/src/screens/SmartIr/styles.js +14 -0
  120. package/src/screens/Unit/AddMenu.js +4 -1
  121. package/src/screens/Unit/Detail.js +31 -5
  122. package/src/screens/Unit/components/MyUnitDevice/index.js +2 -4
  123. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +38 -9
  124. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +32 -1
  125. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +1 -1
  126. package/src/utils/I18n/translations/en.json +40 -2
  127. package/src/utils/I18n/translations/vi.json +40 -3
  128. package/src/utils/Route/index.js +11 -0
@@ -0,0 +1,205 @@
1
+ import React, { useEffect, useCallback, useState } from 'react';
2
+ import { SafeAreaView, View, TouchableOpacity } from 'react-native';
3
+ import { useTranslations } from '../../hooks/Common/useTranslations';
4
+ import Routes from '../../utils/Route';
5
+ import { useNavigation } from '@react-navigation/native';
6
+ import * as Progress from 'react-native-progress';
7
+ import ImageSuccessfully from '../../Images/Common/SuccessfullyConnected.svg';
8
+
9
+ import Text from '../Text';
10
+ import { axiosPost } from '../../utils/Apis/axios';
11
+ import { API, Colors, Constants } from '../../configs';
12
+ import styles from './styles';
13
+ import DeviceItem from './DeviceItem/DeviceItem';
14
+ import { useSCContextSelector } from '../../context';
15
+
16
+ const ConnectingProcess = ({ route }) => {
17
+ const { navigate, goBack } = useNavigation();
18
+ const t = useTranslations();
19
+
20
+ const {
21
+ scan_sensor_data,
22
+ gateway,
23
+ station,
24
+ unit,
25
+ unit_id,
26
+ unit_name,
27
+ devicePrefixName,
28
+ wifi_ssid,
29
+ wifi_pass,
30
+ chip_id,
31
+ } = route.params;
32
+ const [percent, setPercent] = useState(0);
33
+ const [isLoading, setIsLoading] = useState(true);
34
+ const [sensor, setSensor] = useState(null);
35
+ const user = useSCContextSelector((state) => state?.auth?.account?.user);
36
+ useEffect(() => {
37
+ processLoading();
38
+ }, [processLoading]);
39
+
40
+ const processLoading = useCallback(() => {
41
+ let interval;
42
+ if (isLoading) {
43
+ interval = setInterval(() => {
44
+ setPercent((prev) => {
45
+ if (prev === 1) {
46
+ clearInterval(interval);
47
+ return 1;
48
+ } else {
49
+ return prev + 0.2;
50
+ }
51
+ });
52
+ }, 180);
53
+ } else {
54
+ clearInterval(interval);
55
+ }
56
+ }, [isLoading]);
57
+
58
+ const ConnectingDevice = useCallback(async () => {
59
+ setIsLoading(true);
60
+ switch (devicePrefixName) {
61
+ case 'SENSOR':
62
+ {
63
+ const body = { imei: scan_sensor_data?.imei, chip: gateway?.id };
64
+ const { success, data } = await axiosPost(
65
+ API.SUB_UNIT.SENSOR_SCAN(station.id),
66
+ body
67
+ );
68
+ if (success) {
69
+ setSensor(data);
70
+ } else {
71
+ goBack();
72
+ }
73
+ }
74
+ break;
75
+ case 'ROBOT': {
76
+ const { success, data } = await axiosPost(API.UNIT.CHIP_SCAN(unit.id), {
77
+ imei: gateway?.imei,
78
+ qr_code: scan_sensor_data?.imei,
79
+ name: gateway?.model,
80
+ station: station?.id,
81
+ wifi_ssid: wifi_ssid,
82
+ wifi_pass: wifi_pass,
83
+ phone: user?.phone_number,
84
+ });
85
+ if (success) {
86
+ setSensor(data);
87
+ } else {
88
+ goBack();
89
+ }
90
+ break;
91
+ }
92
+ case 'LITE': {
93
+ const { success } = await axiosPost(API.UNIT.ADD_GATEWAY(unit_id), {
94
+ chip: chip_id,
95
+ imei: gateway?.imei,
96
+ chip_name: gateway?.model,
97
+ });
98
+ if (success) {
99
+ setSensor({ name: gateway?.model });
100
+ } else {
101
+ goBack();
102
+ }
103
+ break;
104
+ }
105
+ }
106
+ setIsLoading(false);
107
+ }, [
108
+ devicePrefixName,
109
+ scan_sensor_data?.imei,
110
+ gateway?.id,
111
+ gateway?.imei,
112
+ gateway?.model,
113
+ station,
114
+ goBack,
115
+ unit,
116
+ wifi_ssid,
117
+ wifi_pass,
118
+ user?.phone_number,
119
+ unit_id,
120
+ chip_id,
121
+ ]);
122
+
123
+ const Connecting = useCallback(() => {
124
+ return (
125
+ <>
126
+ <View style={styles.progressBar}>
127
+ <View style={styles.connecting}>
128
+ <Text type="H4" bold>
129
+ {t('connecting')}
130
+ </Text>
131
+ </View>
132
+ </View>
133
+ <View style={styles.percentLoad}>
134
+ <Progress.Bar
135
+ progress={percent}
136
+ animated={true}
137
+ color={Colors.Primary}
138
+ indeterminateAnimationDuration={1000}
139
+ height={7}
140
+ width={Constants.width - 80}
141
+ useNativeDriver={true}
142
+ />
143
+ <Text style={styles.textPercentLoad}>{`${parseInt(
144
+ percent * 100,
145
+ 10
146
+ )}%`}</Text>
147
+ </View>
148
+ </>
149
+ );
150
+ }, [percent, t]);
151
+
152
+ const ConnectingSuccess = useCallback(() => {
153
+ return (
154
+ <View style={styles.ConnectingSuccess}>
155
+ <ImageSuccessfully />
156
+ <Text bold style={styles.connectingText}>
157
+ {t('successfully_connected')}
158
+ </Text>
159
+ <Text size={14} style={styles.textHome}>
160
+ {`${unit?.name || unit_name} ${
161
+ station?.name !== undefined ? '- ' + station?.name : ''
162
+ }`}
163
+ </Text>
164
+ <DeviceItem icon={sensor?.icon_kit} name={sensor?.name} />
165
+ </View>
166
+ );
167
+ }, [sensor?.icon_kit, sensor?.name, station?.name, t, unit?.name, unit_name]);
168
+
169
+ const handleDone = useCallback(() => {
170
+ navigate(Routes.UnitStack, {
171
+ screen: Routes.UnitDetail,
172
+ params: {
173
+ unitId: unit?.id || unit_id,
174
+ unitData: unit,
175
+ routeName: 'DashboardStack',
176
+ stationId: station?.id,
177
+ },
178
+ });
179
+ }, [navigate, station?.id, unit, unit_id]);
180
+
181
+ useEffect(() => {
182
+ ConnectingDevice();
183
+ }, [ConnectingDevice]);
184
+
185
+ return (
186
+ <SafeAreaView style={styles.wrap}>
187
+ <View style={styles.boxText}>
188
+ <Text bold style={styles.connectingText}>
189
+ {t('connect_device')}
190
+ </Text>
191
+ {!!isLoading && <Connecting />}
192
+ {!isLoading && <ConnectingSuccess />}
193
+ </View>
194
+ {!isLoading && (
195
+ <TouchableOpacity style={styles.buttonDone} onPress={handleDone}>
196
+ <Text color={Colors.Primary} type={'H4'}>
197
+ {t('done')}
198
+ </Text>
199
+ </TouchableOpacity>
200
+ )}
201
+ </SafeAreaView>
202
+ );
203
+ };
204
+
205
+ export default ConnectingProcess;
@@ -0,0 +1,69 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../../configs';
3
+ import {
4
+ getStatusBarHeight,
5
+ getBottomSpace,
6
+ } from 'react-native-iphone-x-helper';
7
+
8
+ export default StyleSheet.create({
9
+ wrap: {
10
+ paddingTop: getStatusBarHeight(true),
11
+ backgroundColor: Colors.White,
12
+ width: '100%',
13
+ height: '100%',
14
+ justifyContent: 'space-between',
15
+ },
16
+ connectingText: {
17
+ marginLeft: 30,
18
+ marginTop: 16,
19
+ fontSize: 20,
20
+ color: Colors.Gray9,
21
+ },
22
+ animatedEllipsis: {
23
+ fontSize: 25,
24
+ color: Colors.Gray9,
25
+ marginTop: 14,
26
+ },
27
+ warningText: {
28
+ marginHorizontal: 30,
29
+ marginTop: 16,
30
+ fontSize: 14,
31
+ color: Colors.Gray8,
32
+ },
33
+ boxText: {
34
+ flex: 1,
35
+ },
36
+ progressBar: {
37
+ flexDirection: 'column',
38
+ marginTop: 180,
39
+ marginHorizontal: 30,
40
+ },
41
+ connecting: {
42
+ flexDirection: 'row',
43
+ justifyContent: 'center',
44
+ marginBottom: 10,
45
+ },
46
+ percentLoad: {
47
+ flexDirection: 'row',
48
+ justifyContent: 'center',
49
+ alignItems: 'center',
50
+ },
51
+ textPercentLoad: {
52
+ marginLeft: 10,
53
+ },
54
+ ConnectingSuccess: {
55
+ marginTop: 180,
56
+ justifyContent: 'center',
57
+ alignItems: 'center',
58
+ },
59
+ textHome: {
60
+ paddingTop: 16,
61
+ paddingBottom: 8,
62
+ },
63
+ buttonDone: {
64
+ width: '100%',
65
+ justifyContent: 'center',
66
+ alignItems: 'center',
67
+ paddingBottom: getBottomSpace() + 24,
68
+ },
69
+ });
@@ -42,7 +42,7 @@ const DisplayTextDisconnected = memo(({ type }) => {
42
42
  return <Text style={styles.redStatus}>{text}</Text>;
43
43
  });
44
44
 
45
- const DisconnectedView = memo(({ sensor, type }) => {
45
+ const DisconnectedView = memo(({ sensor, type, isDeviceHasBle }) => {
46
46
  const t = useTranslations();
47
47
  return (
48
48
  <View style={styles.statusContainer}>
@@ -74,6 +74,12 @@ const DisconnectedView = memo(({ sensor, type }) => {
74
74
  <CircleView size={6} backgroundColor={Colors.Gray8} />
75
75
  <Text style={styles.noticeText}>{t('check_the_wifi')}</Text>
76
76
  </View>
77
+ {isDeviceHasBle && (
78
+ <View style={styles.infoRow}>
79
+ <CircleView size={6} backgroundColor={Colors.Gray8} />
80
+ <Text style={styles.noticeText}>{t('check_the_ble')}</Text>
81
+ </View>
82
+ )}
77
83
  </View>
78
84
  </View>
79
85
  );
@@ -14,7 +14,7 @@ import Text from '../../commons/Text';
14
14
  import { isDeviceConnected } from '../../iot/RemoteControl/Bluetooth';
15
15
 
16
16
  import { Colors, Constants } from '../../configs';
17
- import { TESTID } from '../../configs/Constants';
17
+ import { TESTID, DEVICE_TYPE } from '../../configs/Constants';
18
18
  import FImage from '../../commons/FImage';
19
19
 
20
20
  const marginItem = 12;
@@ -61,11 +61,16 @@ const ItemDevice = memo(
61
61
  status === undefined
62
62
  ? isNetworkConnected && sensor.is_connected
63
63
  : isNetworkConnected && status.is_connected;
64
- const isBLEConnected = isDeviceConnected(
64
+ const isConnectedViaBLE = isDeviceConnected(
65
65
  sensor?.remote_control_options?.bluetooth?.address
66
66
  );
67
+ const isConnectedViaGGHome =
68
+ !!sensor &&
69
+ sensor?.is_other_device &&
70
+ !sensor?.device_type !== DEVICE_TYPE.LG_THINQ &&
71
+ isGGHomeConnected;
67
72
  const isConnected =
68
- isConnectedViaInternet || isGGHomeConnected || isBLEConnected;
73
+ isConnectedViaInternet || isConnectedViaGGHome || isConnectedViaBLE;
69
74
  const borderColor = isConnected ? Colors.Gray4 : Colors.Red6;
70
75
  const textConnected = isConnected ? t('connected') : t('disconnected');
71
76
 
@@ -47,45 +47,9 @@ const chartOptions = {
47
47
  text: '',
48
48
  },
49
49
  labels: {
50
- formatter: function (value) {
51
- const time = new Date(this.value || value);
52
- let date = ('0' + time.getDate()).slice(-2);
53
- let month = ('0' + (time.getMonth() + 1)).slice(-2);
54
- return `${date}.${month}`;
55
- },
56
- },
57
- minRange: 3600 * 24 * 1000,
58
- },
59
- plotOptions: {
60
- series: {
61
- events: {
62
- legendItemClick: function () {
63
- const { index, visible, chart } = this;
64
- const { series } = chart;
65
- series.forEach((serie, i) => {
66
- if (i !== index) {
67
- serie.visible ? serie.show() : serie.hide();
68
- }
69
- });
70
- const isHiding = (serie, i) => {
71
- if (i === index) {
72
- return visible;
73
- }
74
- return !serie.visible;
75
- };
76
- if (this.chart.series.every(isHiding)) {
77
- this.chart.yAxis[0].update({
78
- min: 0,
79
- max: 100,
80
- });
81
- } else {
82
- this.chart.yAxis[0].update({
83
- min: undefined,
84
- max: undefined,
85
- });
86
- }
87
- },
88
- },
50
+ align: 'center',
51
+ padding: 70,
52
+ format: '{value:%d.%m %H:%M}',
89
53
  },
90
54
  },
91
55
  };
@@ -5,9 +5,9 @@ import renderer, { act } from 'react-test-renderer';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
7
 
8
- const wrapComponent = (sensor) => (
8
+ const wrapComponent = (sensor, isDeviceHasBle) => (
9
9
  <SCProvider initState={mockSCStore({})}>
10
- <DisconnectedView sensor={sensor} />
10
+ <DisconnectedView sensor={sensor} isDeviceHasBle={isDeviceHasBle} />
11
11
  </SCProvider>
12
12
  );
13
13
 
@@ -63,4 +63,15 @@ describe('Test DisconnectedView', () => {
63
63
  const Views = instance.findAllByType(View);
64
64
  expect(Views).toHaveLength(15);
65
65
  });
66
+
67
+ test('render DisconnectedView text check bluetooth', () => {
68
+ const isDeviceHasBle = true;
69
+ const sensor = { icon: 'test' };
70
+ act(() => {
71
+ tree = renderer.create(wrapComponent(sensor, isDeviceHasBle));
72
+ });
73
+ const instance = tree.root;
74
+ const Views = instance.findAllByType(View);
75
+ expect(Views).toHaveLength(17);
76
+ });
66
77
  });
@@ -111,7 +111,7 @@ const styles = StyleSheet.create({
111
111
  icons: {
112
112
  position: 'absolute',
113
113
  right: 0,
114
- top: 7,
114
+ top: -5,
115
115
  bottom: 0,
116
116
  width: 40,
117
117
  justifyContent: 'center',
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import { TouchableOpacity } from 'react-native';
6
+ import MediaPlay from '../index';
7
+
8
+ jest.mock('react', () => {
9
+ return {
10
+ ...jest.requireActual('react'),
11
+ memo: (x) => x,
12
+ };
13
+ });
14
+
15
+ const wrapComponent = (props) => (
16
+ <SCProvider initState={mockSCStore({})}>
17
+ <MediaPlay {...props} />
18
+ </SCProvider>
19
+ );
20
+
21
+ describe('Test MediaPlayer', () => {
22
+ let tree, props;
23
+
24
+ beforeAll(() => {
25
+ jest.useFakeTimers();
26
+ props = {
27
+ uri: 'uri',
28
+ previewUri: 'previewUri',
29
+ thumbnail: 'thumbnail',
30
+ background: 'background',
31
+ };
32
+ });
33
+
34
+ it('Test render', async () => {
35
+ await act(async () => {
36
+ tree = await create(wrapComponent(props));
37
+ });
38
+ const instance = tree.root;
39
+ const pauseButton = instance.findByType(TouchableOpacity);
40
+ await act(async () => {
41
+ await pauseButton.props.onPress();
42
+ });
43
+ jest.runAllTimers();
44
+ });
45
+ });
@@ -21,7 +21,8 @@ export const RowItem = memo(
21
21
  type, //primary | disable | undefined
22
22
  leftIcon,
23
23
  text,
24
- subtext,
24
+ isShowSubText = true,
25
+ subtext = '',
25
26
  subtextColor = Colors.Gray6,
26
27
  rightComponent,
27
28
  onPress,
@@ -40,14 +41,18 @@ export const RowItem = memo(
40
41
  <View style={styles.wrapItem}>
41
42
  <TouchableOpacity onPress={onPress} disabled={type === 'disable'}>
42
43
  <View style={styles.Border}>
43
- <View style={styles.paddingLeft16}>
44
- <CircleView size={40} backgroundColor={circleColor} center>
45
- {leftIcon}
46
- </CircleView>
47
- </View>
44
+ {!!leftIcon && (
45
+ <View style={styles.paddingLeft16}>
46
+ <CircleView size={40} backgroundColor={circleColor} center>
47
+ {leftIcon}
48
+ </CircleView>
49
+ </View>
50
+ )}
48
51
  <View style={styles.columeFlex}>
49
52
  <Text style={styles.titleName}> {text}</Text>
50
- <Text style={styles.status}> {subtext}</Text>
53
+ {!!isShowSubText && (
54
+ <Text style={styles.status}> {subtext}</Text>
55
+ )}
51
56
  </View>
52
57
  {!!rightComponent && (
53
58
  <View style={styles.endFlex}>{rightComponent}</View>
@@ -4,7 +4,7 @@ import { useNavigation, useIsFocused } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
 
6
6
  import { Images, Device, API } from '../../configs';
7
- import { SubUnitName, TESTID } from '../../configs/Constants';
7
+ import { TESTID } from '../../configs/Constants';
8
8
  import { Section } from '../Section';
9
9
  import Text from '../Text';
10
10
  import ItemDevice from '../Device/ItemDevice';
@@ -104,28 +104,16 @@ const ShortDetailSubUnit = ({
104
104
  };
105
105
 
106
106
  const handleOnAddNew = () => {
107
- if (!station.isFavorites) {
108
- navigate(Routes.AddDeviceStack, {
109
- screen: Routes.ScanSensorQR,
110
- params: {
111
- station_id: station.id,
112
- unit_id: unit.id,
113
- unit_name: unit.name,
114
- },
115
- });
116
- } else {
117
- alert(t('feature_under_development'));
118
- }
107
+ navigate(Routes.AddDeviceStack, {
108
+ screen: Routes.ScanSensorQR,
109
+ params: {
110
+ station_id: station?.id,
111
+ unit_id: unit.id,
112
+ unit_name: unit.name,
113
+ },
114
+ });
119
115
  };
120
116
 
121
- const itemAddNewTitle = t(
122
- station?.isFavorites
123
- ? 'add_to_favorites'
124
- : station?.name === SubUnitName.smart
125
- ? 'add_script'
126
- : 'add_new'
127
- );
128
-
129
117
  return (
130
118
  <Section style={styles.noShadow}>
131
119
  {renderCamera()}
@@ -156,7 +144,7 @@ const ShortDetailSubUnit = ({
156
144
  status={sensorsStatus.find((s) => s.id === sensor.id)}
157
145
  />
158
146
  ))}
159
- <ItemAddNew title={itemAddNewTitle} onAddNew={handleOnAddNew} />
147
+ <ItemAddNew title={t('add_new_device')} onAddNew={handleOnAddNew} />
160
148
  </View>
161
149
  </Section>
162
150
  );