diff --git a/Package.swift b/Package.swift index 8c3d7c2..36b01db 100644 --- a/Package.swift +++ b/Package.swift @@ -16,8 +16,8 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/nathantannar4/Engine", from: "1.9.0"), - .package(url: "https://github.com/nathantannar4/Turbocharger", from: "1.3.1"), + .package(url: "https://github.com/nathantannar4/Engine", from: "1.9.3"), + .package(url: "https://github.com/nathantannar4/Turbocharger", from: "1.3.3"), ], targets: [ .target( diff --git a/Sources/Transmission/Sources/PresentationLinkModifier.swift b/Sources/Transmission/Sources/PresentationLinkModifier.swift index cad5956..ea16f26 100644 --- a/Sources/Transmission/Sources/PresentationLinkModifier.swift +++ b/Sources/Transmission/Sources/PresentationLinkModifier.swift @@ -408,6 +408,12 @@ private struct PresentationLinkModifierBody< adapter.viewController.presentationDelegate = context.coordinator } + var presentingViewController = presentingViewController + if !transition.value.options.shouldAutomaticallyDismissPresentedView { + while let presenting = presentingViewController.presentedViewController { + presentingViewController = presenting + } + } let present: () -> Void = { guard let viewController = adapter.viewController else { return } presentingViewController.present( diff --git a/Sources/Transmission/Sources/PresentationLinkTransition.swift b/Sources/Transmission/Sources/PresentationLinkTransition.swift index 390f1ab..d48dbee 100644 --- a/Sources/Transmission/Sources/PresentationLinkTransition.swift +++ b/Sources/Transmission/Sources/PresentationLinkTransition.swift @@ -115,6 +115,8 @@ extension PresentationLinkTransition { public var isDestinationReusable: Bool /// When `true`, the destination will be dismissed when the presentation source is dismantled public var shouldAutomaticallyDismissDestination: Bool + /// When `true`, the destination will be presented after dismissing the view the presentation source is already presenting. + public var shouldAutomaticallyDismissPresentedView: Bool public var modalPresentationCapturesStatusBarAppearance: Bool public var preferredPresentationBackgroundColor: Color? @@ -122,12 +124,14 @@ extension PresentationLinkTransition { isInteractive: Bool = true, isDestinationReusable: Bool = false, shouldAutomaticallyDismissDestination: Bool = true, + shouldAutomaticallyDismissPresentedView: Bool = true, modalPresentationCapturesStatusBarAppearance: Bool = false, preferredPresentationBackgroundColor: Color? = nil ) { self.isInteractive = isInteractive self.isDestinationReusable = isDestinationReusable self.shouldAutomaticallyDismissDestination = shouldAutomaticallyDismissDestination + self.shouldAutomaticallyDismissPresentedView = shouldAutomaticallyDismissPresentedView self.modalPresentationCapturesStatusBarAppearance = modalPresentationCapturesStatusBarAppearance self.preferredPresentationBackgroundColor = preferredPresentationBackgroundColor }