mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
UI adjustments
This commit is contained in:
parent
8086b0974b
commit
0f9ab62415
3 changed files with 11 additions and 15 deletions
|
@ -25,6 +25,12 @@ final class CapsuleButton: UIButton {
|
||||||
backgroundColor = isHighlighted ? Self.highlightedColor : .link
|
backgroundColor = isHighlighted ? Self.highlightedColor : .link
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
backgroundColor = isEnabled ? .link : UIColor.link.withAlphaComponent(0.5)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension CapsuleButton {
|
private extension CapsuleButton {
|
||||||
|
@ -45,5 +51,6 @@ private extension CapsuleButton {
|
||||||
titleLabel?.font = .preferredFont(forTextStyle: .headline)
|
titleLabel?.font = .preferredFont(forTextStyle: .headline)
|
||||||
setTitleColor(.white, for: .normal)
|
setTitleColor(.white, for: .normal)
|
||||||
setTitleColor(.lightText, for: .highlighted)
|
setTitleColor(.lightText, for: .highlighted)
|
||||||
|
setTitleColor(.lightText, for: .disabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,8 @@ import ViewModels
|
||||||
|
|
||||||
final class PollView: UIView {
|
final class PollView: UIView {
|
||||||
private let stackView = UIStackView()
|
private let stackView = UIStackView()
|
||||||
private let voteButtonStackView = UIStackView()
|
|
||||||
private let bottomStackView = UIStackView()
|
private let bottomStackView = UIStackView()
|
||||||
private let voteButton = UIButton(type: .system)
|
private let voteButton = CapsuleButton()
|
||||||
private let refreshButton = UIButton(type: .system)
|
private let refreshButton = UIButton(type: .system)
|
||||||
private let refreshDividerLabel = UILabel()
|
private let refreshDividerLabel = UILabel()
|
||||||
private let votesCountLabel = UILabel()
|
private let votesCountLabel = UILabel()
|
||||||
|
@ -65,7 +64,7 @@ final class PollView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viewModel.isPollExpired, !viewModel.hasVotedInPoll {
|
if !viewModel.isPollExpired, !viewModel.hasVotedInPoll {
|
||||||
stackView.addArrangedSubview(voteButtonStackView)
|
stackView.addArrangedSubview(voteButton)
|
||||||
|
|
||||||
selectionCancellable = viewModel.$pollOptionSelections.sink { [weak self] in
|
selectionCancellable = viewModel.$pollOptionSelections.sink { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
@ -147,11 +146,6 @@ private extension PollView {
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.spacing = .defaultSpacing
|
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.setTitle(NSLocalizedString("status.poll.vote", comment: ""), for: .normal)
|
||||||
voteButton.addAction(UIAction { [weak self] _ in self?.viewModel?.vote() }, for: .touchUpInside)
|
voteButton.addAction(UIAction { [weak self] _ in self?.viewModel?.vote() }, for: .touchUpInside)
|
||||||
|
|
||||||
|
@ -175,19 +169,16 @@ private extension PollView {
|
||||||
|
|
||||||
bottomStackView.addArrangedSubview(UIView())
|
bottomStackView.addArrangedSubview(UIView())
|
||||||
|
|
||||||
let voteButtonHeightConstraint = voteButton.heightAnchor.constraint(equalToConstant: .minimumButtonDimension)
|
|
||||||
let refreshButtonHeightConstraint = refreshButton.heightAnchor.constraint(
|
let refreshButtonHeightConstraint = refreshButton.heightAnchor.constraint(
|
||||||
equalToConstant: .minimumButtonDimension / 2)
|
equalToConstant: .minimumButtonDimension / 2)
|
||||||
|
|
||||||
refreshButtonHeightConstraint.priority = .justBelowMax
|
refreshButtonHeightConstraint.priority = .justBelowMax
|
||||||
refreshButtonHeightConstraint.priority = .justBelowMax
|
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||||
stackView.topAnchor.constraint(equalTo: topAnchor),
|
stackView.topAnchor.constraint(equalTo: topAnchor),
|
||||||
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||||
voteButtonHeightConstraint,
|
|
||||||
refreshButtonHeightConstraint
|
refreshButtonHeightConstraint
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ViewModels
|
||||||
|
|
||||||
final class StatusBodyView: UIView {
|
final class StatusBodyView: UIView {
|
||||||
let spoilerTextLabel = UILabel()
|
let spoilerTextLabel = UILabel()
|
||||||
let toggleShowContentButton = UIButton(type: .system)
|
let toggleShowContentButton = CapsuleButton()
|
||||||
let contentTextView = TouchFallthroughTextView()
|
let contentTextView = TouchFallthroughTextView()
|
||||||
let attachmentsView = AttachmentsView()
|
let attachmentsView = AttachmentsView()
|
||||||
let pollView = PollView()
|
let pollView = PollView()
|
||||||
|
@ -152,14 +152,12 @@ private extension StatusBodyView {
|
||||||
addSubview(stackView)
|
addSubview(stackView)
|
||||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.spacing = .compactSpacing
|
stackView.spacing = .defaultSpacing
|
||||||
|
|
||||||
spoilerTextLabel.numberOfLines = 0
|
spoilerTextLabel.numberOfLines = 0
|
||||||
spoilerTextLabel.adjustsFontForContentSizeCategory = true
|
spoilerTextLabel.adjustsFontForContentSizeCategory = true
|
||||||
stackView.addArrangedSubview(spoilerTextLabel)
|
stackView.addArrangedSubview(spoilerTextLabel)
|
||||||
|
|
||||||
toggleShowContentButton.titleLabel?.font = .preferredFont(forTextStyle: .headline)
|
|
||||||
toggleShowContentButton.titleLabel?.adjustsFontForContentSizeCategory = true
|
|
||||||
toggleShowContentButton.addAction(
|
toggleShowContentButton.addAction(
|
||||||
UIAction { [weak self] _ in self?.viewModel?.toggleShowContent() },
|
UIAction { [weak self] _ in self?.viewModel?.toggleShowContent() },
|
||||||
for: .touchUpInside)
|
for: .touchUpInside)
|
||||||
|
|
Loading…
Reference in a new issue