From 0b31446817c0ea06b2ad10302c87065e6d625d11 Mon Sep 17 00:00:00 2001
From: Mauro <34335419+Velin92@users.noreply.github.com>
Date: Fri, 27 Oct 2023 15:54:30 +0200
Subject: [PATCH] Resizable Composer With Completion Suggestion View (#1971)
* resizable composer with suggestions view
* FF cleanup
* removing the view when the vertical size is compact
* merge conflict fix
* done
* solving a conflict
* Update ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift
Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
* pr suggestion
---------
Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
---
.../FlowCoordinators/RoomFlowCoordinator.swift | 4 ++--
.../UserSessionFlowCoordinator.swift | 2 +-
.../Sources/Mocks/Generated/GeneratedMocks.swift | 5 -----
ElementX/Sources/Other/Pills/MentionBuilder.swift | 12 ------------
ElementX/Sources/Other/Pills/MessageText.swift | 2 +-
.../Other/SwiftUI/Animation/ShimmerModifier.swift | 2 +-
.../CompletionSuggestionService.swift | 7 +------
.../CompletionSuggestionServiceProtocol.swift | 4 ----
.../ComposerToolbar/ComposerToolbarModels.swift | 1 -
.../ComposerToolbar/ComposerToolbarViewModel.swift | 9 +++------
.../View/CompletionSuggestionView.swift | 12 ++++++------
.../ComposerToolbar/View/ComposerToolbar.swift | 13 +++++++++++--
.../ComposerToolbar/View/MessageComposer.swift | 12 +++++++++---
.../Screens/HomeScreen/View/HomeScreen.swift | 2 +-
.../HomeScreen/View/HomeScreenEmptyStateView.swift | 2 +-
.../HomeScreen/View/HomeScreenRoomCell.swift | 2 +-
.../View/Timeline/FormattedBodyText.swift | 2 +-
.../DeveloperOptionsScreenModels.swift | 1 -
.../View/DeveloperOptionsScreen.swift | 5 -----
.../Fixtures/RoomTimelineItemFixtures.swift | 2 +-
.../Sources/UITests/UITestsAppCoordinator.swift | 2 +-
.../Sources/AttributedStringBuilderTests.swift | 2 +-
UnitTests/Sources/AttributedStringTests.swift | 2 +-
.../Sources/CompletionSuggestionServiceTests.swift | 6 +++---
.../Sources/ComposerToolbarViewModelTests.swift | 1 -
UnitTests/Sources/HomeScreenViewModelTests.swift | 2 +-
.../PreviewTests/test_completionSuggestion.2.png | 4 ++--
changelog.d/pr-1971.feature | 1 +
28 files changed, 50 insertions(+), 71 deletions(-)
create mode 100644 changelog.d/pr-1971.feature
diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
index 330e944ac..fe11790a5 100644
--- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
+++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
@@ -337,7 +337,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
let timelineItemFactory = RoomTimelineItemFactory(userID: userID,
mediaProvider: userSession.mediaProvider,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: appSettings.permalinkBaseURL,
- mentionBuilder: MentionBuilder(mentionsEnabled: appSettings.mentionsEnabled)),
+ mentionBuilder: MentionBuilder()),
stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID),
appSettings: appSettings)
@@ -351,7 +351,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
analytics.trackViewRoom(isDM: roomProxy.isDirect, isSpace: roomProxy.isSpace)
- let completionSuggestionService = CompletionSuggestionService(roomProxy: roomProxy, areSuggestionsEnabled: appSettings.mentionsEnabled)
+ let completionSuggestionService = CompletionSuggestionService(roomProxy: roomProxy)
let parameters = RoomScreenCoordinatorParameters(roomProxy: roomProxy,
timelineController: timelineController,
diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift
index de760ffff..db1d9e5e9 100644
--- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift
+++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift
@@ -304,7 +304,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private func presentHomeScreen() {
let parameters = HomeScreenCoordinatorParameters(userSession: userSession,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL,
- mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled)),
+ mentionBuilder: MentionBuilder()),
bugReportService: bugReportService,
navigationStackCoordinator: detailNavigationStackCoordinator,
selectedRoomPublisher: selectedRoomSubject.asCurrentValuePublisher())
diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
index 1e3beed04..ff0da9e23 100644
--- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
+++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
@@ -686,11 +686,6 @@ class BugReportServiceMock: BugReportServiceProtocol {
}
}
class CompletionSuggestionServiceMock: CompletionSuggestionServiceProtocol {
- var areSuggestionsEnabled: Bool {
- get { return underlyingAreSuggestionsEnabled }
- set(value) { underlyingAreSuggestionsEnabled = value }
- }
- var underlyingAreSuggestionsEnabled: Bool!
var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> {
get { return underlyingSuggestionsPublisher }
set(value) { underlyingSuggestionsPublisher = value }
diff --git a/ElementX/Sources/Other/Pills/MentionBuilder.swift b/ElementX/Sources/Other/Pills/MentionBuilder.swift
index 110253921..30a96ad17 100644
--- a/ElementX/Sources/Other/Pills/MentionBuilder.swift
+++ b/ElementX/Sources/Other/Pills/MentionBuilder.swift
@@ -18,15 +18,7 @@ import Foundation
import UIKit
struct MentionBuilder: MentionBuilderProtocol {
- // Can be removed when mentions are enabled by default
- let mentionsEnabled: Bool
-
func handleUserMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, userID: String) {
- guard mentionsEnabled else {
- attributedString.addAttributes([.MatrixUserID: userID], range: range)
- return
- }
-
let attributes = attributedString.attributes(at: 0, longestEffectiveRange: nil, in: range)
let font = attributes[.font] as? UIFont ?? .preferredFont(forTextStyle: .body)
let blockquote = attributes[.MatrixBlockquote]
@@ -48,10 +40,6 @@ struct MentionBuilder: MentionBuilderProtocol {
}
func handleAllUsersMention(for attributedString: NSMutableAttributedString, in range: NSRange) {
- guard mentionsEnabled else {
- return
- }
-
let attributes = attributedString.attributes(at: 0, longestEffectiveRange: nil, in: range)
let font = attributes[.font] as? UIFont ?? .preferredFont(forTextStyle: .body)
let blockquote = attributes[.MatrixBlockquote]
diff --git a/ElementX/Sources/Other/Pills/MessageText.swift b/ElementX/Sources/Other/Pills/MessageText.swift
index f53d65664..a0b8c21fe 100644
--- a/ElementX/Sources/Other/Pills/MessageText.swift
+++ b/ElementX/Sources/Other/Pills/MessageText.swift
@@ -177,7 +177,7 @@ struct MessageText_Previews: PreviewProvider, TestablePreview {
private static let htmlStringWithList = "
This is a list
\n\n- One
\n- Two
\n- And number 3
\n
\n"
- private static let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true))
+ private static let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder())
static var attachmentPreview: some View {
MessageText(attributedString: attributedStringWithAttachment)
diff --git a/ElementX/Sources/Other/SwiftUI/Animation/ShimmerModifier.swift b/ElementX/Sources/Other/SwiftUI/Animation/ShimmerModifier.swift
index 3bd3767c0..7c59a4e82 100644
--- a/ElementX/Sources/Other/SwiftUI/Animation/ShimmerModifier.swift
+++ b/ElementX/Sources/Other/SwiftUI/Animation/ShimmerModifier.swift
@@ -80,7 +80,7 @@ struct ShimmerOverlay_Previews: PreviewProvider, TestablePreview {
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL,
- mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled)),
+ mentionBuilder: MentionBuilder()),
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
diff --git a/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionService.swift b/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionService.swift
index 8c67de8a5..79be7919d 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionService.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionService.swift
@@ -20,17 +20,12 @@ import Foundation
final class CompletionSuggestionService: CompletionSuggestionServiceProtocol {
private let roomProxy: RoomProxyProtocol
private var canMentionAllUsers = false
- let areSuggestionsEnabled: Bool
private(set) var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> = Empty().eraseToAnyPublisher()
private let suggestionTriggerSubject = CurrentValueSubject(nil)
- init(roomProxy: RoomProxyProtocol, areSuggestionsEnabled: Bool) {
+ init(roomProxy: RoomProxyProtocol) {
self.roomProxy = roomProxy
- self.areSuggestionsEnabled = areSuggestionsEnabled
- guard areSuggestionsEnabled else {
- return
- }
suggestionsPublisher = suggestionTriggerSubject
.combineLatest(roomProxy.members)
.map { [weak self] suggestionPattern, members -> [SuggestionItem] in
diff --git a/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionServiceProtocol.swift b/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionServiceProtocol.swift
index df214c55e..4771056b8 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionServiceProtocol.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/CompletionSuggestionServiceProtocol.swift
@@ -18,8 +18,6 @@ import Combine
// sourcery: AutoMockable
protocol CompletionSuggestionServiceProtocol {
- // To be removed once we suggestions and mentions are always enabled
- var areSuggestionsEnabled: Bool { get }
var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> { get }
func setSuggestionTrigger(_ suggestionTrigger: SuggestionPattern?)
@@ -27,13 +25,11 @@ protocol CompletionSuggestionServiceProtocol {
extension CompletionSuggestionServiceMock {
struct CompletionSuggestionServiceMockConfiguration {
- var areSuggestionsEnabled = true
var suggestions: [SuggestionItem] = []
}
convenience init(configuration: CompletionSuggestionServiceMockConfiguration) {
self.init()
- underlyingAreSuggestionsEnabled = configuration.areSuggestionsEnabled
underlyingSuggestionsPublisher = Just(configuration.suggestions).eraseToAnyPublisher()
}
}
diff --git a/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarModels.swift b/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarModels.swift
index 04734f626..f018db3d8 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarModels.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarModels.swift
@@ -67,7 +67,6 @@ enum ComposerToolbarViewAction {
struct ComposerToolbarViewState: BindableState {
var composerMode: RoomScreenComposerMode = .default
var composerEmpty = true
- var areSuggestionsEnabled = true
var suggestions: [SuggestionItem] = []
var audioPlayerState: AudioPlayerState
var audioRecorderState: AudioRecorderState
diff --git a/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarViewModel.swift
index 931f269b5..e23371530 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarViewModel.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/ComposerToolbarViewModel.swift
@@ -45,8 +45,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
self.completionSuggestionService = completionSuggestionService
self.appSettings = appSettings
- super.init(initialViewState: ComposerToolbarViewState(areSuggestionsEnabled: completionSuggestionService.areSuggestionsEnabled,
- audioPlayerState: .init(id: .recorderPreview, duration: 0),
+ super.init(initialViewState: ComposerToolbarViewState(audioPlayerState: .init(id: .recorderPreview, duration: 0),
audioRecorderState: .init(),
bindings: .init()),
imageProvider: mediaProvider)
@@ -89,9 +88,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
.weakAssign(to: \.state.suggestions, on: self)
.store(in: &cancellables)
- if appSettings.mentionsEnabled {
- setupMentionsHandling(mentionDisplayHelper: mentionDisplayHelper)
- }
+ setupMentionsHandling(mentionDisplayHelper: mentionDisplayHelper)
}
// MARK: - Public
@@ -190,7 +187,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
private func setupMentionsHandling(mentionDisplayHelper: MentionDisplayHelper) {
wysiwygViewModel.textView.mentionDisplayHelper = mentionDisplayHelper
- let attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", permalinkBaseURL: appSettings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: appSettings.mentionsEnabled))
+ let attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", permalinkBaseURL: appSettings.permalinkBaseURL, mentionBuilder: MentionBuilder())
wysiwygViewModel.mentionReplacer = ComposerMentionReplacer { urlString, string in
let attributedString: NSMutableAttributedString
diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift b/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift
index d31af494d..e95e4aa55 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift
@@ -19,6 +19,7 @@ import SwiftUI
struct CompletionSuggestionView: View {
let imageProvider: ImageProviderProtocol?
let items: [SuggestionItem]
+ var showBackgroundShadow = true
let onTap: (SuggestionItem) -> Void
private enum Constants {
@@ -27,12 +28,12 @@ struct CompletionSuggestionView: View {
// added by the list itself when presenting the divider
static let listItemSpacing: CGFloat = 4.0
static let leadingPadding: CGFloat = 16.0
- static let maxVisibleRows = 4
+ // To make the scrolling more apparent we show a factional amount
+ static let maxVisibleRows: CGFloat = 4.5
}
// MARK: Public
- var showBackgroundShadow = true
@State private var prototypeListItemFrame: CGRect = .zero
var body: some View {
@@ -68,13 +69,12 @@ struct CompletionSuggestionView: View {
.listRowInsets(.init(top: 0, leading: Constants.leadingPadding, bottom: 0, trailing: 0))
}
.listStyle(PlainListStyle())
- .frame(height: min(contentHeightForRowCount(Constants.maxVisibleRows),
- contentHeightForRowCount(items.count)))
+ .frame(height: contentHeightForRowCount(min(CGFloat(items.count), Constants.maxVisibleRows)))
.background(Color.compound.bgCanvasDefault)
}
- private func contentHeightForRowCount(_ count: Int) -> CGFloat {
- (prototypeListItemFrame.height + Constants.listItemPadding * 2 + Constants.listItemSpacing) * CGFloat(count) - Constants.listItemSpacing / 2 + Constants.topPadding - Constants.listItemPadding
+ private func contentHeightForRowCount(_ count: CGFloat) -> CGFloat {
+ (prototypeListItemFrame.height + Constants.listItemPadding * 2 + Constants.listItemSpacing) * count - Constants.listItemSpacing / 2 + Constants.topPadding - Constants.listItemPadding
}
private struct ListItemPaddingModifier: ViewModifier {
diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/ComposerToolbar.swift b/ElementX/Sources/Screens/ComposerToolbar/View/ComposerToolbar.swift
index 7acb8113f..e2641ca18 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/View/ComposerToolbar.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/View/ComposerToolbar.swift
@@ -38,12 +38,19 @@ struct ComposerToolbar: View {
private let voiceMessageTooltipDuration = 1.0
@State private var frame: CGRect = .zero
+ @Environment(\.verticalSizeClass) private var verticalSizeClass
var body: some View {
VStack(spacing: 8) {
topBar
if context.composerActionsEnabled {
+ if verticalSizeClass != .compact,
+ context.composerExpanded {
+ suggestionView
+ .padding(.leading, -5)
+ .padding(.trailing, -8)
+ }
bottomBar
}
}
@@ -53,7 +60,7 @@ struct ComposerToolbar: View {
ViewFrameReader(frame: $frame)
}
.overlay(alignment: .bottom) {
- if context.viewState.areSuggestionsEnabled {
+ if verticalSizeClass != .compact, !context.composerExpanded {
suggestionView
.offset(y: -frame.height)
}
@@ -68,7 +75,9 @@ struct ComposerToolbar: View {
}
private var suggestionView: some View {
- CompletionSuggestionView(imageProvider: context.imageProvider, items: context.viewState.suggestions) { suggestion in
+ CompletionSuggestionView(imageProvider: context.imageProvider,
+ items: context.viewState.suggestions,
+ showBackgroundShadow: !context.composerExpanded) { suggestion in
context.send(viewAction: .selectedSuggestion(suggestion))
}
}
diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposer.swift b/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposer.swift
index 42dbee8b7..19fc8ae11 100644
--- a/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposer.swift
+++ b/ElementX/Sources/Screens/ComposerToolbar/View/MessageComposer.swift
@@ -62,13 +62,19 @@ struct MessageComposer: View {
}
// MARK: - Private
+
+ @State private var composerFrame = CGRect.zero
private var mainContent: some View {
VStack(alignment: .leading, spacing: -6) {
header
-
- composerView
- .frame(minHeight: composerHeight, alignment: .top)
+ Color.clear
+ .overlay(alignment: .top) {
+ composerView
+ .background(ViewFrameReader(frame: $composerFrame))
+ }
+ .frame(minHeight: ComposerConstant.minHeight, maxHeight: max(composerHeight, composerFrame.height),
+ alignment: .top)
.tint(.compound.iconAccentTertiary)
.padding(.vertical, 10)
.focused($focused)
diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
index 855ff1e35..26afd89a3 100644
--- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
+++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
@@ -339,7 +339,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
return HomeScreenViewModel(userSession: userSession,
- attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled)),
+ attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder()),
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift
index a32747a3e..6a42dc1be 100644
--- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift
+++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift
@@ -155,7 +155,7 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
return HomeScreenViewModel(userSession: userSession,
- attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled)),
+ attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder()),
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift
index 848f6fea0..91ea90029 100644
--- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift
+++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift
@@ -190,7 +190,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
let viewModel = HomeScreenViewModel(userSession: userSession,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL,
- mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled)),
+ mentionBuilder: MentionBuilder()),
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
diff --git a/ElementX/Sources/Screens/RoomScreen/View/Timeline/FormattedBodyText.swift b/ElementX/Sources/Screens/RoomScreen/View/Timeline/FormattedBodyText.swift
index 85f4deda2..ed8dc50a1 100644
--- a/ElementX/Sources/Screens/RoomScreen/View/Timeline/FormattedBodyText.swift
+++ b/ElementX/Sources/Screens/RoomScreen/View/Timeline/FormattedBodyText.swift
@@ -201,7 +201,7 @@ struct FormattedBodyText_Previews: PreviewProvider, TestablePreview {
"This is a list
\n\n- One
\n- Two
\n- And number 3
\n
\n"
]
- let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled))
+ let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder())
ScrollView {
VStack(alignment: .leading, spacing: 24.0) {
diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift
index f9f51d267..fb4180f49 100644
--- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift
+++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift
@@ -49,7 +49,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var userSuggestionsEnabled: Bool { get set }
var readReceiptsEnabled: Bool { get set }
var swiftUITimelineEnabled: Bool { get set }
- var mentionsEnabled: Bool { get set }
var appLockFlowEnabled: Bool { get set }
var elementCallEnabled: Bool { get set }
var chatBackupEnabled: Bool { get set }
diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift
index 46f67f0e7..667daecfb 100644
--- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift
+++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift
@@ -58,11 +58,6 @@ struct DeveloperOptionsScreen: View {
Text("Resets on reboot")
}
- Toggle(isOn: $context.mentionsEnabled) {
- Text("Show user mentions")
- Text("Requires app reboot")
- }
-
Toggle(isOn: $context.elementCallEnabled) {
Text("Element Call")
}
diff --git a/ElementX/Sources/Services/Timeline/Fixtures/RoomTimelineItemFixtures.swift b/ElementX/Sources/Services/Timeline/Fixtures/RoomTimelineItemFixtures.swift
index ea7f55c83..8be148a65 100644
--- a/ElementX/Sources/Services/Timeline/Fixtures/RoomTimelineItemFixtures.swift
+++ b/ElementX/Sources/Services/Timeline/Fixtures/RoomTimelineItemFixtures.swift
@@ -98,7 +98,7 @@ enum RoomTimelineItemFixtures {
sender: .init(id: "", displayName: "Helena"),
content: .init(body: "",
formattedBody: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL,
- mentionBuilder: MentionBuilder(mentionsEnabled: ServiceLocator.shared.settings.mentionsEnabled))
+ mentionBuilder: MentionBuilder())
.fromHTML("Hol' up New home office set up!
That's amazing! Congrats 🥳")))
]
diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift
index bcc42045c..a78779ece 100644
--- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift
+++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift
@@ -176,7 +176,7 @@ class MockScreen: Identifiable {
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
let coordinator = HomeScreenCoordinator(parameters: .init(userSession: session,
- attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true)),
+ attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder()),
bugReportService: BugReportServiceMock(),
navigationStackCoordinator: navigationStackCoordinator,
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher()))
diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift
index 3a6d76925..9e0ab125f 100644
--- a/UnitTests/Sources/AttributedStringBuilderTests.swift
+++ b/UnitTests/Sources/AttributedStringBuilderTests.swift
@@ -19,7 +19,7 @@ import XCTest
class AttributedStringBuilderTests: XCTestCase {
private let permalinkBaseURL = ServiceLocator.shared.settings.permalinkBaseURL
- private lazy var attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true))
+ private lazy var attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: permalinkBaseURL, mentionBuilder: MentionBuilder())
private let maxHeaderPointSize = ceil(UIFont.preferredFont(forTextStyle: .body).pointSize * 1.2)
func testRenderHTMLStringWithHeaders() {
diff --git a/UnitTests/Sources/AttributedStringTests.swift b/UnitTests/Sources/AttributedStringTests.swift
index 304973fd4..bbd11ccad 100644
--- a/UnitTests/Sources/AttributedStringTests.swift
+++ b/UnitTests/Sources/AttributedStringTests.swift
@@ -21,7 +21,7 @@ class AttributedStringTests: XCTestCase {
func testReplacingFontWithPresentationIntent() {
// Given a string parsed from HTML that contains specific fixed size fonts.
let boldString = "Bold"
- guard let originalString = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true))
+ guard let originalString = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder())
.fromHTML("Normal \(boldString) Normal.") else {
XCTFail("The attributed string should be built from the HTML.")
return
diff --git a/UnitTests/Sources/CompletionSuggestionServiceTests.swift b/UnitTests/Sources/CompletionSuggestionServiceTests.swift
index 41bc58760..b8b260bf9 100644
--- a/UnitTests/Sources/CompletionSuggestionServiceTests.swift
+++ b/UnitTests/Sources/CompletionSuggestionServiceTests.swift
@@ -30,7 +30,7 @@ final class CompletionSuggestionServiceTests: XCTestCase {
let alice: RoomMemberProxyMock = .mockAlice
let members: [RoomMemberProxyMock] = [alice, .mockBob, .mockCharlie, .mockMe]
let roomProxyMock = RoomProxyMock(with: .init(displayName: "test", members: members))
- let service = CompletionSuggestionService(roomProxy: roomProxyMock, areSuggestionsEnabled: true)
+ let service = CompletionSuggestionService(roomProxy: roomProxyMock)
var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in
suggestions == []
@@ -67,7 +67,7 @@ final class CompletionSuggestionServiceTests: XCTestCase {
let alice: RoomMemberProxyMock = .mockAlice
let members: [RoomMemberProxyMock] = [alice, .mockBob, .mockCharlie, .mockMe]
let roomProxyMock = RoomProxyMock(with: .init(displayName: "test", members: members, canUserTriggerRoomNotification: true))
- let service = CompletionSuggestionService(roomProxy: roomProxyMock, areSuggestionsEnabled: true)
+ let service = CompletionSuggestionService(roomProxy: roomProxyMock)
var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in
suggestions == []
@@ -93,7 +93,7 @@ final class CompletionSuggestionServiceTests: XCTestCase {
let bob: RoomMemberProxyMock = .mockBob
let members: [RoomMemberProxyMock] = [alice, bob, .mockMe]
let roomProxyMock = RoomProxyMock(with: .init(displayName: "test", members: members, canUserTriggerRoomNotification: true))
- let service = CompletionSuggestionService(roomProxy: roomProxyMock, areSuggestionsEnabled: true)
+ let service = CompletionSuggestionService(roomProxy: roomProxyMock)
var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in
suggestions == []
diff --git a/UnitTests/Sources/ComposerToolbarViewModelTests.swift b/UnitTests/Sources/ComposerToolbarViewModelTests.swift
index df3fc1698..0e487626b 100644
--- a/UnitTests/Sources/ComposerToolbarViewModelTests.swift
+++ b/UnitTests/Sources/ComposerToolbarViewModelTests.swift
@@ -31,7 +31,6 @@ class ComposerToolbarViewModelTests: XCTestCase {
AppSettings.reset()
appSettings = AppSettings()
appSettings.richTextEditorEnabled = true
- appSettings.mentionsEnabled = true
ServiceLocator.shared.register(appSettings: appSettings)
wysiwygViewModel = WysiwygComposerViewModel()
completionSuggestionServiceMock = CompletionSuggestionServiceMock(configuration: .init())
diff --git a/UnitTests/Sources/HomeScreenViewModelTests.swift b/UnitTests/Sources/HomeScreenViewModelTests.swift
index edd0c36e8..9c55fef90 100644
--- a/UnitTests/Sources/HomeScreenViewModelTests.swift
+++ b/UnitTests/Sources/HomeScreenViewModelTests.swift
@@ -32,7 +32,7 @@ class HomeScreenViewModelTests: XCTestCase {
viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: clientProxy,
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock()),
- attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true)),
+ attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder()),
selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
diff --git a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png
index 56ba0ce4a..f2ffe0c6c 100644
--- a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png
+++ b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:a2e17fe71944d32e3c53a61946de933c39ea14c43e35b3ab7b1dc5bae99e13d6
-size 74940
+oid sha256:506b7cc03102b5cd297485c07af99f578d32882d3348661e77f64e6107084edd
+size 76908
diff --git a/changelog.d/pr-1971.feature b/changelog.d/pr-1971.feature
new file mode 100644
index 000000000..039b19a05
--- /dev/null
+++ b/changelog.d/pr-1971.feature
@@ -0,0 +1 @@
+Pills for user mentions and the completion suggestion view are now enabled.
\ No newline at end of file