From f54f04a406521b5027a94daca14a0f6a26c12ca8 Mon Sep 17 00:00:00 2001 From: Ruslan Kavetsky Date: Wed, 10 Aug 2022 22:44:24 +0800 Subject: [PATCH 1/2] Fix issue with SwiftUI View hosted in a UIHostingController --- .../Core/Presentation/BottomSheetPresentationController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift b/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift index 4d385f7..32a2355 100644 --- a/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift +++ b/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift @@ -534,6 +534,10 @@ extension BottomSheetPresentationController: UIViewControllerAnimatedTransitioni let completion = { (completed: Bool) in transitionContext.completeTransition(completed && !transitionContext.transitionWasCancelled) + // For fix bug: https://openradar.appspot.com/FB9075949 + if transitionContext.transitionWasCancelled { + sourceView.frame = .zero + } } let options: UIView.AnimationOptions = transitionContext.isInteractive ? .curveLinear : .curveEaseInOut From 5831743aa9100eced0886d2ab9ed1db6b3b6b65b Mon Sep 17 00:00:00 2001 From: Ruslan Kavetsky Date: Thu, 29 Sep 2022 16:33:44 +0800 Subject: [PATCH 2/2] Improve fix for interactive dismiss cancellation bug --- .../Core/Presentation/BottomSheetPresentationController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift b/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift index 32a2355..9d81b40 100644 --- a/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift +++ b/Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift @@ -535,8 +535,10 @@ extension BottomSheetPresentationController: UIViewControllerAnimatedTransitioni let completion = { (completed: Bool) in transitionContext.completeTransition(completed && !transitionContext.transitionWasCancelled) // For fix bug: https://openradar.appspot.com/FB9075949 - if transitionContext.transitionWasCancelled { + if #available(iOS 13, *), transitionContext.transitionWasCancelled { + let sourceViewFrame = sourceView.frame sourceView.frame = .zero + sourceView.frame = sourceViewFrame } }