@eohjsc/react-native-smart-city 0.3.92 → 0.3.94
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/package.json +5 -1
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -2
- package/src/commons/AlertAction/index.js +5 -0
- package/src/commons/BottomButtonView/index.js +22 -4
- package/src/commons/Button/index.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +0 -1
- package/src/commons/Device/Emergency/EmergencyDetail.js +4 -2
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +4 -2
- package/src/commons/Device/ProgressBar/index.js +3 -1
- package/src/commons/Device/ProgressBar/styles.js +1 -4
- package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
- package/src/commons/Header/HeaderCustom.js +8 -18
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +84 -129
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +74 -39
- package/src/commons/SubUnit/OneTap/index.js +24 -4
- package/src/commons/ViewButtonBottom/index.js +32 -4
- package/src/configs/API.js +4 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/BLE.js +1 -0
- package/src/context/actionType.ts +2 -1
- package/src/context/mockStore.ts +1 -0
- package/src/context/reducer.ts +12 -1
- package/src/hooks/Explore/useKeyboardAnimated.js +10 -4
- package/src/hooks/IoT/useBluetoothConnection.js +14 -26
- package/src/hooks/useMqtt.js +95 -0
- package/src/iot/Monitor.js +2 -1
- package/src/iot/RemoteControl/Bluetooth.js +56 -19
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +140 -0
- package/src/iot/mqtt.js +233 -0
- package/src/navigations/UnitStack.js +11 -3
- package/src/screens/AddLocationMaps/index.js +18 -16
- package/src/screens/AddLocationMaps/indexStyle.js +3 -0
- package/src/screens/AddNewGateway/ConnectingDevice.js +7 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
- package/src/screens/AddNewGateway/SelectDeviceType.js +67 -9
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +35 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +183 -29
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +3 -6
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +29 -29
- package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +45 -39
- package/src/screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart.js +25 -0
- package/src/screens/{AddNewAutoSmart/index.js → Automate/AddNewAutoSmart/AddTypeSmart.js} +16 -51
- package/src/screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart.js +29 -0
- package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/__test__/AddNewAutoSmart.test.js +11 -11
- package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/styles/AddNewAutoSmartStyles.js +1 -1
- package/src/screens/Automate/Components/InputNameStyles.js +1 -1
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +11 -25
- package/src/screens/Automate/EditActionsList/index.js +32 -33
- package/src/screens/Automate/MultiUnits.js +29 -19
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +78 -5
- package/src/screens/Automate/ScriptDetail/index.js +38 -10
- package/src/screens/Automate/Styles/MultiUnitsStyles.js +1 -1
- package/src/screens/Automate/__test__/MultiUnits.test.js +64 -7
- package/src/screens/Automate/__test__/index.test.js +45 -11
- package/src/screens/Automate/index.js +53 -38
- package/src/screens/Device/__test__/detail.test.js +1 -1
- package/src/screens/Device/__test__/mqttDetail.test.js +599 -0
- package/src/screens/Device/components/SensorDisplayItem.js +1 -7
- package/src/screens/Device/detail.js +64 -30
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +24 -1
- package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +13 -3
- package/src/screens/SelectUnit/__test__/index.test.js +8 -13
- package/src/screens/Sharing/InfoMemberUnit.js +2 -2
- package/src/screens/Sharing/MemberList.js +28 -7
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +32 -18
- package/src/screens/Sharing/__test__/MemberList.test.js +37 -4
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +8 -4
- package/src/screens/SmartAccount/index.js +8 -9
- package/src/screens/SmartAccount/style.js +8 -7
- package/src/screens/Unit/AddMenu.js +42 -19
- package/src/screens/Unit/Detail.js +4 -19
- package/src/screens/Unit/Summaries.js +6 -17
- package/src/screens/Unit/__test__/AddMenu.test.js +68 -15
- package/src/screens/Unit/__test__/Summaries.test.js +2 -2
- package/src/screens/Unit/components/AutomateScript/index.js +1 -1
- package/src/utils/FactoryGateway.js +525 -0
- package/src/utils/I18n/translations/en.js +1409 -0
- package/src/utils/I18n/translations/vi.js +1411 -0
- package/src/utils/I18n/translations.ts +2 -2
- package/src/utils/Permission/backend.js +7 -0
- package/src/utils/Route/index.js +2 -1
- package/src/utils/Utils.js +11 -0
- package/src/commons/Device/SensorConnectedStatus.js +0 -56
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +0 -29
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -74
- package/src/utils/I18n/translations/en.json +0 -1138
- package/src/utils/I18n/translations/vi.json +0 -1136
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.3.
|
|
4
|
+
"version": "0.3.94",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"@testing-library/react-hooks": "^6.0.0",
|
|
130
130
|
"apisauce": "^2.1.5",
|
|
131
131
|
"axios": "^0.19.2",
|
|
132
|
+
"base-64": "^1.0.0",
|
|
132
133
|
"deprecated-react-native-prop-types": "^2.3.0",
|
|
133
134
|
"dotenv": "^8.2.0",
|
|
134
135
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -143,8 +144,10 @@
|
|
|
143
144
|
"patch-package": "^6.2.2",
|
|
144
145
|
"pluralize": "^8.0.0",
|
|
145
146
|
"postinstall": "^0.7.0",
|
|
147
|
+
"precompiled-mqtt": "^4.3.14-beta",
|
|
146
148
|
"pusher-js": "^7.4.0",
|
|
147
149
|
"pusher-js-auth": "^4.0.1",
|
|
150
|
+
"python-struct": "^1.1.3",
|
|
148
151
|
"querystring": "^0.2.0",
|
|
149
152
|
"react-content-loader": "^6.0.3",
|
|
150
153
|
"react-dom": "^17.0.1",
|
|
@@ -161,6 +164,7 @@
|
|
|
161
164
|
"react-native-calendars": "^1.1266.0",
|
|
162
165
|
"react-native-chart-kit": "^6.5.0",
|
|
163
166
|
"react-native-credit-card-input": "^0.4.1",
|
|
167
|
+
"react-native-crypto-aes-cbc": "^1.1.1",
|
|
164
168
|
"react-native-dash": "^0.0.11",
|
|
165
169
|
"react-native-deep-linking": "^2.2.0",
|
|
166
170
|
"react-native-device-info": "^10.3.0",
|
|
@@ -80,6 +80,8 @@ const AlertAction = ({
|
|
|
80
80
|
styleButtonLeft={boxLeftButtonStyle}
|
|
81
81
|
styleButtonRight={boxRightButtonStyle}
|
|
82
82
|
accessibilityLabelPrefix={accessibilityLabelPrefix}
|
|
83
|
+
wrapStyle={styles.wrapViewButtonStyle}
|
|
84
|
+
disableKeyBoardAnimated
|
|
83
85
|
/>
|
|
84
86
|
</View>
|
|
85
87
|
</Animated.View>
|
|
@@ -121,6 +123,9 @@ const styles = StyleSheet.create({
|
|
|
121
123
|
descriptionText: {
|
|
122
124
|
paddingHorizontal: 16,
|
|
123
125
|
},
|
|
126
|
+
wrapViewButtonStyle: {
|
|
127
|
+
position: 'relative',
|
|
128
|
+
},
|
|
124
129
|
});
|
|
125
130
|
|
|
126
131
|
export default AlertAction;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { memo, useState, useEffect } from 'react';
|
|
2
|
+
import { StyleSheet, Animated, Easing, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
5
|
+
import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
|
|
5
6
|
import Button from '../Button';
|
|
6
7
|
|
|
7
8
|
const BottomButtonView = memo(
|
|
@@ -20,13 +21,28 @@ const BottomButtonView = memo(
|
|
|
20
21
|
typeMain = 'primary',
|
|
21
22
|
typeSecondary = 'cancel',
|
|
22
23
|
accessibilityLabelPrefix = '',
|
|
24
|
+
disableBackgroundMainButton = false,
|
|
25
|
+
disableBackgroundSecondButton = false,
|
|
23
26
|
}) => {
|
|
27
|
+
const transY = useKeyboardAnimated();
|
|
28
|
+
const [keyboardAnim] = useState(new Animated.Value(0));
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
Animated.timing(keyboardAnim, {
|
|
32
|
+
toValue: transY,
|
|
33
|
+
duration: Platform.OS === 'ios' ? 220 : 0,
|
|
34
|
+
easing: Easing.linear(),
|
|
35
|
+
useNativeDriver: false,
|
|
36
|
+
}).start();
|
|
37
|
+
}, [keyboardAnim, transY]);
|
|
38
|
+
|
|
24
39
|
return (
|
|
25
|
-
<View
|
|
40
|
+
<Animated.View
|
|
26
41
|
style={[
|
|
27
42
|
typeMain === 'CardShadow'
|
|
28
43
|
? styleCustom.container1
|
|
29
44
|
: styleCustom.container,
|
|
45
|
+
{ bottom: keyboardAnim },
|
|
30
46
|
rowButton && styleCustom.horizontalContainer,
|
|
31
47
|
style,
|
|
32
48
|
]}
|
|
@@ -42,6 +58,7 @@ const BottomButtonView = memo(
|
|
|
42
58
|
textType={textTypeMain}
|
|
43
59
|
style={rowButton && styleCustom.buttonMainRow}
|
|
44
60
|
accessibilityLabel={`${accessibilityLabelPrefix}${AccessibilityLabel.BOTTOM_VIEW_MAIN}`}
|
|
61
|
+
disableBackground={disableBackgroundMainButton}
|
|
45
62
|
/>
|
|
46
63
|
)}
|
|
47
64
|
{secondaryTitle && (
|
|
@@ -56,9 +73,10 @@ const BottomButtonView = memo(
|
|
|
56
73
|
: styleCustom.buttonSecondaryColumn
|
|
57
74
|
}
|
|
58
75
|
accessibilityLabel={`${accessibilityLabelPrefix}${AccessibilityLabel.BOTTOM_VIEW_SECONDARY}`}
|
|
76
|
+
disableBackground={disableBackgroundSecondButton}
|
|
59
77
|
/>
|
|
60
78
|
)}
|
|
61
|
-
</View>
|
|
79
|
+
</Animated.View>
|
|
62
80
|
);
|
|
63
81
|
}
|
|
64
82
|
);
|
|
@@ -133,6 +133,7 @@ export default ({
|
|
|
133
133
|
textSemiBold = true,
|
|
134
134
|
style,
|
|
135
135
|
accessibilityLabel,
|
|
136
|
+
disableBackground = false,
|
|
136
137
|
}) => {
|
|
137
138
|
const styleButton = ButtonStyle[type];
|
|
138
139
|
const textColor = TextColor[type];
|
|
@@ -153,6 +154,7 @@ export default ({
|
|
|
153
154
|
isCardShadow && styles.buttonLeft,
|
|
154
155
|
styleButton,
|
|
155
156
|
style,
|
|
157
|
+
disableBackground && styles.disableBackground,
|
|
156
158
|
]}
|
|
157
159
|
onPress={onPress}
|
|
158
160
|
disabled={isDisabled}
|
|
@@ -202,4 +204,7 @@ const styles = StyleSheet.create({
|
|
|
202
204
|
alignItems: 'flex-start',
|
|
203
205
|
backgroundColor: Colors.Gray1,
|
|
204
206
|
},
|
|
207
|
+
disableBackground: {
|
|
208
|
+
backgroundColor: Colors.Transparent,
|
|
209
|
+
},
|
|
205
210
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
|
-
|
|
5
4
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
5
|
import { Colors } from '../../configs';
|
|
7
6
|
import Text from '../../commons/Text';
|
|
@@ -9,7 +9,6 @@ import { RowUser } from '../../RowUser';
|
|
|
9
9
|
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
10
10
|
import { useEmeragencyContacts } from '../../../screens/EmergencyContacts/hook';
|
|
11
11
|
import { useIsFocused } from '@react-navigation/native';
|
|
12
|
-
import _ from 'lodash';
|
|
13
12
|
|
|
14
13
|
const { standardizeHeight } = standardizeCameraScreenSize(
|
|
15
14
|
Device.screenWidth + 86
|
|
@@ -17,6 +16,7 @@ const { standardizeHeight } = standardizeCameraScreenSize(
|
|
|
17
16
|
|
|
18
17
|
const EmergencyDetail = memo(({ item }) => {
|
|
19
18
|
const t = useTranslations();
|
|
19
|
+
const { uri, preview_uri } = item?.configuration?.camera;
|
|
20
20
|
const groupId = item?.configuration?.device?.group?.id;
|
|
21
21
|
const isFocused = useIsFocused();
|
|
22
22
|
const { listContacts, getListContacts } = useEmeragencyContacts();
|
|
@@ -35,8 +35,10 @@ const EmergencyDetail = memo(({ item }) => {
|
|
|
35
35
|
<View style={styles.first}>
|
|
36
36
|
<Text type="H4">{t('camera')}</Text>
|
|
37
37
|
<MediaPlayer
|
|
38
|
-
uri={
|
|
38
|
+
uri={uri}
|
|
39
|
+
previewUri={preview_uri}
|
|
39
40
|
style={styles.camera}
|
|
41
|
+
key={'camera-emergency'}
|
|
40
42
|
/>
|
|
41
43
|
</View>
|
|
42
44
|
<View style={styles.second}>
|
|
@@ -28,8 +28,10 @@ describe('Test EmergencyDetail', () => {
|
|
|
28
28
|
it('create EmergencyDetail', async () => {
|
|
29
29
|
const item = {
|
|
30
30
|
configuration: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
camera: {
|
|
32
|
+
uri: '123',
|
|
33
|
+
preview_uri: '123',
|
|
34
|
+
},
|
|
33
35
|
device: {
|
|
34
36
|
group: {
|
|
35
37
|
id: 1,
|
|
@@ -28,7 +28,9 @@ const ProgressBar = memo(({ data = [], item }) => {
|
|
|
28
28
|
|
|
29
29
|
<View style={styles.wrapProgressBar}>
|
|
30
30
|
<Progress.Bar
|
|
31
|
-
style={styles.
|
|
31
|
+
style={styles.progressBar}
|
|
32
|
+
width={null}
|
|
33
|
+
height={40}
|
|
32
34
|
progress={percent}
|
|
33
35
|
unfilledColor={Colors.Blue15}
|
|
34
36
|
/>
|
|
@@ -24,10 +24,8 @@ export default StyleSheet.create({
|
|
|
24
24
|
fontWeight: 'bold',
|
|
25
25
|
textTransform: 'uppercase',
|
|
26
26
|
},
|
|
27
|
-
|
|
27
|
+
progressBar: {
|
|
28
28
|
flex: 1,
|
|
29
|
-
width: '100%',
|
|
30
|
-
height: 40,
|
|
31
29
|
color: Colors.Blue16,
|
|
32
30
|
borderWidth: 0,
|
|
33
31
|
borderRadius: 10,
|
|
@@ -40,6 +38,5 @@ export default StyleSheet.create({
|
|
|
40
38
|
},
|
|
41
39
|
textValue: {
|
|
42
40
|
marginLeft: 8,
|
|
43
|
-
width: 45,
|
|
44
41
|
},
|
|
45
42
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
2
|
import { View, Text, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import Images from '../../configs/Images';
|
|
4
4
|
import { Colors } from '../../configs';
|
|
@@ -11,7 +11,6 @@ import { AccessibilityLabel } from '../../configs/Constants';
|
|
|
11
11
|
|
|
12
12
|
const HeaderCustom = ({
|
|
13
13
|
title = '',
|
|
14
|
-
isShowAdd = false,
|
|
15
14
|
isShowRight = false,
|
|
16
15
|
onRefresh,
|
|
17
16
|
showPopoverWithRef,
|
|
@@ -33,18 +32,18 @@ const HeaderCustom = ({
|
|
|
33
32
|
const t = useTranslations();
|
|
34
33
|
const { goBack } = useNavigation();
|
|
35
34
|
const refMenuAction = useRef();
|
|
36
|
-
const refAddAction = useRef();
|
|
37
|
-
const handleAddAction = () => {};
|
|
38
35
|
const handleShowMenuAction = () => showPopoverWithRef(refMenuAction);
|
|
39
36
|
const handleGoback = () => {
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
if (onGoBack) {
|
|
38
|
+
onGoBack();
|
|
39
|
+
} else {
|
|
40
|
+
goBack();
|
|
41
|
+
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const handleClose = useCallback(() => {
|
|
45
45
|
onClose ? onClose() : notImplemented(t);
|
|
46
|
-
|
|
47
|
-
}, []);
|
|
46
|
+
}, [onClose, t]);
|
|
48
47
|
|
|
49
48
|
return (
|
|
50
49
|
<View
|
|
@@ -102,15 +101,6 @@ const HeaderCustom = ({
|
|
|
102
101
|
</TouchableOpacity>
|
|
103
102
|
</>
|
|
104
103
|
)}
|
|
105
|
-
{isShowAdd && (
|
|
106
|
-
<TouchableOpacity
|
|
107
|
-
style={styles.buttonAdd}
|
|
108
|
-
onPress={handleAddAction}
|
|
109
|
-
ref={refAddAction}
|
|
110
|
-
>
|
|
111
|
-
<Icon name={'plus'} size={27} color={Colors.Black} />
|
|
112
|
-
</TouchableOpacity>
|
|
113
|
-
)}
|
|
114
104
|
{isShowClose && (
|
|
115
105
|
<TouchableOpacity style={styles.buttonAdd} onPress={handleClose}>
|
|
116
106
|
<Icon name={'close'} size={24} color={Colors.Black} />
|
|
@@ -122,4 +112,4 @@ const HeaderCustom = ({
|
|
|
122
112
|
);
|
|
123
113
|
};
|
|
124
114
|
|
|
125
|
-
export default
|
|
115
|
+
export default HeaderCustom;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useCallback
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import { TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import moment from 'moment';
|
|
@@ -17,144 +17,99 @@ import { axiosPost } from '../../../utils/Apis/axios';
|
|
|
17
17
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
18
18
|
import { useNavigation } from '@react-navigation/native';
|
|
19
19
|
import Routes from '../../../utils/Route';
|
|
20
|
-
import {
|
|
21
|
-
import { AUTOMATE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
|
|
20
|
+
import { AccessibilityLabel, AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
22
21
|
|
|
23
|
-
const ItemOneTap = memo(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
id,
|
|
28
|
-
type,
|
|
29
|
-
user,
|
|
30
|
-
script,
|
|
31
|
-
activate_at,
|
|
32
|
-
condition,
|
|
33
|
-
config,
|
|
34
|
-
value,
|
|
35
|
-
author = '',
|
|
36
|
-
} = automate;
|
|
37
|
-
const t = useTranslations();
|
|
38
|
-
const idUser = useGetIdUser();
|
|
39
|
-
|
|
40
|
-
const textCondition = useMemo(() => {
|
|
41
|
-
if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
42
|
-
let _condition;
|
|
43
|
-
if (condition === '>') {
|
|
44
|
-
_condition = 'higher_than';
|
|
45
|
-
} else if (condition === '<') {
|
|
46
|
-
_condition = 'lower_than';
|
|
47
|
-
} else if (condition === '=') {
|
|
48
|
-
_condition = 'equal';
|
|
49
|
-
}
|
|
50
|
-
return `${config} ${t(_condition)} ${value}`;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}, [condition, config, t, type, value]);
|
|
22
|
+
const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
23
|
+
const { navigate } = useNavigation();
|
|
24
|
+
const { id, type, script, activate_at, author = '' } = automate;
|
|
25
|
+
const t = useTranslations();
|
|
54
26
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
id,
|
|
58
|
-
automate,
|
|
59
|
-
name: script?.name,
|
|
60
|
-
type: type,
|
|
61
|
-
havePermission: isOwner || user === idUser,
|
|
62
|
-
unit,
|
|
63
|
-
textCondition,
|
|
64
|
-
});
|
|
65
|
-
}, [
|
|
66
|
-
automate,
|
|
67
|
-
isOwner,
|
|
68
|
-
user,
|
|
69
|
-
idUser,
|
|
70
|
-
navigate,
|
|
27
|
+
const goToDetail = useCallback(() => {
|
|
28
|
+
navigate(Routes.ScriptDetail, {
|
|
71
29
|
id,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
textCondition,
|
|
76
|
-
]);
|
|
30
|
+
preAutomate: automate,
|
|
31
|
+
});
|
|
32
|
+
}, [automate, navigate, id]);
|
|
77
33
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
34
|
+
const handleScriptAction = useCallback(async () => {
|
|
35
|
+
const { success } = await axiosPost(API.AUTOMATE.ACTION_ONE_TAP(id));
|
|
36
|
+
if (success) {
|
|
37
|
+
ToastBottomHelper.success(t('activated_successfully'));
|
|
38
|
+
} else {
|
|
39
|
+
ToastBottomHelper.error(t('activation_failed'));
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
}, [id]);
|
|
87
43
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
44
|
+
const displayIcon = () => {
|
|
45
|
+
const iconKit = script?.icon_kit;
|
|
46
|
+
if (iconKit) {
|
|
47
|
+
return <FImage source={{ uri: iconKit }} style={styles.iconSensor} />;
|
|
48
|
+
}
|
|
49
|
+
if (type === AUTOMATE_TYPE.ONE_TAP) {
|
|
50
|
+
return <OneTap />;
|
|
51
|
+
}
|
|
52
|
+
if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
53
|
+
return <ValueChange />;
|
|
54
|
+
}
|
|
55
|
+
if ([AUTOMATE_TYPE.EVENT].includes(type)) {
|
|
56
|
+
return <Event />;
|
|
57
|
+
}
|
|
58
|
+
return <Schedule />;
|
|
59
|
+
};
|
|
60
|
+
const activateAt = activate_at
|
|
61
|
+
? timeDifference(new Date(), moment(activate_at), true)
|
|
62
|
+
: null;
|
|
63
|
+
return (
|
|
64
|
+
<TouchableWithoutFeedback
|
|
65
|
+
onPress={onPressItem || goToDetail}
|
|
66
|
+
accessibilityLabel={`${AccessibilityLabel.AUTOMATE_SCRIPT_NAME}-${id}`}
|
|
67
|
+
>
|
|
68
|
+
<View style={[styles.container, wrapSyles]}>
|
|
69
|
+
<View style={styles.boxIcon}>
|
|
70
|
+
{displayIcon()}
|
|
71
|
+
{type === AUTOMATE_TYPE.ONE_TAP && (
|
|
72
|
+
<TouchableOpacity
|
|
73
|
+
accessibilityLabel={AccessibilityLabel.AUTOMATE_SCRIPT_ACTION}
|
|
74
|
+
onPress={handleScriptAction}
|
|
75
|
+
>
|
|
76
|
+
<CheckCircle />
|
|
77
|
+
</TouchableOpacity>
|
|
78
|
+
)}
|
|
79
|
+
</View>
|
|
80
|
+
<TouchableOpacity
|
|
81
|
+
accessibilityLabel={AccessibilityLabel.GO_DETAIL}
|
|
82
|
+
onPress={onPressItem || goToDetail}
|
|
83
|
+
>
|
|
84
|
+
<Text
|
|
85
|
+
numberOfLines={1}
|
|
86
|
+
semibold
|
|
87
|
+
size={14}
|
|
88
|
+
color={Colors.Gray9}
|
|
89
|
+
type="Body"
|
|
90
|
+
style={styles.name}
|
|
127
91
|
>
|
|
92
|
+
{script?.name}
|
|
93
|
+
</Text>
|
|
94
|
+
<Text numberOfLines={1} type={'Label'} color={Colors.Gray7}>
|
|
95
|
+
{t('created_by', { name: author })}
|
|
96
|
+
</Text>
|
|
97
|
+
<View style={styles.descriptionContainer}>
|
|
128
98
|
<Text
|
|
129
99
|
numberOfLines={1}
|
|
130
100
|
semibold
|
|
131
|
-
size={
|
|
132
|
-
color={Colors.
|
|
133
|
-
type="
|
|
134
|
-
style={styles.name}
|
|
101
|
+
size={12}
|
|
102
|
+
color={Colors.Gray8}
|
|
103
|
+
type="Label"
|
|
135
104
|
>
|
|
136
|
-
{
|
|
137
|
-
</Text>
|
|
138
|
-
<Text numberOfLines={1} type={'Label'} color={Colors.Gray7}>
|
|
139
|
-
{`${t('create_by')} ${author}`}
|
|
105
|
+
{activateAt && t('activated_time', { time: activateAt })}
|
|
140
106
|
</Text>
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
>
|
|
149
|
-
{activateAt && t('activated_time', { time: activateAt })}
|
|
150
|
-
</Text>
|
|
151
|
-
<IconOutline name="right" size={12} />
|
|
152
|
-
</View>
|
|
153
|
-
</TouchableOpacity>
|
|
154
|
-
</View>
|
|
155
|
-
</TouchableWithoutFeedback>
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
);
|
|
107
|
+
<IconOutline name="right" size={12} />
|
|
108
|
+
</View>
|
|
109
|
+
</TouchableOpacity>
|
|
110
|
+
</View>
|
|
111
|
+
</TouchableWithoutFeedback>
|
|
112
|
+
);
|
|
113
|
+
});
|
|
159
114
|
|
|
160
115
|
export default ItemOneTap;
|