|
@@ -34,17 +34,21 @@ export const backButtonHandler = ({dispatch, getState}) => {
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const topOfNavigationStack = ({routes}) => routes[routes.length - 1] || {};
|
|
|
|
+const isRoute = expected => ({routeName}) => routeName === expected;
|
|
|
|
+const isTopRoute = expected => state => isRoute(expected)(topOfNavigationStack(state));
|
|
|
|
+
|
|
export const navigationHelpers = {
|
|
export const navigationHelpers = {
|
|
- topOfNavigationStack: ({routes}) => routes[routes.length - 1] || {},
|
|
|
|
|
|
+ topOfNavigationStack,
|
|
|
|
|
|
resetRoutes: routeNames => reset({
|
|
resetRoutes: routeNames => reset({
|
|
actions: routeNames.map(routeName => navigate({routeName})),
|
|
actions: routeNames.map(routeName => navigate({routeName})),
|
|
index: routeNames.length - 1
|
|
index: routeNames.length - 1
|
|
}),
|
|
}),
|
|
|
|
|
|
- isRoute: expected => ({routeName}) => routeName === expected,
|
|
|
|
|
|
+ isRoute,
|
|
|
|
|
|
- isTopRoute: expected => state => isRoute(expected)(topOfNavigationStack(state)),
|
|
|
|
|
|
+ isTopRoute,
|
|
|
|
|
|
goBackFrom: routeName => ({dispatch, getState}) => {
|
|
goBackFrom: routeName => ({dispatch, getState}) => {
|
|
if (isTopRoute(routeName)(getState())) {
|
|
if (isTopRoute(routeName)(getState())) {
|