Skip to content

Commit 2a3e3b9

Browse files
author
Toine Heuvelmans
authored
Merge pull request #13 from mvolpato/master
Addresses XCode warnings and issue #10 Great, thanks @mvolpato ! 👍
2 parents c1681ea + 540c6a4 commit 2a3e3b9

File tree

6 files changed

+31
-24
lines changed

6 files changed

+31
-24
lines changed

Examples/NavigationTransitionsExample/Transition/Transition/InteractiveZoomTransitionController.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ extension InteractiveZoomTransitionController : SharedElementProvider {
6666

6767
let initialFrame: CGRect
6868
let targetFrame: CGRect
69+
70+
// Get top margin, depending on possible safe area
71+
var yMargin = CollectionViewController.margin
72+
73+
if #available(iOS 11.0, *) {
74+
yMargin += toViewController.collectionView.safeAreaInsets.top
75+
}
6976

7077
if isPresenting {
7178
initialFrame = fromViewController.targetFrame
72-
targetFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: CollectionViewController.margin), size: header.image.frame.size)
79+
targetFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: yMargin), size: header.image.frame.size)
7380
} else {
74-
initialFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: CollectionViewController.margin), size: header.image.frame.size)
81+
initialFrame = CGRect(origin: CGPoint(x: CollectionViewController.margin, y: yMargin), size: header.image.frame.size)
7582
targetFrame = toViewController.targetFrame
7683
}
7784

Transition/Classes/Helpers/AnimationRange+Helpers.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,40 @@ public enum AnimationRangePosition {
2929
}
3030

3131
public extension AnimationRangePosition {
32-
public var reversed: AnimationRangePosition {
32+
var reversed: AnimationRangePosition {
3333
switch self {
3434
case .contains: return .contains
3535
case .isBefore: return .isAfter
3636
case .isAfter: return .isBefore
3737
}
3838
}
39-
public func reversed(_ shouldReverse: Bool) -> AnimationRangePosition {
39+
func reversed(_ shouldReverse: Bool) -> AnimationRangePosition {
4040
return shouldReverse ? reversed : self
4141
}
4242
}
4343

4444

4545
public extension AnimationRange {
4646

47-
public var length: AnimationFraction {
47+
var length: AnimationFraction {
4848
return end - start
4949
}
5050

5151
/// Returns true if the range contains the fraction
52-
public func contains(_ fraction: AnimationFraction) -> Bool {
52+
func contains(_ fraction: AnimationFraction) -> Bool {
5353
return position(fraction) == .contains
5454
}
5555
/// Returns true if the range is positioned before the fraction
56-
public func isBefore(_ fraction: AnimationFraction) -> Bool {
56+
func isBefore(_ fraction: AnimationFraction) -> Bool {
5757
return position(fraction) == .isBefore
5858
}
5959
/// Returns true if the range is positioned after the fraction
60-
public func isAfter(_ fraction: AnimationFraction) -> Bool {
60+
func isAfter(_ fraction: AnimationFraction) -> Bool {
6161
return position(fraction) == .isAfter
6262
}
6363

6464
/// Returns the position of the range relative to the given fraction
65-
public func position(_ fraction: AnimationFraction) -> AnimationRangePosition {
65+
func position(_ fraction: AnimationFraction) -> AnimationRangePosition {
6666

6767
if end < fraction {
6868
return .isBefore
@@ -75,7 +75,7 @@ public extension AnimationRange {
7575

7676
/// Returns the distance (either measured from end or start, if the range is before or after respectively) relative to the fraction.
7777
/// Returns 0 if the range contains the fraction
78-
public func distance(to fraction: AnimationFraction) -> AnimationFraction {
78+
func distance(to fraction: AnimationFraction) -> AnimationFraction {
7979
switch position(fraction) {
8080
case .isBefore: return fraction - end
8181
case .isAfter: return start - fraction
@@ -87,7 +87,7 @@ public extension AnimationRange {
8787
/// If the position is before `fraction`, it'll return 1.
8888
/// If the position is after `fraction`, it'll return 0.
8989
/// Otherwise it maps fraction to the range.
90-
public func relativeFractionComplete(to fraction: AnimationFraction) -> AnimationFraction {
90+
func relativeFractionComplete(to fraction: AnimationFraction) -> AnimationFraction {
9191
switch position(fraction) {
9292
case .isBefore: return 1.0
9393
case .isAfter: return 0.0

Transition/Classes/Helpers/UIViewControllerContextTransitioning+Properties.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public extension UIViewControllerContextTransitioning {
3333
one presenting the "to” view controller or is the one being replaced by the "to”
3434
view controller.
3535
*/
36-
public var fromViewController: UIViewController! {
36+
var fromViewController: UIViewController! {
3737
return self.viewController(forKey: .from)
3838
}
3939

4040
/**
4141
Identifies the view controller that is visible at the end of a completed transition.
4242
This view controller is the one being presented.
4343
*/
44-
public var toViewController: UIViewController! {
44+
var toViewController: UIViewController! {
4545
return self.viewController(forKey: .to)
4646
}
4747

@@ -50,15 +50,15 @@ public extension UIViewControllerContextTransitioning {
5050
Identifies the view that is shown at the beginning of the transition (and at the end
5151
of a canceled transition). This view is typically the presenting view controller’s view.
5252
*/
53-
public var fromView: UIView! {
53+
var fromView: UIView! {
5454
return self.view(forKey: .from) ?? fromViewController.view
5555
}
5656

5757
/**
5858
Identifies the view that is shown at the end of a completed transition. This view is
5959
typically the presented view controller’s view but may also be an ancestor of that view.
6060
*/
61-
public var toView: UIView! {
61+
var toView: UIView! {
6262
return self.view(forKey: .to) ?? toViewController.view
6363
}
6464
}
@@ -70,7 +70,7 @@ public extension UIViewControllerContextTransitioning {
7070
This installs the to and from view when necessary, based on the operation.
7171
It returns the top-most view which is either the fromView or toView.
7272
*/
73-
@discardableResult public func defaultViewSetup(for operation: TransitionOperation) -> UIView? {
73+
@discardableResult func defaultViewSetup(for operation: TransitionOperation) -> UIView? {
7474
switch operation {
7575
case .navigation(let navigationOperation): return defaultViewSetup(for: navigationOperation)
7676
case .modal(let modalOperation): return defaultViewSetup(for: modalOperation)
@@ -79,7 +79,7 @@ public extension UIViewControllerContextTransitioning {
7979
}
8080
}
8181

82-
public func defaultViewSetup(for navigationOperation: UINavigationController.Operation) -> UIView? {
82+
func defaultViewSetup(for navigationOperation: UINavigationController.Operation) -> UIView? {
8383
switch navigationOperation {
8484
case .push:
8585
containerView.addSubview(toView)
@@ -93,7 +93,7 @@ public extension UIViewControllerContextTransitioning {
9393
return navigationOperation == .push ? toView : fromView
9494
}
9595

96-
public func defaultViewSetup(for modalOperation: UIViewControllerModalOperation) -> UIView? {
96+
func defaultViewSetup(for modalOperation: UIViewControllerModalOperation) -> UIView? {
9797
switch modalOperation {
9898
case .present:
9999
containerView.addSubview(toView)
@@ -107,7 +107,7 @@ public extension UIViewControllerContextTransitioning {
107107
return modalOperation == .present ? toView : fromView
108108
}
109109

110-
public func defaultViewSetup(for tabBarOperation: UITabBarControllerOperation) -> UIView? {
110+
func defaultViewSetup(for tabBarOperation: UITabBarControllerOperation) -> UIView? {
111111
guard tabBarOperation != .none else { return nil }
112112
containerView.addSubview(toView)
113113
toView.frame = finalFrame(for: toViewController)

Transition/Classes/Transition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public extension Transition {
5252

5353
/// The effective duration is the duration, influenced by the presence of any timingParameter (in animation or interaction)
5454
/// that has an implicit duration due to a spring timing curve configuration.
55-
public var effectiveDuration: TimeInterval {
55+
var effectiveDuration: TimeInterval {
5656
/// First check if there's any animationLayer that has an implicit duration (due to spring timing parameters) that
5757
/// would effectively stretch up the total duration (i.e. lasting beyond transition.duration).
5858
let animationLayersDuration = animation.layers.reduce(duration) { (currentDuration, animationLayer) -> TimeInterval in

Transition/Classes/TransitionDriver.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,17 +424,17 @@ fileprivate extension TransitionDriver {
424424
return uniqueParticipatingViewControllers.compactMap { $0 as? TransitionPhaseDelegate }
425425
}
426426

427-
fileprivate func willTransition(with sharedElement: SharedElement?) {
427+
func willTransition(with sharedElement: SharedElement?) {
428428
guard let fromViewController = context.fromViewController, let toViewController = context.toViewController else { return }
429429
uniqueTransitionPhaseDelegates.forEach { $0.willTransition(from: fromViewController, to: toViewController, with: sharedElement) }
430430
}
431431

432-
fileprivate func didTransition(with sharedElement: SharedElement?) {
432+
func didTransition(with sharedElement: SharedElement?) {
433433
guard let fromViewController = context.fromViewController, let toViewController = context.toViewController else { return }
434434
uniqueTransitionPhaseDelegates.forEach { $0.didTransition(from: fromViewController, to: toViewController, with: sharedElement) }
435435
}
436436

437-
fileprivate func cancelledTransition(with sharedElement: SharedElement?) {
437+
func cancelledTransition(with sharedElement: SharedElement?) {
438438
guard let fromViewController = context.fromViewController, let toViewController = context.toViewController else { return }
439439
uniqueTransitionPhaseDelegates.forEach { $0.cancelledTransition(from: fromViewController, to: toViewController, with: sharedElement) }
440440
}

Transition/Classes/TransitionOperationContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ public class TransitionOperationContext {
5353
* view controller of the window, a parent view controller that is marked as defining the current context,
5454
* or the last view controller that was presented. This view controller may or may not be the same as the one in the source parameter."
5555
*/
56-
internal(set) var sourceViewController: UIViewController?
56+
var sourceViewController: UIViewController?
5757
}

0 commit comments

Comments
 (0)