@eohjsc/react-native-smart-city 0.3.40 → 0.3.42
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/assets/images/AddNewDevice/gateway-icon.svg +12 -0
- package/package.json +1 -1
- package/src/commons/AlertAction/index.js +22 -5
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/WindSpeed/Anemometer/index.js +21 -17
- package/src/commons/Header/HeaderCustom.js +9 -6
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
- package/src/commons/Processing/__test__/Connecting.test.js +1 -1
- package/src/commons/Processing/index.js +60 -6
- package/src/commons/Processing/styles.js +19 -0
- package/src/commons/SelectGateway/index.js +63 -21
- package/src/commons/SelectGateway/styles.js +25 -4
- package/src/commons/SelectSubUnit/index.js +2 -3
- package/src/commons/SelectSubUnit/styles.js +1 -3
- package/src/commons/SubUnit/ShortDetail.js +8 -6
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +3 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +5 -2
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/hooks/Explore/useKeyboardAnimated.js +13 -22
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
- package/src/hooks/IoT/useRemoteControl.js +9 -2
- package/src/iot/RemoteControl/HomeAssistant.js +1 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +2 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +24 -3
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +43 -19
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +28 -26
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +5 -4
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +5 -5
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectRouterGuide.js +7 -7
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +69 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +71 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +88 -59
- package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +18 -14
- package/src/screens/AddNewGateway/ScanGatewayQR.js +2 -1
- package/src/screens/AddNewGateway/ScanModbusQR.js +10 -6
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +3 -3
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +4 -4
- package/src/screens/AddNewGateway/SelectDeviceType.js +18 -18
- package/src/screens/AddNewGateway/SelectModbusGateway.js +17 -4
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +3 -3
- package/src/screens/AddNewGateway/ShareWifiPassword.js +23 -4
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +5 -1
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +12 -5
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +92 -9
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +1 -3
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +3 -1
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +7 -3
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -2
- package/src/screens/Device/EditDevice/index.js +4 -8
- package/src/screens/Explore/index.js +22 -7
- package/src/screens/HanetCamera/MemberInfo.js +4 -8
- package/src/screens/ScriptDetail/index.js +3 -8
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +22 -41
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +51 -59
- package/src/screens/Unit/AddMenu.js +1 -1
- package/src/screens/Unit/Detail.js +3 -1
- package/src/screens/Unit/ManageUnit.js +25 -47
- package/src/screens/Unit/ManageUnitStyles.js +0 -4
- package/src/screens/Unit/__test__/ManageUnit.test.js +6 -14
- package/src/utils/I18n/translations/en.json +21 -3
- package/src/utils/I18n/translations/vi.json +20 -2
- package/src/hooks/Common/useKeyboardShowTranslation.js +0 -120
- package/src/utils/runTiming.js +0 -52
|
@@ -47,7 +47,10 @@ describe('Test connecting modbus device', () => {
|
|
|
47
47
|
route = {
|
|
48
48
|
params: {
|
|
49
49
|
unitId: 1,
|
|
50
|
-
|
|
50
|
+
subUnit: {
|
|
51
|
+
id: 2,
|
|
52
|
+
station: 'Station 2',
|
|
53
|
+
},
|
|
51
54
|
chipId: 3,
|
|
52
55
|
qrData: {},
|
|
53
56
|
},
|
|
@@ -64,6 +67,9 @@ describe('Test connecting modbus device', () => {
|
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
it('receive sensor-id from channel then rename sensor-id', async () => {
|
|
70
|
+
mock.onPost().reply(200, {
|
|
71
|
+
id: 1,
|
|
72
|
+
});
|
|
67
73
|
await act(async () => {
|
|
68
74
|
tree = await create(wrapComponent(route));
|
|
69
75
|
});
|
|
@@ -74,15 +80,16 @@ describe('Test connecting modbus device', () => {
|
|
|
74
80
|
channel = channels[key];
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
|
-
await act(async () => {
|
|
78
|
-
await channel.trigger('progress', { data: { sensorId: 1 } });
|
|
79
|
-
});
|
|
80
83
|
await act(async () => {
|
|
81
84
|
await channel.trigger('progress', { success: 1 });
|
|
82
85
|
});
|
|
83
86
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.RenameNewDevices, {
|
|
87
|
+
addDeviceType: undefined,
|
|
84
88
|
unitId: 1,
|
|
85
|
-
|
|
89
|
+
subUnit: {
|
|
90
|
+
id: 2,
|
|
91
|
+
station: 'Station 2',
|
|
92
|
+
},
|
|
86
93
|
chipId: 3,
|
|
87
94
|
sensorId: 1,
|
|
88
95
|
});
|
|
@@ -59,6 +59,15 @@ describe('Test rename new devices', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('rendering base', async () => {
|
|
62
|
+
route = {
|
|
63
|
+
params: {
|
|
64
|
+
unitId: 1,
|
|
65
|
+
stationId: 2,
|
|
66
|
+
chipId: 3,
|
|
67
|
+
qrData: {},
|
|
68
|
+
addDeviceType: 'gateway',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
62
71
|
await act(async () => {
|
|
63
72
|
tree = await create(wrapComponent(route));
|
|
64
73
|
});
|
|
@@ -81,7 +90,7 @@ describe('Test rename new devices', () => {
|
|
|
81
90
|
expect(mock.history.get).toHaveLength(1);
|
|
82
91
|
});
|
|
83
92
|
|
|
84
|
-
it('rendering
|
|
93
|
+
it('rendering end devices', async () => {
|
|
85
94
|
mock.onGet().reply(200, {
|
|
86
95
|
id: 1,
|
|
87
96
|
name: 'chip',
|
|
@@ -104,14 +113,6 @@ describe('Test rename new devices', () => {
|
|
|
104
113
|
tree = await create(wrapComponent(route));
|
|
105
114
|
});
|
|
106
115
|
const instance = tree.root;
|
|
107
|
-
expect(
|
|
108
|
-
instance.findAll(
|
|
109
|
-
(el) =>
|
|
110
|
-
el.props.accessibilityLabel?.indexOf(
|
|
111
|
-
`${AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE}-sensor`
|
|
112
|
-
) === 0 && el.type === _TextInput
|
|
113
|
-
)
|
|
114
|
-
).toHaveLength(1);
|
|
115
116
|
expect(
|
|
116
117
|
instance.findAll(
|
|
117
118
|
(el) =>
|
|
@@ -126,6 +127,15 @@ describe('Test rename new devices', () => {
|
|
|
126
127
|
mock.onGet().reply(200, {
|
|
127
128
|
can_rename: true,
|
|
128
129
|
});
|
|
130
|
+
route = {
|
|
131
|
+
params: {
|
|
132
|
+
unitId: 1,
|
|
133
|
+
stationId: 2,
|
|
134
|
+
chipId: 3,
|
|
135
|
+
qrData: {},
|
|
136
|
+
addDeviceType: 'gateway',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
129
139
|
await act(async () => {
|
|
130
140
|
tree = await create(wrapComponent(route));
|
|
131
141
|
});
|
|
@@ -154,6 +164,15 @@ describe('Test rename new devices', () => {
|
|
|
154
164
|
id: 1,
|
|
155
165
|
can_rename: true,
|
|
156
166
|
});
|
|
167
|
+
route = {
|
|
168
|
+
params: {
|
|
169
|
+
unitId: 1,
|
|
170
|
+
stationId: 2,
|
|
171
|
+
chipId: 3,
|
|
172
|
+
qrData: {},
|
|
173
|
+
addDeviceType: 'gateway',
|
|
174
|
+
},
|
|
175
|
+
};
|
|
157
176
|
await act(async () => {
|
|
158
177
|
tree = await create(wrapComponent(route));
|
|
159
178
|
});
|
|
@@ -188,4 +207,68 @@ describe('Test rename new devices', () => {
|
|
|
188
207
|
})
|
|
189
208
|
);
|
|
190
209
|
});
|
|
210
|
+
|
|
211
|
+
it('update end device name', async () => {
|
|
212
|
+
mock.onGet().reply(200, {
|
|
213
|
+
id: 1,
|
|
214
|
+
can_rename: true,
|
|
215
|
+
sensors: [
|
|
216
|
+
{
|
|
217
|
+
id: 1,
|
|
218
|
+
name: 'sensor',
|
|
219
|
+
end_devices: [
|
|
220
|
+
{
|
|
221
|
+
id: 1,
|
|
222
|
+
name: 'end_device',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
await act(async () => {
|
|
230
|
+
tree = await create(wrapComponent(route));
|
|
231
|
+
});
|
|
232
|
+
const instance = tree.root;
|
|
233
|
+
|
|
234
|
+
const chipNameField = instance.find(
|
|
235
|
+
(el) =>
|
|
236
|
+
el.props.accessibilityLabel ===
|
|
237
|
+
`${AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE}-end_device-1` &&
|
|
238
|
+
el.type === _TextInput
|
|
239
|
+
);
|
|
240
|
+
await act(async () => {
|
|
241
|
+
chipNameField.props.onChange('new name');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const doneButton = instance.find(
|
|
245
|
+
(el) =>
|
|
246
|
+
el.props.accessibilityLabel === AccessibilityLabel.BUTTON_DONE &&
|
|
247
|
+
el.type === TouchableOpacity
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await act(async () => {
|
|
251
|
+
doneButton.props.onPress();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
expect(mock.history.post).toHaveLength(1);
|
|
255
|
+
expect(mock.history.post[0].data).toEqual(
|
|
256
|
+
JSON.stringify({
|
|
257
|
+
id: 1,
|
|
258
|
+
can_rename: true,
|
|
259
|
+
sensors: [
|
|
260
|
+
{
|
|
261
|
+
id: 1,
|
|
262
|
+
name: 'sensor',
|
|
263
|
+
end_devices: [
|
|
264
|
+
{
|
|
265
|
+
id: 1,
|
|
266
|
+
name: 'new name',
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
});
|
|
191
274
|
});
|
|
@@ -66,8 +66,6 @@ describe('test scan modbus QR', () => {
|
|
|
66
66
|
it('on scan correct QR code', async () => {
|
|
67
67
|
await scanQRCode({ imei: 'SENSOR-xxx' }, jest.fn());
|
|
68
68
|
expect(mockedNavigate).toHaveBeenCalled();
|
|
69
|
-
expect(mockedNavigate.mock.calls[0][0]).toEqual(
|
|
70
|
-
Routes.ConnectingModbusDevice
|
|
71
|
-
);
|
|
69
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.SelectModbusGateway);
|
|
72
70
|
});
|
|
73
71
|
});
|
|
@@ -43,7 +43,9 @@ describe('Test select modbus gateway', () => {
|
|
|
43
43
|
route = {
|
|
44
44
|
params: {
|
|
45
45
|
unitId: 1,
|
|
46
|
-
|
|
46
|
+
subUnit: {
|
|
47
|
+
id: 2,
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
};
|
|
49
51
|
});
|
|
@@ -68,9 +70,11 @@ describe('Test select modbus gateway', () => {
|
|
|
68
70
|
selectGateway.props.onPressNext({ id: 3 });
|
|
69
71
|
});
|
|
70
72
|
|
|
71
|
-
expect(mockedNavigate).toBeCalledWith(Routes.
|
|
73
|
+
expect(mockedNavigate).toBeCalledWith(Routes.ConnectingModbusDevice, {
|
|
72
74
|
unitId: 1,
|
|
73
|
-
|
|
75
|
+
subUnit: {
|
|
76
|
+
id: 2,
|
|
77
|
+
},
|
|
74
78
|
chipId: 3,
|
|
75
79
|
});
|
|
76
80
|
});
|
|
@@ -43,7 +43,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
43
43
|
route = {
|
|
44
44
|
params: {
|
|
45
45
|
unitId: 1,
|
|
46
|
-
|
|
46
|
+
subUnit: {
|
|
47
|
+
id: 2,
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
};
|
|
49
51
|
});
|
|
@@ -70,7 +72,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
70
72
|
|
|
71
73
|
expect(mockedNavigate).toBeCalledWith(Routes.ZigbeeDeviceConnectGuide, {
|
|
72
74
|
unitId: 1,
|
|
73
|
-
|
|
75
|
+
subUnit: {
|
|
76
|
+
id: 2,
|
|
77
|
+
},
|
|
74
78
|
chipId: 3,
|
|
75
79
|
});
|
|
76
80
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useState, useCallback } from 'react';
|
|
2
|
-
import { View, TouchableOpacity
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
4
4
|
import { HeaderCustom } from '../../../commons/Header';
|
|
5
5
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
@@ -72,12 +72,8 @@ const EditDevice = memo(() => {
|
|
|
72
72
|
}
|
|
73
73
|
}, [stateAlertAction.isDelete, deleteSensor, renameSensor]);
|
|
74
74
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
ios: {
|
|
78
|
-
marginBottom: transY,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
75
|
+
const transY = useKeyboardAnimated();
|
|
76
|
+
|
|
81
77
|
return (
|
|
82
78
|
<View style={styles.wrap}>
|
|
83
79
|
<HeaderCustom title={t('edit_device')} isShowSeparator />
|
|
@@ -130,7 +126,7 @@ const EditDevice = memo(() => {
|
|
|
130
126
|
leftButtonClick={hideAlertAction}
|
|
131
127
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
132
128
|
rightButtonClick={handleRenameOrDelete}
|
|
133
|
-
|
|
129
|
+
transY={transY}
|
|
134
130
|
>
|
|
135
131
|
{!stateAlertAction.isDelete && (
|
|
136
132
|
<_TextInput
|
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
StyleSheet,
|
|
6
6
|
ScrollView,
|
|
7
7
|
FlatList,
|
|
8
|
+
Animated,
|
|
9
|
+
Platform,
|
|
10
|
+
Easing,
|
|
8
11
|
} from 'react-native';
|
|
9
|
-
import Animated from 'react-native-reanimated';
|
|
10
12
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
11
13
|
|
|
12
14
|
import { API, Colors } from '../../configs';
|
|
@@ -27,11 +29,8 @@ let page = 1;
|
|
|
27
29
|
const Explore = ({ navigation }) => {
|
|
28
30
|
const t = useTranslations();
|
|
29
31
|
useBlockBackAndroid();
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const animatedStyle = {
|
|
33
|
-
marginBottom: transY,
|
|
34
|
-
};
|
|
32
|
+
const transY = useKeyboard(80);
|
|
33
|
+
const [keyboardAnim] = useState(new Animated.Value(transY));
|
|
35
34
|
|
|
36
35
|
useSCContextSelector((state) => state.language);
|
|
37
36
|
|
|
@@ -122,9 +121,25 @@ const Explore = ({ navigation }) => {
|
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
123
|
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
Animated.timing(keyboardAnim, {
|
|
126
|
+
toValue: transY,
|
|
127
|
+
duration: 220,
|
|
128
|
+
useNativeDriver: false,
|
|
129
|
+
easing: Easing.linear,
|
|
130
|
+
});
|
|
131
|
+
}, [keyboardAnim, transY]);
|
|
132
|
+
|
|
125
133
|
return (
|
|
126
134
|
<SafeAreaView style={styles.container}>
|
|
127
|
-
<Animated.View
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
{ backgroundColor: Colors.White },
|
|
138
|
+
Platform.OS === 'ios' && {
|
|
139
|
+
marginBottom: keyboardAnim,
|
|
140
|
+
},
|
|
141
|
+
]}
|
|
142
|
+
>
|
|
128
143
|
<FlatList
|
|
129
144
|
data={unitsPublic}
|
|
130
145
|
ListHeaderComponent={listHeader}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, Image
|
|
2
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { IconFill } from '@ant-design/icons-react-native';
|
|
5
|
+
|
|
5
6
|
import { HeaderCustom } from '../../commons/Header';
|
|
6
7
|
import { AlertAction, FullLoading } from '../../commons';
|
|
7
8
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
@@ -160,12 +161,7 @@ const HanetMemberInfo = ({ route }) => {
|
|
|
160
161
|
}
|
|
161
162
|
};
|
|
162
163
|
|
|
163
|
-
const
|
|
164
|
-
const animatedStyle = Platform.select({
|
|
165
|
-
ios: {
|
|
166
|
-
marginBottom: transY,
|
|
167
|
-
},
|
|
168
|
-
});
|
|
164
|
+
const transY = useKeyboardAnimated();
|
|
169
165
|
|
|
170
166
|
return (
|
|
171
167
|
<View style={styles.container}>
|
|
@@ -229,7 +225,7 @@ const HanetMemberInfo = ({ route }) => {
|
|
|
229
225
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
230
226
|
rightButtonClick={handleRenameOrDelete}
|
|
231
227
|
rightButtonStyle={{ color: stateAlertAction.rightColor }}
|
|
232
|
-
|
|
228
|
+
transY={transY}
|
|
233
229
|
>
|
|
234
230
|
{!stateAlertAction.isDelete && (
|
|
235
231
|
<TextInput
|
|
@@ -6,7 +6,7 @@ import React, {
|
|
|
6
6
|
useEffect,
|
|
7
7
|
memo,
|
|
8
8
|
} from 'react';
|
|
9
|
-
import { View, TouchableOpacity, Image
|
|
9
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
10
10
|
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
11
11
|
import { Icon } from '@ant-design/react-native';
|
|
12
12
|
|
|
@@ -83,12 +83,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
83
83
|
(state) => state.app.popoverAnimating
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
const animatedStyle = Platform.select({
|
|
88
|
-
ios: {
|
|
89
|
-
marginBottom: transY,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
86
|
+
const transY = useKeyboardAnimated();
|
|
92
87
|
|
|
93
88
|
const renameScript = useCallback(async () => {
|
|
94
89
|
const { success, data: script } = await axiosPatch(
|
|
@@ -508,7 +503,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
508
503
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
509
504
|
rightButtonClick={handleRenameOrDelete}
|
|
510
505
|
rightButtonStyle={{ color: stateAlertAction.rightColor }}
|
|
511
|
-
|
|
506
|
+
transY={transY}
|
|
512
507
|
>
|
|
513
508
|
{!stateAlertAction.isDelete && havePermission && (
|
|
514
509
|
<_TextInput
|
|
@@ -74,8 +74,9 @@ const SubUnitDetail = ({ route }) => {
|
|
|
74
74
|
|
|
75
75
|
const onAdd = useCallback(() => {
|
|
76
76
|
navigation.navigate(Routes.AddGatewayStack, {
|
|
77
|
-
screen: Routes.
|
|
77
|
+
screen: Routes.SelectDeviceType,
|
|
78
78
|
params: {
|
|
79
|
+
stationName: station.name,
|
|
79
80
|
stationId: station.id,
|
|
80
81
|
unitId: unit.id,
|
|
81
82
|
unitName: unit.name,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, Image
|
|
2
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { connect } from 'react-redux';
|
|
4
4
|
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
@@ -17,15 +17,12 @@ import useBoolean from '../../hooks/Common/useBoolean';
|
|
|
17
17
|
import { ImagePicker, Section } from '../../commons';
|
|
18
18
|
import AlertAction from '../../commons/AlertAction';
|
|
19
19
|
import _TextInput from '../../commons/Form/TextInput';
|
|
20
|
-
import ViewButtonBottom from '../../commons/ViewButtonBottom';
|
|
21
20
|
import Text from '../../commons/Text';
|
|
22
21
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
23
22
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
24
23
|
import { useEmeragencyContacts } from './hooks/useEmergencyContacts';
|
|
25
|
-
import Animated from 'react-native-reanimated';
|
|
26
24
|
import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
|
|
27
25
|
import styles from './EditSubUnitStyles';
|
|
28
|
-
import { ModalCustom } from '../../commons/Modal';
|
|
29
26
|
|
|
30
27
|
const EditSubUnit = ({ route }) => {
|
|
31
28
|
const { unit, station } = route?.params || {};
|
|
@@ -164,12 +161,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
164
161
|
});
|
|
165
162
|
}, [group, navigation, unit.id]);
|
|
166
163
|
|
|
167
|
-
const
|
|
168
|
-
const animatedStyle = Platform.select({
|
|
169
|
-
ios: {
|
|
170
|
-
marginBottom: transY,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
164
|
+
const transY = useKeyboardAnimated();
|
|
173
165
|
|
|
174
166
|
return (
|
|
175
167
|
<View style={styles.container}>
|
|
@@ -220,6 +212,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
220
212
|
<Text
|
|
221
213
|
type={'Body'}
|
|
222
214
|
color={contactsName.length > 0 ? Colors.Primary : Colors.Gray6}
|
|
215
|
+
accessibilityLabel={AccessibilityLabel.CONTACT_NAME}
|
|
223
216
|
>
|
|
224
217
|
{contactsName.length > 0
|
|
225
218
|
? contactsName.join(', ')
|
|
@@ -253,37 +246,25 @@ const EditSubUnit = ({ route }) => {
|
|
|
253
246
|
)}
|
|
254
247
|
</View>
|
|
255
248
|
</View>
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
<AlertAction
|
|
250
|
+
visible={showEdit}
|
|
251
|
+
hideModal={setHideEdit}
|
|
252
|
+
title={t('rename_sub_unit')}
|
|
253
|
+
leftButtonTitle={t('cancel')}
|
|
254
|
+
leftButtonClick={setHideEdit}
|
|
255
|
+
rightButtonTitle={t('rename')}
|
|
256
|
+
rightButtonClick={goRename}
|
|
257
|
+
transY={transY}
|
|
258
|
+
accessibilityLabel={AccessibilityLabel.MANAGE_UNIT_MODAL_RENAME}
|
|
262
259
|
>
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
defaultValue={station.name}
|
|
272
|
-
onChange={onChangeName}
|
|
273
|
-
textInputStyle={styles.textInputStyle}
|
|
274
|
-
wrapStyle={styles.textInputWrapStyle}
|
|
275
|
-
selectionColor={Colors.Primary}
|
|
276
|
-
/>
|
|
277
|
-
|
|
278
|
-
<ViewButtonBottom
|
|
279
|
-
leftTitle={t('cancel')}
|
|
280
|
-
onLeftClick={setHideEdit}
|
|
281
|
-
rightTitle={t('rename')}
|
|
282
|
-
onRightClick={goRename}
|
|
283
|
-
/>
|
|
284
|
-
</View>
|
|
285
|
-
</Animated.View>
|
|
286
|
-
</ModalCustom>
|
|
260
|
+
<_TextInput
|
|
261
|
+
defaultValue={station.name}
|
|
262
|
+
onChange={onChangeName}
|
|
263
|
+
textInputStyle={styles.textInputStyle}
|
|
264
|
+
wrapStyle={styles.textInputWrapStyle}
|
|
265
|
+
selectionColor={Colors.Primary}
|
|
266
|
+
/>
|
|
267
|
+
</AlertAction>
|
|
287
268
|
<AlertAction
|
|
288
269
|
visible={showModalRemoveSubUnit}
|
|
289
270
|
hideModal={hideRemoveSubUnitModal}
|
|
@@ -293,7 +274,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
293
274
|
rightButtonTitle={t('remove')}
|
|
294
275
|
leftButtonClick={hideRemoveSubUnitModal}
|
|
295
276
|
rightButtonClick={onRemoveSubUnit}
|
|
296
|
-
|
|
277
|
+
transY={transY}
|
|
297
278
|
/>
|
|
298
279
|
</View>
|
|
299
280
|
);
|