mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-07 00:17:43 +02:00
Merge pull request #6885 from vector-im/mauroromito/wysiwyg_sendButton_disabled
Send/Edit Button on WYSIWYG is disabled when there is no text instead of being hidden
This commit is contained in:
@@ -38,7 +38,7 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
|
||||
private var heightConstraint: NSLayoutConstraint!
|
||||
private var hostingViewController: VectorHostingController!
|
||||
private var wysiwygViewModel = WysiwygComposerViewModel(textColor: ThemeService.shared().theme.colors.primaryContent)
|
||||
private var viewModel: ComposerViewModelProtocol! = ComposerViewModel(initialViewState: ComposerViewState())
|
||||
private var viewModel: ComposerViewModelProtocol = ComposerViewModel(initialViewState: ComposerViewState())
|
||||
|
||||
// MARK: Public
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let sendButton = app.buttons["sendButton"]
|
||||
XCTAssertFalse(sendButton.exists)
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(sendButton.isEnabled)
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertTrue(sendButton.isEnabled)
|
||||
XCTAssertFalse(app.buttons["editButton"].exists)
|
||||
}
|
||||
|
||||
@@ -38,7 +39,8 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let sendButton = app.buttons["sendButton"]
|
||||
XCTAssertFalse(sendButton.exists)
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertFalse(sendButton.isEnabled)
|
||||
|
||||
let cancelButton = app.buttons["cancelButton"]
|
||||
XCTAssertTrue(cancelButton.exists)
|
||||
@@ -49,7 +51,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(sendButton.exists)
|
||||
XCTAssertTrue(sendButton.isEnabled)
|
||||
XCTAssertFalse(app.buttons["editButton"].exists)
|
||||
|
||||
cancelButton.tap()
|
||||
@@ -64,7 +66,8 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
let wysiwygTextView = app.textViews.allElementsBoundByIndex[0]
|
||||
XCTAssertTrue(wysiwygTextView.exists)
|
||||
let editButton = app.buttons["editButton"]
|
||||
XCTAssert(!editButton.exists)
|
||||
XCTAssertTrue(editButton.exists)
|
||||
XCTAssertFalse(editButton.isEnabled)
|
||||
|
||||
let cancelButton = app.buttons["cancelButton"]
|
||||
XCTAssertTrue(cancelButton.exists)
|
||||
@@ -75,7 +78,7 @@ final class ComposerUITests: MockScreenTestCase {
|
||||
|
||||
wysiwygTextView.tap()
|
||||
wysiwygTextView.typeText("test")
|
||||
XCTAssertTrue(editButton.exists)
|
||||
XCTAssertTrue(editButton.isEnabled)
|
||||
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 showSendButton = false
|
||||
@State private var isActionButtonEnabled = false
|
||||
|
||||
private let horizontalPadding: CGFloat = 12
|
||||
private let borderHeight: CGFloat = 44
|
||||
@@ -161,20 +161,18 @@ struct Composer: View {
|
||||
} label: {
|
||||
if viewModel.viewState.sendMode == .edit {
|
||||
Image(Asset.Images.saveIcon.name)
|
||||
.foregroundColor(theme.colors.tertiaryContent)
|
||||
} else {
|
||||
Image(Asset.Images.sendIcon.name)
|
||||
.foregroundColor(theme.colors.tertiaryContent)
|
||||
}
|
||||
}
|
||||
.disabled(!isActionButtonEnabled)
|
||||
.opacity(isActionButtonEnabled ? 1 : 0.3)
|
||||
.animation(.easeInOut(duration: 0.15), value: isActionButtonEnabled)
|
||||
.accessibilityIdentifier(actionButtonAccessibilityIdentifier)
|
||||
.accessibilityLabel(VectorL10n.send)
|
||||
.isHidden(!showSendButton)
|
||||
}
|
||||
.onChange(of: wysiwygViewModel.isContentEmpty) { empty in
|
||||
withAnimation(.easeInOut(duration: 0.25)) {
|
||||
showSendButton = !empty
|
||||
}
|
||||
isActionButtonEnabled = !empty
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ packages:
|
||||
branch: main
|
||||
WysiwygComposer:
|
||||
url: https://github.com/matrix-org/matrix-wysiwyg-composer-swift
|
||||
branch: main
|
||||
revision: b945a33cea78fb36a386d4ef7f1934b00b1d445c
|
||||
DeviceKit:
|
||||
url: https://github.com/devicekit/DeviceKit
|
||||
majorVersion: 4.7.0
|
||||
|
||||
Reference in New Issue
Block a user