Skip to content

Commit

Permalink
Merge branch 'fix-swiftlint-warnings-in-xcode-ios-ProblemReportViewCo…
Browse files Browse the repository at this point in the history
…ntroller-296'
  • Loading branch information
buggmagnet committed Sep 13, 2023
2 parents 92bd76e + 3c29c35 commit c0ee7f5
Showing 1 changed file with 46 additions and 90 deletions.
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

0 comments on commit c0ee7f5

Please sign in to comment.