flutterings / flutter_redux_navigation

#18 Keep track of previous and current arguments for named routes.

Merged Erik Fahlén Erfa

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -1,5 +1,6 @@
Loading
1 1
import 'package:flutter/material.dart';
2 2
import 'package:flutter_redux_navigation/src/navigate_to_action.dart';
3 +
import 'package:flutter_redux_navigation/src/navigation_destination.dart';
3 4
import 'package:flutter_redux_navigation/src/navigation_holder.dart';
4 5
import 'package:flutter_redux_navigation/src/navigation_state.dart';
5 6
import 'package:redux/redux.dart';
@@ -31,11 +32,11 @@
Loading
31 32
        case NavigationType.shouldReplace:
32 33
          currentState.pushReplacementNamed(navigationAction.name,
33 34
              arguments: navigationAction.arguments);
34 -
          this._setState(navigationAction.name);
35 +
          this._setState(NavigationDestination(navigationAction.name, navigationAction.arguments));
35 36
          break;
36 37
        case NavigationType.shouldPop:
37 38
          currentState.pop();
38 -
          this._setState(NavigatorHolder.state?.previousPath);
39 +
          this._setState(NavigatorHolder.state?.previousDestination);
39 40
          break;
40 41
        case NavigationType.shouldPopUntil:
41 42
          currentState.popUntil(navigationAction.predicate);
@@ -50,7 +51,7 @@
Loading
50 51
        default:
51 52
          currentState.pushNamed(navigationAction.name,
52 53
              arguments: navigationAction.arguments);
53 -
          this._setState(navigationAction.name);
54 +
          this._setState(NavigationDestination(navigationAction.name, navigationAction.arguments));
54 55
      }
55 56
56 57
      if (action.postNavigation != null) {
@@ -61,8 +62,8 @@
Loading
61 62
    next(action);
62 63
  }
63 64
64 -
  void _setState(String currentPath) {
65 +
  void _setState(NavigationDestination currentDestination) {
65 66
    NavigatorHolder.state = NavigationState.transition(
66 -
        NavigatorHolder.state?.currentPath, currentPath);
67 +
        NavigatorHolder.state?.currentDestination, currentDestination);
67 68
  }
68 69
}

@@ -0,0 +1,7 @@
Loading
1 +
/// Groups together the path and arguments of a navigation destination
2 +
class NavigationDestination {
3 +
  final String path;
4 +
  final Object arguments;
5 +
6 +
  NavigationDestination(this.path, this.arguments);
7 +
}

@@ -1,12 +1,20 @@
Loading
1 +
import 'package:flutter_redux_navigation/src/navigation_destination.dart';
2 +
1 3
/// It keeps the current and previous path of the navigation.
2 4
class NavigationState {
3 -
  final String previousPath;
4 -
  final String currentPath;
5 +
  final NavigationDestination previousDestination;
6 +
  final NavigationDestination currentDestination;
7 +
8 +
  @Deprecated('Use previousDestination.path instead')
9 +
  String get previousPath => previousDestination?.path;
10 +
11 +
  @Deprecated('Use currentDestination.path instead')
12 +
  String get currentPath => currentDestination?.path;
5 13
6 -
  NavigationState(this.previousPath, this.currentPath);
14 +
  NavigationState(this.previousDestination, this.currentDestination);
7 15
8 16
  factory NavigationState.initial() => NavigationState(null, null);
9 17
10 -
  factory NavigationState.transition(String previousPath, String currentPath) =>
11 -
      NavigationState(previousPath, currentPath);
18 +
  factory NavigationState.transition(NavigationDestination previousDestination, NavigationDestination currentDestination) =>
19 +
      NavigationState(previousDestination, currentDestination);
12 20
}

Learn more Showing 1 files with coverage changes found.

New file lib/src/navigation_destination.dart
New
Loading file...
Files Coverage
lib/src 100.00%
Project Totals (5 files) 100.00%
Loading