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

Fix Swiftlint warnings in ProblemReportViewController #5106

Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,8 @@ final class ProblemReportViewController: UIViewController, UITextFieldDelegate {
messageTextView.setContentHuggingPriority(.defaultLow, for: .vertical)
messageTextView.setContentCompressionResistancePriority(.defaultLow, for: .vertical)

textFieldsHolder.addSubview(emailTextField)
textFieldsHolder.addSubview(messagePlaceholder)
textFieldsHolder.addSubview(messageTextView)

view.addSubview(scrollView)
scrollView.addSubview(containerView)
containerView.addSubview(subheaderLabel)
containerView.addSubview(textFieldsHolder)
containerView.addSubview(buttonsStackView)

addConstraints()
registerForNotifications()

loadPersistentViewModel()
}

Expand Down Expand Up @@ -345,88 +334,55 @@ final class ProblemReportViewController: UIViewController, UITextFieldDelegate {
}

private func addConstraints() {
activeMessageTextViewConstraints = [
messageTextView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
messageTextView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
messageTextView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
messageTextView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
]

inactiveMessageTextViewConstraints = [
messageTextView.topAnchor.constraint(
equalTo: emailTextField.bottomAnchor,
constant: 12
),
messageTextView.leadingAnchor.constraint(equalTo: textFieldsHolder.leadingAnchor),
messageTextView.trailingAnchor.constraint(equalTo: textFieldsHolder.trailingAnchor),
messageTextView.bottomAnchor.constraint(equalTo: textFieldsHolder.bottomAnchor),
]

var constraints = [
subheaderLabel.topAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.topAnchor),
subheaderLabel.leadingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.leadingAnchor),
subheaderLabel.trailingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.trailingAnchor),

textFieldsHolder.topAnchor.constraint(
equalTo: subheaderLabel.bottomAnchor,
constant: 24
),
textFieldsHolder.leadingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.leadingAnchor),
textFieldsHolder.trailingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.trailingAnchor),

buttonsStackView.topAnchor.constraint(
equalTo: textFieldsHolder.bottomAnchor,
constant: 18
),
buttonsStackView.leadingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.leadingAnchor),
buttonsStackView.trailingAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.trailingAnchor),
buttonsStackView.bottomAnchor
.constraint(equalTo: containerView.layoutMarginsGuide.bottomAnchor),

emailTextField.topAnchor.constraint(equalTo: textFieldsHolder.topAnchor),
emailTextField.leadingAnchor.constraint(equalTo: textFieldsHolder.leadingAnchor),
emailTextField.trailingAnchor.constraint(equalTo: textFieldsHolder.trailingAnchor),

messagePlaceholder.topAnchor.constraint(
equalTo: emailTextField.bottomAnchor,
constant: 12
),
messagePlaceholder.leadingAnchor.constraint(equalTo: textFieldsHolder.leadingAnchor),
messagePlaceholder.trailingAnchor.constraint(equalTo: textFieldsHolder.trailingAnchor),
messagePlaceholder.bottomAnchor.constraint(equalTo: textFieldsHolder.bottomAnchor),
messagePlaceholder.heightAnchor.constraint(equalTo: messageTextView.heightAnchor),

scrollView.frameLayoutGuide.topAnchor.constraint(equalTo: view.topAnchor),
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor),
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.trailingAnchor),

scrollView.contentLayoutGuide.topAnchor.constraint(equalTo: containerView.topAnchor),
scrollView.contentLayoutGuide.bottomAnchor
.constraint(equalTo: containerView.bottomAnchor),
scrollView.contentLayoutGuide.leadingAnchor
.constraint(equalTo: containerView.leadingAnchor),
scrollView.contentLayoutGuide.trailingAnchor
.constraint(equalTo: containerView.trailingAnchor),

scrollView.contentLayoutGuide.widthAnchor
.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor),
scrollView.contentLayoutGuide.heightAnchor
.constraint(greaterThanOrEqualTo: scrollView.safeAreaLayoutGuide.heightAnchor),
activeMessageTextViewConstraints =
messageTextView.pinEdges(.all().excluding(.top), to: view) +
messageTextView.pinEdges(PinnableEdges([.top(0)]), to: view.safeAreaLayoutGuide)

messageTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 150),
]
inactiveMessageTextViewConstraints =
messageTextView.pinEdges(.all().excluding(.top), to: textFieldsHolder) +
[messageTextView.topAnchor.constraint(equalTo: emailTextField.bottomAnchor, constant: 12)]

constraints.append(contentsOf: inactiveMessageTextViewConstraints)
textFieldsHolder.addSubview(emailTextField)
textFieldsHolder.addSubview(messagePlaceholder)
textFieldsHolder.addSubview(messageTextView)

scrollView.addSubview(containerView)
containerView.addSubview(subheaderLabel)
containerView.addSubview(textFieldsHolder)
containerView.addSubview(buttonsStackView)

view.addConstrainedSubviews([scrollView]) {
inactiveMessageTextViewConstraints

subheaderLabel.pinEdges(.all().excluding(.bottom), to: containerView.layoutMarginsGuide)

NSLayoutConstraint.activate(constraints)
textFieldsHolder.pinEdges(PinnableEdges([.leading(0), .trailing(0)]), to: containerView.layoutMarginsGuide)
textFieldsHolder.topAnchor.constraint(equalTo: subheaderLabel.bottomAnchor, constant: 24)

buttonsStackView.pinEdges(.all().excluding(.top), to: containerView.layoutMarginsGuide)
buttonsStackView.topAnchor.constraint(equalTo: textFieldsHolder.bottomAnchor, constant: 18)

emailTextField.pinEdges(.all().excluding(.bottom), to: textFieldsHolder)

messagePlaceholder.pinEdges(.all().excluding(.top), to: textFieldsHolder)
messagePlaceholder.topAnchor.constraint(equalTo: emailTextField.bottomAnchor, constant: 12)
messagePlaceholder.heightAnchor.constraint(equalTo: messageTextView.heightAnchor)

scrollView.frameLayoutGuide.topAnchor.constraint(equalTo: view.topAnchor)
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor)
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.leadingAnchor)
scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.trailingAnchor)

scrollView.contentLayoutGuide.topAnchor.constraint(equalTo: containerView.topAnchor)
scrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: containerView.bottomAnchor)
scrollView.contentLayoutGuide.leadingAnchor.constraint(equalTo: containerView.leadingAnchor)
scrollView.contentLayoutGuide.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor)
scrollView.contentLayoutGuide.heightAnchor
.constraint(greaterThanOrEqualTo: scrollView.safeAreaLayoutGuide.heightAnchor)

messageTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 150)
}
}

private func setDescriptionFieldExpanded(_ isExpanded: Bool) {
Expand Down
Loading