-
Notifications
You must be signed in to change notification settings - Fork 175
/
PageTransition.swift
36 lines (33 loc) 路 1.31 KB
/
PageTransition.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// PageViewTransition.swift
// XCoordinator
//
// Created by Paul Kraft on 29.07.18.
// Copyright 漏 2018 QuickBird Studios. All rights reserved.
//
public typealias PageTransition = Transition<UIPageViewController>
extension Transition where RootViewController: UIPageViewController {
public static func set(_ first: Presentable, _ second: Presentable? = nil,
direction: UIPageViewController.NavigationDirection) -> PageTransition {
let presentables = [first, second].compactMap { $0 }
return PageTransition(presentables: presentables, animation: nil) { options, performer, completion in
performer.set(presentables.map { $0.viewController },
direction: direction,
with: options
) {
presentables.forEach { $0.presented(from: performer) }
completion?()
}
}
}
static func initial(pages: [Presentable]) -> Transition {
return Transition(presentables: pages, animation: nil) { _, performer, completion in
CATransaction.begin()
CATransaction.setCompletionBlock {
pages.forEach { $0.presented(from: performer) }
completion?()
}
CATransaction.commit()
}
}
}