Unverified Commit ccae1afd authored by Tankred Hase's avatar Tankred Hase Committed by GitHub

Merge pull request #1107 from lightninglabs/dev/prevent-back-navigation-from-home

Dev/prevent back navigation from home
parents f39cb66f 04312758
......@@ -15,7 +15,7 @@ import {
// NativeEventEmitter,
} from 'react-native';
import { SecureStore, LocalAuthentication, Linking } from 'expo';
import { NavigationActions } from 'react-navigation';
import { NavigationActions, StackActions } from 'react-navigation';
import { nap } from '../helper';
import store from '../store';
import AppStorage from './app-storage';
......@@ -47,7 +47,7 @@ export const grpc = sinon.createStubInstance(GrpcAction); // STUB DURING DEVELOP
// export const ipc = new IpcAction(grpc);
export const ipc = sinon.createStubInstance(IpcAction); // STUB DURING DEVELOPMENT
export const log = new LogAction(store, ipc, false);
export const nav = new NavAction(store, NavigationActions);
export const nav = new NavAction(store, NavigationActions, StackActions);
export const notify = new NotificationAction(store, nav);
export const wallet = new WalletAction(store, grpc, db, nav, notify);
export const info = new InfoAction(store, grpc, nav, notify);
......
......@@ -5,14 +5,29 @@
*/
class NavAction {
constructor(store, Navigation) {
constructor(store, NavigationActions, StackActions) {
this._store = store;
this._Navigation = Navigation;
this._navActions = NavigationActions;
this._stackActions = StackActions;
}
setTopLevelNavigator(navigatorRef) {
this._navigate = (routeName, params) =>
navigatorRef.dispatch(this._Navigation.navigate({ routeName, params }));
this._navigate = routeName =>
navigatorRef.dispatch(this._navActions.navigate({ routeName }));
this._reset = (stackName, routeName) =>
navigatorRef.dispatch(
this._stackActions.reset({
index: 0,
actions: [
this._navActions.navigate({
routeName: stackName,
action: this._navActions.navigate({ routeName }),
}),
],
})
);
this._store.navReady = true;
}
......@@ -70,6 +85,7 @@ class NavAction {
goLoaderSyncing() {
this._navigate('LoaderSyncing');
this._reset('Main', 'LoaderSyncing');
}
goWait() {
......@@ -78,6 +94,7 @@ class NavAction {
goHome() {
this._navigate('Home');
this._reset('Main', 'Home');
}
goPay() {
......
......@@ -194,11 +194,6 @@ const MainStack = createStackNavigator(
Password,
LoaderSyncing,
Home,
Settings,
SettingsUnit,
SettingsFiat,
CLI,
Notifications,
},
stackOptions
);
......@@ -243,6 +238,17 @@ const ChannelStack = createStackNavigator(
stackOptions
);
const SettingStack = createStackNavigator(
{
Settings,
SettingsUnit,
SettingsFiat,
CLI,
Notifications,
},
stackOptions
);
const RootStack = createStackNavigator(
{
Main: MainStack,
......@@ -250,6 +256,7 @@ const RootStack = createStackNavigator(
Pay: PayStack,
Transactions: TransactionStack,
Channels: ChannelStack,
Settings: SettingStack,
Deposit,
},
{
......
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