Skip to content

Commit 86af78f

Browse files
TaeJoongYoonDivineDominion
authored andcommitted
Renamed Argument Labels for modern Swift naming convention (#116)
``` // From routingActionsForTransitionFrom(_ oldRoute:,newRoute:) // To routingActionsForTransition(from oldRoute:,to newRoute:) // From routableIndexForRouteSegment(_ segment:) // To routableIndex(for segment:) ```
1 parent c9e9173 commit 86af78f

File tree

5 files changed

+43
-26
lines changed

5 files changed

+43
-26
lines changed

.DS_Store

2 KB
Binary file not shown.

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

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

912
**Other:**
1013
- Update to ReSwift 4.1.1 and fix project setup for SwiftPM & Carthage - @djtech42

ReSwiftRouter.xcodeproj/project.pbxproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
625E66CF1C1FFE280027C288 /* ReSwiftRouter */,
196196
625E66F21C2000EA0027C288 /* ReSwiftRouterTests */,
197197
625E66CE1C1FFE280027C288 /* Products */,
198+
6F0B3C2C22969D7700F1BAAC /* Frameworks */,
198199
);
199200
sourceTree = "<group>";
200201
};
@@ -260,6 +261,13 @@
260261
name = Frameworks;
261262
sourceTree = "<group>";
262263
};
264+
6F0B3C2C22969D7700F1BAAC /* Frameworks */ = {
265+
isa = PBXGroup;
266+
children = (
267+
);
268+
name = Frameworks;
269+
sourceTree = "<group>";
270+
};
263271
D47F3A4D1E00839D00AAA70A /* iOS */ = {
264272
isa = PBXGroup;
265273
children = (
@@ -536,6 +544,7 @@
536544
developmentRegion = English;
537545
hasScannedForEncodings = 0;
538546
knownRegions = (
547+
English,
539548
en,
540549
);
541550
mainGroup = 625E66C31C1FFE270027C288;
@@ -1111,6 +1120,7 @@
11111120
PRODUCT_NAME = ReSwiftRouter;
11121121
SKIP_INSTALL = YES;
11131122
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1123+
SWIFT_VERSION = 5.0;
11141124
};
11151125
name = Debug;
11161126
};
@@ -1134,6 +1144,7 @@
11341144
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.ReSwiftRouter";
11351145
PRODUCT_NAME = ReSwiftRouter;
11361146
SKIP_INSTALL = YES;
1147+
SWIFT_VERSION = 5.0;
11371148
};
11381149
name = Release;
11391150
};
@@ -1148,6 +1159,7 @@
11481159
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
11491160
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.SwiftFlowRouterTests";
11501161
PRODUCT_NAME = "$(TARGET_NAME)";
1162+
SWIFT_VERSION = 5.0;
11511163
};
11521164
name = Debug;
11531165
};
@@ -1162,6 +1174,7 @@
11621174
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
11631175
PRODUCT_BUNDLE_IDENTIFIER = "de.benjamin-encz.SwiftFlowRouterTests";
11641176
PRODUCT_NAME = "$(TARGET_NAME)";
1177+
SWIFT_VERSION = 5.0;
11651178
};
11661179
name = Release;
11671180
};

ReSwiftRouter/Router.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ open class Router<State: StateType>: StoreSubscriber {
2525
}
2626

2727
open func newState(state: NavigationState) {
28-
let routingActions = Router.routingActionsForTransitionFrom(
29-
lastNavigationState.route, newRoute: state.route)
28+
let routingActions = Router.routingActionsForTransition(from: lastNavigationState.route,
29+
to: state.route)
3030

3131
routingActions.forEach { routingAction in
3232

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

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

124125
var routingActions: [RoutingActions] = []
125126

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

149150
let popAction = RoutingActions.pop(
150-
responsibleRoutableIndex: routableIndexForRouteSegment(routeBuildingIndex - 1),
151+
responsibleRoutableIndex: routableIndex(for: routeBuildingIndex - 1),
151152
segmentToBePopped: routeSegmentToPop
152153
)
153154

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

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

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

191192
let pushAction = RoutingActions.push(
192-
responsibleRoutableIndex: routableIndexForRouteSegment(routeBuildingIndex),
193+
responsibleRoutableIndex: routableIndex(for: routeBuildingIndex),
193194
segmentToBePushed: routeSegmentToPush
194195
)
195196

ReSwiftRouterTests/ReSwiftRouterTestsUnitTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
2929
let oldRoute: Route = []
3030
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]
3131

32-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
33-
newRoute: newRoute)
32+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
33+
to: newRoute)
3434

3535
var action1Correct: Bool?
3636
var action2Correct: Bool?
@@ -62,8 +62,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
6262
let oldRoute = [tabBarViewControllerIdentifier, counterViewControllerIdentifier]
6363
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier]
6464

65-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
66-
newRoute: newRoute)
65+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
66+
to: newRoute)
6767

6868
var controllerIndex: Int?
6969
var toBeReplaced: RouteElementIdentifier?
@@ -88,8 +88,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
8888
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier,
8989
infoViewControllerIdentifier]
9090

91-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
92-
newRoute: newRoute)
91+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
92+
to: newRoute)
9393

9494
var action1Correct: Bool?
9595
var action2Correct: Bool?
@@ -124,8 +124,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
124124
let oldRoute = [tabBarViewControllerIdentifier]
125125
let newRoute = [statsViewControllerIdentifier]
126126

127-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
128-
newRoute: newRoute)
127+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
128+
to: newRoute)
129129

130130
var controllerIndex: Int?
131131
var toBeReplaced: RouteElementIdentifier?
@@ -149,8 +149,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
149149
let oldRoute: Route = []
150150
let newRoute: Route = []
151151

152-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
153-
newRoute: newRoute)
152+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
153+
to: newRoute)
154154

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

162-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
163-
newRoute: newRoute)
162+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
163+
to: newRoute)
164164

165165
expect(routingActions).to(haveCount(0))
166166
}
@@ -170,8 +170,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
170170
counterViewControllerIdentifier]
171171
let newRoute = [tabBarViewControllerIdentifier]
172172

173-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
174-
newRoute: newRoute)
173+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
174+
to: newRoute)
175175

176176
var action1Correct: Bool?
177177
var action2Correct: Bool?
@@ -204,8 +204,8 @@ class ReSwiftRouterUnitTests: QuickSpec {
204204
let newRoute = [tabBarViewControllerIdentifier, statsViewControllerIdentifier,
205205
counterViewControllerIdentifier]
206206

207-
let routingActions = Router<AppState>.routingActionsForTransitionFrom(oldRoute,
208-
newRoute: newRoute)
207+
let routingActions = Router<AppState>.routingActionsForTransition(from: oldRoute,
208+
to: newRoute)
209209

210210
var action1Correct: Bool?
211211
var action2Correct: Bool?

0 commit comments

Comments
 (0)