From b9e241a24767131998de53c3a6843c622612da93 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 23 Nov 2022 16:00:59 +0100 Subject: [PATCH 1/2] Refactor InfoSheet presentation --- .../Coordinator/InfoSheetCoordinator.swift | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/RiotSwiftUI/Modules/Common/InfoSheet/Coordinator/InfoSheetCoordinator.swift b/RiotSwiftUI/Modules/Common/InfoSheet/Coordinator/InfoSheetCoordinator.swift index 6fb7fc110..54a9719b2 100644 --- a/RiotSwiftUI/Modules/Common/InfoSheet/Coordinator/InfoSheetCoordinator.swift +++ b/RiotSwiftUI/Modules/Common/InfoSheet/Coordinator/InfoSheetCoordinator.swift @@ -64,28 +64,22 @@ private extension InfoSheetCoordinator { // The bottom sheet should be presented with the content intrinsic height as for design requirement // We can do it easily just on iOS 16+ func setupPresentation(of viewController: VectorHostingController) { - let cornerRadius: CGFloat = 24 + let detents: [VectorHostingBottomSheetPreferences.Detent] - guard + if #available(iOS 16, *), - let parentSize = parameters.parentSize, - let presentationController = viewController.sheetPresentationController - else { - viewController.bottomSheetPreferences = .init(cornerRadius: cornerRadius) - return + let parentSize = parameters.parentSize { + + let intrisincSize = viewController.view.systemLayoutSizeFitting(.init(width: parentSize.width, height: UIView.layoutFittingCompressedSize.height), + withHorizontalFittingPriority: .defaultHigh, + verticalFittingPriority: .defaultLow) + + detents = [.custom(height: intrisincSize.height), .large] + } else { + detents = [.medium, .large] } - let intrisincSize = viewController.view.systemLayoutSizeFitting(.init(width: parentSize.width, height: 0), - withHorizontalFittingPriority: .defaultHigh, - verticalFittingPriority: .defaultLow) - - presentationController.preferredCornerRadius = cornerRadius - presentationController.prefersGrabberVisible = true - presentationController.detents = [ - .custom { context in - min(context.maximumDetentValue, intrisincSize.height) - }, - .large() - ] + viewController.bottomSheetPreferences = .init(detents: detents, cornerRadius: 24) + viewController.bottomSheetPreferences?.setup(viewController: viewController) } } From 711acd484c2cef99634251edbc295ba41772e205 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 23 Nov 2022 16:07:55 +0100 Subject: [PATCH 2/2] Add changelog.d file --- changelog.d/pr-7107.change | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-7107.change diff --git a/changelog.d/pr-7107.change b/changelog.d/pr-7107.change new file mode 100644 index 000000000..19600b10b --- /dev/null +++ b/changelog.d/pr-7107.change @@ -0,0 +1 @@ +Refactor bottom sheet presentation in the device manager.