@@ -26,6 +26,8 @@ class NewPostViewController: UIViewController, UITextViewDelegate {
26 var myProtocol: NewPostDelegate?
26 var myProtocol: NewPostDelegate?
28 static var draft: String = ""
28 static var draft: String = ""
29+ static var hashTagsDraft: [String] = []
29 var textView: UITextView!
31 var textView: UITextView!
31 // buttons for attaching images
33 // buttons for attaching images
@@ -95,6 +97,8 @@ class NewPostViewController: UIViewController, UITextViewDelegate {
95 navigationController?.navigationBar.prefersLargeTitles = false
97 navigationController?.navigationBar.prefersLargeTitles = false
96 navigationItem.title = "New post"
98 navigationItem.title = "New post"
97 textView.text = NewPostViewController.draft
99 textView.text = NewPostViewController.draft
100+ tagsField.addTags(NewPostViewController.hashTagsDraft)
100 func setUpAccessoryView(){
104 func setUpAccessoryView(){
@@ -227,6 +231,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate {
227 [weak self]
231 [weak self]
229 NewPostViewController.draft = self?.textView.text ?? ""
233 NewPostViewController.draft = self?.textView.text ?? ""
234+ NewPostViewController.hashTagsDraft = self?.tagsField.tags.map { $0.text } ?? []
230 self?.moveBackToParentVC()
235 self?.moveBackToParentVC()
@@ -235,6 +240,7 @@ class NewPostViewController: UIViewController, UITextViewDelegate {
235 [weak self] (_)
240 [weak self] (_)
237 NewPostViewController.draft = ""
242 NewPostViewController.draft = ""
243+ NewPostViewController.hashTagsDraft = []
238 self?.moveBackToParentVC()
244 self?.moveBackToParentVC()
@@ -307,7 +313,7 @@ extension NewPostViewController: UITextFieldDelegate {
308 func textFieldShouldReturn(_ textField: UITextField) -> Bool {
314 func textFieldShouldReturn(_ textField: UITextField) -> Bool {
309 if textField == tagsField {
315 if textField == tagsField {
310− // hz
316+ textView.becomeFirstResponder()
312 return true
318 return true