mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-23 16:06:38 +02:00
Merge pull request #7085 from vector-im/mauroromito/7082_fix_scrollable_bottom_sheet
Rich Text Editor: Scrollable and Custom Sizable Bottom Sheet
This commit is contained in:
@@ -25,11 +25,26 @@ class VectorHostingBottomSheetPreferences {
|
||||
case medium
|
||||
case large
|
||||
|
||||
/// only available on iOS16, medium behaviour will be used instead
|
||||
/// - Parameters:
|
||||
/// - height: The height of the custom detent, if the height is bigger than the maximum possible height for a detent the latter will be returned
|
||||
/// - identifier: The identifier used to identify the custom detent during detent transitions, by default the value is set to "custom", however if you are supporting multiple custom detents in a bottom sheet, you should specify a different identifier for each
|
||||
case custom(height: CGFloat, identifier: String = "custom")
|
||||
|
||||
@available(iOS 15, *)
|
||||
fileprivate func uiSheetDetent() -> UISheetPresentationController.Detent {
|
||||
switch self {
|
||||
case .medium: return .medium()
|
||||
case .large: return .large()
|
||||
case let .custom(height, identifier):
|
||||
if #available(iOS 16, *) {
|
||||
let identifier = UISheetPresentationController.Detent.Identifier(identifier)
|
||||
return .custom(identifier: identifier) { context in
|
||||
return min(height, context.maximumDetentValue)
|
||||
}
|
||||
} else {
|
||||
return .medium()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +53,12 @@ class VectorHostingBottomSheetPreferences {
|
||||
switch self {
|
||||
case .medium: return .medium
|
||||
case .large: return .large
|
||||
case let .custom(_, identifier):
|
||||
if #available(iOS 16, *) {
|
||||
return UISheetPresentationController.Detent.Identifier(identifier)
|
||||
} else {
|
||||
return .medium
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -48,9 +48,10 @@ final class ComposerCreateActionListCoordinator: NSObject, Coordinator, Presenta
|
||||
view = ComposerCreateActionList(viewModel: viewModel.context)
|
||||
let hostingVC = VectorHostingController(rootView: view)
|
||||
hostingVC.bottomSheetPreferences = VectorHostingBottomSheetPreferences(
|
||||
detents: [.medium],
|
||||
detents: [.custom(height: 470)],
|
||||
prefersGrabberVisible: true,
|
||||
cornerRadius: 20
|
||||
cornerRadius: 20,
|
||||
prefersScrollingExpandsWhenScrolledToEdge: false
|
||||
)
|
||||
hostingController = hostingVC
|
||||
super.init()
|
||||
|
||||
+4
-3
@@ -34,7 +34,7 @@ struct ComposerCreateActionList: View {
|
||||
@ObservedObject var viewModel: ComposerCreateActionListViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading) {
|
||||
ForEach(viewModel.viewState.actions) { action in
|
||||
HStack(spacing: 16) {
|
||||
@@ -78,9 +78,10 @@ struct ComposerCreateActionList: View {
|
||||
|
||||
}
|
||||
}
|
||||
.padding(.top, 8)
|
||||
Spacer()
|
||||
}.background(theme.colors.background.ignoresSafeArea())
|
||||
}
|
||||
.padding(.top, 23)
|
||||
.background(theme.colors.background.ignoresSafeArea())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Rich Text Composer: Bottom Sheet is sized to always show all the elements inside, and in case it reaches the top, is also scrollable.
|
||||
Reference in New Issue
Block a user