mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 08:10:59 +00:00
Account name button
This commit is contained in:
parent
c0ca3f3ad3
commit
e07e7829eb
1 changed files with 38 additions and 2 deletions
|
@ -15,6 +15,7 @@ final class StatusView: UIView {
|
||||||
let rebloggerButton = UIButton()
|
let rebloggerButton = UIButton()
|
||||||
let displayNameLabel = UILabel()
|
let displayNameLabel = UILabel()
|
||||||
let accountLabel = UILabel()
|
let accountLabel = UILabel()
|
||||||
|
let nameButton = UIButton()
|
||||||
let timeLabel = UILabel()
|
let timeLabel = UILabel()
|
||||||
let bodyView = StatusBodyView()
|
let bodyView = StatusBodyView()
|
||||||
let contextParentTimeLabel = UILabel()
|
let contextParentTimeLabel = UILabel()
|
||||||
|
@ -176,19 +177,45 @@ private extension StatusView {
|
||||||
accountLabel.font = .preferredFont(forTextStyle: .subheadline)
|
accountLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||||
accountLabel.adjustsFontForContentSizeCategory = true
|
accountLabel.adjustsFontForContentSizeCategory = true
|
||||||
accountLabel.textColor = .secondaryLabel
|
accountLabel.textColor = .secondaryLabel
|
||||||
|
accountLabel.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
nameAccountTimeStackView.addArrangedSubview(accountLabel)
|
nameAccountTimeStackView.addArrangedSubview(accountLabel)
|
||||||
|
|
||||||
timeLabel.font = .preferredFont(forTextStyle: .subheadline)
|
timeLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||||
timeLabel.adjustsFontForContentSizeCategory = true
|
timeLabel.adjustsFontForContentSizeCategory = true
|
||||||
timeLabel.textColor = .secondaryLabel
|
timeLabel.textColor = .secondaryLabel
|
||||||
|
timeLabel.textAlignment = .right
|
||||||
timeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
timeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
timeLabel.setContentHuggingPriority(.required, for: .horizontal)
|
|
||||||
nameAccountTimeStackView.addArrangedSubview(timeLabel)
|
nameAccountTimeStackView.addArrangedSubview(timeLabel)
|
||||||
|
|
||||||
nameAccountContainerStackView.spacing = .defaultSpacing
|
nameAccountContainerStackView.spacing = .defaultSpacing
|
||||||
nameAccountContainerStackView.addArrangedSubview(nameAccountTimeStackView)
|
nameAccountContainerStackView.addArrangedSubview(nameAccountTimeStackView)
|
||||||
mainStackView.addArrangedSubview(nameAccountContainerStackView)
|
mainStackView.addArrangedSubview(nameAccountContainerStackView)
|
||||||
|
|
||||||
|
nameButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
nameButton.addAction(
|
||||||
|
UIAction { [weak self] _ in
|
||||||
|
self?.displayNameLabel.alpha = 1
|
||||||
|
self?.accountLabel.alpha = 1
|
||||||
|
self?.statusConfiguration.viewModel.accountSelected()
|
||||||
|
},
|
||||||
|
for: .touchUpInside)
|
||||||
|
nameButton.addAction(
|
||||||
|
UIAction { [weak self] _ in
|
||||||
|
self?.displayNameLabel.alpha = 0.5
|
||||||
|
self?.accountLabel.alpha = 0.5
|
||||||
|
},
|
||||||
|
for: .touchDown)
|
||||||
|
|
||||||
|
let unhighlightAction = UIAction { [weak self] _ in
|
||||||
|
self?.displayNameLabel.alpha = 1
|
||||||
|
self?.accountLabel.alpha = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
nameButton.addAction(unhighlightAction, for: .touchUpOutside)
|
||||||
|
nameButton.addAction(unhighlightAction, for: .touchCancel)
|
||||||
|
nameButton.addAction(unhighlightAction, for: .touchDragOutside)
|
||||||
|
nameAccountContainerStackView.addSubview(nameButton)
|
||||||
|
|
||||||
mainStackView.addArrangedSubview(bodyView)
|
mainStackView.addArrangedSubview(bodyView)
|
||||||
|
|
||||||
contextParentTimeLabel.font = .preferredFont(forTextStyle: .footnote)
|
contextParentTimeLabel.font = .preferredFont(forTextStyle: .footnote)
|
||||||
|
@ -339,6 +366,10 @@ private extension StatusView {
|
||||||
avatarButton.topAnchor.constraint(equalTo: avatarImageView.topAnchor),
|
avatarButton.topAnchor.constraint(equalTo: avatarImageView.topAnchor),
|
||||||
avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
|
avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
|
||||||
avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor),
|
avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor),
|
||||||
|
nameButton.leadingAnchor.constraint(equalTo: displayNameLabel.leadingAnchor),
|
||||||
|
nameButton.topAnchor.constraint(equalTo: displayNameLabel.topAnchor),
|
||||||
|
nameButton.trailingAnchor.constraint(equalTo: accountLabel.trailingAnchor),
|
||||||
|
nameButton.bottomAnchor.constraint(equalTo: accountLabel.bottomAnchor),
|
||||||
contextParentTimeApplicationStackView.heightAnchor.constraint(
|
contextParentTimeApplicationStackView.heightAnchor.constraint(
|
||||||
greaterThanOrEqualToConstant: .minimumButtonDimension / 2),
|
greaterThanOrEqualToConstant: .minimumButtonDimension / 2),
|
||||||
interactionsStackView.heightAnchor.constraint(greaterThanOrEqualToConstant: .minimumButtonDimension)
|
interactionsStackView.heightAnchor.constraint(greaterThanOrEqualToConstant: .minimumButtonDimension)
|
||||||
|
@ -441,6 +472,12 @@ private extension StatusView {
|
||||||
mutableDisplayName.insert(emojis: viewModel.accountViewModel.emojis, view: displayNameLabel)
|
mutableDisplayName.insert(emojis: viewModel.accountViewModel.emojis, view: displayNameLabel)
|
||||||
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
|
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
|
||||||
displayNameLabel.attributedText = mutableDisplayName
|
displayNameLabel.attributedText = mutableDisplayName
|
||||||
|
accountLabel.text = viewModel.accountName
|
||||||
|
|
||||||
|
let nameButtonAccessibilityAttributedLabel = mutableDisplayName
|
||||||
|
|
||||||
|
nameButtonAccessibilityAttributedLabel.appendWithSeparator(viewModel.accountName)
|
||||||
|
nameButton.accessibilityAttributedLabel = nameButtonAccessibilityAttributedLabel
|
||||||
|
|
||||||
nameAccountTimeStackView.axis = isContextParent ? .vertical : .horizontal
|
nameAccountTimeStackView.axis = isContextParent ? .vertical : .horizontal
|
||||||
nameAccountTimeStackView.alignment = isContextParent ? .leading : .fill
|
nameAccountTimeStackView.alignment = isContextParent ? .leading : .fill
|
||||||
|
@ -456,7 +493,6 @@ private extension StatusView {
|
||||||
.constraint(equalTo: contextParentBottomNameAccountSpacingView.heightAnchor).isActive = true
|
.constraint(equalTo: contextParentBottomNameAccountSpacingView.heightAnchor).isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
accountLabel.text = viewModel.accountName
|
|
||||||
timeLabel.text = viewModel.time
|
timeLabel.text = viewModel.time
|
||||||
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
||||||
timeLabel.isHidden = isContextParent
|
timeLabel.isHidden = isContextParent
|
||||||
|
|
Loading…
Reference in a new issue