From a20e8b2f484a8d58be67a9293b14945b3b8a1672 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 23 Apr 2023 20:08:57 -0400 Subject: [PATCH] Don't require DuckableContainer to manage navigation controller --- .../Sources/ComposeUI/Controllers/ComposeController.swift | 8 ++++++++ .../Sources/Duckable/DuckAnimationController.swift | 4 ++++ .../Duckable/DuckableContainerViewController.swift | 7 +++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index 6ce9606d9a..b9c03bc079 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -244,6 +244,13 @@ public final class ComposeController: ViewController { } var body: some View { + NavigationView { + navRoot + } + .navigationViewStyle(.stack) + } + + private var navRoot: some View { ZStack(alignment: .top) { // just using .background doesn't work; for some reason it gets inset immediately after the software keyboard is dismissed config.backgroundColor @@ -291,6 +298,7 @@ public final class ComposeController: ViewController { }) .onDisappear(perform: controller.onDisappear) .navigationTitle(controller.navigationTitle) + .navigationBarTitleDisplayMode(.inline) } private var mainList: some View { diff --git a/Packages/Duckable/Sources/Duckable/DuckAnimationController.swift b/Packages/Duckable/Sources/Duckable/DuckAnimationController.swift index 38182104de..2048d7458e 100644 --- a/Packages/Duckable/Sources/Duckable/DuckAnimationController.swift +++ b/Packages/Duckable/Sources/Duckable/DuckAnimationController.swift @@ -63,6 +63,9 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning { let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) { presented.view.layer.opacity = 0 } + fadeAnimator.addCompletion { _ in + presented.view.layer.opacity = 1 + } fadeAnimator.startAnimation(afterDelay: 0.3) } else { @@ -80,6 +83,7 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning { presented.view.layer.opacity = 0 } fadeAnimator.addCompletion { _ in + presented.view.layer.opacity = 1 duckable.duckableViewControllerDidFinishAnimatingDuck() transitionContext.completeTransition(true) } diff --git a/Packages/Duckable/Sources/Duckable/DuckableContainerViewController.swift b/Packages/Duckable/Sources/Duckable/DuckableContainerViewController.swift index e555f68305..57946ecebd 100644 --- a/Packages/Duckable/Sources/Duckable/DuckableContainerViewController.swift +++ b/Packages/Duckable/Sources/Duckable/DuckableContainerViewController.swift @@ -88,10 +88,9 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont private func doPresentDuckable(_ viewController: DuckableViewController, animated: Bool, completion: (() -> Void)?) { viewController.duckableDelegate = self - let nav = UINavigationController(rootViewController: viewController) - nav.modalPresentationStyle = .custom - nav.transitioningDelegate = self - present(nav, animated: animated) { + viewController.modalPresentationStyle = .custom + viewController.transitioningDelegate = self + present(viewController, animated: animated) { self.configureChildForDuckedPlaceholder() completion?() }