@eohjsc/react-native-smart-city 0.3.28 → 0.3.31
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 +1 -1
- package/src/Images/DevMode/close.png +0 -0
- package/src/Images/DevMode/close@2x.png +0 -0
- package/src/Images/DevMode/close@3x.png +0 -0
- package/src/Images/DevMode/plus.png +0 -0
- package/src/Images/DevMode/plus@2x.png +0 -0
- package/src/Images/DevMode/plus@3x.png +0 -0
- package/src/Images/DevMode/remove_circle.png +0 -0
- package/src/Images/DevMode/remove_circle@2x.png +0 -0
- package/src/Images/DevMode/remove_circle@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +36 -17
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +13 -8
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +37 -44
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +7 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -2
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +28 -18
- package/src/commons/ActionGroup/SliderRangeTemplate.js +24 -16
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +48 -58
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +134 -132
- package/src/commons/ActionGroup/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/index.js +35 -10
- 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/BottomButtonView/index.js +1 -0
- package/src/commons/Button/index.js +2 -0
- package/src/commons/DevMode/CardDevMode.js +42 -0
- package/src/commons/DevMode/EmptyComponent.js +18 -0
- package/src/commons/DevMode/Item.js +21 -0
- package/src/commons/DevMode/Styles/CardStyles.js +40 -0
- package/src/commons/DevMode/Styles/EmptyComponentStyles.js +15 -0
- package/src/commons/DevMode/Styles/ItemStyles.js +27 -0
- package/src/commons/DevMode/Styles/TextWithLabelStyles.js +36 -0
- package/src/commons/DevMode/TextWithLabel.js +30 -0
- package/src/commons/DevMode/index.js +5 -1
- package/src/commons/Device/DeviceAlertStatus.js +1 -1
- package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
- package/src/commons/Device/ItemAddNew/index.js +5 -1
- package/src/commons/Device/ItemDevice.js +12 -9
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -1
- package/src/commons/Device/WindDirection/Compass/index.js +1 -1
- package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
- package/src/commons/Header/HeaderCustom.js +8 -2
- package/src/commons/HeaderAni/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +14 -2
- package/src/commons/NavBar/index.js +13 -1
- package/src/commons/Popover/index.js +7 -6
- package/src/commons/Sharing/WrapHeaderScrollable.js +4 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -1
- package/src/commons/SubUnit/ShortDetail.js +1 -0
- package/src/commons/SummaryItem/index.js +2 -1
- 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/API.js +6 -0
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +16 -0
- package/src/configs/Images.js +3 -0
- package/src/context/actionType.ts +12 -0
- package/src/context/mockStore.ts +12 -0
- package/src/context/reducer.ts +43 -1
- package/src/hooks/Common/useDevicesStatus.js +1 -1
- package/src/hooks/IoT/useValueEvaluation.js +10 -19
- package/src/iot/RemoteControl/GoogleHome.js +6 -6
- package/src/navigations/Main.js +26 -2
- package/src/navigations/UnitStack.js +5 -8
- package/src/screens/AddNewAction/Device/index.js +5 -1
- package/src/screens/AddNewAction/SelectAction.js +36 -15
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +1 -0
- package/src/screens/AddNewAutoSmart/index.js +2 -0
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +13 -1
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +27 -0
- package/src/screens/Device/components/DetailHistoryChart.js +7 -5
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +10 -11
- package/src/screens/Device/components/SensorDisplayItem.js +49 -24
- package/src/screens/Device/detail.js +38 -17
- package/src/screens/Device/hooks/useFavoriteDevice.js +4 -2
- package/src/screens/Drawer/index.js +9 -4
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +4 -7
- package/src/screens/Notification/__test__/NotificationItem.test.js +74 -104
- package/src/screens/Notification/components/NotificationItem.js +40 -239
- package/src/screens/ScriptDetail/__test__/index.test.js +40 -1
- package/src/screens/ScriptDetail/index.js +2 -1
- package/src/screens/Sharing/Components/SensorItem.js +4 -1
- package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
- package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +4 -0
- package/src/screens/Sharing/Components/TitleCheckBox.js +17 -8
- package/src/screens/Template/EditTemplate.js +151 -0
- package/src/screens/Template/GatewayList.js +51 -0
- package/src/screens/Template/Information.js +41 -0
- package/src/screens/Template/Styles/EditTemplateStyle.js +109 -0
- package/src/screens/Template/Styles/GatewayStyles.js +46 -0
- package/src/screens/Template/Styles/InformationStyles.js +16 -0
- package/src/screens/Template/Styles/detailStyles.js +35 -0
- package/src/screens/Template/Styles/indexStyles.js +2 -33
- package/src/screens/Template/__test__/EditTemplate.test.js +89 -0
- package/src/screens/Template/__test__/GatewayList.test.js +26 -0
- package/src/screens/Template/__test__/Information.test.js +16 -0
- package/src/screens/Template/__test__/detail.test.js +60 -0
- package/src/screens/Template/__test__/index.test.js +26 -1
- package/src/screens/Template/detail.js +154 -0
- package/src/screens/Template/index.js +39 -32
- package/src/screens/Unit/Detail.js +11 -1
- package/src/screens/Unit/MoreMenu.js +16 -1
- package/src/screens/Unit/SelectAddToFavorites.js +11 -1
- package/src/screens/Unit/SmartAccount.js +1 -1
- package/src/screens/Unit/Station/__test__/index.test.js +18 -2
- package/src/screens/Unit/Station/index.js +0 -1
- package/src/screens/Unit/Summaries.js +6 -1
- package/src/screens/Unit/__test__/Detail.test.js +73 -43
- package/src/screens/Unit/__test__/SmartAccount.test.js +42 -25
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/utils/I18n/translations/en.json +37 -42
- package/src/utils/I18n/translations/vi.json +35 -44
- package/src/utils/Route/index.js +6 -0
|
@@ -21,6 +21,8 @@ const WrapParallaxScrollView = ({
|
|
|
21
21
|
hideRight,
|
|
22
22
|
hideRightPlus,
|
|
23
23
|
contentBackground,
|
|
24
|
+
accessibilityLabel,
|
|
25
|
+
idButtonMore,
|
|
24
26
|
}) => {
|
|
25
27
|
const renderForeground = useCallback(
|
|
26
28
|
() => (
|
|
@@ -32,6 +34,7 @@ const WrapParallaxScrollView = ({
|
|
|
32
34
|
onMore={onMore}
|
|
33
35
|
hideRight={hideRight}
|
|
34
36
|
hideRightPlus={hideRightPlus}
|
|
37
|
+
idButtonMore={idButtonMore}
|
|
35
38
|
/>
|
|
36
39
|
<Text semibold style={styles.nameUnit}>
|
|
37
40
|
{title}
|
|
@@ -39,7 +42,16 @@ const WrapParallaxScrollView = ({
|
|
|
39
42
|
{contentBackground}
|
|
40
43
|
</View>
|
|
41
44
|
),
|
|
42
|
-
[
|
|
45
|
+
[
|
|
46
|
+
onBack,
|
|
47
|
+
onAdd,
|
|
48
|
+
onMore,
|
|
49
|
+
hideRight,
|
|
50
|
+
hideRightPlus,
|
|
51
|
+
idButtonMore,
|
|
52
|
+
title,
|
|
53
|
+
contentBackground,
|
|
54
|
+
]
|
|
43
55
|
);
|
|
44
56
|
const renderBackground = useCallback(
|
|
45
57
|
() => (
|
|
@@ -68,10 +80,11 @@ const WrapParallaxScrollView = ({
|
|
|
68
80
|
onMore={onMore}
|
|
69
81
|
hideRight={hideRight}
|
|
70
82
|
hideRightPlus={hideRightPlus}
|
|
83
|
+
idButtonMore={idButtonMore}
|
|
71
84
|
/>
|
|
72
85
|
</View>
|
|
73
86
|
),
|
|
74
|
-
[title, onBack, onAdd, onMore, hideRight, hideRightPlus]
|
|
87
|
+
[title, onBack, onAdd, onMore, hideRight, hideRightPlus, idButtonMore]
|
|
75
88
|
);
|
|
76
89
|
return (
|
|
77
90
|
<ParallaxScrollView
|
|
@@ -83,6 +96,7 @@ const WrapParallaxScrollView = ({
|
|
|
83
96
|
backgroundColor={Colors.White}
|
|
84
97
|
refreshControl={refreshControl}
|
|
85
98
|
showsVerticalScrollIndicator={false}
|
|
99
|
+
accessibilityLabel={accessibilityLabel}
|
|
86
100
|
>
|
|
87
101
|
{children}
|
|
88
102
|
</ParallaxScrollView>
|
package/src/configs/API.js
CHANGED
|
@@ -200,6 +200,12 @@ const API = {
|
|
|
200
200
|
PUSHER: {
|
|
201
201
|
AUTH: () => '/smart_parking/pusher/auth/',
|
|
202
202
|
},
|
|
203
|
+
// NOTE: DEV MODE
|
|
204
|
+
DEV_MODE: {
|
|
205
|
+
GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/templates/',
|
|
206
|
+
GET_WIDGETS: (templateId) =>
|
|
207
|
+
`/property_manager/iot_dashboard/dev_mode/templates/${templateId}/list_widgets/`,
|
|
208
|
+
},
|
|
203
209
|
};
|
|
204
210
|
|
|
205
211
|
export default API;
|
package/src/configs/Colors.js
CHANGED
|
@@ -135,6 +135,10 @@ export const Colors = {
|
|
|
135
135
|
BlueTransparent5: 'rgba(230, 247, 255, 0.5)',
|
|
136
136
|
Neutral: {
|
|
137
137
|
Neutral3: '#E6E6E6',
|
|
138
|
+
Neutral4: '#B3B3B3',
|
|
138
139
|
Neutral5: '#595959',
|
|
139
140
|
},
|
|
141
|
+
BlackRussian: '#1D2129',
|
|
142
|
+
Salem: '#008040',
|
|
143
|
+
LightGreen: '#8AE699',
|
|
140
144
|
};
|
package/src/configs/Constants.js
CHANGED
|
@@ -313,11 +313,13 @@ export const TESTID = {
|
|
|
313
313
|
SUB_UNIT_GO_DETAIL: 'SUB_UNIT_GO_DETAIL',
|
|
314
314
|
VIEW_SUB_UNIT_AUTOMATE: 'VIEW_SUB_UNIT_AUTOMATE',
|
|
315
315
|
SUB_UNIT_NAME: 'SUB_UNIT_NAME',
|
|
316
|
+
SUB_UNIT_FAVORITES: 'SUB_UNIT_FAVORITES',
|
|
316
317
|
ANIMATED_SCROLL: 'ANIMATED_SCROLL',
|
|
317
318
|
ADD_SUB_UNIT: 'ADD_SUB_UNIT',
|
|
318
319
|
|
|
319
320
|
// NavBar
|
|
320
321
|
NAVBAR_ICON_BARS: 'NAVBAR_ICON_BARS',
|
|
322
|
+
NAVBAR_ICON_BARS_ADD_FAVORITES: 'NAVBAR_ICON_BARS_ADD_FAVORITES',
|
|
321
323
|
NAVBAR_MENU_ACTION_MORE: 'NAVBAR_MENU_ACTION_MORE',
|
|
322
324
|
NAVBAR_ON_SNAP_ITEM: 'NAVBAR_ON_SNAP_ITEM',
|
|
323
325
|
|
|
@@ -400,6 +402,11 @@ export const TESTID = {
|
|
|
400
402
|
//Unit Detail
|
|
401
403
|
UNIT_DETAIL_STATION_LIST: 'UNIT_DETAIL_STATION_LIST',
|
|
402
404
|
UNIT_DETAIL_UNIT_SUMMARY_VIEW: 'UNIT_DETAIL_UNIT_SUMMARY_VIEW',
|
|
405
|
+
UNIT_DETAIL_UNIT_SUMMARY_ITEM: 'UNIT_DETAIL_UNIT_SUMMARY_ITEM',
|
|
406
|
+
UNIT_DETAIL_PARALLAX_SCROLLVIEW: 'UNIT_DETAIL_PARALLAX_SCROLLVIEW',
|
|
407
|
+
UNIT_DETAIL_PARALLAX_BUTTON_MORE: 'UNIT_DETAIL_PARALLAX_BUTTON_MORE',
|
|
408
|
+
UNIT_DETAIL_POPUP_MORE: 'UNIT_DETAIL_POPUP_MORE',
|
|
409
|
+
UNIT_DETAIL_POPUP_MORE_ITEM: 'UNIT_DETAIL_POPUP_MORE_ITEM',
|
|
403
410
|
|
|
404
411
|
ON_CHECK_SPOT_NUMBER: 'ON_CHECK_SPOT_NUMBER',
|
|
405
412
|
ON_BOOK_NOW: 'ON_BOOK_NOW',
|
|
@@ -422,6 +429,7 @@ export const TESTID = {
|
|
|
422
429
|
|
|
423
430
|
// Automate
|
|
424
431
|
AUTOMATE_SCRIPT_ACTION: 'AUTOMATE_SCRIPT_ACTION',
|
|
432
|
+
AUTOMATE_SCRIPT_NAME: 'AUTOMATE_SCRIPT_NAME',
|
|
425
433
|
NAME_YOUR_BUTTON: 'NAME_YOUR_BUTTON',
|
|
426
434
|
BUTTON_ACTIVATE_ONE_TAP: 'BUTTON_ACTIVATE_ONE_TAP',
|
|
427
435
|
BUTTON_EDIT_SCRIPT_ACTION: 'BUTTON_EDIT_SCRIPT_ACTION',
|
|
@@ -439,6 +447,7 @@ export const TESTID = {
|
|
|
439
447
|
|
|
440
448
|
// Header Device
|
|
441
449
|
HEADER_DEVICE_BUTTON_STAR: 'HEADER_DEVICE_BUTTON_STAR',
|
|
450
|
+
HEADER_SCRIPT_DETAIL_BUTTON_STAR: 'HEADER_SCRIPT_DETAIL_BUTTON_STAR',
|
|
442
451
|
HEADER_DEVICE_BUTTON_MORE: 'HEADER_DEVICE_BUTTON_MORE',
|
|
443
452
|
|
|
444
453
|
// EMERGENCY BUTTON
|
|
@@ -661,6 +670,13 @@ export const TESTID = {
|
|
|
661
670
|
ADD_NEW_DEVICE_ADD: 'ADD_NEW_DEVICE_ADD',
|
|
662
671
|
ADD_NEW_DEVICE_THEN_SELECT: 'ADD_NEW_DEVICE_THEN_SELECT',
|
|
663
672
|
|
|
673
|
+
// Add Favorites
|
|
674
|
+
TOUCH_ADD_NEW_FAVORITES: 'TOUCH_ADD_NEW_FAVORITES',
|
|
675
|
+
LIST_FAVORITES: 'LIST_FAVORITES',
|
|
676
|
+
TOUCHABLE_ACTION_ADD_ITEM_FAVORITE: 'TOUCHABLE_ACTION_ADD_ITEM_FAVORITE',
|
|
677
|
+
TOUCHABLE_ACTION_ADD_ITEM_AUTOMATE_FAVORITE:
|
|
678
|
+
'TOUCHABLE_ACTION_ADD_ITEM_AUTOMATE_FAVORITE',
|
|
679
|
+
|
|
664
680
|
// Setup gateway wifi
|
|
665
681
|
SETUP_GATEWAY_WIFI_TITLE: 'SETUP_GATEWAY_WIFI_TITLE',
|
|
666
682
|
SETUP_GATEWAY_WIFI_PLEASE_SELECT_A_WIFI: 'SETUP_GATEWAY_PLEASE_SELECT_A_WIFI',
|
package/src/configs/Images.js
CHANGED
|
@@ -19,4 +19,7 @@ export default {
|
|
|
19
19
|
gateway: require('../Images/DevMode/gateway.png'),
|
|
20
20
|
menu: require('../Images/DevMode/menu.png'),
|
|
21
21
|
search: require('../Images/DevMode/search.png'),
|
|
22
|
+
close: require('../Images/DevMode/close.png'),
|
|
23
|
+
plus: require('../Images/DevMode/plus.png'),
|
|
24
|
+
removeCircle: require('../Images/DevMode/remove_circle.png'),
|
|
22
25
|
};
|
|
@@ -24,6 +24,11 @@ export const Action = {
|
|
|
24
24
|
ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
|
|
25
25
|
SET_DEVICES_STATUS: 'SET_DEVICES_STATUS',
|
|
26
26
|
SET_POPOVER_ANIMATING: 'SET_POPOVER_ANIMATING',
|
|
27
|
+
SET_LOCK_VIEW_PICK_COLOR: 'SET_LOCK_VIEW_PICK_COLOR',
|
|
28
|
+
// NOTE: DEV MODE
|
|
29
|
+
SET_WIDGET_DRAGGING: 'SET_WIDGET_DRAGGING',
|
|
30
|
+
SET_IS_EDITING_TEMPLATE: 'SET_IS_EDITING_TEMPLATE',
|
|
31
|
+
SET_IS_IN_EDIT_TEMPLATE_SCREEN: 'SET_IS_IN_EDIT_TEMPLATE_SCREEN',
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
export type AuthData = {
|
|
@@ -82,6 +87,7 @@ export type AppType = {
|
|
|
82
87
|
camera_opened: any[];
|
|
83
88
|
notificationData: any;
|
|
84
89
|
popoverAnimating: boolean;
|
|
90
|
+
isLockWhenPickColor: boolean;
|
|
85
91
|
};
|
|
86
92
|
|
|
87
93
|
export type IoTType = {
|
|
@@ -92,3 +98,9 @@ export type IoTType = {
|
|
|
92
98
|
statuses: {};
|
|
93
99
|
};
|
|
94
100
|
};
|
|
101
|
+
|
|
102
|
+
export type DevModeType = {
|
|
103
|
+
itemDraggingId: any;
|
|
104
|
+
isEditingTemplate: boolean;
|
|
105
|
+
isInEditTemplateScreen: boolean;
|
|
106
|
+
};
|
package/src/context/mockStore.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const mockDataStore: ContextData = {
|
|
|
38
38
|
isBluetoothEnabled: true,
|
|
39
39
|
isNetworkConnected: true,
|
|
40
40
|
camera_opened: [],
|
|
41
|
+
isLockWhenPickColor: false,
|
|
41
42
|
},
|
|
42
43
|
iot: {
|
|
43
44
|
googlehome: {
|
|
@@ -49,6 +50,11 @@ export const mockDataStore: ContextData = {
|
|
|
49
50
|
},
|
|
50
51
|
valueEvaluations: {},
|
|
51
52
|
fetchedValueEvaluationUnits: [],
|
|
53
|
+
devMode: {
|
|
54
|
+
itemDraggingId: null,
|
|
55
|
+
isEditingTemplate: false,
|
|
56
|
+
isInEditTemplateScreen: false,
|
|
57
|
+
},
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
export const mockSCStore = (data: ContextData): ContextData => {
|
|
@@ -76,6 +82,7 @@ export const mockSCStore = (data: ContextData): ContextData => {
|
|
|
76
82
|
isConnectWifiGateway: false,
|
|
77
83
|
isBluetoothEnabled: true,
|
|
78
84
|
isNetworkConnected: true,
|
|
85
|
+
isLockWhenPickColor: false,
|
|
79
86
|
},
|
|
80
87
|
unit: {
|
|
81
88
|
favoriteDeviceIds: [
|
|
@@ -104,5 +111,10 @@ export const mockSCStore = (data: ContextData): ContextData => {
|
|
|
104
111
|
...data.valueEvaluations,
|
|
105
112
|
},
|
|
106
113
|
fetchedValueEvaluationUnits: [],
|
|
114
|
+
devMode: {
|
|
115
|
+
itemDraggingId: null,
|
|
116
|
+
isEditingTemplate: false,
|
|
117
|
+
isInEditTemplateScreen: false,
|
|
118
|
+
},
|
|
107
119
|
};
|
|
108
120
|
};
|
package/src/context/reducer.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
AutomateType,
|
|
12
12
|
AppType,
|
|
13
13
|
IoTType,
|
|
14
|
+
DevModeType,
|
|
14
15
|
} from './actionType';
|
|
15
16
|
import { uniq, reduce } from 'lodash';
|
|
16
17
|
|
|
@@ -26,6 +27,7 @@ export type ContextData = {
|
|
|
26
27
|
iot: IoTType;
|
|
27
28
|
valueEvaluations: {};
|
|
28
29
|
fetchedValueEvaluationUnits: Array<number>;
|
|
30
|
+
devMode: DevModeType;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export type Action = {
|
|
@@ -61,6 +63,7 @@ export const initialState = {
|
|
|
61
63
|
camera_opened: [],
|
|
62
64
|
notificationData: null,
|
|
63
65
|
popoverAnimating: false,
|
|
66
|
+
isLockWhenPickColor: false,
|
|
64
67
|
},
|
|
65
68
|
iot: {
|
|
66
69
|
googlehome: {
|
|
@@ -72,6 +75,11 @@ export const initialState = {
|
|
|
72
75
|
},
|
|
73
76
|
valueEvaluations: {},
|
|
74
77
|
fetchedValueEvaluationUnits: [],
|
|
78
|
+
devMode: {
|
|
79
|
+
itemDraggingId: null,
|
|
80
|
+
isEditingTemplate: false,
|
|
81
|
+
isInEditTemplateScreen: false,
|
|
82
|
+
},
|
|
75
83
|
};
|
|
76
84
|
|
|
77
85
|
export const reducer = (currentState: ContextData, action: Action) => {
|
|
@@ -317,7 +325,6 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
317
325
|
valueEvaluations: reduce(
|
|
318
326
|
data,
|
|
319
327
|
(dict, item) => {
|
|
320
|
-
// eslint-disable-next-line no-param-reassign
|
|
321
328
|
dict[item.config] = item;
|
|
322
329
|
return dict;
|
|
323
330
|
},
|
|
@@ -351,6 +358,41 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
351
358
|
popoverAnimating: payload,
|
|
352
359
|
},
|
|
353
360
|
};
|
|
361
|
+
case Action.SET_LOCK_VIEW_PICK_COLOR:
|
|
362
|
+
return {
|
|
363
|
+
...currentState,
|
|
364
|
+
app: {
|
|
365
|
+
...currentState.app,
|
|
366
|
+
isLockWhenPickColor: payload,
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
// NOTE: DEV MODE
|
|
370
|
+
case Action.SET_WIDGET_DRAGGING:
|
|
371
|
+
return {
|
|
372
|
+
...currentState,
|
|
373
|
+
devMode: {
|
|
374
|
+
...currentState.devMode,
|
|
375
|
+
itemDraggingId: payload,
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
case Action.SET_IS_EDITING_TEMPLATE:
|
|
380
|
+
return {
|
|
381
|
+
...currentState,
|
|
382
|
+
devMode: {
|
|
383
|
+
...currentState.devMode,
|
|
384
|
+
isEditingTemplate: payload,
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
case Action.SET_IS_IN_EDIT_TEMPLATE_SCREEN:
|
|
389
|
+
return {
|
|
390
|
+
...currentState,
|
|
391
|
+
devMode: {
|
|
392
|
+
...currentState.devMode,
|
|
393
|
+
isInEditTemplateScreen: payload,
|
|
394
|
+
},
|
|
395
|
+
};
|
|
354
396
|
|
|
355
397
|
default:
|
|
356
398
|
return currentState;
|
|
@@ -27,7 +27,7 @@ const useDevicesStatus = (unit, devices) => {
|
|
|
27
27
|
if (success) {
|
|
28
28
|
setAction(Action.SET_DEVICES_STATUS, data);
|
|
29
29
|
}
|
|
30
|
-
timeoutId = setTimeout(() => getDevicesStatus(_unit, _devices),
|
|
30
|
+
timeoutId = setTimeout(() => getDevicesStatus(_unit, _devices), 10000);
|
|
31
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
32
|
}, []);
|
|
33
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useContext, useEffect
|
|
1
|
+
import { useCallback, useContext, useEffect } from 'react';
|
|
2
2
|
import { API } from '../../configs';
|
|
3
3
|
import { SCContext, useSCContextSelector } from '../../context';
|
|
4
4
|
import { Action } from '../../context/actionType';
|
|
@@ -6,14 +6,15 @@ import { axiosGet } from '../../utils/Apis/axios';
|
|
|
6
6
|
|
|
7
7
|
const useValueEvaluations = (unitId) => {
|
|
8
8
|
const { setAction } = useContext(SCContext);
|
|
9
|
-
const
|
|
9
|
+
const fetchedValueEvaluationUnits = useSCContextSelector((state) => {
|
|
10
|
+
return state.fetchedValueEvaluationUnits || [];
|
|
11
|
+
});
|
|
10
12
|
|
|
11
13
|
const fetchConfigValueEvaluations = useCallback(
|
|
12
14
|
async (page = 1) => {
|
|
13
|
-
if (!unitId) {
|
|
15
|
+
if (!unitId || fetchedValueEvaluationUnits.indexOf(unitId) !== -1) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
|
-
setFetching(true);
|
|
17
18
|
const params = new URLSearchParams();
|
|
18
19
|
params.append('config__end_device__station__unit', unitId);
|
|
19
20
|
params.append('page', page);
|
|
@@ -34,25 +35,15 @@ const useValueEvaluations = (unitId) => {
|
|
|
34
35
|
data: [],
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
setFetching(false);
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[unitId, fetchedValueEvaluationUnits]
|
|
40
41
|
);
|
|
41
42
|
|
|
42
|
-
const fetchedValueEvaluationUnits = useSCContextSelector((state) => {
|
|
43
|
-
return state.fetchedValueEvaluationUnits || [];
|
|
44
|
-
});
|
|
45
|
-
|
|
46
43
|
useEffect(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
unitId,
|
|
52
|
-
fetching,
|
|
53
|
-
fetchConfigValueEvaluations,
|
|
54
|
-
fetchedValueEvaluationUnits,
|
|
55
|
-
]);
|
|
44
|
+
fetchConfigValueEvaluations();
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, [unitId]);
|
|
56
47
|
};
|
|
57
48
|
|
|
58
49
|
export default useValueEvaluations;
|
|
@@ -127,12 +127,6 @@ export const googleHomeConnect = async (
|
|
|
127
127
|
for (let i = 0; i < options.length; i++) {
|
|
128
128
|
const option = options[i];
|
|
129
129
|
|
|
130
|
-
if (option.chip_id in oldConnections && !!oldConnections[option.chip_id]) {
|
|
131
|
-
connections[option.chip_id] = oldConnections[option.chip_id];
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
connections[option.chip_id] = 0; // connecting
|
|
135
|
-
|
|
136
130
|
option.config_maps.forEach((configMap) => {
|
|
137
131
|
if (option.text_maps) {
|
|
138
132
|
textMaps[configMap.entity_id] = option.text_maps;
|
|
@@ -156,6 +150,12 @@ export const googleHomeConnect = async (
|
|
|
156
150
|
}
|
|
157
151
|
});
|
|
158
152
|
|
|
153
|
+
if (option.chip_id in oldConnections && !!oldConnections[option.chip_id]) {
|
|
154
|
+
connections[option.chip_id] = oldConnections[option.chip_id];
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
connections[option.chip_id] = 0; // connecting
|
|
158
|
+
|
|
159
159
|
try {
|
|
160
160
|
let auth = new Auth(option.auth);
|
|
161
161
|
const connection = await createConnection({ auth });
|
package/src/navigations/Main.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
|
10
10
|
import { createDrawerNavigator } from '@react-navigation/drawer';
|
|
11
11
|
import { useNavigation } from '@react-navigation/native';
|
|
12
12
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
13
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
13
14
|
|
|
14
15
|
import Tabbar from '../commons/Tabbar';
|
|
15
16
|
import { Colors, Constants, Images } from '../configs';
|
|
@@ -21,9 +22,15 @@ import TemplateStack from './TemplateStack';
|
|
|
21
22
|
import DrawerContainer from '../screens/Drawer';
|
|
22
23
|
import { TESTID } from '../configs/Constants';
|
|
23
24
|
import Text from '../commons/Text';
|
|
25
|
+
import { screenOptions } from './utils';
|
|
26
|
+
import TemplateDetail from '../screens/Template/detail';
|
|
27
|
+
import Information from '../screens/Template/Information';
|
|
28
|
+
import GatewayList from '../screens/Template/GatewayList';
|
|
29
|
+
import EditTemplate from '../screens/Template/EditTemplate';
|
|
24
30
|
|
|
25
31
|
const Tab = createBottomTabNavigator();
|
|
26
32
|
const Drawer = createDrawerNavigator();
|
|
33
|
+
const Stack = createStackNavigator();
|
|
27
34
|
|
|
28
35
|
const getWidth = () => {
|
|
29
36
|
const Width = Constants.width - 12;
|
|
@@ -103,18 +110,35 @@ const MainDevMode = () => {
|
|
|
103
110
|
);
|
|
104
111
|
};
|
|
105
112
|
|
|
106
|
-
const
|
|
113
|
+
const DrawerScreen = () => {
|
|
107
114
|
return (
|
|
108
115
|
<Drawer.Navigator
|
|
109
116
|
backBehavior="none"
|
|
110
117
|
drawerContent={(props) => <DrawerContainer {...props} />}
|
|
111
118
|
drawerStyle={{ paddingTop: getStatusBarHeight() }}
|
|
112
119
|
>
|
|
113
|
-
<Drawer.Screen name={Routes.
|
|
120
|
+
<Drawer.Screen name={Routes.MainDevMode} component={MainDevMode} />
|
|
114
121
|
</Drawer.Navigator>
|
|
115
122
|
);
|
|
116
123
|
};
|
|
117
124
|
|
|
125
|
+
const DevModeStack = () => {
|
|
126
|
+
return (
|
|
127
|
+
<Stack.Navigator
|
|
128
|
+
screenOptions={{
|
|
129
|
+
...screenOptions,
|
|
130
|
+
headerShown: false,
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
<Stack.Screen component={DrawerScreen} name={Routes.DrawerScreen} />
|
|
134
|
+
<Stack.Screen component={TemplateDetail} name={Routes.TemplateDetail} />
|
|
135
|
+
<Stack.Screen component={Information} name={Routes.Information} />
|
|
136
|
+
<Stack.Screen component={GatewayList} name={Routes.GatewayList} />
|
|
137
|
+
<Stack.Screen component={EditTemplate} name={Routes.EditTemplate} />
|
|
138
|
+
</Stack.Navigator>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
118
142
|
export default DevModeStack;
|
|
119
143
|
|
|
120
144
|
const styles = StyleSheet.create({
|
|
@@ -68,7 +68,7 @@ export const UnitStack = memo((props) => {
|
|
|
68
68
|
const t = useTranslations();
|
|
69
69
|
const { setAction } = useContext(SCContext);
|
|
70
70
|
const { route } = props;
|
|
71
|
-
const { unitId, unitData } = route.params.params;
|
|
71
|
+
const { unitId, unitData, isSuccessfullyConnected } = route.params.params;
|
|
72
72
|
|
|
73
73
|
useEffect(() => {
|
|
74
74
|
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
@@ -129,15 +129,12 @@ export const UnitStack = memo((props) => {
|
|
|
129
129
|
}, []);
|
|
130
130
|
|
|
131
131
|
useEffect(() => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (!id) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
132
|
+
const id = unitId || unitData?.id;
|
|
133
|
+
if (id && isSuccessfullyConnected) {
|
|
137
134
|
setAction(Action.NEED_UPDATE_VALUE_EVALUATIONS, id);
|
|
138
|
-
}
|
|
135
|
+
}
|
|
139
136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
-
}, []);
|
|
137
|
+
}, [isSuccessfullyConnected]);
|
|
141
138
|
|
|
142
139
|
return (
|
|
143
140
|
<Stack.Navigator
|
|
@@ -3,6 +3,7 @@ import { TouchableWithoutFeedback, View } from 'react-native';
|
|
|
3
3
|
import { Colors } from '../../../configs';
|
|
4
4
|
import Text from '../../../commons/Text';
|
|
5
5
|
import IconComponent from '../../../commons/IconComponent';
|
|
6
|
+
import { TESTID } from '../../../configs/Constants';
|
|
6
7
|
import styles from './DeviceStyles';
|
|
7
8
|
|
|
8
9
|
const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
|
|
@@ -13,7 +14,10 @@ const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
return (
|
|
16
|
-
<TouchableWithoutFeedback
|
|
17
|
+
<TouchableWithoutFeedback
|
|
18
|
+
onPress={onPressDevice}
|
|
19
|
+
accessibilityLabel={`${TESTID.TOUCHABLE_ACTION_ADD_ITEM_FAVORITE}-${sensor.id}`}
|
|
20
|
+
>
|
|
17
21
|
<View style={[styles.container, isActive]}>
|
|
18
22
|
<View style={styles.boxIcon}>
|
|
19
23
|
<IconComponent
|
|
@@ -10,7 +10,7 @@ import ActionTemplate from '../../commons/ActionTemplate';
|
|
|
10
10
|
import NumberUpDownActionTemplate from '../../commons/OneTapTemplate/NumberUpDownActionTemplate';
|
|
11
11
|
import OptionsDropdownActionTemplate from '../../commons/OneTapTemplate/OptionsDropdownActionTemplate';
|
|
12
12
|
import StatesGridActionTemplate from '../../commons/OneTapTemplate/StatesGridActionTemplate';
|
|
13
|
-
import { axiosGet, axiosPost } from '../../utils/Apis/axios';
|
|
13
|
+
import { axiosGet, axiosPost, axiosPut } from '../../utils/Apis/axios';
|
|
14
14
|
import { API, Images } from '../../configs';
|
|
15
15
|
import {
|
|
16
16
|
CONDITION_TYPES,
|
|
@@ -159,19 +159,35 @@ const SelectAction = memo(({ route }) => {
|
|
|
159
159
|
await checkConditionToContinue();
|
|
160
160
|
} else {
|
|
161
161
|
if (automateId) {
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
let result = false;
|
|
163
|
+
if (isCreateNewAction) {
|
|
164
|
+
let list_action = [...actions];
|
|
165
|
+
list_action = list_action.map((item) => ({
|
|
166
|
+
action: item.action,
|
|
167
|
+
data: item.data,
|
|
168
|
+
}));
|
|
169
|
+
const { success } = await axiosPost(
|
|
170
|
+
API.AUTOMATE.ADD_SCRIPT_ACTION(automateId),
|
|
171
|
+
{
|
|
172
|
+
list_action,
|
|
173
|
+
unit: unit.id,
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
result = success;
|
|
177
|
+
} else {
|
|
178
|
+
const params = {
|
|
179
|
+
unit: isMultiUnits ? null : unit.id,
|
|
180
|
+
type: type,
|
|
181
|
+
name: scriptName,
|
|
182
|
+
action: actions[0].action,
|
|
183
|
+
};
|
|
184
|
+
const { success } = await axiosPut(
|
|
185
|
+
API.AUTOMATE.UPDATE_AUTOMATE(automateId),
|
|
186
|
+
params
|
|
187
|
+
);
|
|
188
|
+
result = success;
|
|
189
|
+
}
|
|
190
|
+
result &&
|
|
175
191
|
navigate(Routes.ScriptDetail, {
|
|
176
192
|
id: automateId,
|
|
177
193
|
name: scriptName,
|
|
@@ -226,12 +242,15 @@ const SelectAction = memo(({ route }) => {
|
|
|
226
242
|
case 'one_button_action_template':
|
|
227
243
|
case 'three_button_action_template':
|
|
228
244
|
case 'OnOffSimpleActionTemplate':
|
|
245
|
+
case 'curtain_action_template':
|
|
229
246
|
index = newActions.findIndex((item) => {
|
|
230
247
|
return (
|
|
231
248
|
item.template === 'on_off_button_action_template' ||
|
|
232
249
|
item.template === 'one_button_action_template' ||
|
|
233
250
|
item.template === 'three_button_action_template' ||
|
|
234
|
-
item.template === 'OnOffSimpleActionTemplate'
|
|
251
|
+
item.template === 'OnOffSimpleActionTemplate' ||
|
|
252
|
+
item.template === 'curtain_action_template' ||
|
|
253
|
+
item.template === 'OnOffSmartLockActionTemplate'
|
|
235
254
|
);
|
|
236
255
|
});
|
|
237
256
|
break;
|
|
@@ -423,6 +442,8 @@ const RenderActionItem = ({ data, onSelectAction }) => {
|
|
|
423
442
|
case 'one_button_action_template':
|
|
424
443
|
case 'three_button_action_template':
|
|
425
444
|
case 'OnOffSimpleActionTemplate':
|
|
445
|
+
case 'curtain_action_template':
|
|
446
|
+
case 'OnOffSmartLockActionTemplate':
|
|
426
447
|
actionTemplate.push(item);
|
|
427
448
|
break;
|
|
428
449
|
case 'OptionsDropdownActionTemplate':
|
|
@@ -78,9 +78,11 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
};
|
|
81
|
+
|
|
81
82
|
const [data] = useState(
|
|
82
83
|
automate?.id ? typeAutoSmart[AUTOMATE_TYPE.AUTOMATE] : typeAutoSmart[type]
|
|
83
84
|
);
|
|
85
|
+
|
|
84
86
|
const [selectedIndex, setSelectedIndex] = useState(
|
|
85
87
|
automate?.id ? data.findIndex((obj) => obj.type === type) : -1
|
|
86
88
|
);
|
|
@@ -4,6 +4,7 @@ import React, {
|
|
|
4
4
|
useCallback,
|
|
5
5
|
useContext,
|
|
6
6
|
useEffect,
|
|
7
|
+
useRef,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
9
10
|
View,
|
|
@@ -45,6 +46,7 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
45
46
|
const [password, setPassword] = useState('');
|
|
46
47
|
const [selectedWifi, setSelectedWifi] = useState('');
|
|
47
48
|
const [isSendWifi, setIsSendWifi] = useState(false);
|
|
49
|
+
const isCheckSocketOnOneTime = useRef(true);
|
|
48
50
|
const { setAction } = useContext(SCContext);
|
|
49
51
|
|
|
50
52
|
const isConnectWifiGateway = useSCContextSelector(
|
|
@@ -106,18 +108,26 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
() => {
|
|
109
|
-
ToastBottomHelper.error('
|
|
111
|
+
ToastBottomHelper.error(t('can_not_login_to_current_ssid'));
|
|
110
112
|
}
|
|
111
113
|
);
|
|
112
114
|
}, 3000);
|
|
113
115
|
}
|
|
116
|
+
if (isCheckSocketOnOneTime.current && data.status === 'error') {
|
|
117
|
+
isCheckSocketOnOneTime.current = false;
|
|
118
|
+
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
119
|
+
setIsShowPopupPassword(false);
|
|
120
|
+
ToastBottomHelper.error(t('confirm_password_not_match'));
|
|
121
|
+
}
|
|
114
122
|
},
|
|
115
123
|
[
|
|
116
124
|
chip_id,
|
|
117
125
|
devicePrefixName,
|
|
126
|
+
isCheckSocketOnOneTime,
|
|
118
127
|
navigate,
|
|
119
128
|
scan_sensor_data,
|
|
120
129
|
setAction,
|
|
130
|
+
t,
|
|
121
131
|
unit_id,
|
|
122
132
|
unit_name,
|
|
123
133
|
wifi_pass,
|
|
@@ -160,6 +170,7 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
160
170
|
goBack();
|
|
161
171
|
});
|
|
162
172
|
|
|
173
|
+
isCheckSocketOnOneTime.current = true;
|
|
163
174
|
sendConnect(0);
|
|
164
175
|
setAction(Action.IS_CONNECT_WIFI_GATEWAY, true);
|
|
165
176
|
setIsSendWifi(true);
|
|
@@ -168,6 +179,7 @@ const GatewayWifiList = memo(({ route }) => {
|
|
|
168
179
|
goBack,
|
|
169
180
|
handleSocketOnMsg,
|
|
170
181
|
isConnectWifiGateway,
|
|
182
|
+
isCheckSocketOnOneTime,
|
|
171
183
|
sendConnect,
|
|
172
184
|
setAction,
|
|
173
185
|
socket,
|