Skip to content

Commit 6e7bc5d

Browse files
committed
Fix Send button design in Comments
1 parent 87ec186 commit 6e7bc5d

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

WordPress/Classes/ViewRelated/Comments/Controllers/Create/CommentCreateViewController.swift

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ import UIKit
22
import WordPressUI
33

44
final class CommentCreateViewController: UIViewController {
5-
private let buttonSend = UIButton(configuration: {
6-
var configuration = UIButton.Configuration.borderedProminent()
7-
configuration.title = Strings.send
8-
configuration.cornerStyle = .capsule
9-
configuration.baseBackgroundColor = UIColor.label
10-
configuration.baseForegroundColor = UIColor.systemBackground
11-
return configuration
12-
}())
13-
145
private let contentView = UIStackView(axis: .vertical, [])
156
private let editorVC = CommentEditorViewController()
167
private let viewModel: CommentCreateViewModel
@@ -32,7 +23,6 @@ final class CommentCreateViewController: UIViewController {
3223

3324
setupView()
3425
setupNavigationBar()
35-
setupAccessibility()
3626

3727
didChangeText(editorVC.initialContent ?? "")
3828
}
@@ -62,10 +52,6 @@ final class CommentCreateViewController: UIViewController {
6252
editorVC.didMove(toParent: self)
6353
}
6454

65-
private func setupAccessibility() {
66-
navigationItem.rightBarButtonItem?.accessibilityIdentifier = "button_send_comment"
67-
}
68-
6955
// MARK: - Actions
7056

7157
@objc private func buttonSendTapped() {
@@ -86,7 +72,7 @@ final class CommentCreateViewController: UIViewController {
8672
}
8773

8874
private func setLoading(_ isLoading: Bool) {
89-
navigationItem.rightBarButtonItem = isLoading ? .activityIndicator : UIBarButtonItem(customView: buttonSend)
75+
navigationItem.rightBarButtonItem = isLoading ? .activityIndicator : makeSendButton()
9076
navigationItem.leftBarButtonItem?.isEnabled = !isLoading
9177
editorVC.isEnabled = !isLoading
9278
}
@@ -128,14 +114,21 @@ final class CommentCreateViewController: UIViewController {
128114

129115
navigationItem.leftBarButtonItem = UIBarButtonItem(title: SharedStrings.Button.cancel, style: .plain, target: self, action: #selector(buttonCancelTapped))
130116

131-
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: buttonSend)
132-
buttonSend.addTarget(self, action: #selector(buttonSendTapped), for: .primaryActionTriggered)
117+
navigationItem.rightBarButtonItem = makeSendButton()
118+
navigationItem.rightBarButtonItem?.isEnabled = false
119+
}
120+
121+
private func makeSendButton() -> UIBarButtonItem {
122+
let button = UIBarButtonItem(title: Strings.send, style: .done, target: self, action: #selector(buttonSendTapped))
123+
button.accessibilityIdentifier = "button_send_comment"
124+
button.tintColor = UIAppColor.tint
125+
return button
133126
}
134127

135128
private func didChangeText(_ text: String) {
136129
let text = text.trimmingCharacters(in: .whitespacesAndNewlines)
137130
let isEnabled = !text.isEmpty
138-
buttonSend.isEnabled = isEnabled
131+
navigationItem.rightBarButtonItem?.isEnabled = isEnabled
139132
isModalInPresentation = isEnabled
140133
}
141134
}

0 commit comments

Comments
 (0)