Don't require DuckableContainer to manage navigation controller

This commit is contained in:
Shadowfacts 2023-04-23 20:08:57 -04:00
parent b3d5ed8505
commit a20e8b2f48
3 changed files with 15 additions and 4 deletions

View File

@ -244,6 +244,13 @@ public final class ComposeController: ViewController {
} }
var body: some View { var body: some View {
NavigationView {
navRoot
}
.navigationViewStyle(.stack)
}
private var navRoot: some View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
// just using .background doesn't work; for some reason it gets inset immediately after the software keyboard is dismissed // just using .background doesn't work; for some reason it gets inset immediately after the software keyboard is dismissed
config.backgroundColor config.backgroundColor
@ -291,6 +298,7 @@ public final class ComposeController: ViewController {
}) })
.onDisappear(perform: controller.onDisappear) .onDisappear(perform: controller.onDisappear)
.navigationTitle(controller.navigationTitle) .navigationTitle(controller.navigationTitle)
.navigationBarTitleDisplayMode(.inline)
} }
private var mainList: some View { private var mainList: some View {

View File

@ -63,6 +63,9 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) { let fadeAnimator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
presented.view.layer.opacity = 0 presented.view.layer.opacity = 0
} }
fadeAnimator.addCompletion { _ in
presented.view.layer.opacity = 1
}
fadeAnimator.startAnimation(afterDelay: 0.3) fadeAnimator.startAnimation(afterDelay: 0.3)
} else { } else {
@ -80,6 +83,7 @@ class DuckAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
presented.view.layer.opacity = 0 presented.view.layer.opacity = 0
} }
fadeAnimator.addCompletion { _ in fadeAnimator.addCompletion { _ in
presented.view.layer.opacity = 1
duckable.duckableViewControllerDidFinishAnimatingDuck() duckable.duckableViewControllerDidFinishAnimatingDuck()
transitionContext.completeTransition(true) transitionContext.completeTransition(true)
} }

View File

@ -88,10 +88,9 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
private func doPresentDuckable(_ viewController: DuckableViewController, animated: Bool, completion: (() -> Void)?) { private func doPresentDuckable(_ viewController: DuckableViewController, animated: Bool, completion: (() -> Void)?) {
viewController.duckableDelegate = self viewController.duckableDelegate = self
let nav = UINavigationController(rootViewController: viewController) viewController.modalPresentationStyle = .custom
nav.modalPresentationStyle = .custom viewController.transitioningDelegate = self
nav.transitioningDelegate = self present(viewController, animated: animated) {
present(nav, animated: animated) {
self.configureChildForDuckedPlaceholder() self.configureChildForDuckedPlaceholder()
completion?() completion?()
} }