From 46eb6b6a663663f1fb5f5f626e8557718fbbfacf Mon Sep 17 00:00:00 2001 From: Thomas Mellenthin Date: Mon, 25 Apr 2022 12:29:06 +0200 Subject: [PATCH 1/2] Fix half-opened bottom sheet when returning from background. The home-gesture on iOS devices without a physical home button can collide with the DragGesture that is attached to the bottom sheet. The gesture allows to hide the presented bottom sheet by dragging the top bar down to the edge of the screen. However, when swiping up from the bottom to send the app to the background, the gesture still receives changes. When the bottom sheet is hidden, this can lead to a miscalculation of the sheet position. See the attached video to the PR. The fix is to ignore the swipe-up gesture when the bottom sheet is hidden. --- Sources/BottomSheet/BottomSheet.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/BottomSheet/BottomSheet.swift b/Sources/BottomSheet/BottomSheet.swift index d4b136b..4828d85 100644 --- a/Sources/BottomSheet/BottomSheet.swift +++ b/Sources/BottomSheet/BottomSheet.swift @@ -91,7 +91,10 @@ public struct BottomSheet: View { .gesture( DragGesture() .onChanged({ (value) in - + // ignore the swipe-up gesture which could collide with the iOS-global "go to homescreen"-gesture + let isSwipeUp = value.startLocation.y > value.location.y + if isPresented == false, isSwipeUp { return } + let offsetY = value.translation.height self.draggedOffset = offsetY From a38d105bf789f10e3c3ba6e818f2cd13f2630a67 Mon Sep 17 00:00:00 2001 From: Thomas Mellenthin Date: Mon, 25 Apr 2022 12:37:52 +0200 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e62cbc..51e941e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ BottomSheet adheres to [Semantic Versioning](http://semver.org/). ### Changed +Fix half-opened bottom sheet when returning from background. + - 1.0.6 Removing List padding on examples.