Skip to content

Commit

Permalink
Merge pull request #60 from quickbirdstudios/fix/splitCoordinator-set…
Browse files Browse the repository at this point in the history
…ViewControllers-transaction

Ensure presented(from:) is called at the correct time in TabBarTransition and SplitCoordinator
  • Loading branch information
pauljohanneskraft committed Jan 10, 2019
2 parents 663415c + a517872 commit 842ea31
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion XCoordinator.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'XCoordinator'
spec.version = '1.2.2'
spec.version = '1.2.3'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://github.com/quickbirdstudios/XCoordinator'
spec.authors = { 'Stefan Kofler' => 'stefan.kofler@quickbirdstudios.com', 'Paul Kraft' => 'pauljohannes.kraft@quickbirdstudios.com' }
Expand Down
7 changes: 1 addition & 6 deletions XCoordinator/Classes/SplitCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
// Copyright © 2018 QuickBird Studios. All rights reserved.
//

public typealias SplitTransition = Transition<UISplitViewController>

open class SplitCoordinator<RouteType: Route>: BaseCoordinator<RouteType, SplitTransition> {

// MARK: - Init

public init(master: Presentable, detail: Presentable?) {
super.init(initialRoute: nil)
rootViewController.viewControllers = [master.viewController, detail?.viewController].compactMap { $0 }
master.presented(from: self)
detail?.presented(from: self)
super.init(initialTransition: .set([master, detail].compactMap { $0 }))
}
}
22 changes: 22 additions & 0 deletions XCoordinator/Classes/SplitTransition.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// SplitTransition.swift
// Action
//
// Created by Paul Kraft on 10.01.19.
//

public typealias SplitTransition = Transition<UISplitViewController>

extension Transition where RootViewController: UISplitViewController {
static func set(_ presentables: [Presentable]) -> Transition {
return Transition(presentables: presentables, animation: nil) { _, performer, completion in
CATransaction.begin()
CATransaction.setCompletionBlock {
presentables.forEach { $0.presented(from: performer) }
completion?()
}
performer.rootViewController.viewControllers = presentables.map { $0.viewController }
CATransaction.commit()
}
}
}
5 changes: 4 additions & 1 deletion XCoordinator/Classes/TabBarTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ extension Transition where RootViewController: UITabBarController {
performer.set(presentables.map { $0.viewController },
with: options,
animation: animation,
completion: completion)
completion: {
presentables.forEach { $0.presented(from: performer) }
completion?()
})
}
}

Expand Down

0 comments on commit 842ea31

Please sign in to comment.