From 2232bb8fb7495419d33e17ed87e0e4527cfdbbbf Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 13 Jun 2019 18:12:29 -0700 Subject: [PATCH] Copy content warning on reply Closes #21 --- .../Compose/ComposeViewController.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Tusker/Screens/Compose/ComposeViewController.swift b/Tusker/Screens/Compose/ComposeViewController.swift index 96b645ec..df9d6038 100644 --- a/Tusker/Screens/Compose/ComposeViewController.swift +++ b/Tusker/Screens/Compose/ComposeViewController.swift @@ -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() {