Skip to content
Open
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 @@ -51,10 +51,7 @@ final class PublishPostViewController<ViewModel: PostSettingsViewModelProtocol>:
publishVC.onCompletion = completion
// - warning: Has to be UIKit because some of the `PostSettingsView` rows rely on it.
let navigationVC = UINavigationController(rootViewController: publishVC)
navigationVC.sheetPresentationController?.detents = [
.custom(identifier: .medium, resolver: { _ in 526 }),
.large()
]
configureSheetPresentation(of: navigationVC, from: presentingViewController)
presentingViewController.present(navigationVC, animated: true)
}

Expand Down Expand Up @@ -90,10 +87,7 @@ final class PublishPostViewController<ViewModel: PostSettingsViewModelProtocol>:
completion(result)
}
let navigationVC = UINavigationController(rootViewController: publishVC)
navigationVC.sheetPresentationController?.detents = [
.custom(identifier: .medium, resolver: { _ in 526 }),
.large()
]
configureSheetPresentation(of: navigationVC, from: presentingViewController)
presentingViewController.present(navigationVC, animated: true)
}

Expand Down Expand Up @@ -121,6 +115,27 @@ final class PublishPostViewController<ViewModel: PostSettingsViewModelProtocol>:
}
}

/// Configures how the publishing sheet is presented based on the screen size.
///
/// In compact width, the sheet opens at a partial-height detent that can be
/// dragged to full height. In regular width, it is presented as a plain form
/// sheet instead. A sheet resting at a non-large detent is not marked as
/// accessibility-modal by UIKit, which left Voice Control unable to reach any
/// of the sheet's elements when presented over the editor (CMM-2216).
private func configureSheetPresentation(
of navigationVC: UINavigationController,
from presentingViewController: UIViewController
) {
if presentingViewController.traitCollection.horizontalSizeClass == .regular {
navigationVC.modalPresentationStyle = .formSheet
} else {
navigationVC.sheetPresentationController?.detents = [
.custom(identifier: .medium, resolver: { _ in 526 }),
.large()
]
}
}

struct PublishPostView<ViewModel: PostSettingsViewModelProtocol>: View {
@ObservedObject var viewModel: ViewModel
var uploadsViewModel: PostMediaUploadsViewModel?
Expand Down