From bf18ba4f86ac71ef802a4394cde5abac6b2ab5ab Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 15 Nov 2022 15:27:43 +0100 Subject: [PATCH 1/4] first type of fix --- .../CreateActionList/View/ComposerCreateActionList.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift index 7f2733e2b..08a30f673 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) { From 96c5337204045e9e13a9c9742deecb425e9b6b91 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Wed, 16 Nov 2022 17:23:32 +0100 Subject: [PATCH 2/4] scrollable bottom sheet, with custom size on iOS 16 --- .../VectorHostingBottomSheetPreferences.swift | 18 ++++++++++++++++++ .../ComposerCreateActionListCoordinator.swift | 5 +++-- .../View/ComposerCreateActionList.swift | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift index cb5afa51a..664710e5d 100644 --- a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift +++ b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift @@ -25,11 +25,23 @@ class VectorHostingBottomSheetPreferences { case medium case large + /// only available on iOS16, medium behaviour will be used instead + 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 +50,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 08a30f673..5da2b1d11 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift @@ -78,9 +78,10 @@ struct ComposerCreateActionList: View { } } - .padding(.top, 8) Spacer() - }.background(theme.colors.background.ignoresSafeArea()) + } + .padding(.top, 23) + .background(theme.colors.background.ignoresSafeArea()) } } From 7d24e7f89455edac3723b3df728399cdaafad822 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Wed, 16 Nov 2022 17:28:53 +0100 Subject: [PATCH 3/4] changelog --- changelog.d/7082.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7082.bugfix 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. From f2611bf7cd8cca3a43462e2c3992c8fa5713a514 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Fri, 18 Nov 2022 11:33:40 +0100 Subject: [PATCH 4/4] some more documentation on how to use the custom detent --- .../Common/SwiftUI/VectorHostingBottomSheetPreferences.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift index 664710e5d..d7f94c626 100644 --- a/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift +++ b/Riot/Modules/Common/SwiftUI/VectorHostingBottomSheetPreferences.swift @@ -26,6 +26,9 @@ class VectorHostingBottomSheetPreferences { 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, *)