Skip to content

Commit 4a50da5

Browse files
authored
Merge pull request #85 from getsentry/feature/improve-user-feeback
Improve User Feeback
2 parents 3daa9b3 + 93c8144 commit 4a50da5

8 files changed

+117
-37
lines changed

Sources/ios/Assets.xcassets/sentry-glyph-black.imageset/Contents.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "sentry-glyph-black.pdf"
5+
"filename" : "sentry-glyph-black.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"filename" : "[email protected]",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "universal",
15+
"filename" : "[email protected]",
16+
"scale" : "3x"
617
}
718
],
819
"info" : {
Binary file not shown.
Loading
Loading
Loading

Sources/ios/UserFeedback.storyboard

+19-18
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="1000" text="It looks like we're having some internal issues." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="7hj-0c-bhv">
3232
<rect key="frame" x="16" y="28" width="382" height="48"/>
3333
<fontDescription key="fontDescription" type="system" pointSize="20"/>
34-
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
34+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
3535
<nil key="highlightedColor"/>
3636
</label>
3737
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" text="Our team has been notified. If you'd like to help, tell us what happened below." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="8" translatesAutoresizingMaskIntoConstraints="NO" id="pQh-Nn-xPX">
3838
<rect key="frame" x="24" y="84" width="366" height="38.333333333333329"/>
3939
<fontDescription key="fontDescription" type="system" pointSize="16"/>
40-
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
40+
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
4141
<nil key="highlightedColor"/>
4242
</label>
4343
</subviews>
@@ -76,7 +76,7 @@
7676
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uks-MI-jgZ">
7777
<rect key="frame" x="24" y="13" width="48" height="17"/>
7878
<fontDescription key="fontDescription" type="system" pointSize="14"/>
79-
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
79+
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
8080
<nil key="highlightedColor"/>
8181
</label>
8282
</subviews>
@@ -110,7 +110,7 @@
110110
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Email:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UcC-PW-ioD">
111111
<rect key="frame" x="24" y="13" width="48" height="17"/>
112112
<fontDescription key="fontDescription" type="system" pointSize="14"/>
113-
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
113+
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
114114
<nil key="highlightedColor"/>
115115
</label>
116116
</subviews>
@@ -133,8 +133,8 @@
133133
<autoresizingMask key="autoresizingMask"/>
134134
<subviews>
135135
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" placeholder="I clicked on X and then this happened" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="UJb-Ie-rFk">
136-
<rect key="frame" x="25" y="16" width="365" height="148"/>
137-
<nil key="textColor"/>
136+
<rect key="frame" x="25" y="16" width="365" height="147"/>
137+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
138138
<fontDescription key="fontDescription" type="system" pointSize="14"/>
139139
<textInputTraits key="textInputTraits" returnKeyType="send"/>
140140
<connections>
@@ -158,31 +158,32 @@
158158
<rect key="frame" x="0.0" y="0.0" width="414" height="59.5"/>
159159
<autoresizingMask key="autoresizingMask"/>
160160
<subviews>
161-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SENTRY" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tf4-kn-B2U">
162-
<rect key="frame" x="330" y="19" width="64" height="21"/>
163-
<fontDescription key="fontDescription" type="system" pointSize="17"/>
161+
<label opaque="NO" userInteractionEnabled="NO" alpha="0.75" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SENTRY" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tf4-kn-B2U">
162+
<rect key="frame" x="340" y="21.333333333333336" width="54" height="17.000000000000007"/>
163+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
164+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
164165
<nil key="highlightedColor"/>
165166
</label>
166167
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Crash reports powered by" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="b3o-7r-1u9">
167-
<rect key="frame" x="143" y="22" width="147" height="15"/>
168-
<fontDescription key="fontDescription" type="system" pointSize="12"/>
169-
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
168+
<rect key="frame" x="171.66666666666663" y="23" width="136.33333333333337" height="13.333333333333336"/>
169+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
170+
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
170171
<nil key="highlightedColor"/>
171172
</label>
172-
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="NFt-xw-keo">
173-
<rect key="frame" x="290" y="10" width="40" height="40"/>
173+
<imageView userInteractionEnabled="NO" alpha="0.75" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="NFt-xw-keo">
174+
<rect key="frame" x="316" y="20" width="20" height="20"/>
174175
<constraints>
175-
<constraint firstAttribute="width" constant="40" id="8Lu-8a-DHh"/>
176-
<constraint firstAttribute="height" constant="40" id="OKW-29-URA"/>
176+
<constraint firstAttribute="width" constant="20" id="8Lu-8a-DHh"/>
177+
<constraint firstAttribute="height" constant="20" id="OKW-29-URA"/>
177178
</constraints>
178179
</imageView>
179180
</subviews>
180181
<constraints>
181182
<constraint firstAttribute="trailingMargin" secondItem="tf4-kn-B2U" secondAttribute="trailing" constant="12" id="9kE-H0-qrl"/>
182-
<constraint firstItem="NFt-xw-keo" firstAttribute="leading" secondItem="b3o-7r-1u9" secondAttribute="trailing" id="ZgZ-K2-xgl"/>
183+
<constraint firstItem="NFt-xw-keo" firstAttribute="leading" secondItem="b3o-7r-1u9" secondAttribute="trailing" constant="8" id="ZgZ-K2-xgl"/>
183184
<constraint firstItem="b3o-7r-1u9" firstAttribute="centerY" secondItem="kHQ-92-YRE" secondAttribute="centerY" id="ase-Bs-yEN"/>
184185
<constraint firstItem="NFt-xw-keo" firstAttribute="centerY" secondItem="kHQ-92-YRE" secondAttribute="centerY" id="h3r-xs-Mdr"/>
185-
<constraint firstItem="tf4-kn-B2U" firstAttribute="leading" secondItem="NFt-xw-keo" secondAttribute="trailing" id="oZ2-oD-1Lo"/>
186+
<constraint firstItem="tf4-kn-B2U" firstAttribute="leading" secondItem="NFt-xw-keo" secondAttribute="trailing" constant="4" id="oZ2-oD-1Lo"/>
186187
<constraint firstItem="tf4-kn-B2U" firstAttribute="centerY" secondItem="kHQ-92-YRE" secondAttribute="centerY" id="vqc-8c-duv"/>
187188
</constraints>
188189
</tableViewCellContentView>

Sources/ios/UserFeedbackTableViewController.swift

+57-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
public final class UserFeedbackTableViewController: UITableViewController, UITextFieldDelegate {
11+
public final class UserFeedbackTableViewController: UITableViewController, UITextFieldDelegate, ViewModelDelegate {
1212

1313
@IBOutlet weak var titleLabel: UILabel!
1414
@IBOutlet weak var subtitleLabel: UILabel!
@@ -33,13 +33,15 @@ public final class UserFeedbackTableViewController: UITableViewController, UITex
3333
super.viewDidLoad()
3434
clearsSelectionOnViewWillAppear = false
3535
tableView.tableFooterView = UIView()
36+
viewModel?.delegate = self
37+
setupInterface()
3638
}
3739

3840
public override func viewWillAppear(_ animated: Bool) {
3941
super.viewWillAppear(animated)
4042
updateInterface()
4143
}
42-
44+
4345
func dismissViewController() {
4446
#if swift(>=3.0)
4547
dismiss(animated: true, completion: nil)
@@ -52,39 +54,41 @@ public final class UserFeedbackTableViewController: UITableViewController, UITex
5254
submitUserFeedback()
5355
}
5456

55-
private func updateInterface() {
57+
private func setupInterface() {
5658
guard let viewModel = viewModel else {
5759
SentryLog.Error.log("UserFeedbackTableViewController has no UserFeedbackViewModel set")
5860
return
5961
}
6062

63+
nameTextField.text = viewModel.nameTextFieldValue
64+
emailTextField.text = viewModel.emailTextFieldValue
65+
commentsTextField.text = viewModel.commentsTextFieldValue
66+
nameTextField.textColor = viewModel.defaultTextColor
67+
emailTextField.textColor = viewModel.defaultTextColor
68+
commentsTextField.textColor = viewModel.defaultTextColor
69+
6170
titleLabel.text = viewModel.title
6271
subtitleLabel.text = viewModel.subTitle
6372

64-
nameTextField.text = viewModel.nameTextFieldValue
6573
nameLabel.text = viewModel.nameLabel
6674

67-
emailTextField.text = viewModel.emailTextFieldValue
6875
emailLabel.text = viewModel.emailLabel
69-
70-
commentsTextField.text = viewModel.commentsTextFieldValue
71-
commentsTextField.placeholder = viewModel.commentsTextFieldPlaceholder
72-
76+
7377
#if swift(>=3.0)
78+
commentsTextField.attributedPlaceholder = NSAttributedString(string: viewModel.commentsTextFieldPlaceholder, attributes: [NSForegroundColorAttributeName: UIColor.darkGray])
7479
poweredByTableViewCell.isHidden = !viewModel.showSentryBranding
7580

7681
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismissViewController))
77-
navigationItem.rightBarButtonItem = UIBarButtonItem(title: viewModel.submitButtonText, style: .done, target: self, action: #selector(onClickSubmit))
78-
7982
if let bundleURL = Bundle(for: type(of: self)).url(forResource: "assets", withExtension: "bundle"),
8083
let bundle = Bundle(url: bundleURL) {
81-
sentryLogoImageView.image = UIImage(named: "sentry-glyph-black", in: bundle, compatibleWith: nil)
84+
sentryLogoImageView.image = UIImage(named: "sentry-glyph-black", in: bundle, compatibleWith: nil)
8285
}
8386
#else
87+
commentsTextField.attributedPlaceholder = NSAttributedString(string: viewModel.commentsTextFieldPlaceholder, attributes: [NSForegroundColorAttributeName: UIColor.darkGrayColor()])
88+
8489
poweredByTableViewCell.hidden = !viewModel.showSentryBranding
85-
90+
8691
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: #selector(dismissViewController))
87-
navigationItem.rightBarButtonItem = UIBarButtonItem(title: viewModel.submitButtonText, style: .Done, target: self, action: #selector(onClickSubmit))
8892

8993
if let bundleURL = NSBundle(forClass: self.dynamicType).URLForResource("assets", withExtension: "bundle"),
9094
let bundle = NSBundle(URL: bundleURL) {
@@ -95,6 +99,23 @@ public final class UserFeedbackTableViewController: UITableViewController, UITex
9599
title = viewModel.viewControllerTitle
96100
}
97101

102+
private func updateInterface() {
103+
guard let viewModel = viewModel else {
104+
SentryLog.Error.log("UserFeedbackTableViewController has no UserFeedbackViewModel set")
105+
return
106+
}
107+
108+
#if swift(>=3.0)
109+
let rightBarButton = UIBarButtonItem(title: viewModel.submitButtonText, style: .done, target: self, action: #selector(onClickSubmit))
110+
navigationItem.rightBarButtonItem = rightBarButton
111+
rightBarButton.isEnabled = viewModel.submitButtonEnabled
112+
#else
113+
let rightBarButton = UIBarButtonItem(title: viewModel.submitButtonText, style: .Done, target: self, action: #selector(onClickSubmit))
114+
navigationItem.rightBarButtonItem = rightBarButton
115+
rightBarButton.enabled = viewModel.submitButtonEnabled
116+
#endif
117+
}
118+
98119
private func submitUserFeedback() {
99120
guard let viewModel = viewModel else {
100121
SentryLog.Error.log("UserFeedbackTableViewController has no UserFeedbackViewModel set")
@@ -116,8 +137,30 @@ public final class UserFeedbackTableViewController: UITableViewController, UITex
116137
}
117138
}
118139

140+
// MARK: ViewModelDelegate
141+
142+
func signalUpdate() {
143+
updateInterface()
144+
}
145+
119146
// MARK: UITextFieldDelegate
120147

148+
public func textFieldDidBeginEditing(_ textField: UITextField) {
149+
viewModel?.validatedUserFeedback(nameTextField: nameTextField, emailTextField: emailTextField, commentsTextField: commentsTextField)
150+
}
151+
152+
#if swift(>=3.0)
153+
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
154+
viewModel?.validatedUserFeedback(nameTextField: nameTextField, emailTextField: emailTextField, commentsTextField: commentsTextField)
155+
return true
156+
}
157+
#else
158+
public func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
159+
viewModel?.validatedUserFeedback(nameTextField: nameTextField, emailTextField: emailTextField, commentsTextField: commentsTextField)
160+
return true
161+
}
162+
#endif
163+
121164
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
122165
switch textField {
123166
case nameTextField:

0 commit comments

Comments
 (0)