Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(user-feedback): ui tests to display form, submit, cancel #4536

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more docs, theming
  • Loading branch information
armcknight committed Nov 14, 2024
commit f24bd668433481c37f0990a47aa3f73e230ed066
12 changes: 7 additions & 5 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
uiForm.messagePlaceholder = "Describe the nature of the jank. Its essence, if you will."
}
config.configureTheme = { theme in
let fontSize: CGFloat = 25

let fontFamily: String
if Locale.current.languageCode == "ar" { // arabic; ar_EG
fontFamily = "Damascus"
Expand All @@ -218,15 +216,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} else {
fontFamily = "ChalkboardSE-Regular"
}
theme.font = UIFont(name: fontFamily, size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)
theme.fontFamily = fontFamily
theme.outlineStyle = .init(outlineColor: .purple)
theme.foreground = .purple
theme.background = .purple.withAlphaComponent(0.1)
theme.background = .init(red: 0.95, green: 0.9, blue: 0.95, alpha: 1)
theme.submitBackground = .orange
theme.submitForeground = .purple
theme.buttonBackground = .purple
theme.buttonForeground = .white
}
config.onSubmitSuccess = { info in
let name = info["name"] ?? "$shakespearean_insult_name"
let alert = UIAlertController(title: "Thanks?", message: "We have enough jank of our own, we really didn't need yours too, \(name).", preferredStyle: .alert)
alert.addAction(.init(title: "Derp", style: .default))
alert.addAction(.init(title: "Deal with it 🕶️", style: .default))
self.window?.rootViewController?.present(alert, animated: true)
}
config.onSubmitError = { error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,48 @@
@available(iOS 13.0, *)
@objcMembers
public class SentryUserFeedbackThemeConfiguration: NSObject {
lazy var defaultFont = UIFont.preferredFont(forTextStyle: .callout)

lazy var defaultTitleFont = UIFont.preferredFont(forTextStyle: .title1)
/**
* The font family to use for form text elements.
* - note: Defaults to the system default, if this property is `nil`.
*/
public lazy var fontFamily: String? = nil

lazy var defaultHeadingFont = UIFont.preferredFont(forTextStyle: .headline)
/**
* Font for form input elements.
* - note: Defaults to `UIFont.TextStyle.callout`.
*/
lazy var font = scaledFont(style: .callout)

/**
* The default font to use.
* - note: Defaults to the current system default.
* Font for main header title of the feedback form.
* - note: Defaults to `UIFont.TextStyle.title1`.
*/
public lazy var font = defaultFont
lazy var headerFont = scaledFont(style: .title1)

public lazy var titleFont = defaultTitleFont
/**
* Font for titles of text fields and buttons in the form.
* - note: Defaults to `UIFont.TextStyle.headline`.
*/
lazy var titleFont = scaledFont(style: .headline)

public lazy var headingFont = defaultHeadingFont
/**
* Return a scaled font for the given style, using the configured font family.
*/
func scaledFont(style: UIFont.TextStyle) -> UIFont {
guard let fontFamily = fontFamily, let font = UIFont(name: fontFamily, size: UIFont.systemFontSize) else {
return UIFont.preferredFont(forTextStyle: style)

Check warning on line 41 in Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift#L41

Added line #L41 was not covered by tests
}
return UIFontMetrics(forTextStyle: style).scaledFont(for: font)
}

Check warning on line 44 in Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift#L44

Added line #L44 was not covered by tests

/**
* Helps respond to dynamic font size changes when the app is in the background, and then comes back to the foreground.
*/
func updateDefaultFonts() {
defaultFont = UIFont.preferredFont(forTextStyle: .callout)
defaultTitleFont = UIFont.preferredFont(forTextStyle: .title1)
defaultHeadingFont = UIFont.preferredFont(forTextStyle: .headline)
font = defaultFont
titleFont = defaultTitleFont
headingFont = defaultHeadingFont
font = scaledFont(style: .callout)
headerFont = scaledFont(style: .title1)
titleFont = scaledFont(style: .headline)
}

Check warning on line 53 in Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift#L50-L53

Added lines #L50 - L53 were not covered by tests

/**
* Foreground text color of the widget and form.
Expand Down Expand Up @@ -102,19 +120,25 @@
public var outlineWidth: CGFloat = 0.5

public init(outlineColor: UIColor = UIColor(white: 204 / 255, alpha: 1), cornerRadius: CGFloat = 5, outlineWidth: CGFloat = 0.5) {
self.outlineColor = outlineColor
self.cornerRadius = cornerRadius
self.outlineWidth = outlineWidth
}

Check warning on line 126 in Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/Configuration/SentryUserFeedbackThemeConfiguration.swift#L123-L126

Added lines #L123 - L126 were not covered by tests
}

// We need to keep a reference to a default instance of this for comparison purposes later. We don't use the default to give UITextFields a default style, instead, we use `UITextField.BorderStyle.roundedRect` if `SentryUserFeedbackThemeConfiguration.outlineStyle == defaultOutlineStyle`.
/**
* - note: We need to keep a reference to a default instance of this for comparison purposes later. We don't use the default to give UITextFields a default style, instead, we use `UITextField.BorderStyle.roundedRect` if `SentryUserFeedbackThemeConfiguration.outlineStyle == defaultOutlineStyle`.
*/
let defaultOutlineStyle = OutlineStyle()

// Options for styling the outline of input elements and buttons in the feedback form.
/**
* Options for styling the outline of input elements and buttons in the feedback form.
*/
public lazy var outlineStyle: OutlineStyle = defaultOutlineStyle

// The background color to use for text inputs in the feedback form.
/**
* Background color to use for text inputs in the feedback form.
*/
public var inputBackground: UIColor = UIColor.secondarySystemBackground
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,316 +16,313 @@
weak var delegate: (any SentryUserFeedbackFormDelegate)?

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if config.theme.font == config.theme.defaultFont {
config.theme.updateDefaultFonts()
config.recalculateScaleFactors()
}

config.theme.updateDefaultFonts()
config.recalculateScaleFactors()
updateLayout()
}

Check warning on line 22 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L19-L22

Added lines #L19 - L22 were not covered by tests

let formElementHeight: CGFloat = 40
let logoWidth: CGFloat = 47
lazy var messageTextViewHeightConstraint = messageTextView.heightAnchor.constraint(equalToConstant: config.theme.font.lineHeight * 5)
lazy var logoViewWidthConstraint = sentryLogoView.widthAnchor.constraint(equalToConstant: logoWidth * config.scaleFactor)
lazy var messagePlaceholderLeadingConstraint = messageTextViewPlaceholder.leadingAnchor.constraint(equalTo: messageTextView.leadingAnchor, constant: messageTextView.textContainerInset.left + 5)
lazy var messagePlaceholderTopConstraint = messageTextViewPlaceholder.topAnchor.constraint(equalTo: messageTextView.topAnchor, constant: messageTextView.textContainerInset.top)
lazy var fullNameTextFieldHeightConstraint = fullNameTextField.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var emailTextFieldHeightConstraint = emailTextField.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var addScreenshotButtonHeightConstraint = addScreenshotButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var removeScreenshotButtonHeightConstraint = removeScreenshotButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var submitButtonHeightConstraint = submitButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var cancelButtonHeightConstraint = cancelButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)

init(config: SentryUserFeedbackConfiguration, delegate: any SentryUserFeedbackFormDelegate) {
self.config = config
self.delegate = delegate
super.init(nibName: nil, bundle: nil)
view.backgroundColor = .systemBackground

view.backgroundColor = config.theme.background

NSLayoutConstraint.activate([
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: config.margin),
scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: config.margin),
scrollView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -config.margin),
scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -config.margin),

stack.topAnchor.constraint(equalTo: scrollView.topAnchor),
stack.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
stack.widthAnchor.constraint(equalTo: scrollView.widthAnchor),

messageTextViewHeightConstraint,

logoViewWidthConstraint,
sentryLogoView.heightAnchor.constraint(equalTo: sentryLogoView.widthAnchor, multiplier: 41 / 47),

fullNameTextFieldHeightConstraint,
emailTextFieldHeightConstraint,
addScreenshotButtonHeightConstraint,
removeScreenshotButtonHeightConstraint,
submitButtonHeightConstraint,
cancelButtonHeightConstraint,

// the extra 5 pixels was observed experimentally and is invariant under changes in dynamic type sizes
messagePlaceholderLeadingConstraint,
messagePlaceholderTopConstraint
])

Check warning on line 58 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L25-L58

Added lines #L25 - L58 were not covered by tests
[fullNameTextField, emailTextField].forEach {
$0.font = config.theme.font
$0.adjustsFontForContentSizeCategory = true

Check warning on line 61 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L60-L61

Added lines #L60 - L61 were not covered by tests
if config.theme.outlineStyle == config.theme.defaultOutlineStyle {
$0.borderStyle = .roundedRect

Check warning on line 63 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L63

Added line #L63 was not covered by tests
} else {
$0.layer.cornerRadius = config.theme.outlineStyle.cornerRadius
$0.layer.borderWidth = config.theme.outlineStyle.outlineWidth
$0.layer.borderColor = config.theme.outlineStyle.outlineColor.cgColor

Check warning on line 67 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L65-L67

Added lines #L65 - L67 were not covered by tests
}
}

Check warning on line 70 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L70

Added line #L70 was not covered by tests
[fullNameTextField, emailTextField, messageTextView].forEach {
$0.backgroundColor = config.theme.inputBackground

Check warning on line 72 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L72

Added line #L72 was not covered by tests
}

Check warning on line 74 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L74

Added line #L74 was not covered by tests
[fullNameLabel, emailLabel, messageLabel].forEach {
$0.font = config.theme.headingFont
$0.font = config.theme.titleFont
$0.adjustsFontForContentSizeCategory = true

Check warning on line 77 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L76-L77

Added lines #L76 - L77 were not covered by tests
}

Check warning on line 79 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L79

Added line #L79 was not covered by tests
[submitButton, addScreenshotButton, removeScreenshotButton, cancelButton].forEach {
$0.titleLabel?.font = config.theme.headingFont
$0.titleLabel?.font = config.theme.titleFont
$0.titleLabel?.adjustsFontForContentSizeCategory = true

Check warning on line 82 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L81-L82

Added lines #L81 - L82 were not covered by tests
}

Check warning on line 84 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L84

Added line #L84 was not covered by tests
[submitButton, addScreenshotButton, removeScreenshotButton, cancelButton, messageTextView].forEach {
$0.layer.cornerRadius = config.theme.outlineStyle.cornerRadius
$0.layer.borderWidth = config.theme.outlineStyle.outlineWidth
$0.layer.borderColor = config.theme.outlineStyle.outlineColor.cgColor

Check warning on line 88 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L86-L88

Added lines #L86 - L88 were not covered by tests
}

Check warning on line 90 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L90

Added line #L90 was not covered by tests
[addScreenshotButton, removeScreenshotButton, cancelButton].forEach {
$0.backgroundColor = config.theme.buttonBackground
$0.setTitleColor(config.theme.buttonForeground, for: .normal)

Check warning on line 93 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L92-L93

Added lines #L92 - L93 were not covered by tests
}
}

Check warning on line 95 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L95

Added line #L95 was not covered by tests

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Check warning on line 99 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L99

Added line #L99 was not covered by tests

// MARK: Actions

func addScreenshotButtonTapped() {

}

Check warning on line 105 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L104-L105

Added lines #L104 - L105 were not covered by tests

func removeScreenshotButtonTapped() {

}

Check warning on line 109 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L108-L109

Added lines #L108 - L109 were not covered by tests

func submitFeedbackButtonTapped() {
// TODO: validate and package entries
delegate?.confirmed()
}

Check warning on line 114 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L112-L114

Added lines #L112 - L114 were not covered by tests

func cancelButtonTapped() {
delegate?.cancelled()
}

Check warning on line 118 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L117-L118

Added lines #L117 - L118 were not covered by tests

// MARK: UI
// MARK: Layout

let formElementHeight: CGFloat = 40
let logoWidth: CGFloat = 47
lazy var messageTextViewHeightConstraint = messageTextView.heightAnchor.constraint(equalToConstant: config.theme.font.lineHeight * 5)
lazy var logoViewWidthConstraint = sentryLogoView.widthAnchor.constraint(equalToConstant: logoWidth * config.scaleFactor)
lazy var messagePlaceholderLeadingConstraint = messageTextViewPlaceholder.leadingAnchor.constraint(equalTo: messageTextView.leadingAnchor, constant: messageTextView.textContainerInset.left + 5)
lazy var messagePlaceholderTopConstraint = messageTextViewPlaceholder.topAnchor.constraint(equalTo: messageTextView.topAnchor, constant: messageTextView.textContainerInset.top)
lazy var fullNameTextFieldHeightConstraint = fullNameTextField.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var emailTextFieldHeightConstraint = emailTextField.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var addScreenshotButtonHeightConstraint = addScreenshotButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var removeScreenshotButtonHeightConstraint = removeScreenshotButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var submitButtonHeightConstraint = submitButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)
lazy var cancelButtonHeightConstraint = cancelButton.heightAnchor.constraint(equalToConstant: formElementHeight * config.scaleFactor)

func updateLayout() {
let verticalPadding: CGFloat = 8
messageTextView.textContainerInset = .init(top: verticalPadding * config.scaleFactor, left: 2 * config.scaleFactor, bottom: verticalPadding * config.scaleFactor, right: 2 * config.scaleFactor)

messageTextViewHeightConstraint.constant = config.theme.font.lineHeight * 5
logoViewWidthConstraint.constant = logoWidth * config.scaleFactor
messagePlaceholderLeadingConstraint.constant = messageTextView.textContainerInset.left + 5
messagePlaceholderTopConstraint.constant = messageTextView.textContainerInset.top
fullNameTextFieldHeightConstraint.constant = formElementHeight * config.scaleFactor
emailTextFieldHeightConstraint.constant = formElementHeight * config.scaleFactor
addScreenshotButtonHeightConstraint.constant = formElementHeight * config.scaleFactor
removeScreenshotButtonHeightConstraint.constant = formElementHeight * config.scaleFactor
submitButtonHeightConstraint.constant = formElementHeight * config.scaleFactor
cancelButtonHeightConstraint.constant = formElementHeight * config.scaleFactor


}

Check warning on line 149 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L136-L149

Added lines #L136 - L149 were not covered by tests

// MARK: UI Elements

lazy var formTitleLabel = {
let label = UILabel(frame: .zero)
label.text = config.formConfig.formTitle
label.font = config.theme.titleFont
label.font = config.theme.headerFont
label.setContentCompressionResistancePriority(.required, for: .horizontal)
label.adjustsFontForContentSizeCategory = true
return label

Check warning on line 159 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L154-L159

Added lines #L154 - L159 were not covered by tests
}()

lazy var sentryLogoView = {
let shapeLayer = CAShapeLayer()
shapeLayer.path = SentryIconography.logo
shapeLayer.fillColor = self.config.theme.foreground.cgColor

let view = UIView(frame: .zero)
view.layer.addSublayer(shapeLayer)
view.accessibilityLabel = "provided by Sentry" // ???: what do we want to say here?
return view

Check warning on line 170 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L163-L170

Added lines #L163 - L170 were not covered by tests
}()

lazy var fullNameLabel = {
let label = UILabel(frame: .zero)
label.text = config.formConfig.nameLabelContents
return label

Check warning on line 176 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L174-L176

Added lines #L174 - L176 were not covered by tests
}()

lazy var fullNameTextField = {
let field = UITextField(frame: .zero)
field.placeholder = config.formConfig.namePlaceholder
field.accessibilityLabel = config.formConfig.nameTextFieldAccessibilityLabel
return field

Check warning on line 183 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L180-L183

Added lines #L180 - L183 were not covered by tests
}()

lazy var emailLabel = {
let label = UILabel(frame: .zero)
label.text = config.formConfig.emailLabelContents
return label

Check warning on line 189 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L187-L189

Added lines #L187 - L189 were not covered by tests
}()

lazy var emailTextField = {
let field = UITextField(frame: .zero)
field.placeholder = config.formConfig.emailPlaceholder
field.accessibilityLabel = config.formConfig.emailTextFieldAccessibilityLabel
return field

Check warning on line 196 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L193-L196

Added lines #L193 - L196 were not covered by tests
}()

lazy var messageLabel = {
let label = UILabel(frame: .zero)
label.text = config.formConfig.messageLabelContents
return label

Check warning on line 202 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L200-L202

Added lines #L200 - L202 were not covered by tests
}()

lazy var messageTextViewPlaceholder = {
let label = UILabel(frame: .zero)
label.text = config.formConfig.messagePlaceholder
label.font = config.theme.font
label.textColor = .placeholderText
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontForContentSizeCategory = true
return label

Check warning on line 212 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L206-L212

Added lines #L206 - L212 were not covered by tests
}()

lazy var messageTextView = {
let textView = UITextView(frame: .zero)
textView.font = config.theme.font
textView.adjustsFontForContentSizeCategory = true
textView.accessibilityLabel = config.formConfig.messageTextViewAccessibilityLabel
textView.delegate = self
return textView

Check warning on line 221 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L216-L221

Added lines #L216 - L221 were not covered by tests
}()

lazy var addScreenshotButton = {
let button = UIButton(frame: .zero)
button.setTitle(config.formConfig.addScreenshotButtonLabel, for: .normal)
button.accessibilityLabel = config.formConfig.addScreenshotButtonAccessibilityLabel
button.addTarget(self, action: #selector(addScreenshotButtonTapped), for: .touchUpInside)
return button

Check warning on line 229 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L225-L229

Added lines #L225 - L229 were not covered by tests
}()

lazy var removeScreenshotButton = {
let button = UIButton(frame: .zero)
button.setTitle(config.formConfig.removeScreenshotButtonLabel, for: .normal)
button.accessibilityLabel = config.formConfig.removeScreenshotButtonAccessibilityLabel
button.addTarget(self, action: #selector(removeScreenshotButtonTapped), for: .touchUpInside)
return button

Check warning on line 237 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L233-L237

Added lines #L233 - L237 were not covered by tests
}()

lazy var submitButton = {
let button = UIButton(frame: .zero)
button.setTitle(config.formConfig.submitButtonLabel, for: .normal)
button.accessibilityLabel = config.formConfig.submitButtonAccessibilityLabel
button.backgroundColor = config.theme.submitBackground
button.setTitleColor(config.theme.submitForeground, for: .normal)
button.addTarget(self, action: #selector(submitFeedbackButtonTapped), for: .touchUpInside)
return button

Check warning on line 247 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L241-L247

Added lines #L241 - L247 were not covered by tests
}()

lazy var cancelButton = {
let button = UIButton(frame: .zero)
button.setTitle(config.formConfig.cancelButtonLabel, for: .normal)
button.accessibilityLabel = config.formConfig.cancelButtonAccessibilityLabel
button.addTarget(self, action: #selector(cancelButtonTapped), for: .touchUpInside)
return button

Check warning on line 255 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L251-L255

Added lines #L251 - L255 were not covered by tests
}()

lazy var stack = {
let headerStack = UIStackView(arrangedSubviews: [self.formTitleLabel])

Check warning on line 259 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L259

Added line #L259 was not covered by tests
if self.config.formConfig.showBranding {
headerStack.addArrangedSubview(self.sentryLogoView)

Check warning on line 261 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L261

Added line #L261 was not covered by tests
}

let stack = UIStackView()
stack.axis = .vertical
stack.spacing = 50

stack.addArrangedSubview(headerStack)

let inputStack = UIStackView()
inputStack.axis = .vertical
inputStack.spacing = config.theme.font.xHeight

Check warning on line 273 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L263-L273

Added lines #L263 - L273 were not covered by tests
if self.config.formConfig.showName {
inputStack.addArrangedSubview(self.fullNameLabel)
inputStack.addArrangedSubview(self.fullNameTextField)

Check warning on line 276 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L275-L276

Added lines #L275 - L276 were not covered by tests
}

Check warning on line 278 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L278

Added line #L278 was not covered by tests
if self.config.formConfig.showEmail {
inputStack.addArrangedSubview(self.emailLabel)
inputStack.addArrangedSubview(self.emailTextField)

Check warning on line 281 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L280-L281

Added lines #L280 - L281 were not covered by tests
}

inputStack.addArrangedSubview(self.messageLabel)

let messageAndScreenshotStack = UIStackView(arrangedSubviews: [self.messageTextView])
messageAndScreenshotStack.axis = .vertical

Check warning on line 288 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L283-L288

Added lines #L283 - L288 were not covered by tests
if self.config.formConfig.enableScreenshot {
messageAndScreenshotStack.addArrangedSubview(self.addScreenshotButton)

Check warning on line 290 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L290

Added line #L290 was not covered by tests
}
messageAndScreenshotStack.spacing = config.theme.font.lineHeight - config.theme.font.xHeight

inputStack.addArrangedSubview(messageAndScreenshotStack)

stack.addArrangedSubview(inputStack)

let controlsStack = UIStackView()
controlsStack.axis = .vertical
controlsStack.spacing = config.theme.font.lineHeight - config.theme.font.xHeight
controlsStack.addArrangedSubview(self.submitButton)
controlsStack.addArrangedSubview(self.cancelButton)
stack.addArrangedSubview(controlsStack)

stack.translatesAutoresizingMaskIntoConstraints = false

Check warning on line 306 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L292-L306

Added lines #L292 - L306 were not covered by tests
return stack
}()

Check warning on line 308 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L308

Added line #L308 was not covered by tests

lazy var scrollView = {
let scrollView = UIScrollView(frame: view.bounds)
view.addSubview(scrollView)
scrollView.addSubview(stack)
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(messageTextViewPlaceholder)
return scrollView

Check warning on line 316 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L311-L316

Added lines #L311 - L316 were not covered by tests
}()
}

// MARK: UITextViewDelegate
@available(iOS 13.0, *)
extension SentryUserFeedbackForm: UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
messageTextViewPlaceholder.isHidden = textView.text != ""
}

Check warning on line 325 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackForm.swift#L324-L325

Added lines #L324 - L325 were not covered by tests
}

#endif // os(iOS) && !SENTRY_NO_UIKIT
Loading