@eohjsc/react-native-smart-city 0.7.3 → 0.7.4
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/Automation-fill.svg +85 -0
- package/assets/images/Map/LocationPin.svg +10 -0
- package/assets/images/Scenario-filled.svg +22 -0
- package/assets/images/schedule-fill.svg +48 -0
- package/package.json +20 -17
- package/src/commons/Action/ItemQuickAction.js +1 -1
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +9 -10
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/index.test.js +6 -6
- package/src/commons/ActionGroup/index.js +2 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
- package/src/commons/Automate/ItemAutomate.js +9 -41
- package/src/commons/Automate/ItemConditionScriptDetail.js +109 -0
- package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
- package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +1 -0
- package/src/commons/ButtonPopup/index.js +3 -2
- package/src/commons/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
- package/src/commons/DateTimeRangeChange/index.js +1 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +20 -19
- package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -3
- package/src/commons/Device/HorizontalBarChart.js +54 -34
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Device/ItemDevice.js +5 -21
- package/src/commons/Device/SonosSpeaker/index.js +3 -3
- package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
- package/src/commons/DisplayChecking/index.js +2 -2
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
- package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
- package/src/commons/FlatListDnD/index.js +12 -9
- package/src/commons/Grid/GridItem.js +10 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
- package/src/commons/Header/HeaderCustom.js +2 -2
- package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
- package/src/commons/HeaderAni/index.js +2 -2
- package/src/commons/IconComponent/index.js +3 -3
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
- package/src/commons/MenuActionMore/MenuActionMoreStyles.js +2 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/NavBar/NavBarStyles.js +1 -1
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
- package/src/commons/Popover/__test__/index.test.js +3 -3
- package/src/commons/Processing/__test__/Connecting.test.js +4 -4
- package/src/commons/SearchLocation/index.js +3 -3
- package/src/commons/SelectActionCard/index.js +2 -2
- package/src/commons/SelectSubUnit/index.js +6 -2
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +5 -5
- package/src/commons/Sharing/BtnRemoveMember.js +2 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +6 -7
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
- package/src/commons/SubUnit/OneTap/index.js +9 -8
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
- package/src/commons/Unit/HeaderUnit/index.js +30 -22
- package/src/commons/Unit/SharedUnit.js +7 -7
- package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +34 -2
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +88 -8
- package/src/commons/WrapParallaxScrollView/index.js +9 -10
- package/src/configs/API.js +1 -1
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Constants.js +3 -3
- package/src/configs/Theme.js +1 -1
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
- package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
- package/src/hooks/IoT/useRemoteControl.js +24 -13
- package/src/hooks/useMqtt.js +2 -2
- package/src/iot/RemoteControl/Bluetooth.js +19 -22
- package/src/iot/RemoteControl/Internet.js +13 -5
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
- package/src/navigations/EmergencyContactsStack.js +4 -3
- package/src/navigations/SharedStack.js +2 -0
- package/src/navigations/UnitStack.js +56 -57
- package/src/screens/AQIGuide/index.js +0 -2
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddLocationMaps/__test__/index.test.js +12 -12
- package/src/screens/AddLocationMaps/index.js +16 -19
- package/src/screens/AddLocationMaps/indexStyle.js +1 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
- package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
- package/src/screens/AddNewGateway/ShareWifiPassword.js +16 -15
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
- package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +38 -22
- package/src/screens/AllGateway/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
- package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
- package/src/screens/AllGateway/test-utils.js +3 -4
- package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
- package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
- package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +12 -12
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +9 -9
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +39 -10
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
- package/src/screens/Automate/Components/InputName.js +10 -7
- package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
- package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
- package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -7
- package/src/screens/Automate/EditActionsList/index.js +19 -17
- package/src/screens/Automate/MultiUnits.js +19 -22
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +18 -8
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
- package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +42 -17
- package/src/screens/Automate/ScriptDetail/__test__/useStarredScript.test.js +6 -6
- package/src/screens/Automate/ScriptDetail/index.js +51 -40
- package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +29 -18
- package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
- package/src/screens/Automate/SetSchedule/index.js +8 -7
- package/src/screens/Automate/Styles/indexStyles.js +1 -1
- package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
- package/src/screens/Automate/__test__/index.test.js +0 -1
- package/src/screens/Automate/index.js +36 -34
- package/src/screens/ChangePosition/__test__/index.test.js +6 -6
- package/src/screens/ChangePosition/index.js +2 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +13 -13
- package/src/screens/Device/EditDevice/index.js +4 -4
- package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
- package/src/screens/Device/__test__/detail.test.js +14 -14
- package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
- package/src/screens/Device/components/BluetoothDevice.js +135 -0
- package/src/screens/Device/components/SensorDisplayItem.js +9 -8
- package/src/screens/Device/detail.js +70 -62
- package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
- package/src/screens/Drawer/Drawer.test.js +2 -2
- package/src/screens/Drawer/index.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
- package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
- package/src/screens/GuestInfo/index.js +2 -2
- package/src/screens/HanetCamera/ManageAccess.js +3 -3
- package/src/screens/HanetCamera/MemberInfo.js +2 -2
- package/src/screens/HanetCamera/__test__/Detail.test.js +9 -9
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +3 -3
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
- package/src/screens/Notification/__test__/Notification.test.js +9 -9
- package/src/screens/Notification/components/NotificationItem.js +3 -4
- package/src/screens/Notification/index.js +3 -3
- package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
- package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +8 -8
- package/src/screens/SelectUnit/index.js +4 -4
- package/src/screens/SharedUnit/TabHeader.js +2 -2
- package/src/screens/Sharing/Components/EndDevice.js +3 -3
- package/src/screens/Sharing/UnitMemberList.js +2 -2
- package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +7 -7
- package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
- package/src/screens/SmartAccount/Connecting/index.js +5 -5
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
- package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
- package/src/screens/SmartIr/components/SelectBrand.js +2 -2
- package/src/screens/SubUnit/AddSubUnit.js +28 -26
- package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
- package/src/screens/SubUnit/EditSubUnit.js +12 -11
- package/src/screens/SubUnit/ManageSubUnit.js +3 -3
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
- package/src/screens/Template/EditTemplate.js +6 -4
- package/src/screens/Template/__test__/EditTemplate.test.js +7 -7
- package/src/screens/Template/__test__/detail.test.js +4 -4
- package/src/screens/Template/__test__/index.test.js +1 -1
- package/src/screens/UVIndexGuide/index.js +2 -4
- package/src/screens/Unit/Detail.js +1 -5
- package/src/screens/Unit/MoreMenu.js +6 -5
- package/src/screens/Unit/SelectAddToFavorites.js +2 -2
- package/src/screens/Unit/SelectAddress.js +16 -12
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/__test__/MoreMenu.test.js +5 -1
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
- package/src/screens/Unit/__test__/Summaries.test.js +7 -7
- package/src/screens/Unit/components/AutomateScript/index.js +5 -5
- package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
- package/src/screens/Unit/components/Header/index.js +2 -2
- package/src/screens/Unit/components/SharedUnit/index.js +5 -5
- package/src/screens/Unit/components/__test__/AutomateScript.test.js +3 -3
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
- package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
- package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +5 -5
- package/src/screens/UnitSummary/index.js +6 -2
- package/src/utils/Apis/axios.js +5 -5
- package/src/utils/Functions/ShortEmail.js +1 -0
- package/src/utils/I18n/translations/en.js +6 -3
- package/src/utils/I18n/translations/vi.js +8 -4
- package/src/utils/__test__/Utils.test.js +16 -16
- package/src/utils/bluetooth.js +3 -0
- package/assets/images/OneTap.svg +0 -14
- package/assets/images/Schedule.svg +0 -39
- package/assets/images/ValueChange.svg +0 -49
|
@@ -6,7 +6,7 @@ import styles from './ControlPlayStyles';
|
|
|
6
6
|
import { Pause } from './Icon';
|
|
7
7
|
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
10
10
|
|
|
11
11
|
const ControlPlay = memo(
|
|
12
12
|
({ onPressPrev, onPressStop, onPressNext, wrapStyle }) => {
|
|
@@ -19,9 +19,9 @@ const ControlPlay = memo(
|
|
|
19
19
|
AccessibilityLabel.SMART_TIVI_TEMPLATE.PREV_BUTTON
|
|
20
20
|
}
|
|
21
21
|
>
|
|
22
|
-
<
|
|
22
|
+
<IconOutline
|
|
23
23
|
size={32}
|
|
24
|
-
name={'
|
|
24
|
+
name={'backward'}
|
|
25
25
|
color={Colors.Gray9}
|
|
26
26
|
style={[styles.button]}
|
|
27
27
|
/>
|
|
@@ -42,9 +42,9 @@ const ControlPlay = memo(
|
|
|
42
42
|
AccessibilityLabel.SMART_TIVI_TEMPLATE.NEXT_BUTTON
|
|
43
43
|
}
|
|
44
44
|
>
|
|
45
|
-
<
|
|
45
|
+
<IconOutline
|
|
46
46
|
size={32}
|
|
47
|
-
name={'
|
|
47
|
+
name={'forward'}
|
|
48
48
|
color={Colors.Gray9}
|
|
49
49
|
style={[styles.button]}
|
|
50
50
|
/>
|
|
@@ -6,7 +6,7 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { View, TouchableOpacity } from 'react-native';
|
|
9
|
-
import
|
|
9
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
10
10
|
import Text from '../../commons/Text';
|
|
11
11
|
import { useConfigGlobalState } from '../../iot/states';
|
|
12
12
|
import styles from './TerminalBoxTemplateStyle';
|
|
@@ -174,7 +174,7 @@ const TerminalBoxTemplate = ({ item, doAction, isWidgetOrder }) => {
|
|
|
174
174
|
accessibilityLabel={AccessibilityLabel.TERMINAL_BOX_BUTTON_SEND}
|
|
175
175
|
disabled={!value}
|
|
176
176
|
>
|
|
177
|
-
<
|
|
177
|
+
<IconOutline name="send" size={25} />
|
|
178
178
|
</TouchableOpacity>
|
|
179
179
|
</View>
|
|
180
180
|
</View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { View, TouchableOpacity } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import Text from '../../commons/Text';
|
|
5
5
|
import { AlertAction } from '../../commons';
|
|
6
6
|
import { useDropdownAction } from './hooks/useDropdownAction';
|
|
@@ -48,7 +48,7 @@ const TextBoxTemplate = ({ item, doAction, isWidgetOrder }) => {
|
|
|
48
48
|
onPress={onShowAlert}
|
|
49
49
|
accessibilityLabel={AccessibilityLabel.TEXT_BOX_BUTTON_EDIT}
|
|
50
50
|
>
|
|
51
|
-
<
|
|
51
|
+
<IconOutline name="edit" size={25} />
|
|
52
52
|
</TouchableOpacity>
|
|
53
53
|
</View>
|
|
54
54
|
<AlertAction
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import renderer, { act } from 'react-test-renderer';
|
|
3
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
|
|
5
5
|
import { SCProvider } from '../../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
@@ -47,6 +47,6 @@ describe('Test ThreeButtonCircle', () => {
|
|
|
47
47
|
await act(async () => {
|
|
48
48
|
touchableOpacities[0].props.onPress();
|
|
49
49
|
});
|
|
50
|
-
expect(mockOnButton1Press).
|
|
50
|
+
expect(mockOnButton1Press).toHaveBeenCalled();
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import renderer, { act } from 'react-test-renderer';
|
|
3
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
|
|
5
5
|
import { SCProvider } from '../../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
@@ -47,6 +47,6 @@ describe('Test ThreeButtonDefault', () => {
|
|
|
47
47
|
await act(async () => {
|
|
48
48
|
touchableOpacities[0].props.onPress();
|
|
49
49
|
});
|
|
50
|
-
expect(mockOnButton1Press).
|
|
50
|
+
expect(mockOnButton1Press).toHaveBeenCalled();
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { Switch, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
5
5
|
import moment from 'moment';
|
|
6
6
|
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
@@ -183,7 +183,10 @@ const TimerActionTemplate = ({ item = {}, doAction, sensor = {} }) => {
|
|
|
183
183
|
<Text>{title}</Text>
|
|
184
184
|
{configuration.config_hour && configuration.config_minute && (
|
|
185
185
|
<View style={styles.wrapTimer}>
|
|
186
|
-
<
|
|
186
|
+
<IconOutline
|
|
187
|
+
style={styles.iconClockCircle}
|
|
188
|
+
name={'clock-circle'}
|
|
189
|
+
/>
|
|
187
190
|
<Text type="Label" color={Colors.Gray7}>
|
|
188
191
|
{textTimer ? textTimer : t('set_time')}
|
|
189
192
|
</Text>
|
|
@@ -193,7 +196,7 @@ const TimerActionTemplate = ({ item = {}, doAction, sensor = {} }) => {
|
|
|
193
196
|
{configuration.config_hour && !configuration.config_minute && (
|
|
194
197
|
<View style={styles.timerButton}>
|
|
195
198
|
<Text style={styles.textTimerEndLine}>{textTimer}</Text>
|
|
196
|
-
<
|
|
199
|
+
<IconOutline name="right" size={20} />
|
|
197
200
|
</View>
|
|
198
201
|
)}
|
|
199
202
|
</TouchableOpacity>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
2
2
|
import React, { memo, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { TouchableOpacity, View } from 'react-native';
|
|
4
4
|
|
|
@@ -122,7 +122,7 @@ const TwoButtonTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
|
|
|
122
122
|
key={index}
|
|
123
123
|
>
|
|
124
124
|
<View style={styles.smallCircle}>
|
|
125
|
-
<
|
|
125
|
+
<IconOutline
|
|
126
126
|
name={button?.isCheckOnOff ? button?.icon_on : button?.icon_off}
|
|
127
127
|
size={44}
|
|
128
128
|
color={button?.isCheckOnOff ? Colors.Green7 : Colors.Gray6}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
2
1
|
import React, { useContext } from 'react';
|
|
2
|
+
import ColorPicker from 'react-native-wheel-color-picker';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import
|
|
5
|
-
import { WheelColorPicker } from '../ColorPickerTemplate';
|
|
4
|
+
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
6
5
|
import { SCProvider } from '../../../context';
|
|
7
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
8
8
|
import { useConfigGlobalState } from '../../../iot/states';
|
|
9
|
-
import
|
|
10
|
-
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
9
|
+
import ColorPickerTemplate, { WheelColorPicker } from '../ColorPickerTemplate';
|
|
11
10
|
|
|
12
11
|
const mockSetAction = jest.fn();
|
|
13
12
|
|
|
@@ -106,7 +105,7 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
106
105
|
await act(async () => {
|
|
107
106
|
await wheelpicker.props.onStart();
|
|
108
107
|
});
|
|
109
|
-
expect(mockSetAction).
|
|
108
|
+
expect(mockSetAction).toHaveBeenCalled();
|
|
110
109
|
});
|
|
111
110
|
|
|
112
111
|
it('test WheelColorPicker onChangeColorComplete', async () => {
|
|
@@ -123,13 +122,13 @@ describe('Test ColorPickerTemplate', () => {
|
|
|
123
122
|
await act(async () => {
|
|
124
123
|
await wheelpicker.props.onStart();
|
|
125
124
|
});
|
|
126
|
-
expect(mockSetAction).
|
|
127
|
-
expect(mockDoAction).
|
|
125
|
+
expect(mockSetAction).toHaveBeenCalledTimes(1);
|
|
126
|
+
expect(mockDoAction).toHaveBeenCalledTimes(0);
|
|
128
127
|
|
|
129
128
|
await act(async () => {
|
|
130
129
|
await wheelpicker.props.onChangeColorComplete('#ffffff');
|
|
131
130
|
});
|
|
132
|
-
expect(mockSetAction).
|
|
133
|
-
expect(mockDoAction).
|
|
131
|
+
expect(mockSetAction).toHaveBeenCalledTimes(2);
|
|
132
|
+
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
134
133
|
});
|
|
135
134
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
2
|
-
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { act, create } from 'react-test-renderer';
|
|
5
|
-
import
|
|
3
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
6
4
|
import { SCProvider } from '../../../context';
|
|
7
5
|
import { mockSCStore } from '../../../context/mockStore';
|
|
6
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
8
7
|
import { useConfigGlobalState } from '../../../iot/states';
|
|
8
|
+
import OnOffSmartLock from '../OnOffSmartLock/OnOffSmartLock';
|
|
9
9
|
|
|
10
10
|
jest.mock('../../../iot/Monitor');
|
|
11
11
|
const mockDoAction = jest.fn();
|
|
@@ -76,7 +76,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
76
76
|
await act(async () => {
|
|
77
77
|
await button.props.onPress();
|
|
78
78
|
});
|
|
79
|
-
expect(mockDoAction).
|
|
79
|
+
expect(mockDoAction).toHaveBeenCalledWith(actionOnData, '{"door_lock":0}');
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('render with template OnOffSmartLockActionTemplate doAction unlock', async () => {
|
|
@@ -96,6 +96,6 @@ describe('Test OnOffTemplate', () => {
|
|
|
96
96
|
await act(async () => {
|
|
97
97
|
await button.props.onPress();
|
|
98
98
|
});
|
|
99
|
-
expect(mockDoAction).
|
|
99
|
+
expect(mockDoAction).toHaveBeenCalledWith(actionOffData, '{"door_lock":1}');
|
|
100
100
|
});
|
|
101
101
|
});
|
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
|
|
4
4
|
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
5
7
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
6
8
|
import OnOffTemplate from '../OnOffTemplate';
|
|
7
9
|
import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
|
|
8
10
|
import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
|
|
9
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
10
|
-
import { SCProvider } from '../../../context';
|
|
11
11
|
|
|
12
12
|
const wrapComponent = (item, mockDoAction, sensor) => (
|
|
13
13
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -118,7 +118,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
118
118
|
const instance = tree.root;
|
|
119
119
|
const template = instance.findAllByType(OnOffSimpleTemplate);
|
|
120
120
|
expect(template).toHaveLength(1);
|
|
121
|
-
expect(watchMultiConfigs).
|
|
121
|
+
expect(watchMultiConfigs).toHaveBeenCalledTimes(0);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
it('template OnOffSimpleActionTemplate doAction with is_on_value, match configValue', async () => {
|
|
@@ -135,7 +135,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
135
135
|
await template.props.triggerAction();
|
|
136
136
|
});
|
|
137
137
|
expect(mockDoAction).toHaveBeenCalledWith(actionOffData, undefined, false);
|
|
138
|
-
expect(watchMultiConfigs).
|
|
138
|
+
expect(watchMultiConfigs).toHaveBeenCalledTimes(0);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
it('template OnOffSimpleActionTemplate doAction with is_on_value, not match configValue', async () => {
|
|
@@ -167,7 +167,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
167
167
|
await template.props.triggerAction();
|
|
168
168
|
});
|
|
169
169
|
expect(mockDoAction).toHaveBeenCalledWith(actionOffData, undefined, false);
|
|
170
|
-
expect(watchMultiConfigs).
|
|
170
|
+
expect(watchMultiConfigs).toHaveBeenCalledTimes(0);
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
it('render with template OnOffSimpleActionTemplate with just action_data', async () => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import OptionsDropdownActionTemplate from '../../../commons/ActionGroup/OptionsDropdownActionTemplate';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { TouchableOpacity } from 'react-native';
|
|
4
3
|
import { act, create } from 'react-test-renderer';
|
|
5
|
-
import Text from '../../../commons/Text';
|
|
6
|
-
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
7
4
|
import { AlertAction, RadioCircle } from '../../../commons';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
5
|
+
import OptionsDropdownActionTemplate from '../../../commons/ActionGroup/OptionsDropdownActionTemplate';
|
|
6
|
+
import Text from '../../../commons/Text';
|
|
7
|
+
import { AccessibilityLabel, DEVICE_TYPE } from '../../../configs/Constants';
|
|
10
8
|
import { SCProvider } from '../../../context';
|
|
11
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
10
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
11
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
12
12
|
|
|
13
|
-
import SvgDoorState from '../../../../assets/images/Device/door-state.svg';
|
|
14
13
|
import SvgCurrentState from '../../../../assets/images/Device/current-state.svg';
|
|
14
|
+
import SvgDoorState from '../../../../assets/images/Device/door-state.svg';
|
|
15
15
|
import SvgWindStrength from '../../../../assets/images/Device/wind-strength.svg';
|
|
16
16
|
|
|
17
17
|
const wrapComponent = (item, mockDoAction, sensor) => (
|
|
@@ -190,8 +190,8 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
190
190
|
value: 1,
|
|
191
191
|
});
|
|
192
192
|
is_managed_by_backend
|
|
193
|
-
? expect(watchMultiConfigs).not.
|
|
194
|
-
: expect(watchMultiConfigs).not.
|
|
193
|
+
? expect(watchMultiConfigs).not.toHaveBeenCalled()
|
|
194
|
+
: expect(watchMultiConfigs).not.toHaveBeenCalled();
|
|
195
195
|
|
|
196
196
|
expect(texts[1].props.children).toEqual('Level2'); // TODO: should be Level1, configValues make change again
|
|
197
197
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
4
5
|
import Text from '../../Text';
|
|
5
6
|
import StatesGridActionTemplate from '../StatesGridActionTemplate';
|
|
6
|
-
import { DEVICE_TYPE } from '../../../configs/Constants';
|
|
7
7
|
|
|
8
8
|
const mockDoAction = jest.fn();
|
|
9
9
|
const mockActionData = jest.fn();
|
|
@@ -74,7 +74,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
74
74
|
await act(async () => {
|
|
75
75
|
await touchableOpacities[0].props.onPress();
|
|
76
76
|
});
|
|
77
|
-
expect(mockDoAction).
|
|
77
|
+
expect(mockDoAction).toHaveBeenCalledWith(mockActionData, null);
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it('test trigger special action', async () => {
|
|
@@ -96,7 +96,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
96
96
|
await act(async () => {
|
|
97
97
|
await touchableOpacities[0].props.onPress();
|
|
98
98
|
});
|
|
99
|
-
expect(mockDoAction).
|
|
99
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
100
100
|
mockActionData,
|
|
101
101
|
JSON.stringify({ config_id: 1, config_value: undefined })
|
|
102
102
|
);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Switch, TouchableOpacity } from 'react-native';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import TimerActionTemplate from '../TimerActionTemplate';
|
|
5
3
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
6
4
|
import ScrollPicker from 'react-native-wheel-scrollview-picker';
|
|
5
|
+
import { act, create } from 'react-test-renderer';
|
|
6
|
+
import TimerActionTemplate from '../TimerActionTemplate';
|
|
7
7
|
|
|
8
8
|
import moment from 'moment';
|
|
9
|
-
import Text from '../../Text';
|
|
10
|
-
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
11
9
|
import { SCProvider } from '../../../context';
|
|
12
10
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
|
+
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
12
|
+
import Text from '../../Text';
|
|
13
13
|
|
|
14
14
|
jest.mock('../../../iot/Monitor');
|
|
15
15
|
|
|
@@ -81,7 +81,7 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
81
81
|
await act(async () => {
|
|
82
82
|
await switchButton.props.onValueChange();
|
|
83
83
|
});
|
|
84
|
-
expect(mockDoAction).
|
|
84
|
+
expect(mockDoAction).toHaveBeenCalled();
|
|
85
85
|
|
|
86
86
|
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
87
87
|
await act(async () => {
|
|
@@ -128,6 +128,6 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
128
128
|
await act(async () => {
|
|
129
129
|
await touchableOpacities[2].props.onPress(3);
|
|
130
130
|
});
|
|
131
|
-
expect(mockDoAction).
|
|
131
|
+
expect(mockDoAction).toHaveBeenCalled();
|
|
132
132
|
});
|
|
133
133
|
});
|
|
@@ -123,7 +123,7 @@ describe('Test TwoButtonTemplate', () => {
|
|
|
123
123
|
expect(touchableOpacities.length).toEqual(2);
|
|
124
124
|
await touchableOpacities[0].props.onPress();
|
|
125
125
|
await touchableOpacities[1].props.onPress();
|
|
126
|
-
expect(mockDoAction).
|
|
126
|
+
expect(mockDoAction).toHaveBeenCalled();
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('render TouchableOpacity TwoButtonTemplate without is_on_value', async () => {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
|
-
TouchableOpacity,
|
|
4
|
-
Switch,
|
|
5
3
|
ActivityIndicator,
|
|
6
4
|
ScrollView,
|
|
5
|
+
Switch,
|
|
6
|
+
TouchableOpacity,
|
|
7
7
|
} from 'react-native';
|
|
8
|
-
import renderer, { act } from 'react-test-renderer';
|
|
9
8
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
9
|
+
import renderer, { act } from 'react-test-renderer';
|
|
10
10
|
|
|
11
|
+
import { Slider } from '@miblanchard/react-native-slider';
|
|
11
12
|
import ActionGroup from '..';
|
|
12
|
-
import Text from '../../Text';
|
|
13
13
|
import { AccessibilityLabel, BUTTON_TYPE } from '../../../configs/Constants';
|
|
14
14
|
import { SCProvider } from '../../../context';
|
|
15
15
|
import { mockSCStore } from '../../../context/mockStore';
|
|
16
|
-
import { Slider } from '@miblanchard/react-native-slider';
|
|
17
|
-
import { WheelColorPicker } from '../ColorPickerTemplate';
|
|
18
16
|
import RadioCircle from '../../RadioCircle';
|
|
17
|
+
import Text from '../../Text';
|
|
18
|
+
import { WheelColorPicker } from '../ColorPickerTemplate';
|
|
19
19
|
import SwitchButtonTemplate from '../OnOffTemplate/SwitchButtonTemplate';
|
|
20
20
|
|
|
21
21
|
const wrapComponent = (item, mockDoAction, sensor) => (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import Text from '../Text';
|
|
3
3
|
import OneBigButtonTemplate from './OneBigButtonTemplate';
|
|
4
4
|
import ThreeButtonTemplate from './ThreeButtonTemplate';
|
|
@@ -74,4 +74,4 @@ const ActionGroup = (params = {}) => {
|
|
|
74
74
|
);
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
export default
|
|
77
|
+
export default ActionGroup;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
|
|
4
|
+
import Modal from 'react-native-modal';
|
|
4
5
|
import ActionTemplate from '..';
|
|
6
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
5
7
|
import { SCProvider } from '../../../context';
|
|
6
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
9
|
import SelectActionCard from '../../SelectActionCard';
|
|
8
|
-
import Modal from 'react-native-modal';
|
|
9
|
-
import ThreeButtonAction from '../ThreeButtonAction';
|
|
10
|
-
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
11
10
|
import Text from '../../Text';
|
|
11
|
+
import ThreeButtonAction from '../ThreeButtonAction';
|
|
12
12
|
import { showAllCards } from './utils';
|
|
13
13
|
|
|
14
14
|
const mockOnSelectAction = jest.fn();
|
|
@@ -81,7 +81,7 @@ describe('Test ActionTemplate', () => {
|
|
|
81
81
|
template: 'three_button_action_template',
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
|
-
expect(mockOnSelectAction).
|
|
84
|
+
expect(mockOnSelectAction).toHaveBeenCalledWith({
|
|
85
85
|
action: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
86
86
|
action_name: 'OPEN',
|
|
87
87
|
data: null,
|
|
@@ -1,72 +1,40 @@
|
|
|
1
|
-
import React, { useCallback
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import { Colors } from '../../configs';
|
|
5
5
|
import styles from './ItemAutomateStyles';
|
|
6
6
|
import { AUTOMATES } from '../../configs/Constants';
|
|
7
7
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
8
|
-
import { generateAutomationConditionText } from '../../screens/Automate/ScriptDetail/utils';
|
|
9
|
-
import { useGetEvaluateValue } from '../../screens/Device/hooks/useEvaluateValue';
|
|
10
8
|
|
|
11
9
|
const ItemAutomate = ({
|
|
12
10
|
automate,
|
|
13
11
|
isSelected = false,
|
|
14
|
-
disabledOnPress = false,
|
|
15
12
|
index,
|
|
16
13
|
setSelectedIndex,
|
|
17
|
-
onPress,
|
|
18
|
-
enableScript = true,
|
|
19
14
|
}) => {
|
|
20
15
|
const t = useTranslations();
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const textCondition = useMemo(() => {
|
|
27
|
-
return generateAutomationConditionText(automate, valueEvaluations, t);
|
|
28
|
-
}, [automate, t, valueEvaluations]);
|
|
29
|
-
|
|
30
|
-
const renderText = useMemo(() => {
|
|
31
|
-
if (textCondition) {
|
|
32
|
-
return textCondition;
|
|
33
|
-
} else if (isSelected && isItemOneTap) {
|
|
34
|
-
return t('quick_button_create_at_dashboard');
|
|
35
|
-
} else {
|
|
36
|
-
return t(item?.explanation);
|
|
37
|
-
}
|
|
38
|
-
}, [isItemOneTap, isSelected, item?.explanation, t, textCondition]);
|
|
16
|
+
const { type } = automate;
|
|
17
|
+
const item = AUTOMATES[type];
|
|
18
|
+
/* istanbul ignore next */
|
|
19
|
+
const { icon: Icon, title, explanation } = item || {};
|
|
39
20
|
|
|
40
21
|
const handleSelectIndex = useCallback(() => {
|
|
41
|
-
if (onPress) {
|
|
42
|
-
onPress();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (!setSelectedIndex) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
22
|
setSelectedIndex(index);
|
|
50
|
-
}, [index, setSelectedIndex
|
|
23
|
+
}, [index, setSelectedIndex]);
|
|
51
24
|
|
|
52
25
|
return (
|
|
53
26
|
<TouchableOpacity
|
|
54
27
|
onPress={handleSelectIndex}
|
|
55
|
-
disabled={disabledOnPress}
|
|
56
28
|
style={[styles.wrap, isSelected && styles.active]}
|
|
57
29
|
>
|
|
58
30
|
<View style={styles.row}>
|
|
59
31
|
<View style={styles.wrapIcon}>{!!Icon && <Icon />}</View>
|
|
60
32
|
<View style={styles.wrapTitle}>
|
|
61
|
-
<Text
|
|
62
|
-
|
|
63
|
-
bold
|
|
64
|
-
color={enableScript ? Colors.Black : Colors.Gray7}
|
|
65
|
-
>
|
|
66
|
-
{t(item?.title)}
|
|
33
|
+
<Text type="H4" bold color={Colors.Black}>
|
|
34
|
+
{t(title)}
|
|
67
35
|
</Text>
|
|
68
36
|
<Text type="Label" color={Colors.Gray8} numberOfLines={1}>
|
|
69
|
-
{
|
|
37
|
+
{t(explanation)}
|
|
70
38
|
</Text>
|
|
71
39
|
</View>
|
|
72
40
|
</View>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import { View, TouchableOpacity, Platform } from 'react-native';
|
|
3
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
4
|
+
import Text from '../Text';
|
|
5
|
+
import { Colors } from '../../configs';
|
|
6
|
+
import styles from './ItemConditionScriptDetailStyles';
|
|
7
|
+
import { AccessibilityLabel, AUTOMATES } from '../../configs/Constants';
|
|
8
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
9
|
+
import { generateAutomationConditionText } from '../../screens/Automate/ScriptDetail/utils';
|
|
10
|
+
import { useGetEvaluateValue } from '../../screens/Device/hooks/useEvaluateValue';
|
|
11
|
+
import MenuActionMore from '../MenuActionMore';
|
|
12
|
+
import { usePopover } from '../../hooks/Common';
|
|
13
|
+
import Routes from '../../utils/Route';
|
|
14
|
+
import { useNavigation } from '@react-navigation/native';
|
|
15
|
+
import { PopoverMode } from 'react-native-popover-view';
|
|
16
|
+
|
|
17
|
+
const ItemConditionScriptDetail = ({
|
|
18
|
+
automate,
|
|
19
|
+
onPress,
|
|
20
|
+
enableScript = true,
|
|
21
|
+
}) => {
|
|
22
|
+
const t = useTranslations();
|
|
23
|
+
const refMenuAction = useRef();
|
|
24
|
+
const { navigate } = useNavigation();
|
|
25
|
+
const { type, config, unit, value_change } = automate;
|
|
26
|
+
const { end_device_id, unit_id } = value_change || {};
|
|
27
|
+
/* istanbul ignore next */
|
|
28
|
+
const item = AUTOMATES[type] || {};
|
|
29
|
+
const { icon: Icon, title } = item;
|
|
30
|
+
const valueEvaluations = useGetEvaluateValue(config, unit);
|
|
31
|
+
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
32
|
+
usePopover();
|
|
33
|
+
|
|
34
|
+
const textCondition = useMemo(
|
|
35
|
+
() => generateAutomationConditionText(automate, valueEvaluations, t),
|
|
36
|
+
[automate, valueEvaluations, t]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const renderText = useMemo(() => {
|
|
40
|
+
if (textCondition) {
|
|
41
|
+
return textCondition;
|
|
42
|
+
}
|
|
43
|
+
return t('quick_button_create_at_dashboard');
|
|
44
|
+
}, [textCondition, t]);
|
|
45
|
+
|
|
46
|
+
const handleShowMenuAction = useCallback(() => {
|
|
47
|
+
showPopoverWithRef(refMenuAction);
|
|
48
|
+
}, [showPopoverWithRef]);
|
|
49
|
+
|
|
50
|
+
const listMenuItem = useMemo(() => {
|
|
51
|
+
const items = [{ text: t('edit_condition'), doAction: onPress }];
|
|
52
|
+
if (value_change) {
|
|
53
|
+
items.unshift({
|
|
54
|
+
text: t('device_display'),
|
|
55
|
+
doAction: () =>
|
|
56
|
+
navigate(Routes.DeviceDetail, {
|
|
57
|
+
unitId: unit_id,
|
|
58
|
+
sensorId: end_device_id,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return items;
|
|
63
|
+
}, [value_change, t, onPress, navigate, unit_id, end_device_id]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View style={styles.wrap}>
|
|
67
|
+
<View style={styles.col}>
|
|
68
|
+
<View style={styles.wrapIcon}>{Icon && <Icon />}</View>
|
|
69
|
+
<View style={styles.wrapTitle}>
|
|
70
|
+
<Text
|
|
71
|
+
type="H4"
|
|
72
|
+
bold
|
|
73
|
+
color={enableScript ? Colors.Black : Colors.Gray7}
|
|
74
|
+
>
|
|
75
|
+
{t(title)}
|
|
76
|
+
</Text>
|
|
77
|
+
<Text type="Label" color={Colors.Gray8} numberOfLines={1}>
|
|
78
|
+
{renderText}
|
|
79
|
+
</Text>
|
|
80
|
+
</View>
|
|
81
|
+
</View>
|
|
82
|
+
<View>
|
|
83
|
+
<TouchableOpacity
|
|
84
|
+
onPress={handleShowMenuAction}
|
|
85
|
+
ref={refMenuAction}
|
|
86
|
+
accessibilityLabel={AccessibilityLabel.ICON_MENU_POPUP}
|
|
87
|
+
>
|
|
88
|
+
<MaterialIcons name="more-vert" size={27} color={Colors.Black} />
|
|
89
|
+
</TouchableOpacity>
|
|
90
|
+
</View>
|
|
91
|
+
<MenuActionMore
|
|
92
|
+
isVisible={showingPopover}
|
|
93
|
+
hideMore={hidePopover}
|
|
94
|
+
listMenuItem={listMenuItem}
|
|
95
|
+
childRef={childRef}
|
|
96
|
+
onItemClick={(object) => object.doAction()}
|
|
97
|
+
isTextCenter={false}
|
|
98
|
+
wrapStyle={styles.wrapStyle}
|
|
99
|
+
mode={
|
|
100
|
+
/* istanbul ignore next */
|
|
101
|
+
Platform.OS === 'ios' ? PopoverMode.JS_MODAL : PopoverMode.RN_MODAL
|
|
102
|
+
}
|
|
103
|
+
accessibilityLabel={AccessibilityLabel.MENU_ACTION_LIST_TOUCHABLE}
|
|
104
|
+
/>
|
|
105
|
+
</View>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default ItemConditionScriptDetail;
|