danielsaidi / SwiftUIKit

SwiftUIKit is a Swift SDK that adds extra functionality to Swift & SwiftUI.
MIT License
1.42k stars 56 forks source link

Undimmed detents no longer work when passing a 'selection'. #28

Closed bachlis closed 11 months ago

bachlis commented 1 year ago

Hey, love your code thanks for your help! 😁

I'm facing an issue all of a sudden with your PresentationDetents code and was wondering if you could help me resolve it.

Suddenly (I believe after I updated to XCode 15) the sheet is no longer keeping the undimmed state of its background after dragging it. For example when the sheet opens up everything is fine, but when I try dragging it slightly it dims my background again not respecting the largestUndimmed I set. I noticed that this only happens when setting a selection, like so:

.presentationDetents(
  [
    .fraction(0.1),
    .fraction(0.5),
    .fraction(1)
  ],
  largestUndimmed: .fraction(0.5),
  selection: $currentSheetPosition
)

However, I really need the selection parameter there as it lets me control the state of the sheet. Can you help me resolve this please?

danielsaidi commented 1 year ago

Hi @bachlis

Hmmm, that's strange. I haven't updated myself so I haven't seen this behavior 😬

I'm currently swamped with a couple of projects, but I will leave this open until I (or someone else) have time to look at it.

Just let me know if you find a solution, and I'll update the lib 👍

bachlis commented 1 year ago

thanks for your quick response! 🙌 I tried a few different things but none of them seemed to work 😥 I will be moving away from this and instead use the built in property presentationBackgroundInteraction (docs) which is unfortunately only available for iOS 16.4 upwards. Oh well 😄

danielsaidi commented 1 year ago

Yeah, I use the native approach as well now, so I'll probably deprecate this. 😬