Skip to content

Commit

Permalink
Fix color picker crush on iOS 16
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Jul 13, 2024
1 parent 0b94d80 commit 44f9f2c
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,22 @@ private class CustomColorPickerViewController: UIColorPickerViewController {
super.viewDidLoad()

#if !os(visionOS)
guard let sheet = sheetPresentationController else { return }
sheet.prefersGrabberVisible = true

sheet.detents = [.custom(resolver: { [unowned self] context in
let height = preferredContentSize.height
return min(height, context.maximumDetentValue)
})]

publisher(for: \.preferredContentSize).sink(receiveValue: { _ in
sheet.animateChanges {
sheet.invalidateDetents()
}
}).store(in: disposeBag)
// Custom detents started to be supported for remote view controllers yet from iOS 17
if #available(iOS 17, *) {
guard let sheet = sheetPresentationController else { return }
sheet.prefersGrabberVisible = true

sheet.detents = [.custom(resolver: { [unowned self] context in
let height = preferredContentSize.height
return min(height, context.maximumDetentValue)
})]

publisher(for: \.preferredContentSize).sink(receiveValue: { _ in
sheet.animateChanges {
sheet.invalidateDetents()
}
}).store(in: disposeBag)
}
#endif
}

Expand Down

0 comments on commit 44f9f2c

Please sign in to comment.