Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0 #15

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
21 changes: 2 additions & 19 deletions XCoordinator-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
9B5657D42315FB3500F4F4F7 /* TransitionAnimation+Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B5657A42315FB3500F4F4F7 /* TransitionAnimation+Defaults.swift */; };
9B5657D62315FB3500F4F4F7 /* CGAffineTransform+InPlace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B5657A62315FB3500F4F4F7 /* CGAffineTransform+InPlace.swift */; };
9B5657D92315FB9700F4F4F7 /* Action in Frameworks */ = {isa = PBXBuildFile; productRef = 9B5657D82315FB9700F4F4F7 /* Action */; };
9B5657DC2315FC1000F4F4F7 /* RxCocoa in Frameworks */ = {isa = PBXBuildFile; productRef = 9B5657DB2315FC1000F4F4F7 /* RxCocoa */; };
9BD3EBF42330CE46005861BF /* Transitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD3EBF32330CE46005861BF /* Transitions.swift */; };
9BD3EBFD2330D84F005861BF /* XCText+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD3EBF62330D84E005861BF /* XCText+Extras.swift */; };
9BD3EBFE2330D84F005861BF /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD3EBF72330D84F005861BF /* XCTestManifests.swift */; };
Expand Down Expand Up @@ -167,7 +166,6 @@
buildActionMask = 2147483647;
files = (
9B0A753A2316C1810092CA3A /* XCoordinatorRx in Frameworks */,
9B5657DC2315FC1000F4F4F7 /* RxCocoa in Frameworks */,
9B5657D92315FB9700F4F4F7 /* Action in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -449,7 +447,6 @@
name = "XCoordinator-Example";
packageProductDependencies = (
9B5657D82315FB9700F4F4F7 /* Action */,
9B5657DB2315FC1000F4F4F7 /* RxCocoa */,
9B0A75392316C1810092CA3A /* XCoordinatorRx */,
);
productName = "XCoordinator-Example";
Expand Down Expand Up @@ -526,7 +523,6 @@
mainGroup = 9B56572C2315FA7B00F4F4F7;
packageReferences = (
9B5657D72315FB9700F4F4F7 /* XCRemoteSwiftPackageReference "Action" */,
9B5657DA2315FC1000F4F4F7 /* XCRemoteSwiftPackageReference "RxSwift" */,
9B5657DD2315FC5C00F4F4F7 /* XCRemoteSwiftPackageReference "XCoordinator" */,
);
productRefGroup = 9B5657362315FA7B00F4F4F7 /* Products */;
Expand Down Expand Up @@ -956,20 +952,12 @@
minimumVersion = 4.0.1;
};
};
9B5657DA2315FC1000F4F4F7 /* XCRemoteSwiftPackageReference "RxSwift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ReactiveX/RxSwift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.1;
};
};
9B5657DD2315FC5C00F4F4F7 /* XCRemoteSwiftPackageReference "XCoordinator" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/quickbirdstudios/XCoordinator.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.2;
branch = feature/3.0.0;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand All @@ -985,11 +973,6 @@
package = 9B5657D72315FB9700F4F4F7 /* XCRemoteSwiftPackageReference "Action" */;
productName = Action;
};
9B5657DB2315FC1000F4F4F7 /* RxCocoa */ = {
isa = XCSwiftPackageProductDependency;
package = 9B5657DA2315FC1000F4F4F7 /* XCRemoteSwiftPackageReference "RxSwift" */;
productName = RxCocoa;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 9B56572D2315FA7B00F4F4F7 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
{
"object": {
"pins": [
{
"package": "Action",
"repositoryURL": "https://github.com/RxSwiftCommunity/Action.git",
"state": {
"branch": null,
"revision": "cdade63f7bbe1f5e1eff7779e5858a796dc2c001",
"version": "4.0.1"
}
},
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
"state": {
"branch": null,
"revision": "b3e888b4972d9bc76495dd74d30a8c7fad4b9395",
"version": "5.0.1"
}
},
{
"package": "XCoordinator",
"repositoryURL": "https://github.com/quickbirdstudios/XCoordinator.git",
"state": {
"branch": null,
"revision": "0c16cc7061f93d278279137277efb13385e960a6",
"version": "2.0.5"
}
"pins" : [
{
"identity" : "action",
"kind" : "remoteSourceControl",
"location" : "https://github.com/RxSwiftCommunity/Action.git",
"state" : {
"revision" : "21110e93ef7b08ce9f01806827e4f381b5b09ab1",
"version" : "4.3.0"
}
]
},
"version": 1
},
{
"identity" : "rxswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift.git",
"state" : {
"revision" : "b4307ba0b6425c0ba4178e138799946c3da594f8",
"version" : "6.5.0"
}
},
{
"identity" : "xcoordinator",
"kind" : "remoteSourceControl",
"location" : "https://github.com/quickbirdstudios/XCoordinator.git",
"state" : {
"branch" : "feature/3.0.0",
"revision" : "aef3a89868b4e12e6191f2d72282cb9415dbc6ea"
}
}
],
"version" : 2
}
3 changes: 2 additions & 1 deletion XCoordinator-Example/Common/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
//

import UIKit
import XCoordinator

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: Stored properties

private lazy var mainWindow = UIWindow()
private let router = AppCoordinator().strongRouter
private let router: any Router<AppRoute> = AppCoordinator()

// MARK: UIApplicationDelegate

Expand Down
2 changes: 1 addition & 1 deletion XCoordinator-Example/Coordinators/AboutCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AboutCoordinator: NavigationCoordinator<AboutRoute> {
switch route {
case .home:
let viewController = AboutViewController()
let viewModel = AboutViewModelImpl(router: unownedRouter)
let viewModel = AboutViewModelImpl(router: self)
viewController.bind(to: viewModel)
return .push(viewController)
case .website:
Expand Down
32 changes: 18 additions & 14 deletions XCoordinator-Example/Coordinators/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCoordinator

enum AppRoute: Route {
case login
case home(StrongRouter<HomeRoute>?)
case home((any Router<HomeRoute>)?)
case newsDetail(News)
}

Expand All @@ -29,40 +29,44 @@ class AppCoordinator: NavigationCoordinator<AppRoute> {
switch route {
case .login:
let viewController = LoginViewController.instantiateFromNib()
let viewModel = LoginViewModelImpl(router: unownedRouter)
let viewModel = LoginViewModelImpl(router: self)
viewController.bind(to: viewModel)
return .push(viewController)
case let .home(router):
if let router = router {
return .presentFullScreen(router, animation: .fade)
if let router {
return .presentFullScreen(router.asPresentable, animation: .fade)
}
let alert = UIAlertController(
title: "How would you like to login?",
message: "Please choose the type of coordinator used for the `Home` scene.",
preferredStyle: .alert)
alert.addAction(
.init(title: "\(HomeTabCoordinator.self)", style: .default) { [unowned self] _ in
self.trigger(.home(HomeTabCoordinator().strongRouter))
self.trigger(.home(HomeTabCoordinator()))
}
)
alert.addAction(
.init(title: "\(HomeSplitCoordinator.self)", style: .default) { [unowned self] _ in
self.trigger(.home(HomeSplitCoordinator().strongRouter))
self.trigger(.home(HomeSplitCoordinator()))
}
)
alert.addAction(
.init(title: "\(HomePageCoordinator.self)", style: .default) { [unowned self] _ in
self.trigger(.home(HomePageCoordinator().strongRouter))
self.trigger(.home(HomePageCoordinator()))
}
)
alert.addAction(
.init(title: "Random", style: .default) { [unowned self] _ in
let routers: [() -> StrongRouter<HomeRoute>] = [
{ HomeTabCoordinator().strongRouter },
{ HomeSplitCoordinator().strongRouter },
{ HomeTabCoordinator().strongRouter }
]
let router = routers.randomElement().map { $0() }
let router: any Router<HomeRoute> = {
switch Int.random(in: 0..<3) {
case 0:
return HomeTabCoordinator()
case 1:
return HomeSplitCoordinator()
default:
return HomeTabCoordinator()
}
}()
self.trigger(.home(router))
}
)
Expand All @@ -71,7 +75,7 @@ class AppCoordinator: NavigationCoordinator<AppRoute> {
return .multiple(
.dismissAll(),
.popToRoot(),
deepLink(AppRoute.home(HomePageCoordinator().strongRouter),
deepLink(AppRoute.home(HomePageCoordinator()),
HomeRoute.news,
NewsRoute.newsDetail(news))
)
Expand Down
16 changes: 8 additions & 8 deletions XCoordinator-Example/Coordinators/HomePageCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ class HomePageCoordinator: PageCoordinator<HomeRoute> {

// MARK: Stored properties

private let newsRouter: StrongRouter<NewsRoute>
private let userListRouter: StrongRouter<UserListRoute>
private let newsRouter: any Router<NewsRoute>
private let userListRouter: any Router<UserListRoute>

// MARK: Initialization

init(newsRouter: StrongRouter<NewsRoute> = NewsCoordinator().strongRouter,
userListRouter: StrongRouter<UserListRoute> = UserListCoordinator().strongRouter) {
init(newsRouter: any Router<NewsRoute> = NewsCoordinator(),
userListRouter: any Router<UserListRoute> = UserListCoordinator()) {
self.newsRouter = newsRouter
self.userListRouter = userListRouter

super.init(
rootViewController: .init(transitionStyle: .scroll,
navigationOrientation: .horizontal,
options: nil),
pages: [userListRouter, newsRouter], loop: false,
set: userListRouter, direction: .forward
pages: [userListRouter.asPresentable, newsRouter.asPresentable], loop: false,
set: userListRouter.asPresentable, direction: .forward
)
}

Expand All @@ -36,9 +36,9 @@ class HomePageCoordinator: PageCoordinator<HomeRoute> {
override func prepareTransition(for route: HomeRoute) -> PageTransition {
switch route {
case .news:
return .set(newsRouter, direction: .forward)
return .set(newsRouter.asPresentable, direction: .forward)
case .userList:
return .set(userListRouter, direction: .reverse)
return .set(userListRouter.asPresentable, direction: .reverse)
}
}

Expand Down
14 changes: 7 additions & 7 deletions XCoordinator-Example/Coordinators/HomeSplitCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ class HomeSplitCoordinator: SplitCoordinator<HomeRoute> {

// MARK: Stored properties

private let newsRouter: StrongRouter<NewsRoute>
private let userListRouter: StrongRouter<UserListRoute>
private let newsRouter: any Router<NewsRoute>
private let userListRouter: any Router<UserListRoute>

// MARK: Initialization

init(newsRouter: StrongRouter<NewsRoute> = NewsCoordinator().strongRouter,
userListRouter: StrongRouter<UserListRoute> = UserListCoordinator().strongRouter) {
init(newsRouter: any Router<NewsRoute> = NewsCoordinator(),
userListRouter: any Router<UserListRoute> = UserListCoordinator()) {
self.newsRouter = newsRouter
self.userListRouter = userListRouter

super.init(master: userListRouter, detail: newsRouter)
super.init(primary: userListRouter.asPresentable, secondary: newsRouter.asPresentable)
}

// MARK: Overrides

override func prepareTransition(for route: HomeRoute) -> SplitTransition {
switch route {
case .news:
return .showDetail(newsRouter)
return .showDetail(newsRouter.asPresentable)
case .userList:
return .show(userListRouter)
return .show(userListRouter.asPresentable)
}
}

Expand Down
16 changes: 7 additions & 9 deletions XCoordinator-Example/Coordinators/HomeTabCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class HomeTabCoordinator: TabBarCoordinator<HomeRoute> {

// MARK: Stored properties

private let newsRouter: StrongRouter<NewsRoute>
private let userListRouter: StrongRouter<UserListRoute>
private let newsRouter: any Router<NewsRoute>
private let userListRouter: any Router<UserListRoute>

// MARK: Initialization

Expand All @@ -30,26 +30,24 @@ class HomeTabCoordinator: TabBarCoordinator<HomeRoute> {
let userListCoordinator = UserListCoordinator()
userListCoordinator.rootViewController.tabBarItem = UITabBarItem(tabBarSystemItem: .more, tag: 1)

self.init(newsRouter: newsCoordinator.strongRouter,
userListRouter: userListCoordinator.strongRouter)
self.init(newsRouter: newsCoordinator, userListRouter: userListCoordinator)
}

init(newsRouter: StrongRouter<NewsRoute>,
userListRouter: StrongRouter<UserListRoute>) {
init(newsRouter: any Router<NewsRoute>, userListRouter: any Router<UserListRoute>) {
self.newsRouter = newsRouter
self.userListRouter = userListRouter

super.init(tabs: [newsRouter, userListRouter], select: userListRouter)
super.init(tabs: [newsRouter.asPresentable, userListRouter.asPresentable], select: userListRouter.asPresentable)
}

// MARK: Overrides

override func prepareTransition(for route: HomeRoute) -> TabBarTransition {
switch route {
case .news:
return .select(newsRouter)
return .select(newsRouter.asPresentable)
case .userList:
return .select(userListRouter)
return .select(userListRouter.asPresentable)
}
}

Expand Down
2 changes: 1 addition & 1 deletion XCoordinator-Example/Coordinators/NewsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NewsCoordinator: NavigationCoordinator<NewsRoute> {
case .news:
let viewController = NewsViewController.instantiateFromNib()
let service = MockNewsService()
let viewModel = NewsViewModelImpl(newsService: service, router: unownedRouter)
let viewModel = NewsViewModelImpl(newsService: service, router: self)
viewController.bind(to: viewModel)
return .push(viewController)
case .newsDetail(let news):
Expand Down
2 changes: 1 addition & 1 deletion XCoordinator-Example/Coordinators/UserCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UserCoordinator: NavigationCoordinator<UserRoute> {
return .push(viewController, animation: .fade)
case let .user(username):
let viewController = UserViewController.instantiateFromNib()
let viewModel = UserViewModelImpl(router: unownedRouter, username: username)
let viewModel = UserViewModelImpl(router: self, username: username)
viewController.bind(to: viewModel)
return .push(viewController)
case let .alert(title, message):
Expand Down
4 changes: 2 additions & 2 deletions XCoordinator-Example/Coordinators/UserListCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class UserListCoordinator: NavigationCoordinator<UserListRoute> {
switch route {
case .home:
let viewController = HomeViewController.instantiateFromNib()
let viewModel = HomeViewModelImpl(router: unownedRouter)
let viewModel = HomeViewModelImpl(router: self)
viewController.bind(to: viewModel)
return .push(viewController)
case .users:
let viewController = UsersViewController.instantiateFromNib()
let viewModel = UsersViewModelImpl(userService: MockUserService(), router: unownedRouter)
let viewModel = UsersViewModelImpl(userService: MockUserService(), router: self)
viewController.bind(to: viewModel)
return .push(viewController, animation: .fade)
case .user(let username):
Expand Down
4 changes: 2 additions & 2 deletions XCoordinator-Example/Scenes/About/AboutViewModelImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class AboutViewModelImpl: AboutViewModel, AboutViewModelInput, AboutViewModelOut

// MARK: Stored properties

private let router: UnownedRouter<AboutRoute>
private unowned let router: any Router<AboutRoute>

// MARK: Initialization

init(router: UnownedRouter<AboutRoute>) {
init(router: any Router<AboutRoute>) {
self.router = router
}

Expand Down
Loading