@eohjsc/react-native-smart-city 0.3.31 → 0.3.34
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/add-gateway-icon.svg +13 -0
- package/assets/images/AddNewDevice/add-modbus-device-icon.svg +8 -0
- package/assets/images/AddNewDevice/add-wifi-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/add-zigbee-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/interact-smartphone-icon.svg +14 -0
- package/index.js +2 -0
- package/package.json +8 -5
- package/src/Images/SmartAccount/DienQuang.png +0 -0
- package/src/Images/SmartAccount/DienQuang@2x.png +0 -0
- package/src/Images/SmartAccount/DienQuang@3x.png +0 -0
- package/src/Images/SmartAccount/LG.png +0 -0
- package/src/Images/SmartAccount/LG@2x.png +0 -0
- package/src/Images/SmartAccount/LG@3x.png +0 -0
- package/src/Images/SmartAccount/Samsung.png +0 -0
- package/src/Images/SmartAccount/Samsung@2x.png +0 -0
- package/src/Images/SmartAccount/Samsung@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +20 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +35 -11
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +9 -6
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +5 -2
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +10 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +4 -4
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -6
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +8 -4
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +28 -10
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +25 -12
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +13 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +9 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +16 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +10 -4
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +21 -7
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +4 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +7 -7
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +9 -5
- package/src/commons/ActionGroup/__test__/index.test.js +5 -3
- package/src/commons/ActionTemplate/OnOffButtonAction.js +14 -5
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +23 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
- package/src/commons/ActionTemplate/index.js +1 -0
- package/src/commons/AlertAction/index.js +2 -2
- package/src/commons/Auth/AccountItem.js +9 -3
- package/src/commons/Auth/__test__/AccountItem.test.js +6 -3
- package/src/commons/Automate/ItemAutomate.js +22 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -5
- package/src/commons/Button/index.js +0 -2
- package/src/commons/ButtonPopup/index.js +3 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +4 -2
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +6 -3
- package/src/commons/Dashboard/MyUnit/index.js +5 -3
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +2 -2
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +3 -2
- package/src/commons/Device/FlatListItems.js +2 -2
- package/src/commons/Device/ItemAddNew/index.js +7 -12
- package/src/commons/Device/ItemDevice.js +16 -11
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +5 -2
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +8 -4
- package/src/commons/Device/__test__/FlatListItems.test.js +3 -2
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +4 -2
- package/src/commons/Explore/ActivityIndicator/index.js +5 -2
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +3 -3
- package/src/commons/Explore/SearchBox/index.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +4 -4
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +11 -8
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -2
- package/src/commons/FieldTemplate/PasscodeField/index.js +2 -2
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +12 -7
- package/src/commons/Form/TextInput.js +2 -2
- package/src/commons/Form/TextInputPassword.js +2 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +5 -3
- package/src/commons/GroupCheckBox/index.js +2 -2
- package/src/commons/HeaderAni/index.js +2 -3
- package/src/commons/MediaPlayerDetail/index.js +2 -2
- package/src/commons/MenuActionList/index.js +2 -2
- package/src/commons/MenuActionMore/index.js +2 -3
- package/src/commons/NavBar/index.js +2 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +12 -6
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +7 -3
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +11 -8
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +9 -5
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +5 -3
- package/src/commons/Popover/index.js +2 -13
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -3
- package/src/commons/PreventAccess/index.js +3 -3
- package/src/commons/{Connecting → Processing}/__test__/Connecting.test.js +5 -4
- package/src/commons/Processing/index.js +93 -0
- package/src/commons/{Connecting → Processing}/styles.js +9 -1
- package/src/commons/SelectGateway/index.js +105 -0
- package/src/commons/SelectGateway/styles.js +55 -0
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +106 -0
- package/src/commons/SelectSubUnit/index.js +124 -0
- package/src/commons/SelectSubUnit/styles.js +52 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +105 -0
- package/src/commons/SelectUnit/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -4
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +25 -10
- package/src/commons/SubUnit/OneTap/index.js +9 -4
- package/src/commons/SubUnit/ShortDetail.js +11 -29
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +15 -10
- package/src/commons/SummaryItem/index.js +2 -2
- package/src/commons/Tabbar/__test__/index.test.js +97 -0
- package/src/commons/Unit/HeaderUnit/index.js +4 -5
- package/src/commons/Unit/SharedUnit.js +10 -8
- package/src/commons/Unit/__test__/HeaderUnit.test.js +13 -5
- package/src/commons/Unit/__test__/SharedUnit.test.js +30 -11
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +13 -8
- package/src/commons/UnitSummary/AirQuality/index.js +7 -3
- package/src/commons/UnitSummary/TotalPowerBox.js +2 -2
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -2
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +3 -2
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/commons/ViewButtonBottom/index.js +4 -4
- package/src/commons/WheelDateTimePicker/index.js +5 -3
- package/src/commons/WrapParallaxScrollView/index.js +2 -1
- package/src/configs/API.js +16 -14
- package/src/configs/AccessibilityLabel.js +629 -0
- package/src/configs/Constants.js +1 -604
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +10 -3
- package/src/context/mockStore.ts +6 -3
- package/src/context/reducer.ts +45 -8
- package/src/hoc/__test__/withRemoteControl.test.js +24 -0
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +55 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +19 -15
- package/src/hooks/Common/{useGGHomeDeviceConnected.js → useHomeAssistantDeviceConnected.js} +3 -3
- package/src/hooks/Common/usePopover.js +6 -1
- package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js} +18 -18
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +17 -12
- package/src/hooks/IoT/index.js +2 -2
- package/src/hooks/IoT/useHomeAssistantConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +6 -6
- package/src/hooks/__test__/useInitDeepLink.test.js +28 -0
- package/src/hooks/useReceiveNotifications.js +2 -4
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +21 -17
- package/src/iot/RemoteControl/LG.js +2 -1
- package/src/iot/RemoteControl/__test__/{GoogleHome.test.js → HomeAssistant.test.js} +30 -30
- package/src/navigations/AddDeviceStack.js +0 -14
- package/src/navigations/AddGatewayStack.js +56 -21
- package/src/navigations/Main.js +2 -2
- package/src/navigations/SmartAccountStack.js +52 -0
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +1 -1
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +5 -3
- package/src/screens/AQIGuide/index.js +5 -3
- package/src/screens/ActivityLog/FilterPopup.js +2 -2
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +3 -2
- package/src/screens/ActivityLog/index.js +3 -3
- package/src/screens/AddCommon/SelectSubUnit.js +49 -192
- package/src/screens/AddCommon/SelectUnit.js +58 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +25 -61
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +41 -32
- package/src/screens/AddLocationMaps/__test__/index.test.js +13 -7
- package/src/screens/AddLocationMaps/index.js +3 -3
- package/src/screens/AddNewAction/Device/index.js +2 -2
- package/src/screens/AddNewAction/SelectAction.js +16 -7
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +8 -3
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -7
- package/src/screens/AddNewAutoSmart/index.js +9 -12
- package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +7 -4
- package/src/screens/AddNewDevice/index.js +4 -4
- package/src/screens/AddNewGateway/ConnectingDevice.js +40 -0
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +61 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +70 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +167 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +58 -0
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +16 -8
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +23 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +141 -0
- package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +75 -0
- package/src/screens/AddNewGateway/ScanGatewayQR.js +80 -0
- package/src/screens/AddNewGateway/ScanModbusQR.js +53 -0
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +55 -0
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +31 -0
- package/src/screens/AddNewGateway/SelectDeviceType.js +147 -0
- package/src/screens/AddNewGateway/SelectDeviceTypeStyles.js +51 -0
- package/src/screens/AddNewGateway/SelectDeviceUnit.js +29 -0
- package/src/screens/AddNewGateway/SelectModbusGateway.js +34 -0
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +34 -0
- package/src/screens/AddNewGateway/ShareWifiPassword.js +198 -0
- package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +44 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -4
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +63 -0
- package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js} +15 -10
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +224 -0
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +72 -0
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +75 -0
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +73 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +47 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +124 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +48 -0
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +155 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -1
- package/src/screens/AddNewGateway/index.js +4 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +5 -4
- package/src/screens/AddNewOneTap/index.js +4 -4
- package/src/screens/Automate/__test__/index.test.js +2 -2
- package/src/screens/Automate/index.js +6 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +3 -2
- package/src/screens/ConfirmUnitDeletion/index.js +3 -3
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +5 -5
- package/src/screens/Device/EditDevice/index.js +3 -3
- package/src/screens/Device/__test__/detail.test.js +38 -22
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +6 -6
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +28 -22
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/DeviceInfo/__test__/index.test.js +8 -4
- package/src/screens/DeviceInfo/index.js +10 -6
- package/src/screens/Drawer/index.js +21 -9
- package/src/screens/EditActionsList/__tests__/index.test.js +120 -0
- package/src/screens/EditActionsList/index.js +15 -5
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +9 -5
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +7 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +3 -2
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +6 -3
- package/src/screens/EnterPassword/index.js +5 -3
- package/src/screens/GuestInfo/__test__/index.test.js +18 -12
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +2 -2
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +3 -3
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +4 -4
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -3
- package/src/screens/GuestInfo/index.js +1 -1
- package/src/screens/HanetCamera/Detail.js +10 -4
- package/src/screens/HanetCamera/ManageAccess.js +4 -4
- package/src/screens/HanetCamera/MemberInfo.js +1 -1
- package/src/screens/HanetCamera/__test__/Detail.test.js +5 -3
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +10 -4
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +4 -2
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +4 -4
- package/src/screens/MoveToAnotherSubUnit/index.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +9 -6
- package/src/screens/PlayBackCamera/index.js +6 -6
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +10 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +43 -38
- package/src/screens/ScriptDetail/index.js +26 -16
- package/src/screens/SelectUnit/__test__/index.test.js +4 -3
- package/src/screens/SelectUnit/index.js +3 -3
- package/src/screens/SetSchedule/index.js +1 -1
- package/src/screens/SharedUnit/__test__/ShareUnit.test.js +25 -0
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/{SensorItem.js → DeviceItem.js} +40 -30
- package/src/screens/Sharing/Components/Styles/{SensorItemStyles.js → DeviceItemStyles.js} +0 -0
- package/src/screens/Sharing/Components/__test__/{SensorItem.test.js → DeviceItem.test.js} +10 -8
- package/src/screens/Sharing/Components/index.js +2 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +139 -123
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/Styles/SelectPermissionStyles.js +2 -2
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +67 -14
- package/src/screens/Sharing/__test__/SelectUser.test.js +7 -4
- package/src/screens/SideMenuDetail/__test__/index.test.js +11 -7
- package/src/screens/SideMenuDetail/index.js +2 -2
- package/src/screens/SmartAccount/Connecting/index.js +171 -0
- package/src/{commons/ConnectingProcess/styles.js → screens/SmartAccount/Connecting/style.js} +3 -22
- package/src/screens/SmartAccount/ListDevice/DeviceItem.js +45 -0
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +34 -0
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +139 -0
- package/src/screens/SmartAccount/ListDevice/index.js +186 -0
- package/src/screens/SmartAccount/ListDevice/styles/DeviceItemStyles.js +70 -0
- package/src/screens/SmartAccount/ListDevice/styles/index.js +85 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +37 -0
- package/src/{commons/ConnectingProcess/DeviceItem → screens/SmartAccount/SuccessfullyConnected}/DeviceItemStyles.js +13 -5
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +65 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +88 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +101 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +42 -0
- package/src/screens/SmartAccount/__test__/Connecting.test.js +86 -0
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +249 -0
- package/src/screens/SmartAccount/index.js +172 -0
- package/src/screens/SmartAccount/style.js +70 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +4 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SmartIr.test.js +14 -6
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +4 -2
- package/src/screens/SmartIr/components/{SelectDeviceType.js → SelectIrDeviceType.js} +2 -2
- package/src/screens/SmartIr/index.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +7 -3
- package/src/screens/SubUnit/Detail.js +6 -6
- package/src/screens/SubUnit/EditSubUnit.js +10 -6
- package/src/screens/SubUnit/ManageSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +6 -3
- package/src/screens/SubUnit/__test__/Detail.test.js +5 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +9 -5
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +3 -2
- package/src/screens/SyncLGDevice/AddLGDevice.js +4 -4
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +44 -14
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +2 -1
- package/src/screens/Template/__test__/detail.test.js +9 -1
- package/src/screens/Template/index.js +0 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +10 -25
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +10 -10
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +7 -8
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +8 -5
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/Station/index.js +2 -2
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +6 -6
- package/src/screens/Unit/__test__/Detail.test.js +17 -12
- package/src/screens/Unit/__test__/ManageUnit.test.js +40 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +15 -8
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -5
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/screens/Unit/components/ListMyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +9 -5
- package/src/screens/Unit/components/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +8 -5
- package/src/screens/Unit/components/SharedUnit/index.js +12 -6
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +24 -9
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +25 -11
- package/src/screens/UnitSummary/__test__/index.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +5 -4
- package/src/screens/UnitSummary/components/RunningDevices/index.js +6 -3
- package/src/screens/UnitSummary/components/TotalPowerBox/index.js +2 -2
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +3 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/index.js +10 -8
- package/src/screens/WaterQualityGuide/__test__/index.test.js +17 -12
- package/src/screens/WaterQualityGuide/index.js +26 -10
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.json +36 -11
- package/src/utils/I18n/translations/vi.json +36 -10
- package/src/utils/Route/index.js +19 -10
- package/src/utils/Utils.js +6 -7
- package/src/utils/Validation.js +4 -0
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +0 -163
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +0 -19
- package/src/commons/ConnectingProcess/index.js +0 -213
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/iot/RemoteControl/index.js +0 -55
- package/src/screens/AddNewDevice/ConnectDevices.js +0 -184
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -131
- package/src/screens/AddNewGateway/ConnectedGateway.js +0 -139
- package/src/screens/AddNewGateway/ConnectingGateway.js +0 -137
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +0 -214
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +0 -319
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +0 -75
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +0 -130
- package/src/screens/AddNewGateway/SelectGateway.js +0 -133
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -207
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -71
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +0 -96
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -120
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +0 -115
- package/src/screens/ScanChipQR/hooks/index.js +0 -120
- package/src/screens/ScanChipQR/index.js +0 -29
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +0 -111
- package/src/screens/ScanSensorQR/hooks/index.js +0 -40
- package/src/screens/ScanSensorQR/index.js +0 -39
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import GatewayWifiList from '../GatewayWifiList';
|
|
4
|
-
import { Text, ScrollView, TouchableOpacity, Platform } from 'react-native';
|
|
5
|
-
import { getTranslate } from '../../../../utils/I18n';
|
|
6
|
-
import { SCProvider } from '../../../../context';
|
|
7
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
-
import TextInputPassword from '../../../../commons/Form/TextInputPassword';
|
|
9
|
-
import { TESTID } from '../../../../configs/Constants';
|
|
10
|
-
import WifiManager from 'react-native-wifi-reborn';
|
|
11
|
-
import { useNavigation } from '@react-navigation/native';
|
|
12
|
-
import Routes from '../../../../utils/Route';
|
|
13
|
-
|
|
14
|
-
const wrapComponent = (route, state = {}) => (
|
|
15
|
-
<SCProvider initState={{ ...mockSCStore({}), ...state }}>
|
|
16
|
-
<GatewayWifiList route={route} />
|
|
17
|
-
</SCProvider>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
describe('Test GatewayWifiList', () => {
|
|
21
|
-
let tree;
|
|
22
|
-
const socket = {
|
|
23
|
-
on: jest.fn(),
|
|
24
|
-
send: jest.fn(),
|
|
25
|
-
};
|
|
26
|
-
let route = {
|
|
27
|
-
params: {
|
|
28
|
-
list_wifi: [{ ssid: 'eoh@io' }, { ssid: 'eoh@ras.io' }],
|
|
29
|
-
socket: socket,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
test('create', async () => {
|
|
34
|
-
await act(async () => {
|
|
35
|
-
tree = await create(wrapComponent(route));
|
|
36
|
-
});
|
|
37
|
-
const instance = tree.root;
|
|
38
|
-
const texts = instance.findAllByType(Text);
|
|
39
|
-
expect(texts).toHaveLength(10);
|
|
40
|
-
expect(texts[1].props.children).toEqual(getTranslate('en', 'set_network'));
|
|
41
|
-
expect(texts[3].props.children).toEqual('eoh@io');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('onPress wifi', async () => {
|
|
45
|
-
await act(async () => {
|
|
46
|
-
tree = await create(wrapComponent(route));
|
|
47
|
-
});
|
|
48
|
-
const instance = tree.root;
|
|
49
|
-
const scrollView = instance.findAllByType(ScrollView);
|
|
50
|
-
expect(scrollView).toHaveLength(1);
|
|
51
|
-
const touchableOpacity = instance.findAllByType(TouchableOpacity);
|
|
52
|
-
expect(touchableOpacity).toHaveLength(6);
|
|
53
|
-
await act(async () => {
|
|
54
|
-
await touchableOpacity[1].props.onPress();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('onChange TextInputPassword', async () => {
|
|
59
|
-
await act(async () => {
|
|
60
|
-
tree = await create(wrapComponent(route));
|
|
61
|
-
});
|
|
62
|
-
const instance = tree.root;
|
|
63
|
-
const textInputPassword = instance.findAllByType(TextInputPassword);
|
|
64
|
-
expect(textInputPassword).toHaveLength(1);
|
|
65
|
-
await act(async () => {
|
|
66
|
-
await textInputPassword[0].props.onChange();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const ButtonPopup = instance.find(
|
|
70
|
-
(el) => el.props.testID === TESTID.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
71
|
-
);
|
|
72
|
-
await act(async () => {
|
|
73
|
-
await ButtonPopup.props.onPressMain();
|
|
74
|
-
});
|
|
75
|
-
await act(async () => {
|
|
76
|
-
await ButtonPopup.props.onPressSecondary();
|
|
77
|
-
});
|
|
78
|
-
await act(async () => {
|
|
79
|
-
await ButtonPopup.props.onClose();
|
|
80
|
-
});
|
|
81
|
-
expect(ButtonPopup).toBeDefined();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('on device is connected to wifi and mobile re-connect to internet', async () => {
|
|
85
|
-
jest.useFakeTimers();
|
|
86
|
-
Platform.OS = 'android';
|
|
87
|
-
|
|
88
|
-
await act(async () => {
|
|
89
|
-
tree = await create(wrapComponent(route, {}));
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const instance = tree.root;
|
|
93
|
-
const ButtonPopup = instance.find(
|
|
94
|
-
(el) => el.props.testID === TESTID.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
95
|
-
);
|
|
96
|
-
await act(async () => {
|
|
97
|
-
await ButtonPopup.props.onPressMain();
|
|
98
|
-
});
|
|
99
|
-
expect(socket.on).toBeCalled();
|
|
100
|
-
expect(socket.on.mock.calls[0][0]).toEqual('message');
|
|
101
|
-
jest.runOnlyPendingTimers();
|
|
102
|
-
expect(socket.send).toBeCalled();
|
|
103
|
-
|
|
104
|
-
const mockWifiThen = jest.fn();
|
|
105
|
-
WifiManager.getCurrentWifiSSID.mockImplementation(() => ({
|
|
106
|
-
then: mockWifiThen,
|
|
107
|
-
}));
|
|
108
|
-
|
|
109
|
-
// receive message
|
|
110
|
-
await act(async () => {
|
|
111
|
-
await socket.on.mock.calls[0][1](
|
|
112
|
-
JSON.stringify({
|
|
113
|
-
gateway: true,
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
jest.runOnlyPendingTimers();
|
|
118
|
-
|
|
119
|
-
expect(WifiManager.getCurrentWifiSSID).toBeCalled();
|
|
120
|
-
expect(mockWifiThen).toBeCalled();
|
|
121
|
-
|
|
122
|
-
// get ssid success
|
|
123
|
-
act(() => {
|
|
124
|
-
mockWifiThen.mock.calls[0][0]('new-ssid');
|
|
125
|
-
});
|
|
126
|
-
const { navigate } = useNavigation();
|
|
127
|
-
expect(navigate).toBeCalled();
|
|
128
|
-
expect(navigate.mock.calls[0][0]).toEqual(Routes.AddDeviceStack);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
3
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
-
import { SafeAreaView, ScrollView, TouchableOpacity, View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
import { API } from '../../configs';
|
|
7
|
-
import { Section, RadioCircle, ViewButtonBottom } from '../../commons';
|
|
8
|
-
import { axiosGet } from '../../utils/Apis/axios';
|
|
9
|
-
import Text from '../../commons/Text';
|
|
10
|
-
import Routes from '../../utils/Route';
|
|
11
|
-
import { TESTID } from '../../configs/Constants';
|
|
12
|
-
import styles from './SelectGatewayStyles';
|
|
13
|
-
|
|
14
|
-
const AddNewGatewaySelectGateway = ({ route }) => {
|
|
15
|
-
const t = useTranslations();
|
|
16
|
-
const navigation = useNavigation();
|
|
17
|
-
const isFocused = useIsFocused();
|
|
18
|
-
const { addType, unit_id, scan_sensor_data, devicePrefixName } = route.params;
|
|
19
|
-
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
20
|
-
|
|
21
|
-
const [gateways, setGateways] = useState([]);
|
|
22
|
-
const [title, setTitle] = useState('');
|
|
23
|
-
const [subTitle, setSubTitle] = useState('');
|
|
24
|
-
const [gateway, setGateway] = useState({});
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
switch (addType) {
|
|
28
|
-
case 'AddDeviceNewFlow':
|
|
29
|
-
setTitle(t('text_select_a_gateway'));
|
|
30
|
-
setSubTitle(t('text_select_a_gateway'));
|
|
31
|
-
break;
|
|
32
|
-
default:
|
|
33
|
-
setTitle(t('text_select_a_gateway'));
|
|
34
|
-
setSubTitle(t('text_select_a_gateway'));
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}, [title, subTitle, addType, t]);
|
|
38
|
-
|
|
39
|
-
const fetchDetails = useCallback(async () => {
|
|
40
|
-
const { success, data } = await axiosGet(
|
|
41
|
-
API.CHIP.GET_CHIPS_FROM_UNIT(unit_id)
|
|
42
|
-
);
|
|
43
|
-
if (success) {
|
|
44
|
-
setGateways(data);
|
|
45
|
-
}
|
|
46
|
-
}, [unit_id]);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
isFocused && fetchDetails();
|
|
50
|
-
}, [fetchDetails, isFocused]);
|
|
51
|
-
|
|
52
|
-
const onPressNext = useCallback(() => {
|
|
53
|
-
switch (addType) {
|
|
54
|
-
case 'AddDeviceNewFlow':
|
|
55
|
-
navigation.navigate(Routes.AddCommonSelectSubUnit, {
|
|
56
|
-
unit_id: unit_id,
|
|
57
|
-
addType: 'AddDeviceNewFlow',
|
|
58
|
-
scan_sensor_data,
|
|
59
|
-
gateway,
|
|
60
|
-
devicePrefixName,
|
|
61
|
-
});
|
|
62
|
-
break;
|
|
63
|
-
default:
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}, [
|
|
67
|
-
addType,
|
|
68
|
-
devicePrefixName,
|
|
69
|
-
gateway,
|
|
70
|
-
navigation,
|
|
71
|
-
scan_sensor_data,
|
|
72
|
-
unit_id,
|
|
73
|
-
]);
|
|
74
|
-
|
|
75
|
-
const handleSelectIndex = (index) => {
|
|
76
|
-
setGateway(gateways[index]);
|
|
77
|
-
if (index !== selectedIndex) {
|
|
78
|
-
setSelectedIndex(index);
|
|
79
|
-
} else {
|
|
80
|
-
setSelectedIndex(-1);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<SafeAreaView style={styles.container}>
|
|
86
|
-
<Text semibold style={styles.title}>
|
|
87
|
-
{title}
|
|
88
|
-
</Text>
|
|
89
|
-
<Text style={styles.subtitle}>{subTitle}</Text>
|
|
90
|
-
<View style={styles.contentContainer}>
|
|
91
|
-
<ScrollView
|
|
92
|
-
style={styles.scrollContainer}
|
|
93
|
-
showsVerticalScrollIndicator={false}
|
|
94
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
95
|
-
>
|
|
96
|
-
<Section type={'border'}>
|
|
97
|
-
{gateways.map((item, index) => (
|
|
98
|
-
<TouchableOpacity
|
|
99
|
-
key={index}
|
|
100
|
-
style={styles.rowContainer}
|
|
101
|
-
onPress={() => handleSelectIndex(index)}
|
|
102
|
-
>
|
|
103
|
-
<RadioCircle
|
|
104
|
-
active={selectedIndex === index}
|
|
105
|
-
testID={TESTID.SELECT_GATEWAY_RADIO_BUTTON}
|
|
106
|
-
/>
|
|
107
|
-
<TouchableOpacity
|
|
108
|
-
style={styles.row}
|
|
109
|
-
onPress={() => handleSelectIndex(index)}
|
|
110
|
-
testID={TESTID.SELECT_GATEWAY_NAME}
|
|
111
|
-
>
|
|
112
|
-
<Text style={styles.text} testID={TESTID.SELECT_GATEWAY_NAME}>
|
|
113
|
-
{item.name}
|
|
114
|
-
</Text>
|
|
115
|
-
</TouchableOpacity>
|
|
116
|
-
</TouchableOpacity>
|
|
117
|
-
))}
|
|
118
|
-
</Section>
|
|
119
|
-
</ScrollView>
|
|
120
|
-
<ViewButtonBottom
|
|
121
|
-
leftTitle={t('cancel')}
|
|
122
|
-
onLeftClick={() => navigation.goBack()}
|
|
123
|
-
rightTitle={t('next')}
|
|
124
|
-
rightDisabled={selectedIndex === -1}
|
|
125
|
-
onRightClick={onPressNext}
|
|
126
|
-
testIDPrefix={TESTID.PREFIX.SELECT_UNIT}
|
|
127
|
-
/>
|
|
128
|
-
</View>
|
|
129
|
-
</SafeAreaView>
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export default AddNewGatewaySelectGateway;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { ScrollView, SafeAreaView, PermissionsAndroid } from 'react-native';
|
|
3
|
-
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
4
|
-
import wifi from 'react-native-android-wifi';
|
|
5
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
|
-
|
|
7
|
-
import { Colors } from '../../configs';
|
|
8
|
-
import { AlertAction, Section, ViewButtonBottom } from '../../commons';
|
|
9
|
-
import {
|
|
10
|
-
BLE_INIT_NAME,
|
|
11
|
-
BLE_NOTIFY_WIFI_OK,
|
|
12
|
-
TESTID,
|
|
13
|
-
} from '../../configs/Constants';
|
|
14
|
-
import base64 from 'react-native-base64';
|
|
15
|
-
import Text from '../../commons/Text';
|
|
16
|
-
import Routes from '../../utils/Route';
|
|
17
|
-
import _TextInput from '../../commons/Form/TextInput';
|
|
18
|
-
import DisplayChecking from '../../commons/DisplayChecking';
|
|
19
|
-
import _TextInputPassword from '../../commons/Form/TextInputPassword';
|
|
20
|
-
import {
|
|
21
|
-
getDeviceByName,
|
|
22
|
-
readCharacteristic,
|
|
23
|
-
scanBluetoothDevices,
|
|
24
|
-
sendDataOverBluetooth,
|
|
25
|
-
subcribeCharacteristicNotify,
|
|
26
|
-
} from '../../iot/RemoteControl/Bluetooth';
|
|
27
|
-
import styles from './SetupGatewayWifiStyles';
|
|
28
|
-
|
|
29
|
-
const SetupGatewayWifi = memo(({ route }) => {
|
|
30
|
-
const t = useTranslations();
|
|
31
|
-
const { unit_id } = route.params;
|
|
32
|
-
const isFocused = useIsFocused();
|
|
33
|
-
const { navigate, goBack } = useNavigation();
|
|
34
|
-
const [wifiName, setWifiName] = useState('');
|
|
35
|
-
const [wifiPass, setWifiPass] = useState('');
|
|
36
|
-
const [displayLoadingConnect, setDisplayLoadingConnect] = useState(false);
|
|
37
|
-
const [displayConnectFail, setDisplayConnectFail] = useState(false);
|
|
38
|
-
const [timeoutSubcribtion, setTimeoutSubcribtion] = useState(null);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const wifiPermission = async () => {
|
|
42
|
-
try {
|
|
43
|
-
const granted = await PermissionsAndroid.request(
|
|
44
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
|
|
45
|
-
{
|
|
46
|
-
title: t('wifi_networks'),
|
|
47
|
-
message: t('wifi_permission'),
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
51
|
-
wifi.getSSID((ssid) => {
|
|
52
|
-
setWifiName(ssid);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
// eslint-disable-next-line no-empty
|
|
56
|
-
} catch (err) {}
|
|
57
|
-
};
|
|
58
|
-
wifiPermission();
|
|
59
|
-
}, [t]);
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (isFocused) {
|
|
63
|
-
scanBluetoothDevices([BLE_INIT_NAME]);
|
|
64
|
-
}
|
|
65
|
-
return () => {
|
|
66
|
-
clearTimeout(timeoutSubcribtion);
|
|
67
|
-
};
|
|
68
|
-
}, [isFocused, timeoutSubcribtion]);
|
|
69
|
-
|
|
70
|
-
const onRight = useCallback(async () => {
|
|
71
|
-
// get device and send wifi + pass
|
|
72
|
-
const device = getDeviceByName(BLE_INIT_NAME);
|
|
73
|
-
await sendDataOverBluetooth(
|
|
74
|
-
device,
|
|
75
|
-
{
|
|
76
|
-
type: 'init',
|
|
77
|
-
ssid: wifiName,
|
|
78
|
-
password: wifiPass,
|
|
79
|
-
},
|
|
80
|
-
true
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// subcribe + handle if right notify
|
|
84
|
-
const subcription = await subcribeCharacteristicNotify(
|
|
85
|
-
device,
|
|
86
|
-
async (error, characteristicNotify) => {
|
|
87
|
-
if (error) {
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const notify = base64.decode(characteristicNotify.value);
|
|
92
|
-
if (notify === BLE_NOTIFY_WIFI_OK) {
|
|
93
|
-
const characteristicRead = await readCharacteristic(device);
|
|
94
|
-
|
|
95
|
-
const readJsonData = base64.decode(characteristicRead.value);
|
|
96
|
-
const readData = JSON.parse(readJsonData);
|
|
97
|
-
|
|
98
|
-
subcription.remove();
|
|
99
|
-
await device.cancelConnection();
|
|
100
|
-
setDisplayLoadingConnect(false);
|
|
101
|
-
|
|
102
|
-
navigate(Routes.AddNewGateway, {
|
|
103
|
-
unit_id,
|
|
104
|
-
wifiName,
|
|
105
|
-
wifiPass,
|
|
106
|
-
imei: readData.imei,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
setDisplayLoadingConnect(true);
|
|
113
|
-
|
|
114
|
-
const timeoutId = setTimeout(async () => {
|
|
115
|
-
setDisplayLoadingConnect(false);
|
|
116
|
-
setDisplayConnectFail(true);
|
|
117
|
-
subcription.remove();
|
|
118
|
-
await device.cancelConnection();
|
|
119
|
-
}, 7000);
|
|
120
|
-
setTimeoutSubcribtion(timeoutId);
|
|
121
|
-
}, [navigate, unit_id, wifiName, wifiPass]);
|
|
122
|
-
|
|
123
|
-
const onChangeWifiName = useCallback((text) => {
|
|
124
|
-
setWifiName(text);
|
|
125
|
-
}, []);
|
|
126
|
-
|
|
127
|
-
const onChangeWifiPass = useCallback((text) => {
|
|
128
|
-
setWifiPass(text);
|
|
129
|
-
}, []);
|
|
130
|
-
|
|
131
|
-
const onHideDisplayConnectFail = useCallback(() => {
|
|
132
|
-
setDisplayConnectFail(false);
|
|
133
|
-
}, []);
|
|
134
|
-
|
|
135
|
-
const onHideDisplayLoading = useCallback(() => {
|
|
136
|
-
setDisplayLoadingConnect(false);
|
|
137
|
-
}, []);
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<SafeAreaView style={styles.wrap}>
|
|
141
|
-
<Text semibold size={20} color={Colors.Black} style={styles.txtHeader}>
|
|
142
|
-
{t('add_new_gateway')}
|
|
143
|
-
</Text>
|
|
144
|
-
<Text size={14} color={Colors.Gray8} style={styles.txtNote}>
|
|
145
|
-
{t('please_select_a_wifi_network')}
|
|
146
|
-
</Text>
|
|
147
|
-
|
|
148
|
-
<ScrollView
|
|
149
|
-
style={styles.scrollContainer}
|
|
150
|
-
showsVerticalScrollIndicator={false}
|
|
151
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
152
|
-
>
|
|
153
|
-
<Section type={'border'}>
|
|
154
|
-
<Text style={styles.textWifi} bold color={Colors.Primary}>
|
|
155
|
-
{t('wifi_name')}
|
|
156
|
-
</Text>
|
|
157
|
-
<_TextInput
|
|
158
|
-
placeholder={t('wifi')}
|
|
159
|
-
wrapStyle={styles.noMarginTop}
|
|
160
|
-
onChange={onChangeWifiName}
|
|
161
|
-
textInputStyle={styles.wifiInput}
|
|
162
|
-
selectionColor={Colors.Primary}
|
|
163
|
-
value={wifiName}
|
|
164
|
-
/>
|
|
165
|
-
<Text style={styles.textWifi} bold color={Colors.Primary}>
|
|
166
|
-
{t('password')}
|
|
167
|
-
</Text>
|
|
168
|
-
<_TextInputPassword
|
|
169
|
-
secureTextEntry
|
|
170
|
-
placeholder={t('password')}
|
|
171
|
-
wrapStyle={styles.noMarginTop}
|
|
172
|
-
onChange={onChangeWifiPass}
|
|
173
|
-
value={wifiPass}
|
|
174
|
-
textInputStyle={styles.wifiInput}
|
|
175
|
-
selectionColor={Colors.Primary}
|
|
176
|
-
/>
|
|
177
|
-
</Section>
|
|
178
|
-
</ScrollView>
|
|
179
|
-
|
|
180
|
-
<DisplayChecking
|
|
181
|
-
isOpacityLayout={false} // conflict with AlertAction Modal
|
|
182
|
-
visible={displayLoadingConnect}
|
|
183
|
-
onClose={onHideDisplayLoading}
|
|
184
|
-
message={t('push_and_wait_chip_response')}
|
|
185
|
-
/>
|
|
186
|
-
|
|
187
|
-
<AlertAction
|
|
188
|
-
testID={TESTID.SET_UP_GATEWAY_WIFI.BUTTON_ALERT}
|
|
189
|
-
visible={displayConnectFail} // TODO display True based on bluetooth response with imei
|
|
190
|
-
hideModal={onHideDisplayConnectFail}
|
|
191
|
-
title={wifiName ? `"${wifiName}"` : ''}
|
|
192
|
-
message={t('could_not_connect_to_network')}
|
|
193
|
-
leftButtonTitle={t('ok')}
|
|
194
|
-
leftButtonClick={onHideDisplayConnectFail}
|
|
195
|
-
/>
|
|
196
|
-
|
|
197
|
-
<ViewButtonBottom
|
|
198
|
-
leftTitle={t('cancel')}
|
|
199
|
-
onLeftClick={goBack}
|
|
200
|
-
rightTitle={t('text_next')}
|
|
201
|
-
onRightClick={onRight}
|
|
202
|
-
/>
|
|
203
|
-
</SafeAreaView>
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
export default SetupGatewayWifi;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
import { TESTID } from '../../../configs/Constants';
|
|
5
|
-
import ConnectedGateway from '../ConnectedGateway';
|
|
6
|
-
import { SCProvider } from '../../../context';
|
|
7
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
-
import { getTranslate } from '../../../utils/I18n';
|
|
9
|
-
|
|
10
|
-
const mockedNavigate = jest.fn();
|
|
11
|
-
jest.mock('@react-navigation/native', () => {
|
|
12
|
-
return {
|
|
13
|
-
...jest.requireActual('@react-navigation/native'),
|
|
14
|
-
useNavigation: () => ({
|
|
15
|
-
navigate: mockedNavigate,
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const wrapComponent = (route) => (
|
|
21
|
-
<SCProvider initState={mockSCStore({})}>
|
|
22
|
-
<ConnectedGateway route={route} />
|
|
23
|
-
</SCProvider>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
describe('Test ConnectedGateway', () => {
|
|
27
|
-
let tree;
|
|
28
|
-
let route;
|
|
29
|
-
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
mockedNavigate.mockClear();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
route = {
|
|
36
|
-
params: {
|
|
37
|
-
new_chip: {
|
|
38
|
-
id: 1,
|
|
39
|
-
name: 'Chip name',
|
|
40
|
-
imei: 'ABC123',
|
|
41
|
-
},
|
|
42
|
-
station_id: 2,
|
|
43
|
-
unit_id: 1,
|
|
44
|
-
unit_name: 'Unit name',
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const getText = (instance, id) => {
|
|
50
|
-
return instance.find((el) => el.props.testID === id);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
test('create', async () => {
|
|
54
|
-
await act(async () => {
|
|
55
|
-
tree = await create(wrapComponent(route));
|
|
56
|
-
});
|
|
57
|
-
const instance = tree.root;
|
|
58
|
-
|
|
59
|
-
const textSuccess = getText(instance, TESTID.CONNECTED_GATEWAY_SUCCESS);
|
|
60
|
-
const textUnitName = getText(instance, TESTID.CONNECTED_GATEWAY_UNIT_NAME);
|
|
61
|
-
const textChipName = getText(instance, TESTID.CONNECTED_GATEWAY_CHIP_NAME);
|
|
62
|
-
const textDone = getText(instance, TESTID.CONNECTED_GATEWAY_DONE);
|
|
63
|
-
|
|
64
|
-
expect(textSuccess.props.children).toEqual(
|
|
65
|
-
getTranslate('en', 'successfully_connected')
|
|
66
|
-
);
|
|
67
|
-
expect(textUnitName.props.children).toEqual('Unit name');
|
|
68
|
-
expect(textChipName.props.children).toEqual('Chip name - ABC123');
|
|
69
|
-
expect(textDone.props.children).toEqual(getTranslate('en', 'done'));
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
|
|
5
|
-
import ConnectingGateway from '../ConnectingGateway';
|
|
6
|
-
import Text from '../../../commons/Text';
|
|
7
|
-
import API from '../../../configs/API';
|
|
8
|
-
import Routes from '../../../utils/Route';
|
|
9
|
-
import { getTranslate } from '../../../utils/I18n';
|
|
10
|
-
import { SCProvider } from '../../../context';
|
|
11
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
-
import api from '../../../utils/Apis/axios';
|
|
13
|
-
|
|
14
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
15
|
-
|
|
16
|
-
const mockedNavigate = jest.fn();
|
|
17
|
-
jest.mock('@react-navigation/native', () => {
|
|
18
|
-
return {
|
|
19
|
-
...jest.requireActual('@react-navigation/native'),
|
|
20
|
-
useNavigation: () => ({
|
|
21
|
-
navigate: mockedNavigate,
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const wrapComponent = (route) => (
|
|
27
|
-
<SCProvider initState={mockSCStore({})}>
|
|
28
|
-
<ConnectingGateway route={route} />
|
|
29
|
-
</SCProvider>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
describe('Test ConnectingGateway', () => {
|
|
33
|
-
let tree;
|
|
34
|
-
let route;
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
mockedNavigate.mockClear();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
route = {
|
|
42
|
-
params: {
|
|
43
|
-
new_chip: {
|
|
44
|
-
id: 1,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('create', async () => {
|
|
51
|
-
await act(async () => {
|
|
52
|
-
tree = await create(wrapComponent(route));
|
|
53
|
-
});
|
|
54
|
-
const instance = tree.root;
|
|
55
|
-
const texts = instance.findAllByType(Text);
|
|
56
|
-
expect(texts).toHaveLength(8);
|
|
57
|
-
expect(texts[0].props.children).toEqual(
|
|
58
|
-
getTranslate('en', 'connecting_your_gateway')
|
|
59
|
-
);
|
|
60
|
-
expect(texts[1].props.children).toEqual(
|
|
61
|
-
getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('call setInterval api success', async () => {
|
|
66
|
-
jest.useFakeTimers();
|
|
67
|
-
mock.onGet(API.CHIP.CHECK_FINALIZED()).reply(200, {});
|
|
68
|
-
await act(async () => {
|
|
69
|
-
tree = await create(wrapComponent(route));
|
|
70
|
-
});
|
|
71
|
-
await act(async () => {
|
|
72
|
-
await jest.runOnlyPendingTimers();
|
|
73
|
-
});
|
|
74
|
-
expect(setInterval).toHaveBeenCalled();
|
|
75
|
-
expect(mockedNavigate).not.toHaveBeenCalledWith(
|
|
76
|
-
Routes.ConnectedGateway,
|
|
77
|
-
route.params
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('call setInterval api fail', async () => {
|
|
82
|
-
jest.useFakeTimers();
|
|
83
|
-
mock.onGet(API.CHIP.CHECK_FINALIZED()).reply(400);
|
|
84
|
-
await act(async () => {
|
|
85
|
-
tree = await create(wrapComponent(route));
|
|
86
|
-
});
|
|
87
|
-
await act(async () => {
|
|
88
|
-
await jest.runOnlyPendingTimers();
|
|
89
|
-
});
|
|
90
|
-
expect(setInterval).toHaveBeenCalled();
|
|
91
|
-
expect(mockedNavigate).not.toHaveBeenCalledWith(
|
|
92
|
-
Routes.ConnectedGateway,
|
|
93
|
-
route.params
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
});
|