From 44f9f2c79f412d2e71300b51da7b164f0fa2909a Mon Sep 17 00:00:00 2001 From: Daniil Vinogradov Date: Sat, 13 Jul 2024 13:50:13 +0200 Subject: [PATCH] Fix color picker crush on iOS 16 --- .../PRColorPicker/PRColorPickerCell.swift | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/iTorrent/Screens/Preferences/Root/Cells/PRColorPicker/PRColorPickerCell.swift b/iTorrent/Screens/Preferences/Root/Cells/PRColorPicker/PRColorPickerCell.swift index 8afac9ff..9ef27733 100644 --- a/iTorrent/Screens/Preferences/Root/Cells/PRColorPicker/PRColorPickerCell.swift +++ b/iTorrent/Screens/Preferences/Root/Cells/PRColorPicker/PRColorPickerCell.swift @@ -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 }