Copy content warning on reply

Closes #21
This commit is contained in:
Shadowfacts 2019-06-13 18:12:29 -07:00
parent b478f6e982
commit 2232bb8fb7
Signed by: shadowfacts
GPG Key ID: 83FB3304046BADA4
1 changed files with 10 additions and 8 deletions

View File

@ -103,7 +103,7 @@ class ComposeViewController: UIViewController {
let toolbar = UIToolbar()
contentWarningBarButtonItem = UIBarButtonItem(title: "CW", style: .plain, target: self, action: #selector(contentWarningButtonPressed))
visibilityBarButtonItem = UIBarButtonItem(image: Preferences.shared.defaultPostVisibility.image, style: .plain, target: self, action: #selector(visibilityButtonPressed))
visibilityBarButtonItem = UIBarButtonItem(image: nil, style: .plain, target: self, action: #selector(visibilityButtonPressed))
toolbar.items = [
contentWarningBarButtonItem,
visibilityBarButtonItem,
@ -127,6 +127,9 @@ class ComposeViewController: UIViewController {
if let inReplyToID = inReplyToID, let inReplyTo = MastodonCache.status(for: inReplyToID) {
visibility = inReplyTo.visibility
contentWarningEnabled = !inReplyTo.spoilerText.isEmpty
contentWarningContainerView.isHidden = !contentWarningEnabled
contentWarningTextField.text = inReplyTo.spoilerText
let replyView = ComposeStatusReplyView.create()
replyView.updateUI(for: inReplyTo)
@ -159,11 +162,11 @@ class ComposeViewController: UIViewController {
updateCharactersRemaining()
updatePlaceholder()
contentWarningEnabled = false
NotificationCenter.default.addObserver(self, selector: #selector(contentWarningTextFieldDidChange), name: UITextField.textDidChangeNotification, object: contentWarningTextField)
if inReplyToID == nil {
visibility = Preferences.shared.defaultPostVisibility
contentWarningEnabled = false
}
}
@ -288,12 +291,6 @@ class ComposeViewController: UIViewController {
func contentWarningStateChanged() {
contentWarningContainerView.isHidden = !contentWarningEnabled
contentWarningBarButtonItem.style = contentWarningEnabled ? .done : .plain
if contentWarningEnabled {
contentWarningTextField.becomeFirstResponder()
} else {
statusTextView.becomeFirstResponder()
}
}
func visibilityChanged() {
@ -360,6 +357,11 @@ class ComposeViewController: UIViewController {
@objc func contentWarningButtonPressed() {
contentWarningEnabled = !contentWarningEnabled
if contentWarningEnabled {
contentWarningTextField.becomeFirstResponder()
} else {
statusTextView.becomeFirstResponder()
}
}
@objc func contentWarningTextFieldDidChange() {