mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 02:52:45 +02:00
Merge pull request #6952 from vector-im/mauroromito/6941_wysiwyg_voice_message_support
Rich Text Composer - Voice Message Support
This commit is contained in:
@@ -40,11 +40,13 @@ enum MockComposerScreenState: MockScreenState, CaseIterable {
|
||||
|
||||
viewModel.callback = { [weak viewModel, weak wysiwygviewModel] result in
|
||||
guard let viewModel = viewModel else { return }
|
||||
if viewModel.sendMode == .edit {
|
||||
wysiwygviewModel?.setHtmlContent("")
|
||||
}
|
||||
switch result {
|
||||
case .cancel: viewModel.sendMode = .send
|
||||
case .cancel:
|
||||
if viewModel.sendMode == .edit {
|
||||
wysiwygviewModel?.setHtmlContent("")
|
||||
}
|
||||
viewModel.sendMode = .send
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,12 +127,14 @@ enum ComposerSendMode: Equatable {
|
||||
case createDM
|
||||
}
|
||||
|
||||
enum ComposerViewAction {
|
||||
enum ComposerViewAction: Equatable {
|
||||
case cancel
|
||||
case contentDidChange(isEmpty: Bool)
|
||||
}
|
||||
|
||||
enum ComposerViewModelResult {
|
||||
enum ComposerViewModelResult: Equatable {
|
||||
case cancel
|
||||
case contentDidChange(isEmpty: Bool)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let sendButton = app.buttons["sendButton"]
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(sendButton.isEnabled)
|
||||
XCTAssertFalse(sendButton.exists)
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(sendButton.isEnabled)
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(app.buttons["editButton"].exists)
|
||||
}
|
||||
|
||||
@@ -39,8 +38,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let sendButton = app.buttons["sendButton"]
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(sendButton.isEnabled)
|
||||
XCTAssertFalse(sendButton.exists)
|
||||
|
||||
let cancelButton = app.buttons["cancelButton"]
|
||||
XCTAssertTrue(cancelButton.exists)
|
||||
@@ -51,7 +49,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(sendButton.isEnabled)
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(app.buttons["editButton"].exists)
|
||||
|
||||
cancelButton.tap()
|
||||
@@ -66,8 +64,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let editButton = app.buttons["editButton"]
|
||||
XCTAssertTrue(editButton.exists)
|
||||
XCTAssertFalse(editButton.isEnabled)
|
||||
XCTAssertFalse(editButton.exists)
|
||||
|
||||
let cancelButton = app.buttons["cancelButton"]
|
||||
XCTAssertTrue(cancelButton.exists)
|
||||
@@ -78,7 +75,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(editButton.isEnabled)
|
||||
XCTAssertTrue(editButton.exists)
|
||||
XCTAssertFalse(app.buttons["sendButton"].exists)
|
||||
|
||||
cancelButton.tap()
|
||||
|
||||
@@ -26,7 +26,7 @@ struct Composer: View {
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@State private var focused = false
|
||||
@State private var isActionButtonEnabled = false
|
||||
@State private var isActionButtonShowing = false
|
||||
|
||||
private let horizontalPadding: CGFloat = 12
|
||||
private let borderHeight: CGFloat = 40
|
||||
@@ -148,7 +148,7 @@ struct Composer: View {
|
||||
.resizable()
|
||||
.foregroundColor(theme.colors.tertiaryContent)
|
||||
.frame(width: 14, height: 14)
|
||||
|
||||
|
||||
}
|
||||
.frame(width: 36, height: 36)
|
||||
.background(Circle().fill(theme.colors.system))
|
||||
@@ -159,16 +159,6 @@ struct Composer: View {
|
||||
}
|
||||
.frame(height: 44)
|
||||
Spacer()
|
||||
// ZStack {
|
||||
// TODO: Add support for voice messages
|
||||
// Button {
|
||||
//
|
||||
// } label: {
|
||||
// Image(Asset.Images.voiceMessageRecordButtonDefault.name)
|
||||
// .foregroundColor(theme.colors.tertiaryContent)
|
||||
// }
|
||||
// .isHidden(showSendButton)
|
||||
// .isHidden(true)
|
||||
Button {
|
||||
sendMessageAction(wysiwygViewModel.content)
|
||||
wysiwygViewModel.clearContent()
|
||||
@@ -181,18 +171,18 @@ struct Composer: View {
|
||||
}
|
||||
.frame(width: 36, height: 36)
|
||||
.padding(.leading, 8)
|
||||
.disabled(!isActionButtonEnabled)
|
||||
.opacity(isActionButtonEnabled ? 1 : 0.3)
|
||||
.animation(.easeInOut(duration: 0.15), value: isActionButtonEnabled)
|
||||
.isHidden(!isActionButtonShowing)
|
||||
.accessibilityIdentifier(actionButtonAccessibilityIdentifier)
|
||||
.accessibilityLabel(VectorL10n.send)
|
||||
.onChange(of: wysiwygViewModel.isContentEmpty) { empty in
|
||||
isActionButtonEnabled = !empty
|
||||
.onChange(of: wysiwygViewModel.isContentEmpty) { isEmpty in
|
||||
viewModel.send(viewAction: .contentDidChange(isEmpty: isEmpty))
|
||||
withAnimation(.easeInOut(duration: 0.15)) {
|
||||
isActionButtonShowing = !isEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.bottom, 4)
|
||||
.animation(.none)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ final class ComposerViewModel: ComposerViewModelType, ComposerViewModelProtocol
|
||||
switch viewAction {
|
||||
case .cancel:
|
||||
callback?(.cancel)
|
||||
case let .contentDidChange(isEmpty):
|
||||
callback?(.contentDidChange(isEmpty: isEmpty))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user