diff --git a/Display/GenerateImage.swift b/Display/GenerateImage.swift index 87e777b32c..d0a75a8b88 100644 --- a/Display/GenerateImage.swift +++ b/Display/GenerateImage.swift @@ -80,7 +80,28 @@ public func generateFilledCircleImage(radius: CGFloat, color: UIColor?, backgrou } public func generateStretchableFilledCircleImage(radius: CGFloat, color: UIColor?, backgroundColor: UIColor? = nil) -> UIImage? { - return generateFilledCircleImage(radius: radius, color: color, backgroundColor: backgroundColor)?.stretchableImage(withLeftCapWidth: Int(radius), topCapHeight: Int(radius)) + let intRadius = Int(radius) + let cap = intRadius == 1 ? 2 : intRadius + return generateFilledCircleImage(radius: radius, color: color, backgroundColor: backgroundColor)?.stretchableImage(withLeftCapWidth: cap, topCapHeight: cap) +} + +public func generateVerticallyStretchableFilledCircleImage(radius: CGFloat, color: UIColor?, backgroundColor: UIColor? = nil) -> UIImage? { + return generateImage(CGSize(width: radius * 2.0, height: radius * 2.0 + radius), contextGenerator: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) + if let backgroundColor = backgroundColor { + context.setFillColor(backgroundColor.cgColor) + context.fill(CGRect(origin: CGPoint(), size: size)) + } + + if let color = color { + context.setFillColor(color.cgColor) + } else { + context.setFillColor(UIColor.clear.cgColor) + context.setBlendMode(.copy) + } + context.fillEllipse(in: CGRect(origin: CGPoint(), size: CGSize(width: radius + radius, height: radius + radius))) + context.fillEllipse(in: CGRect(origin: CGPoint(x: 0.0, y: radius), size: CGSize(width: radius + radius, height: radius + radius))) + })?.stretchableImage(withLeftCapWidth: Int(radius), topCapHeight: Int(radius)) } public func generateTintedImage(image: UIImage?, color: UIColor, backgroundColor: UIColor? = nil) -> UIImage? { diff --git a/Display/NavigationController.swift b/Display/NavigationController.swift index 0e4dd1d01b..ccac1ccfcc 100644 --- a/Display/NavigationController.swift +++ b/Display/NavigationController.swift @@ -129,12 +129,12 @@ open class NavigationController: NavigationControllerProxy, ContainableControlle self.navigationTransitionCoordinator = navigationTransitionCoordinator } case UIGestureRecognizerState.changed: - if let navigationTransitionCoordinator = self.navigationTransitionCoordinator { + if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion { let translation = recognizer.translation(in: self.view).x navigationTransitionCoordinator.progress = max(0.0, min(1.0, translation / self.view.frame.width)) } case UIGestureRecognizerState.ended: - if let navigationTransitionCoordinator = self.navigationTransitionCoordinator { + if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion { let velocity = recognizer.velocity(in: self.view).x if velocity > 1000 || navigationTransitionCoordinator.progress > 0.2 { @@ -183,7 +183,7 @@ open class NavigationController: NavigationControllerProxy, ContainableControlle } } case .cancelled: - if let navigationTransitionCoordinator = self.navigationTransitionCoordinator { + if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion { if self.viewControllers.count >= 2 && self.navigationTransitionCoordinator == nil { let topController = self.viewControllers[self.viewControllers.count - 1] as UIViewController let bottomController = self.viewControllers[self.viewControllers.count - 2] as UIViewController @@ -318,6 +318,8 @@ open class NavigationController: NavigationControllerProxy, ContainableControlle let navigationTransitionCoordinator = NavigationTransitionCoordinator(transition: .Push, container: self.view, topView: topView, topNavigationBar: (topController as? ViewController)?.navigationBar, bottomView: bottomView, bottomNavigationBar: (bottomController as? ViewController)?.navigationBar) self.navigationTransitionCoordinator = navigationTransitionCoordinator + topView.isUserInteractionEnabled = false + navigationTransitionCoordinator.animateCompletion(0.0, completion: { [weak self] in if let strongSelf = self { strongSelf.navigationTransitionCoordinator = nil @@ -328,6 +330,8 @@ open class NavigationController: NavigationControllerProxy, ContainableControlle topController.setIgnoreAppearanceMethodInvocations(false) bottomController.setIgnoreAppearanceMethodInvocations(false) + topController.view.isUserInteractionEnabled = true + bottomController.viewDidDisappear(true) topController.viewDidAppear(true) diff --git a/Display/NavigationTransitionCoordinator.swift b/Display/NavigationTransitionCoordinator.swift index 9e38577d36..26858c75ee 100644 --- a/Display/NavigationTransitionCoordinator.swift +++ b/Display/NavigationTransitionCoordinator.swift @@ -37,6 +37,8 @@ class NavigationTransitionCoordinator { private let inlineNavigationBarTransition: Bool + private(set) var animatingCompletion = false + init(transition: NavigationTransition, container: UIView, topView: UIView, topNavigationBar: NavigationBar?, bottomView: UIView, bottomNavigationBar: NavigationBar?) { self.transition = transition self.container = container @@ -176,6 +178,7 @@ class NavigationTransitionCoordinator { } func animateCompletion(_ velocity: CGFloat, completion: @escaping () -> ()) { + self.animatingCompletion = true let distance = (1.0 - self.progress) * self.container.bounds.size.width let f = { switch self.transition {