UI adjustments

This commit is contained in:
Justin Mazzocchi 2021-01-30 22:47:49 -08:00
parent 8086b0974b
commit 0f9ab62415
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
3 changed files with 11 additions and 15 deletions

View file

@ -25,6 +25,12 @@ final class CapsuleButton: UIButton {
backgroundColor = isHighlighted ? Self.highlightedColor : .link
}
}
override var isEnabled: Bool {
didSet {
backgroundColor = isEnabled ? .link : UIColor.link.withAlphaComponent(0.5)
}
}
}
private extension CapsuleButton {
@ -45,5 +51,6 @@ private extension CapsuleButton {
titleLabel?.font = .preferredFont(forTextStyle: .headline)
setTitleColor(.white, for: .normal)
setTitleColor(.lightText, for: .highlighted)
setTitleColor(.lightText, for: .disabled)
}
}

View file

@ -7,9 +7,8 @@ import ViewModels
final class PollView: UIView {
private let stackView = UIStackView()
private let voteButtonStackView = UIStackView()
private let bottomStackView = UIStackView()
private let voteButton = UIButton(type: .system)
private let voteButton = CapsuleButton()
private let refreshButton = UIButton(type: .system)
private let refreshDividerLabel = UILabel()
private let votesCountLabel = UILabel()
@ -65,7 +64,7 @@ final class PollView: UIView {
}
if !viewModel.isPollExpired, !viewModel.hasVotedInPoll {
stackView.addArrangedSubview(voteButtonStackView)
stackView.addArrangedSubview(voteButton)
selectionCancellable = viewModel.$pollOptionSelections.sink { [weak self] in
guard let self = self else { return }
@ -147,11 +146,6 @@ private extension PollView {
stackView.axis = .vertical
stackView.spacing = .defaultSpacing
voteButtonStackView.addArrangedSubview(voteButton)
voteButtonStackView.addArrangedSubview(UIView())
voteButton.titleLabel?.font = .preferredFont(forTextStyle: .headline)
voteButton.titleLabel?.adjustsFontForContentSizeCategory = true
voteButton.setTitle(NSLocalizedString("status.poll.vote", comment: ""), for: .normal)
voteButton.addAction(UIAction { [weak self] _ in self?.viewModel?.vote() }, for: .touchUpInside)
@ -175,19 +169,16 @@ private extension PollView {
bottomStackView.addArrangedSubview(UIView())
let voteButtonHeightConstraint = voteButton.heightAnchor.constraint(equalToConstant: .minimumButtonDimension)
let refreshButtonHeightConstraint = refreshButton.heightAnchor.constraint(
equalToConstant: .minimumButtonDimension / 2)
refreshButtonHeightConstraint.priority = .justBelowMax
refreshButtonHeightConstraint.priority = .justBelowMax
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
voteButtonHeightConstraint,
refreshButtonHeightConstraint
])
}

View file

@ -6,7 +6,7 @@ import ViewModels
final class StatusBodyView: UIView {
let spoilerTextLabel = UILabel()
let toggleShowContentButton = UIButton(type: .system)
let toggleShowContentButton = CapsuleButton()
let contentTextView = TouchFallthroughTextView()
let attachmentsView = AttachmentsView()
let pollView = PollView()
@ -152,14 +152,12 @@ private extension StatusBodyView {
addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = .compactSpacing
stackView.spacing = .defaultSpacing
spoilerTextLabel.numberOfLines = 0
spoilerTextLabel.adjustsFontForContentSizeCategory = true
stackView.addArrangedSubview(spoilerTextLabel)
toggleShowContentButton.titleLabel?.font = .preferredFont(forTextStyle: .headline)
toggleShowContentButton.titleLabel?.adjustsFontForContentSizeCategory = true
toggleShowContentButton.addAction(
UIAction { [weak self] _ in self?.viewModel?.toggleShowContent() },
for: .touchUpInside)