diff --git a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift index cb5afa51a..d7f94c626 100644 --- a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift +++ b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift @@ -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 + } } } } diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift index cb52281eb..f5adcc75a 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift @@ -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() diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift index 7f2733e2b..5da2b1d11 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift @@ -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()) } } diff --git a/changelog.d/7082.bugfix b/changelog.d/7082.bugfix new file mode 100644 index 000000000..d5d2f2fa7 --- /dev/null +++ b/changelog.d/7082.bugfix @@ -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.