diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Contents.json b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Contents.json index dbee5479f..3451f0d6c 100644 --- a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Contents.json +++ b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Contents.json @@ -1,17 +1,17 @@ { "images" : [ { - "filename" : "action_formatting_disabled.png", + "filename" : "Frame 143.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "action_formatting_disabled@2x.png", + "filename" : "Frame 143@2x.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "action_formatting_disabled@3x.png", + "filename" : "Frame 143@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143.png new file mode 100644 index 000000000..8cc5f79e8 Binary files /dev/null and b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143.png differ diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@2x.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@2x.png new file mode 100644 index 000000000..1e4244a85 Binary files /dev/null and b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@2x.png differ diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@3x.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@3x.png new file mode 100644 index 000000000..88aaee3ba Binary files /dev/null and b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/Frame 143@3x.png differ diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled.png deleted file mode 100644 index f7ef2b190..000000000 Binary files a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled.png and /dev/null differ diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@2x.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@2x.png deleted file mode 100644 index 270dd75d2..000000000 Binary files a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@2x.png and /dev/null differ diff --git a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@3x.png b/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@3x.png deleted file mode 100644 index 9394656ff..000000000 Binary files a/Riot/Assets/Images.xcassets/Room/Actions/action_formatting_disabled.imageset/action_formatting_disabled@3x.png and /dev/null differ diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift index f5adcc75a..eebab63f0 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Coordinator/ComposerCreateActionListCoordinator.swift @@ -41,14 +41,23 @@ final class ComposerCreateActionListCoordinator: NSObject, Coordinator, Presenta // MARK: - Setup init(actions: [ComposerCreateAction], wysiwygEnabled: Bool, textFormattingEnabled: Bool) { + let isScrollingEnabled: Bool + if #available(iOS 16, *) { + isScrollingEnabled = false + } else { + isScrollingEnabled = true + } viewModel = ComposerCreateActionListViewModel(initialViewState: ComposerCreateActionListViewState( actions: actions, wysiwygEnabled: wysiwygEnabled, + isScrollingEnabled: isScrollingEnabled, bindings: ComposerCreateActionListBindings(textFormattingEnabled: textFormattingEnabled))) view = ComposerCreateActionList(viewModel: viewModel.context) let hostingVC = VectorHostingController(rootView: view) + let height = hostingVC.sizeThatFits(in: CGSize(width: hostingVC.view.frame.width, height: UIView.layoutFittingCompressedSize.height)).height hostingVC.bottomSheetPreferences = VectorHostingBottomSheetPreferences( - detents: [.custom(height: 470)], + // on iOS 15 custom will be replaced by medium which may require some scrolling + detents: [.custom(height: height)], prefersGrabberVisible: true, cornerRadius: 20, prefersScrollingExpandsWhenScrolledToEdge: false @@ -56,6 +65,7 @@ final class ComposerCreateActionListCoordinator: NSObject, Coordinator, Presenta hostingController = hostingVC super.init() hostingVC.presentationController?.delegate = self + hostingVC.bottomSheetPreferences?.setup(viewController: hostingVC) } // MARK: - Public diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/MockComposerCreateActionListScreenState.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/MockComposerCreateActionListScreenState.swift index cb1a53b88..8089ab7ae 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/MockComposerCreateActionListScreenState.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/MockComposerCreateActionListScreenState.swift @@ -36,6 +36,7 @@ enum MockComposerCreateActionListScreenState: MockScreenState, CaseIterable { let viewModel = ComposerCreateActionListViewModel(initialViewState: ComposerCreateActionListViewState( actions: actions, wysiwygEnabled: true, + isScrollingEnabled: false, bindings: ComposerCreateActionListBindings(textFormattingEnabled: true))) return ( diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Model/ComposerCreateActionListModels.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Model/ComposerCreateActionListModels.swift index 6c42041b7..d1194e175 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Model/ComposerCreateActionListModels.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/Model/ComposerCreateActionListModels.swift @@ -38,6 +38,7 @@ struct ComposerCreateActionListViewState: BindableState { /// The list of composer create actions to display to the user let actions: [ComposerCreateAction] let wysiwygEnabled: Bool + let isScrollingEnabled: Bool var bindings: ComposerCreateActionListBindings } diff --git a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift index 5da2b1d11..80a7f7f67 100644 --- a/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift +++ b/RiotSwiftUI/Modules/Room/Composer/CreateActionList/View/ComposerCreateActionList.swift @@ -32,56 +32,68 @@ struct ComposerCreateActionList: View { // MARK: Public @ObservedObject var viewModel: ComposerCreateActionListViewModel.Context + + private var internalView: some View { + VStack(alignment: .leading) { + ForEach(viewModel.viewState.actions) { action in + HStack(spacing: 16) { + Image(action.icon) + .renderingMode(.template) + .foregroundColor(theme.colors.accent) + Text(action.title) + .foregroundColor(theme.colors.primaryContent) + .font(theme.fonts.body) + .accessibilityIdentifier(action.accessibilityIdentifier) + Spacer() + } + .contentShape(Rectangle()) + .onTapGesture { + viewModel.send(viewAction: .selectAction(action)) + } + .padding(.horizontal, 16) + .padding(.vertical, 12) + } + if viewModel.viewState.wysiwygEnabled { + SeparatorLine() + HStack(spacing: 16) { + Image(textFormattingIcon) + .renderingMode(.template) + .foregroundColor(theme.colors.accent) + Text(VectorL10n.wysiwygComposerStartActionTextFormatting) + .foregroundColor(theme.colors.primaryContent) + .font(theme.fonts.body) + .accessibilityIdentifier("textFormatting") + Spacer() + Toggle("", isOn: $viewModel.textFormattingEnabled) + .toggleStyle(ComposerToggleActionStyle()) + .labelsHidden() + .onChange(of: viewModel.textFormattingEnabled) { isOn in + viewModel.send(viewAction: .toggleTextFormatting(isOn)) + } + } + .contentShape(Rectangle()) + .padding(.horizontal, 16) + .padding(.vertical, 12) + + } + } + } var body: some View { - ScrollView { - VStack(alignment: .leading) { - ForEach(viewModel.viewState.actions) { action in - HStack(spacing: 16) { - Image(action.icon) - .renderingMode(.template) - .foregroundColor(theme.colors.accent) - Text(action.title) - .foregroundColor(theme.colors.primaryContent) - .font(theme.fonts.body) - .accessibilityIdentifier(action.accessibilityIdentifier) - Spacer() - } - .contentShape(Rectangle()) - .onTapGesture { - viewModel.send(viewAction: .selectAction(action)) - } - .padding(.horizontal, 16) - .padding(.vertical, 12) - } - if viewModel.viewState.wysiwygEnabled { - SeparatorLine() - HStack(spacing: 16) { - Image(textFormattingIcon) - .renderingMode(.template) - .foregroundColor(theme.colors.accent) - Text(VectorL10n.wysiwygComposerStartActionTextFormatting) - .foregroundColor(theme.colors.primaryContent) - .font(theme.fonts.body) - .accessibilityIdentifier("textFormatting") - Spacer() - Toggle("", isOn: $viewModel.textFormattingEnabled) - .toggleStyle(ComposerToggleActionStyle()) - .labelsHidden() - .onChange(of: viewModel.textFormattingEnabled) { isOn in - viewModel.send(viewAction: .toggleTextFormatting(isOn)) - } - } - .contentShape(Rectangle()) - .padding(.horizontal, 16) - .padding(.vertical, 12) - - } + if viewModel.viewState.isScrollingEnabled { + ScrollView { + internalView } - Spacer() + .padding(.top, 23) + .background(theme.colors.background.ignoresSafeArea()) + } else { + VStack { + internalView + Spacer() + } + .padding(.top, 23) + .background(theme.colors.background.ignoresSafeArea()) } - .padding(.top, 23) - .background(theme.colors.background.ignoresSafeArea()) } }