Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 563d1e4

Browse files
jamucrnystrom
authored andcommitted
Remove image upload description (#1550)
* Remove description field on image upload * Use title text as alt name if available
1 parent d7627b3 commit 563d1e4

File tree

2 files changed

+12
-58
lines changed

2 files changed

+12
-58
lines changed

Classes/Image Upload/ImageUpload.storyboard

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<deployment identifier="iOS"/>
87
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
98
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
109
</dependencies>
@@ -20,19 +19,19 @@
2019
<sections>
2120
<tableViewSection id="s1r-s0-sed">
2221
<cells>
23-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="120" id="bPq-Rw-PLO">
24-
<rect key="frame" x="0.0" y="35" width="375" height="120"/>
22+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="300" id="bPq-Rw-PLO">
23+
<rect key="frame" x="0.0" y="35" width="375" height="300"/>
2524
<autoresizingMask key="autoresizingMask"/>
2625
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="bPq-Rw-PLO" id="ItG-Cs-Vvc">
27-
<rect key="frame" x="0.0" y="0.0" width="375" height="119.5"/>
26+
<rect key="frame" x="0.0" y="0.0" width="375" height="299.5"/>
2827
<autoresizingMask key="autoresizingMask"/>
2928
<subviews>
3029
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="d7E-xB-fht">
31-
<rect key="frame" x="0.0" y="0.0" width="375" height="119"/>
30+
<rect key="frame" x="0.0" y="0.0" width="375" height="299.5"/>
3231
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
3332
</imageView>
3433
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QMZ-yn-I5R">
35-
<rect key="frame" x="0.0" y="0.0" width="375" height="119.5"/>
34+
<rect key="frame" x="0.0" y="0.0" width="375" height="299.5"/>
3635
<connections>
3736
<action selector="didPressPreviewImage" destination="fex-dK-757" eventType="touchUpInside" id="pwI-Uk-KaF"/>
3837
</connections>
@@ -55,7 +54,7 @@
5554
<tableViewSection headerTitle="TITLE" id="8bB-fg-hEC">
5655
<cells>
5756
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="qHM-9o-Ifd">
58-
<rect key="frame" x="0.0" y="211" width="375" height="44"/>
57+
<rect key="frame" x="0.0" y="391" width="375" height="44"/>
5958
<autoresizingMask key="autoresizingMask"/>
6059
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qHM-9o-Ifd" id="J4O-t2-43c">
6160
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
@@ -78,32 +77,6 @@
7877
</tableViewCell>
7978
</cells>
8079
</tableViewSection>
81-
<tableViewSection headerTitle="DESCRIPTION" id="nli-98-Nxa">
82-
<cells>
83-
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="150" id="FD5-IO-LTm">
84-
<rect key="frame" x="0.0" y="311" width="375" height="150"/>
85-
<autoresizingMask key="autoresizingMask"/>
86-
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="FD5-IO-LTm" id="58C-S9-icB">
87-
<rect key="frame" x="0.0" y="0.0" width="375" height="149.5"/>
88-
<autoresizingMask key="autoresizingMask"/>
89-
<subviews>
90-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="iqO-9E-R2C" customClass="MessageTextView" customModule="MessageViewController">
91-
<rect key="frame" x="16" y="8" width="343" height="133.5"/>
92-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
93-
<fontDescription key="fontDescription" type="system" pointSize="16"/>
94-
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
95-
</textView>
96-
</subviews>
97-
<constraints>
98-
<constraint firstItem="iqO-9E-R2C" firstAttribute="top" secondItem="58C-S9-icB" secondAttribute="top" constant="8" id="CxK-BZ-dH5"/>
99-
<constraint firstAttribute="bottom" secondItem="iqO-9E-R2C" secondAttribute="bottom" constant="8" id="gD8-pz-f3L"/>
100-
<constraint firstAttribute="trailing" secondItem="iqO-9E-R2C" secondAttribute="trailing" constant="16" id="kfh-DG-Twc"/>
101-
<constraint firstItem="iqO-9E-R2C" firstAttribute="leading" secondItem="58C-S9-icB" secondAttribute="leading" constant="16" id="kqI-9T-iR3"/>
102-
</constraints>
103-
</tableViewCellContentView>
104-
</tableViewCell>
105-
</cells>
106-
</tableViewSection>
10780
</sections>
10881
<connections>
10982
<outlet property="dataSource" destination="fex-dK-757" id="jyz-X2-QEj"/>
@@ -122,7 +95,6 @@
12295
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
12396
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
12497
<connections>
125-
<outlet property="bodyTextView" destination="iqO-9E-R2C" id="aaV-Ga-YE8"/>
12698
<outlet property="previewImageView" destination="d7E-xB-fht" id="vag-wx-uwe"/>
12799
<outlet property="titleTextField" destination="IrO-7N-7EE" id="8Xt-hT-Ycb"/>
128100
</connections>

Classes/Image Upload/ImageUploadTableViewController.swift

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
230212
extension 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

Comments
 (0)