@@ -23,10 +23,6 @@ class ImageUploadTableViewController: UITableViewController {
2323 }
2424 }
2525 @IBOutlet private var titleTextField : UITextField !
26- @IBOutlet private var bodyTextView : MessageTextView !
27-
28- private var bodyPlaceholder : String ?
29- private var bodyTextColor : UIColor ?
3026
3127 private var image : UIImage ! // Set through the create function
3228 private var username : String ?
@@ -41,12 +37,6 @@ class ImageUploadTableViewController: UITableViewController {
4137 return raw
4238 }
4339
44- private var descriptionText : String ? {
45- let raw = bodyTextView. text. trimmingCharacters ( in: . whitespacesAndNewlines)
46- if raw. isEmpty { return nil }
47- return raw
48- }
49-
5040 class func create( _ image: UIImage , username: String ? , delegate: ImageUploadDelegate ) -> ImageUploadTableViewController ? {
5141 let storyboard = UIStoryboard ( name: " ImageUpload " , bundle: nil )
5242
@@ -67,8 +57,6 @@ class ImageUploadTableViewController: UITableViewController {
6757 // Set the preview image
6858 previewImageView. image = image
6959
70- // Set title field delegate so return moves to next field
71- titleTextField. delegate = self
7260
7361 // Set the right button item to spinning until we have compression info
7462 setRightBarItemSpinning ( )
@@ -78,12 +66,6 @@ class ImageUploadTableViewController: UITableViewController {
7866
7967 // Setup view colors and styles
8068 let placeholderText = NSLocalizedString ( " Optional " , comment: " " )
81- bodyTextView. placeholderText = placeholderText
82- bodyTextView. placeholderTextColor = Styles . Colors. Gray. light. color
83- bodyTextView. font = Styles . Text. body. preferredFont
84- bodyTextView. textContainerInset = . zero
85- bodyTextView. textContainer. lineFragmentPadding = 0
86-
8769 titleTextField. textColor = Styles . Colors. Gray. dark. color
8870 titleTextField. font = Styles . Text. body. preferredFont
8971 titleTextField. attributedPlaceholder = NSAttributedString (
@@ -93,6 +75,7 @@ class ImageUploadTableViewController: UITableViewController {
9375 . font: Styles . Text. body. preferredFont
9476 ]
9577 )
78+ titleTextField. delegate = self
9679
9780 // Compress and encode the image in the background to speed up the upload process
9881 image. compressAndEncode { [ weak self] result in
@@ -143,7 +126,7 @@ class ImageUploadTableViewController: UITableViewController {
143126 self . dismiss ( animated: trueUnlessReduceMotionEnabled)
144127 }
145128
146- if titleText == nil && descriptionText == nil {
129+ if titleText == nil {
147130 dismissBlock ( )
148131 return
149132 }
@@ -192,7 +175,7 @@ class ImageUploadTableViewController: UITableViewController {
192175 return
193176 }
194177
195- var name = " GitHawk Upload "
178+ var name = self ? . titleText ?? " GitHawk Upload "
196179
197180 if let username = self ? . username {
198181 name += " by \( username) "
@@ -203,7 +186,7 @@ class ImageUploadTableViewController: UITableViewController {
203186 base64Image: compressionData,
204187 name: name,
205188 title: self ? . titleText ?? " " ,
206- description: self ? . descriptionText ?? " " ) { [ weak self] result in
189+ description: " " ) { [ weak self] result in
207190
208191 switch result {
209192 case . error:
@@ -226,11 +209,10 @@ class ImageUploadTableViewController: UITableViewController {
226209}
227210
228211// MARK: UITextFieldDelegate
229-
230212extension ImageUploadTableViewController : UITextFieldDelegate {
231213 /// Called when the user taps return on the title field, moves their cursor to the body
232214 func textFieldShouldReturn( _ textField: UITextField ) -> Bool {
233- bodyTextView . becomeFirstResponder ( )
234- return false
215+ view . endEditing ( true )
216+ return true
235217 }
236218}
0 commit comments