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

[NT-1188] Convert UILabels in Beta Tools to UITextViews #1171

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
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
50 changes: 31 additions & 19 deletions Kickstarter-iOS/Views/BetaToolsFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ protocol BetaToolsFooterViewDelegate: AnyObject {
final class BetaToolsFooterView: UIView {
// MARK: - Properties

private let appVersionDetailLabel: UILabel = { UILabel(frame: .zero) }()
private let appVersionDetailTextView: UITextView = { UITextView(frame: .zero) }()
private let appVersionStackView: UIStackView = { UIStackView(frame: .zero) }()
private let appVersionTitleLabel: UILabel = { UILabel(frame: .zero) }()
private let betaFeedbackButton = UIButton(type: .custom)
private let deviceIdentifierDetailLabel: UILabel = { UILabel(frame: .zero) }()
private let deviceIdentifierDetailTextView: UITextView = { UITextView(frame: .zero) }()
private let deviceIdentifierStackView: UIStackView = { UIStackView(frame: .zero) }()
private let deviceIdentifierTitleLabel: UILabel = { UILabel(frame: .zero) }()
private let rootStackView: UIStackView = { UIStackView(frame: .zero) }()
Expand Down Expand Up @@ -44,10 +44,13 @@ final class BetaToolsFooterView: UIView {
|> ksr_addSubviewToParent()
|> ksr_constrainViewToMarginsInParent()

_ = ([self.appVersionTitleLabel, self.appVersionDetailLabel], self.appVersionStackView)
_ = ([self.appVersionTitleLabel, self.appVersionDetailTextView], self.appVersionStackView)
|> ksr_addArrangedSubviewsToStackView()

_ = ([self.deviceIdentifierTitleLabel, self.deviceIdentifierDetailLabel], self.deviceIdentifierStackView)
_ = (
[self.deviceIdentifierTitleLabel, self.deviceIdentifierDetailTextView],
self.deviceIdentifierStackView
)
|> ksr_addArrangedSubviewsToStackView()

_ = (
Expand All @@ -70,8 +73,8 @@ final class BetaToolsFooterView: UIView {
override func bindStyles() {
super.bindStyles()

_ = self.appVersionDetailLabel
|> appVersionDetailLabelStyle
_ = self.appVersionDetailTextView
|> appVersionDetailTextViewStyle

_ = self.appVersionStackView
|> appVersionStackViewStyle
Expand All @@ -82,8 +85,8 @@ final class BetaToolsFooterView: UIView {
_ = self.betaFeedbackButton
|> betaFeedbackButtonStyle

_ = self.deviceIdentifierDetailLabel
|> deviceIdentifierDetailLabelStyle
_ = self.deviceIdentifierDetailTextView
|> deviceIdentifierDetailTextViewStyle

_ = self.deviceIdentifierStackView
|> deviceIdentifierStackViewStyle
Expand All @@ -104,9 +107,9 @@ final class BetaToolsFooterView: UIView {

// MARK: - Styles

private let appVersionDetailLabelStyle: LabelStyle = { label in
label
|> baseDetailLabelStyle
private let appVersionDetailTextViewStyle: TextViewStyle = { textView in
textView
|> baseTextViewStyle
|> \.text .~ AppEnvironment.current.mainBundle.appVersionString
}

Expand All @@ -127,11 +130,12 @@ private let betaFeedbackButtonStyle: ButtonStyle = { button in
|> UIButton.lens.title(for: .normal) .~ "Submit feedback for beta"
}

private let deviceIdentifierDetailLabelStyle: LabelStyle = { label in
label
|> baseDetailLabelStyle
|> \.minimumScaleFactor .~ 0.5
private let deviceIdentifierDetailTextViewStyle: TextViewStyle = { textView in
_ = textView
|> baseTextViewStyle
|> \.text .~ AppEnvironment.current.device.identifierForVendor?.uuidString

return textView
}

private let deviceIdentifierStackViewStyle: StackViewStyle = { stackView in
Expand All @@ -151,12 +155,20 @@ private let rootStackViewStyle: StackViewStyle = { stackView in
|> \.spacing .~ Styles.grid(2)
}

private let baseDetailLabelStyle: LabelStyle = { label in
label
private let baseTextViewStyle: TextViewStyle = { textView in
_ = textView
|> \.font .~ .ksr_headline(size: 15)
|> \.textColor .~ .ksr_text_dark_grey_500
|> \.lineBreakMode .~ .byWordWrapping
|> \.textAlignment .~ .left
|> \.isScrollEnabled .~ false

_ = textView
|> \.textContainerInset .~ UIEdgeInsets.zero
|> \.textContainer.lineFragmentPadding .~ 0
|> \.isEditable .~ false
|> \.isUserInteractionEnabled .~ true
|> \.adjustsFontForContentSizeCategory .~ true

return textView
}

private let baseTitleLabelStyle: LabelStyle = { label in
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.