@eohjsc/react-native-smart-city 0.3.29 → 0.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -5
- package/src/Images/DevMode/close.png +0 -0
- package/src/Images/DevMode/close@2x.png +0 -0
- package/src/Images/DevMode/close@3x.png +0 -0
- package/src/Images/DevMode/plus.png +0 -0
- package/src/Images/DevMode/plus@2x.png +0 -0
- package/src/Images/DevMode/plus@3x.png +0 -0
- package/src/Images/DevMode/remove_circle.png +0 -0
- package/src/Images/DevMode/remove_circle@2x.png +0 -0
- package/src/Images/DevMode/remove_circle@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +2 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +17 -9
- package/src/commons/ActionGroup/ColorPickerTemplate.js +36 -17
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +18 -13
- 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 +38 -45
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -0
- 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 +9 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -2
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +38 -22
- package/src/commons/ActionGroup/SliderRangeTemplate.js +24 -16
- 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 +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +50 -60
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
- 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 +7 -5
- package/src/commons/ActionGroup/index.js +35 -10
- 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 +13 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -4
- package/src/commons/Button/index.js +2 -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/DevMode/CardDevMode.js +42 -0
- package/src/commons/DevMode/EmptyComponent.js +18 -0
- package/src/commons/DevMode/Item.js +21 -0
- package/src/commons/DevMode/Styles/CardStyles.js +40 -0
- package/src/commons/DevMode/Styles/EmptyComponentStyles.js +15 -0
- package/src/commons/DevMode/Styles/ItemStyles.js +27 -0
- package/src/commons/DevMode/Styles/TextWithLabelStyles.js +36 -0
- package/src/commons/DevMode/TextWithLabel.js +30 -0
- package/src/commons/DevMode/index.js +5 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +3 -3
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
- 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 +10 -11
- package/src/commons/Device/ItemDevice.js +27 -20
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -1
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +6 -3
- package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
- 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/Header/HeaderCustom.js +8 -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 +6 -5
- package/src/commons/NavBar/index.js +4 -4
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +11 -5
- 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 -12
- 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 +55 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +106 -0
- package/src/commons/SelectUnit/styles.js +54 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +6 -4
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -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/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 +12 -14
- package/src/configs/AccessibilityLabel.js +608 -0
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +1 -593
- package/src/configs/Images.js +3 -0
- package/src/context/actionType.ts +19 -3
- package/src/context/mockStore.ts +18 -3
- package/src/context/reducer.ts +66 -9
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +1 -1
- 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/IoT/useValueEvaluation.js +10 -19
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +27 -23
- 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 +51 -21
- package/src/navigations/Main.js +28 -4
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +5 -8
- 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 +44 -191
- package/src/screens/AddCommon/SelectUnit.js +51 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +7 -50
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +28 -26
- 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 +5 -1
- package/src/screens/AddNewAction/SelectAction.js +36 -20
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +3 -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 +11 -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/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +21 -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 +57 -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 +52 -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 +302 -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__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +73 -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 +89 -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 +294 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +27 -0
- 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/DetailHistoryChart.js +7 -5
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +16 -17
- package/src/screens/Device/components/SensorDisplayItem.js +51 -26
- package/src/screens/Device/detail.js +65 -38
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/Device/hooks/useFavoriteDevice.js +4 -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 +30 -13
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +11 -7
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +9 -10
- 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/Notification/__test__/NotificationItem.test.js +6 -30
- package/src/screens/Notification/components/NotificationItem.js +3 -19
- 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 +8 -4
- package/src/screens/ScriptDetail/index.js +7 -5
- 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/Sharing/Components/SensorItem.js +6 -3
- package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
- package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +4 -0
- package/src/screens/Sharing/Components/TitleCheckBox.js +17 -8
- package/src/screens/Sharing/Components/__test__/SensorItem.test.js +4 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +9 -4
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- 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/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 +7 -4
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +152 -0
- package/src/screens/Template/GatewayList.js +51 -0
- package/src/screens/Template/Information.js +41 -0
- package/src/screens/Template/Styles/EditTemplateStyle.js +109 -0
- package/src/screens/Template/Styles/GatewayStyles.js +46 -0
- package/src/screens/Template/Styles/InformationStyles.js +16 -0
- package/src/screens/Template/Styles/detailStyles.js +35 -0
- package/src/screens/Template/Styles/indexStyles.js +2 -33
- package/src/screens/Template/__test__/EditTemplate.test.js +89 -0
- package/src/screens/Template/__test__/GatewayList.test.js +26 -0
- package/src/screens/Template/__test__/Information.test.js +16 -0
- package/src/screens/Template/__test__/detail.test.js +68 -0
- package/src/screens/Template/__test__/index.test.js +26 -1
- package/src/screens/Template/detail.js +154 -0
- package/src/screens/Template/index.js +38 -32
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +6 -20
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +14 -9
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +11 -2
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +1 -1
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +19 -3
- 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 +90 -55
- 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 +42 -25
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +8 -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 +25 -10
- package/src/utils/I18n/translations/vi.json +22 -9
- package/src/utils/Route/index.js +22 -10
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +0 -41
- 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/commons/ConnectingProcess/styles.js +0 -69
- 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 -307
- 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,137 +0,0 @@
|
|
|
1
|
-
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { API, Colors } from '../../configs';
|
|
4
|
-
import Text from '../../commons/Text';
|
|
5
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
|
-
import { useNavigation } from '@react-navigation/native';
|
|
7
|
-
import Routes from '../../utils/Route';
|
|
8
|
-
import { axiosGet } from '../../utils/Apis/axios';
|
|
9
|
-
import { IconOutline } from '@ant-design/icons-react-native';
|
|
10
|
-
import styles from './ConnectingGatewayStyles';
|
|
11
|
-
|
|
12
|
-
const ProcessItem = ({ title, active, line }) => {
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<View style={styles.processItem}>
|
|
16
|
-
<View
|
|
17
|
-
style={[styles.processCircle, active && styles.processCircleActive]}
|
|
18
|
-
>
|
|
19
|
-
<IconOutline
|
|
20
|
-
name="radar-chart"
|
|
21
|
-
size={16}
|
|
22
|
-
color={active ? Colors.White : Colors.Gray5}
|
|
23
|
-
/>
|
|
24
|
-
</View>
|
|
25
|
-
<Text
|
|
26
|
-
center
|
|
27
|
-
type="Label"
|
|
28
|
-
color={Colors.Gray7}
|
|
29
|
-
style={styles.textProcessItem}
|
|
30
|
-
>
|
|
31
|
-
{title}
|
|
32
|
-
</Text>
|
|
33
|
-
</View>
|
|
34
|
-
{line && <View style={[styles.line, active && styles.lineActive]} />}
|
|
35
|
-
</>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const ConnectingGateway = memo(({ route }) => {
|
|
40
|
-
const t = useTranslations();
|
|
41
|
-
const { navigate } = useNavigation();
|
|
42
|
-
const { new_chip } = route.params;
|
|
43
|
-
const [finalizeStatus, setFinalizeStatus] = useState(0);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const checkChipFinalized = setInterval(async () => {
|
|
47
|
-
const { success, data } = await axiosGet(
|
|
48
|
-
API.CHIP.CHECK_FINALIZED(),
|
|
49
|
-
{
|
|
50
|
-
params: {
|
|
51
|
-
chip_id: new_chip.id,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
true
|
|
55
|
-
);
|
|
56
|
-
if (success) {
|
|
57
|
-
const { control, config, bluetooth } = data;
|
|
58
|
-
if (control) {
|
|
59
|
-
setFinalizeStatus(1);
|
|
60
|
-
}
|
|
61
|
-
if (config) {
|
|
62
|
-
setFinalizeStatus(2);
|
|
63
|
-
}
|
|
64
|
-
if (bluetooth) {
|
|
65
|
-
setFinalizeStatus(3);
|
|
66
|
-
}
|
|
67
|
-
if (control && config && bluetooth) {
|
|
68
|
-
navigate(Routes.ConnectedGateway, route.params);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, 3000);
|
|
72
|
-
return () => clearInterval(checkChipFinalized);
|
|
73
|
-
}, [navigate, new_chip.id, route.params]);
|
|
74
|
-
|
|
75
|
-
const percent = useMemo(() => {
|
|
76
|
-
if (finalizeStatus === 0) {
|
|
77
|
-
return '0%';
|
|
78
|
-
}
|
|
79
|
-
if (finalizeStatus === 1) {
|
|
80
|
-
return '30%';
|
|
81
|
-
}
|
|
82
|
-
if (finalizeStatus === 2) {
|
|
83
|
-
return '60%';
|
|
84
|
-
}
|
|
85
|
-
return '100%';
|
|
86
|
-
}, [finalizeStatus]);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<View style={styles.wrap}>
|
|
90
|
-
<Text semibold size={20} color={Colors.Black} style={styles.txtHeader}>
|
|
91
|
-
{t('connecting_your_gateway')}
|
|
92
|
-
</Text>
|
|
93
|
-
<Text size={14} color={Colors.Gray} style={styles.txtNote}>
|
|
94
|
-
{t('dont_turn_off_the_device_or_close_this_app')}
|
|
95
|
-
</Text>
|
|
96
|
-
<View style={styles.scan}>
|
|
97
|
-
<View style={styles.layout}>
|
|
98
|
-
<View style={styles.layout1}>
|
|
99
|
-
<View style={styles.outsideCircle}>
|
|
100
|
-
<View style={styles.circle}>
|
|
101
|
-
<IconOutline name="search" size={28} color={Colors.White} />
|
|
102
|
-
</View>
|
|
103
|
-
</View>
|
|
104
|
-
<Text
|
|
105
|
-
style={styles.textPercent}
|
|
106
|
-
color={Colors.Gray7}
|
|
107
|
-
semibold
|
|
108
|
-
center
|
|
109
|
-
>
|
|
110
|
-
{percent}
|
|
111
|
-
</Text>
|
|
112
|
-
</View>
|
|
113
|
-
</View>
|
|
114
|
-
<View style={styles.layoutProcess}>
|
|
115
|
-
<View style={styles.layoutProcess1}>
|
|
116
|
-
<ProcessItem
|
|
117
|
-
title="Finalize control"
|
|
118
|
-
line
|
|
119
|
-
active={[1, 2, 3].includes(finalizeStatus)}
|
|
120
|
-
/>
|
|
121
|
-
<ProcessItem
|
|
122
|
-
title="Finalize config"
|
|
123
|
-
line
|
|
124
|
-
active={[2, 3].includes(finalizeStatus)}
|
|
125
|
-
/>
|
|
126
|
-
<ProcessItem
|
|
127
|
-
title="Finalize bluetooth"
|
|
128
|
-
active={[3].includes(finalizeStatus)}
|
|
129
|
-
/>
|
|
130
|
-
</View>
|
|
131
|
-
</View>
|
|
132
|
-
</View>
|
|
133
|
-
</View>
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
export default ConnectingGateway;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
memo,
|
|
3
|
-
useEffect,
|
|
4
|
-
useState,
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import {
|
|
9
|
-
View,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
Text,
|
|
12
|
-
PermissionsAndroid,
|
|
13
|
-
Platform,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
import WifiManager from 'react-native-wifi-reborn';
|
|
16
|
-
import { useNavigation } from '@react-navigation/native';
|
|
17
|
-
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
18
|
-
import dgram from 'react-native-udp';
|
|
19
|
-
import { HeaderCustom } from '../../../commons/Header';
|
|
20
|
-
import ScanQrGateway from '../../../../assets/images/scan-qr-gateway.svg';
|
|
21
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
22
|
-
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
23
|
-
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
24
|
-
import { Colors } from '../../../configs';
|
|
25
|
-
import Routes from '../../../utils/Route';
|
|
26
|
-
import { SCContext } from '../../../context';
|
|
27
|
-
import { Action } from '../../../context/actionType';
|
|
28
|
-
import { TESTID } from '../../../configs/Constants';
|
|
29
|
-
import Connecting from '../../../commons/Connecting';
|
|
30
|
-
|
|
31
|
-
const isAndroid = Platform.OS === 'android';
|
|
32
|
-
let socket,
|
|
33
|
-
intervalSend = null;
|
|
34
|
-
|
|
35
|
-
const ConnectWifiWarning = memo(({ route }) => {
|
|
36
|
-
const {
|
|
37
|
-
wifi_ssid,
|
|
38
|
-
wifi_pass,
|
|
39
|
-
unit_id,
|
|
40
|
-
chip_id,
|
|
41
|
-
devicePrefixName,
|
|
42
|
-
body,
|
|
43
|
-
unit_name,
|
|
44
|
-
} = route.params;
|
|
45
|
-
const t = useTranslations();
|
|
46
|
-
const { navigate, goBack } = useNavigation();
|
|
47
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
48
|
-
const [isConnect, setIsConnect] = useState(false);
|
|
49
|
-
const [isPercentConnect, setIsPercentConnect] = useState(0);
|
|
50
|
-
|
|
51
|
-
const { setAction } = useContext(SCContext);
|
|
52
|
-
|
|
53
|
-
const getPermissionWifiAndroid = useCallback(async () => {
|
|
54
|
-
return await PermissionsAndroid.request(
|
|
55
|
-
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
|
|
56
|
-
{
|
|
57
|
-
title: t('location_permission_required_wifi_title'),
|
|
58
|
-
message: t('location_permission_required_wifi_message'),
|
|
59
|
-
buttonNegative: t('deny'),
|
|
60
|
-
buttonPositive: t('allow'),
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (isAndroid) {
|
|
68
|
-
(async () => {
|
|
69
|
-
const granted = await getPermissionWifiAndroid();
|
|
70
|
-
if (!granted) {
|
|
71
|
-
ToastBottomHelper.error(
|
|
72
|
-
'Fail permission',
|
|
73
|
-
'You need to grant permission to continue'
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
})();
|
|
77
|
-
}
|
|
78
|
-
}, [getPermissionWifiAndroid]);
|
|
79
|
-
|
|
80
|
-
const handleSend = async () => {
|
|
81
|
-
socket = dgram.createSocket({ type: 'udp4' });
|
|
82
|
-
socket.bind(54321);
|
|
83
|
-
setIsPercentConnect(1);
|
|
84
|
-
|
|
85
|
-
socket.on('message', (msg, rinfo) => {
|
|
86
|
-
clearInterval(intervalSend);
|
|
87
|
-
const data = JSON.parse(msg.toString());
|
|
88
|
-
if (Object.prototype.hasOwnProperty.call(data, 'wifi')) {
|
|
89
|
-
navigate(Routes.GatewayWifiList, {
|
|
90
|
-
list_wifi: data.wifi,
|
|
91
|
-
unit_id: unit_id,
|
|
92
|
-
chip_id: chip_id,
|
|
93
|
-
scan_sensor_data: { ...body },
|
|
94
|
-
wifi_ssid: wifi_ssid,
|
|
95
|
-
wifi_pass: wifi_pass,
|
|
96
|
-
unit_name: unit_name,
|
|
97
|
-
devicePrefixName: devicePrefixName,
|
|
98
|
-
socket: socket,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
socket.on('error', () => {
|
|
104
|
-
ToastBottomHelper.error(t('server_error'));
|
|
105
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
106
|
-
goBack();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
intervalSend = setInterval(() => {
|
|
110
|
-
socket.send(
|
|
111
|
-
JSON.stringify({ type: 'scan', data: { wifi: '' } }),
|
|
112
|
-
undefined,
|
|
113
|
-
undefined,
|
|
114
|
-
54321,
|
|
115
|
-
'192.168.27.1',
|
|
116
|
-
undefined
|
|
117
|
-
);
|
|
118
|
-
}, 5000); // workaround, todo Bang continue research
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const handleConnectWifiGateway = async () => {
|
|
122
|
-
setIsLoading(true);
|
|
123
|
-
setIsConnect(true);
|
|
124
|
-
// eslint-disable-next-line promise/prefer-await-to-then
|
|
125
|
-
WifiManager.connectToProtectedSSID(wifi_ssid, wifi_pass, false).then(
|
|
126
|
-
() => {
|
|
127
|
-
handleSend();
|
|
128
|
-
},
|
|
129
|
-
(e) => {
|
|
130
|
-
ToastBottomHelper.error('Connection failed!');
|
|
131
|
-
goBack();
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
return () => intervalSend && clearInterval(intervalSend);
|
|
138
|
-
}, []);
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<View style={styles.screen}>
|
|
142
|
-
{!isLoading ? (
|
|
143
|
-
<>
|
|
144
|
-
<HeaderCustom title={t('scan_qr')} isShowSeparator />
|
|
145
|
-
<View style={styles.container}>
|
|
146
|
-
<ScanQrGateway />
|
|
147
|
-
<View style={styles.content}>
|
|
148
|
-
<Text style={styles.text}>
|
|
149
|
-
{t('connecting_gateway_warning_1')}
|
|
150
|
-
</Text>
|
|
151
|
-
<Text style={styles.text}>
|
|
152
|
-
{t('connecting_gateway_warning_2')}
|
|
153
|
-
</Text>
|
|
154
|
-
</View>
|
|
155
|
-
</View>
|
|
156
|
-
<BottomButtonView
|
|
157
|
-
testID={TESTID.CONNECT_WIFI_WARNING.BUTTON_BOTTOM}
|
|
158
|
-
style={styles.viewBottomFixed}
|
|
159
|
-
mainTitle={t('ok')}
|
|
160
|
-
onPressMain={handleConnectWifiGateway}
|
|
161
|
-
typeMain={'primary'}
|
|
162
|
-
/>
|
|
163
|
-
</>
|
|
164
|
-
) : (
|
|
165
|
-
<View style={styles.centerLoading}>
|
|
166
|
-
<Connecting
|
|
167
|
-
isLoading={isLoading}
|
|
168
|
-
isConnect={isConnect}
|
|
169
|
-
isPercentConnect={isPercentConnect}
|
|
170
|
-
/>
|
|
171
|
-
</View>
|
|
172
|
-
)}
|
|
173
|
-
</View>
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
export default ConnectWifiWarning;
|
|
178
|
-
|
|
179
|
-
const styles = StyleSheet.create({
|
|
180
|
-
viewBottomFixed: {
|
|
181
|
-
position: 'absolute',
|
|
182
|
-
bottom: 0,
|
|
183
|
-
left: 0,
|
|
184
|
-
right: 0,
|
|
185
|
-
paddingBottom: getBottomSpace() > 0 ? getBottomSpace() : 32,
|
|
186
|
-
paddingTop: 24,
|
|
187
|
-
backgroundColor: Colors.Gray2,
|
|
188
|
-
borderColor: Colors.ShadownTransparent,
|
|
189
|
-
borderTopWidth: 1,
|
|
190
|
-
},
|
|
191
|
-
screen: {
|
|
192
|
-
flex: 1,
|
|
193
|
-
backgroundColor: Colors.Gray2,
|
|
194
|
-
},
|
|
195
|
-
container: {
|
|
196
|
-
flex: 1,
|
|
197
|
-
alignItems: 'center',
|
|
198
|
-
marginTop: 50,
|
|
199
|
-
},
|
|
200
|
-
content: {
|
|
201
|
-
alignItems: 'center',
|
|
202
|
-
width: '80%',
|
|
203
|
-
marginTop: 50,
|
|
204
|
-
},
|
|
205
|
-
text: {
|
|
206
|
-
textAlign: 'center',
|
|
207
|
-
lineHeight: 24,
|
|
208
|
-
},
|
|
209
|
-
centerLoading: {
|
|
210
|
-
flex: 1,
|
|
211
|
-
justifyContent: 'center',
|
|
212
|
-
alignItems: 'center',
|
|
213
|
-
},
|
|
214
|
-
});
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
memo,
|
|
3
|
-
useState,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import {
|
|
9
|
-
View,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
TouchableOpacity,
|
|
12
|
-
ScrollView,
|
|
13
|
-
ActivityIndicator,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
import { HeaderCustom } from '../../../commons/Header';
|
|
16
|
-
import { Colors } from '../../../configs';
|
|
17
|
-
import Text from '../../../commons/Text';
|
|
18
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
19
|
-
import WifiIcon from '../../../../assets/images/wifi.svg';
|
|
20
|
-
import ButtonPopup from '../../../commons/ButtonPopup';
|
|
21
|
-
import TextInputPassword from '../../../commons/Form/TextInputPassword';
|
|
22
|
-
import { SCContext, useSCContextSelector } from '../../../context';
|
|
23
|
-
import { Action } from '../../../context/actionType';
|
|
24
|
-
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
25
|
-
import Routes from '../../../utils/Route';
|
|
26
|
-
import WifiManager from 'react-native-wifi-reborn';
|
|
27
|
-
import { useNavigation } from '@react-navigation/native';
|
|
28
|
-
import { TESTID } from '../../../configs/Constants';
|
|
29
|
-
|
|
30
|
-
const GatewayWifiList = memo(({ route }) => {
|
|
31
|
-
const {
|
|
32
|
-
list_wifi,
|
|
33
|
-
socket,
|
|
34
|
-
unit_name,
|
|
35
|
-
wifi_pass,
|
|
36
|
-
wifi_ssid,
|
|
37
|
-
scan_sensor_data,
|
|
38
|
-
unit_id,
|
|
39
|
-
chip_id,
|
|
40
|
-
devicePrefixName,
|
|
41
|
-
} = route.params;
|
|
42
|
-
const t = useTranslations();
|
|
43
|
-
const { navigate, goBack } = useNavigation();
|
|
44
|
-
const [isShowPopupPassword, setIsShowPopupPassword] = useState(false);
|
|
45
|
-
const [password, setPassword] = useState('');
|
|
46
|
-
const [selectedWifi, setSelectedWifi] = useState('');
|
|
47
|
-
const [isSendWifi, setIsSendWifi] = useState(false);
|
|
48
|
-
const { setAction } = useContext(SCContext);
|
|
49
|
-
|
|
50
|
-
const isConnectWifiGateway = useSCContextSelector(
|
|
51
|
-
(state) => state.app.isConnectWifiGateway
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const showPopupPassword = (ssid) => {
|
|
55
|
-
setIsShowPopupPassword(true);
|
|
56
|
-
setSelectedWifi(ssid);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const onPasswordChange = useCallback(
|
|
60
|
-
(newPassword) => {
|
|
61
|
-
setPassword(newPassword?.toString());
|
|
62
|
-
},
|
|
63
|
-
[setPassword]
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const handleSocketOnMsg = useCallback(
|
|
67
|
-
(msg) => {
|
|
68
|
-
const data = JSON.parse(msg.toString());
|
|
69
|
-
if (Object.prototype.hasOwnProperty.call(data, 'gateway')) {
|
|
70
|
-
const checkWifiInterval = setInterval(() => {
|
|
71
|
-
// eslint-disable-next-line promise/prefer-await-to-then
|
|
72
|
-
WifiManager.getCurrentWifiSSID().then(
|
|
73
|
-
(ssid) => {
|
|
74
|
-
if (ssid !== wifi_ssid) {
|
|
75
|
-
const IsRobot = devicePrefixName === 'ROBOT';
|
|
76
|
-
if (IsRobot) {
|
|
77
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
78
|
-
navigate(Routes.AddDeviceStack, {
|
|
79
|
-
screen: Routes.AddCommonSelectSubUnit,
|
|
80
|
-
params: {
|
|
81
|
-
scan_sensor_data: scan_sensor_data,
|
|
82
|
-
addType: 'AddDeviceNewFlow',
|
|
83
|
-
gateway: data?.gateway,
|
|
84
|
-
unit_id: unit_id,
|
|
85
|
-
devicePrefixName: devicePrefixName,
|
|
86
|
-
wifi_ssid: wifi_ssid,
|
|
87
|
-
wifi_pass: wifi_pass,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
clearInterval(checkWifiInterval);
|
|
91
|
-
} else {
|
|
92
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
93
|
-
navigate(Routes.AddDeviceStack, {
|
|
94
|
-
screen: Routes.ConnectingProcess,
|
|
95
|
-
params: {
|
|
96
|
-
unit_id: unit_id,
|
|
97
|
-
unit_name: unit_name,
|
|
98
|
-
scan_sensor_data: scan_sensor_data,
|
|
99
|
-
gateway: data?.gateway,
|
|
100
|
-
devicePrefixName: devicePrefixName,
|
|
101
|
-
chip_id: chip_id,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
clearInterval(checkWifiInterval);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
() => {
|
|
109
|
-
ToastBottomHelper.error('Cannot get current SSID!');
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
}, 3000);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
[
|
|
116
|
-
chip_id,
|
|
117
|
-
devicePrefixName,
|
|
118
|
-
navigate,
|
|
119
|
-
scan_sensor_data,
|
|
120
|
-
setAction,
|
|
121
|
-
unit_id,
|
|
122
|
-
unit_name,
|
|
123
|
-
wifi_pass,
|
|
124
|
-
wifi_ssid,
|
|
125
|
-
]
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const sendConnect = useCallback(
|
|
129
|
-
(i) => {
|
|
130
|
-
const timeoutSendConnect = setTimeout(async () => {
|
|
131
|
-
i++;
|
|
132
|
-
socket.send(
|
|
133
|
-
JSON.stringify({
|
|
134
|
-
type: 'connect',
|
|
135
|
-
data: { wifi: { ssid: selectedWifi, pass: password } },
|
|
136
|
-
}),
|
|
137
|
-
undefined,
|
|
138
|
-
undefined,
|
|
139
|
-
54321,
|
|
140
|
-
'192.168.27.1',
|
|
141
|
-
undefined
|
|
142
|
-
);
|
|
143
|
-
if (i < 3) {
|
|
144
|
-
sendConnect(i);
|
|
145
|
-
clearTimeout(timeoutSendConnect);
|
|
146
|
-
}
|
|
147
|
-
}, 1000);
|
|
148
|
-
},
|
|
149
|
-
[password, selectedWifi, socket]
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const connectWifi = useCallback(async () => {
|
|
153
|
-
if (!isConnectWifiGateway) {
|
|
154
|
-
socket.on('message', (msg, rinfo) => {
|
|
155
|
-
handleSocketOnMsg(msg);
|
|
156
|
-
});
|
|
157
|
-
socket.on('error', () => {
|
|
158
|
-
ToastBottomHelper.error(t('server_error'));
|
|
159
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
160
|
-
goBack();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
sendConnect(0);
|
|
164
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, true);
|
|
165
|
-
setIsSendWifi(true);
|
|
166
|
-
}
|
|
167
|
-
}, [
|
|
168
|
-
goBack,
|
|
169
|
-
handleSocketOnMsg,
|
|
170
|
-
isConnectWifiGateway,
|
|
171
|
-
sendConnect,
|
|
172
|
-
setAction,
|
|
173
|
-
socket,
|
|
174
|
-
t,
|
|
175
|
-
]);
|
|
176
|
-
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (!isConnectWifiGateway) {
|
|
179
|
-
setIsShowPopupPassword(false);
|
|
180
|
-
}
|
|
181
|
-
}, [isConnectWifiGateway]);
|
|
182
|
-
|
|
183
|
-
const onCloseModal = useCallback(() => {
|
|
184
|
-
if (isSendWifi) {
|
|
185
|
-
setAction(Action.IS_CONNECT_WIFI_GATEWAY, false);
|
|
186
|
-
setIsShowPopupPassword(false);
|
|
187
|
-
setIsSendWifi(false);
|
|
188
|
-
}
|
|
189
|
-
}, [isSendWifi, setAction]);
|
|
190
|
-
|
|
191
|
-
const handleOnGoBack = useCallback(() => {
|
|
192
|
-
navigate(Routes.Dashboard);
|
|
193
|
-
}, [navigate]);
|
|
194
|
-
|
|
195
|
-
return (
|
|
196
|
-
<View style={styles.screen}>
|
|
197
|
-
<HeaderCustom
|
|
198
|
-
onGoBack={handleOnGoBack}
|
|
199
|
-
title={t('connect_home_wifi')}
|
|
200
|
-
isShowSeparator
|
|
201
|
-
/>
|
|
202
|
-
<View>
|
|
203
|
-
<Text style={styles.title} semibold type="H3">
|
|
204
|
-
{t('set_network')}
|
|
205
|
-
</Text>
|
|
206
|
-
<Text style={styles.subTitle} type="Body">
|
|
207
|
-
{t('select_wifi')}
|
|
208
|
-
</Text>
|
|
209
|
-
|
|
210
|
-
<ScrollView
|
|
211
|
-
style={styles.listContainer}
|
|
212
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
213
|
-
>
|
|
214
|
-
{!!list_wifi.length &&
|
|
215
|
-
list_wifi.map((item, index) => (
|
|
216
|
-
<TouchableOpacity
|
|
217
|
-
key={index}
|
|
218
|
-
style={styles.listItem}
|
|
219
|
-
onPress={() => showPopupPassword(item.ssid)}
|
|
220
|
-
>
|
|
221
|
-
<Text type="H4" style={styles.textItem}>
|
|
222
|
-
{item.ssid}
|
|
223
|
-
</Text>
|
|
224
|
-
<View style={styles.wifiIcon}>
|
|
225
|
-
<WifiIcon />
|
|
226
|
-
</View>
|
|
227
|
-
</TouchableOpacity>
|
|
228
|
-
))}
|
|
229
|
-
</ScrollView>
|
|
230
|
-
</View>
|
|
231
|
-
|
|
232
|
-
<ButtonPopup
|
|
233
|
-
testID={TESTID.GATEWAY_WIFI_LIST.BUTTON_POPUP}
|
|
234
|
-
visible={isShowPopupPassword}
|
|
235
|
-
mainTitle={
|
|
236
|
-
isConnectWifiGateway ? (
|
|
237
|
-
<ActivityIndicator color={Colors.White} size={'small'} />
|
|
238
|
-
) : (
|
|
239
|
-
t('connect')
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
onPressMain={connectWifi}
|
|
243
|
-
secondaryTitle={t('cancel')}
|
|
244
|
-
typeSecondary={isConnectWifiGateway ? 'disabled' : 'cancel'}
|
|
245
|
-
onPressSecondary={() => setIsShowPopupPassword(false)}
|
|
246
|
-
hideClose
|
|
247
|
-
onClose={isSendWifi ? onCloseModal : () => <></>}
|
|
248
|
-
>
|
|
249
|
-
<>
|
|
250
|
-
<Text>{t('enter_wifi_password')}</Text>
|
|
251
|
-
<TextInputPassword
|
|
252
|
-
secureTextEntry
|
|
253
|
-
placeholder={t('password')}
|
|
254
|
-
onChange={onPasswordChange}
|
|
255
|
-
value={password}
|
|
256
|
-
textInputStyle={styles.input}
|
|
257
|
-
selectionColor={Colors.Primary}
|
|
258
|
-
/>
|
|
259
|
-
</>
|
|
260
|
-
</ButtonPopup>
|
|
261
|
-
</View>
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
export default GatewayWifiList;
|
|
266
|
-
|
|
267
|
-
const styles = StyleSheet.create({
|
|
268
|
-
screen: {
|
|
269
|
-
flex: 1,
|
|
270
|
-
backgroundColor: Colors.Gray2,
|
|
271
|
-
},
|
|
272
|
-
title: {
|
|
273
|
-
marginVertical: 16,
|
|
274
|
-
marginLeft: 16,
|
|
275
|
-
},
|
|
276
|
-
subTitle: {
|
|
277
|
-
marginBottom: 16,
|
|
278
|
-
marginLeft: 16,
|
|
279
|
-
},
|
|
280
|
-
listContainer: {
|
|
281
|
-
borderWidth: 1,
|
|
282
|
-
backgroundColor: Colors.White,
|
|
283
|
-
borderRadius: 20,
|
|
284
|
-
borderColor: Colors.Gray4,
|
|
285
|
-
},
|
|
286
|
-
listItem: {
|
|
287
|
-
borderBottomColor: Colors.Gray4,
|
|
288
|
-
flex: 1,
|
|
289
|
-
flexDirection: 'row',
|
|
290
|
-
justifyContent: 'space-between',
|
|
291
|
-
alignItems: 'center',
|
|
292
|
-
},
|
|
293
|
-
textItem: {
|
|
294
|
-
paddingVertical: 16,
|
|
295
|
-
paddingLeft: 16,
|
|
296
|
-
},
|
|
297
|
-
wifiIcon: {
|
|
298
|
-
paddingRight: 16,
|
|
299
|
-
},
|
|
300
|
-
input: {
|
|
301
|
-
height: 40,
|
|
302
|
-
marginVertical: 12,
|
|
303
|
-
borderWidth: 1,
|
|
304
|
-
padding: 10,
|
|
305
|
-
borderColor: Colors.Gray5,
|
|
306
|
-
},
|
|
307
|
-
});
|