Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

- Removes the compatibility of this with `ReSwift-Recorder`, which itself is being deprecated.
- Ensures compatibility with latest versions of `ReSwift` which have removed these types.
- Renamed argument labels for modern Swift conformance ([#116](<https://github.com/ReSwift/ReSwift-Router/pull/116>)) - @TaeJoongYoon
- Renamed `routingActionsForTransitionFrom(_ oldRoute:,newRoute:)` method to `routingActionsForTransition(from oldRoute:,to newRoute:)`
- Renamed `routableIndexForRouteSegment(_ segment:)` method to `routableIndex(for segment:)`

**Other:**
- Update to ReSwift 4.1.1 and fix project setup for SwiftPM & Carthage - @djtech42
Expand Down
13 changes: 13 additions & 0 deletions ReSwiftRouter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
625E66CF1C1FFE280027C288 /* ReSwiftRouter */,
625E66F21C2000EA0027C288 /* ReSwiftRouterTests */,
625E66CE1C1FFE280027C288 /* Products */,
6F0B3C2C22969D7700F1BAAC /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -260,6 +261,13 @@
name = Frameworks;
sourceTree = "<group>";
};
6F0B3C2C22969D7700F1BAAC /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
D47F3A4D1E00839D00AAA70A /* iOS */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -536,6 +544,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 625E66C31C1FFE270027C288;
Expand Down Expand Up @@ -1111,6 +1120,7 @@
PRODUCT_NAME = ReSwiftRouter;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1134,6 +1144,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.ReSwiftRouter";
PRODUCT_NAME = ReSwiftRouter;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -1148,6 +1159,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.SwiftFlowRouterTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1162,6 +1174,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.SwiftFlowRouterTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
21 changes: 11 additions & 10 deletions ReSwiftRouter/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ open class Router<State: StateType>: StoreSubscriber {
}

open func newState(state: NavigationState) {
let routingActions = Router.routingActionsForTransitionFrom(
lastNavigationState.route, newRoute: state.route)
let routingActions = Router.routingActionsForTransition(from: lastNavigationState.route,
to: state.route)

routingActions.forEach { routingAction in

Expand Down Expand Up @@ -114,12 +114,13 @@ open class Router<State: StateType>: StoreSubscriber {
// is not represented in the route, e.g.
// route = ["tabBar"]
// routables = [RootRoutable, TabBarRoutable]
static func routableIndexForRouteSegment(_ segment: Int) -> Int {
return segment + 1
static func routableIndex(for segment: Int) -> Int {
return segment + 1
}

static func routingActionsForTransitionFrom(_ oldRoute: Route,
newRoute: Route) -> [RoutingActions] {
static func routingActionsForTransition(
from oldRoute: Route,
to newRoute: Route) -> [RoutingActions] {

var routingActions: [RoutingActions] = []

Expand Down Expand Up @@ -147,7 +148,7 @@ open class Router<State: StateType>: StoreSubscriber {
let routeSegmentToPop = oldRoute[routeBuildingIndex]

let popAction = RoutingActions.pop(
responsibleRoutableIndex: routableIndexForRouteSegment(routeBuildingIndex - 1),
responsibleRoutableIndex: routableIndex(for: routeBuildingIndex - 1),
segmentToBePopped: routeSegmentToPop
)

Expand All @@ -160,7 +161,7 @@ open class Router<State: StateType>: StoreSubscriber {
// we need to pop the route segment after the commonSubroute"
if oldRoute.count > newRoute.count {
let popAction = RoutingActions.pop(
responsibleRoutableIndex: routableIndexForRouteSegment(routeBuildingIndex - 1),
responsibleRoutableIndex: routableIndex(for: routeBuildingIndex - 1),
segmentToBePopped: oldRoute[routeBuildingIndex]
)

Expand All @@ -172,7 +173,7 @@ open class Router<State: StateType>: StoreSubscriber {
// the old route element with the new one"
else if oldRoute.count > (commonSubroute + 1) && newRoute.count > (commonSubroute + 1) {
let changeAction = RoutingActions.change(
responsibleRoutableIndex: routableIndexForRouteSegment(commonSubroute),
responsibleRoutableIndex: routableIndex(for: commonSubroute),
segmentToBeReplaced: oldRoute[commonSubroute + 1],
newSegment: newRoute[commonSubroute + 1])

Expand All @@ -189,7 +190,7 @@ open class Router<State: StateType>: StoreSubscriber {
let routeSegmentToPush = newRoute[routeBuildingIndex + 1]

let pushAction = RoutingActions.push(
responsibleRoutableIndex: routableIndexForRouteSegment(routeBuildingIndex),
responsibleRoutableIndex: routableIndex(for: routeBuildingIndex),
segmentToBePushed: routeSegmentToPush
)

Expand Down
32 changes: 16 additions & 16 deletions ReSwiftRouterTests/ReSwiftRouterTestsUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let oldRoute: Route = []
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var action1Correct: Bool?
var action2Correct: Bool?
Expand Down Expand Up @@ -62,8 +62,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let oldRoute = [tabBarViewControllerIdentifier, counterViewControllerIdentifier]
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var controllerIndex: Int?
var toBeReplaced: RouteElementIdentifier?
Expand All @@ -88,8 +88,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier,
infoViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var action1Correct: Bool?
var action2Correct: Bool?
Expand Down Expand Up @@ -124,8 +124,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let oldRoute = [tabBarViewControllerIdentifier]
let newRoute = [statsViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var controllerIndex: Int?
var toBeReplaced: RouteElementIdentifier?
Expand All @@ -149,8 +149,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let oldRoute: Route = []
let newRoute: Route = []

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

expect(routingActions).to(haveCount(0))
}
Expand All @@ -159,8 +159,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let oldRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

expect(routingActions).to(haveCount(0))
}
Expand All @@ -170,8 +170,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
counterViewControllerIdentifier]
let newRoute = [tabBarViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var action1Correct: Bool?
var action2Correct: Bool?
Expand Down Expand Up @@ -204,8 +204,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier,
counterViewControllerIdentifier]

let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
newRoute: newRoute)
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
to: newRoute)

var action1Correct: Bool?
var action2Correct: Bool?
Expand Down