|
|
|
@ -37,6 +37,7 @@ class ComposeViewController: UIViewController {
|
|
|
|
|
@IBOutlet weak var inReplyToContentLabel: StatusContentLabel! |
|
|
|
|
@IBOutlet weak var inReplyToLabel: UILabel! |
|
|
|
|
@IBOutlet weak var statusTextView: UITextView! |
|
|
|
|
@IBOutlet weak var charactersRemainingLabel: UILabel! |
|
|
|
|
@IBOutlet weak var visibilityButton: UIButton! |
|
|
|
|
@IBOutlet weak var postButton: UIButton! |
|
|
|
|
@IBOutlet weak var contentWarningTextField: UITextField! |
|
|
|
@ -72,6 +73,7 @@ class ComposeViewController: UIViewController {
|
|
|
|
|
statusTextView.placeholder = "What is on your mind?" |
|
|
|
|
statusTextView.layer.cornerRadius = 5 |
|
|
|
|
statusTextView.layer.masksToBounds = true |
|
|
|
|
statusTextView.delegate = self |
|
|
|
|
visibilityButton.setTitle(visibility.displayName, for: .normal) |
|
|
|
|
contentWarningTextField.delegate = self |
|
|
|
|
|
|
|
|
@ -118,6 +120,8 @@ class ComposeViewController: UIViewController {
|
|
|
|
|
statusTextView.textViewDidChange(statusTextView) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateCharactersRemaining() |
|
|
|
|
|
|
|
|
|
progressView.progress = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -134,6 +138,19 @@ class ComposeViewController: UIViewController {
|
|
|
|
|
mediaStackView.addArrangedSubview(mediaView) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func updateCharactersRemaining() { |
|
|
|
|
let count = CharacterCounter.count(text: statusTextView.text) |
|
|
|
|
let remaining = (MastodonController.shared.instance.maxStatusCharacters ?? 500) - count |
|
|
|
|
if remaining < 0 { |
|
|
|
|
charactersRemainingLabel.textColor = .red |
|
|
|
|
postButton.isEnabled = false |
|
|
|
|
} else { |
|
|
|
|
charactersRemainingLabel.textColor = .darkGray |
|
|
|
|
postButton.isEnabled = true |
|
|
|
|
} |
|
|
|
|
charactersRemainingLabel.text = remaining.description |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - Navigation |
|
|
|
|
|
|
|
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { |
|
|
|
@ -279,6 +296,12 @@ extension ComposeViewController: UITextFieldDelegate {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extension ComposeViewController: UITextViewDelegate { |
|
|
|
|
func textViewDidChange(_ textView: UITextView) { |
|
|
|
|
updateCharactersRemaining() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extension ComposeViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { |
|
|
|
|
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { |
|
|
|
|
if let selectedImage = info[.originalImage] as? UIImage { |
|
|
|
|