Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor bottom sheet presentation #7107

Merged
merged 2 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
1 change: 1 addition & 0 deletions changelog.d/pr-7107.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor bottom sheet presentation in the device manager.