Unverified Commit 78a1b5d6 authored by Hanwen Cheng's avatar Hanwen Cheng Committed by GitHub
Browse files

fix: prevent back on network choser android (#601)

* rebase on master

* use iphone 11 for e2e

* update os version
parent 23cc5f65
Pipeline #90575 failed with stages
in 5 minutes and 41 seconds
......@@ -133,7 +133,7 @@
"build": "yarn xcbuild:githubActions",
"type": "ios.simulator",
"device": {
"os": "iOS 13.3",
"os": "iOS 13.4",
"type": "iPhone 8"
}
},
......
......@@ -15,7 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { useState } from 'react';
import { ScrollView } from 'react-native';
import { BackHandler, ScrollView } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
import { NetworkCard } from 'components/AccountCard';
import { SafeAreaViewContainer } from 'components/SafeAreaContainer';
......@@ -68,6 +69,25 @@ export default function NetworkSelector({
const { identities, currentIdentity } = accounts.state;
const seedRefHooks = useSeedRef(currentIdentity!.encryptedSeed);
// catch android back button and prevent exiting the app
useFocusEffect(
React.useCallback((): any => {
const handleBackButton = (): boolean => {
if (shouldShowMoreNetworks) {
setShouldShowMoreNetworks(false);
return true;
} else {
return false;
}
};
const backHandler = BackHandler.addEventListener(
'hardwareBackPress',
handleBackButton
);
return (): void => backHandler.remove();
}, [shouldShowMoreNetworks])
);
const sortNetworkKeys = (
[, params1]: [any, NetworkParams],
[, params2]: [any, NetworkParams]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment