Locked indicator

This commit is contained in:
Justin Mazzocchi 2020-11-10 16:53:31 -08:00
parent 67e1a59ffd
commit b302388a9b
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
2 changed files with 19 additions and 1 deletions

View file

@ -34,6 +34,8 @@ public extension AccountViewModel {
var accountName: String { "@".appending(accountService.account.acct) }
var isLocked: Bool { accountService.account.locked }
var fields: [Account.Field] { accountService.account.fields }
var note: NSAttributedString { accountService.account.note.attributed }

View file

@ -10,7 +10,9 @@ final class AccountHeaderView: UIView {
let avatarImageView = UIImageView()
let avatarButton = UIButton()
let displayNameLabel = UILabel()
let accountStackView = UIStackView()
let accountLabel = UILabel()
let lockedImageView = UIImageView()
let fieldsStackView = UIStackView()
let noteTextView = TouchFallthroughTextView()
let segmentedControl = UISegmentedControl()
@ -34,6 +36,7 @@ final class AccountHeaderView: UIView {
}
accountLabel.text = accountViewModel.accountName
lockedImageView.isHidden = !accountViewModel.isLocked
for view in fieldsStackView.arrangedSubviews {
fieldsStackView.removeArrangedSubview(view)
@ -141,11 +144,24 @@ private extension AccountHeaderView {
displayNameLabel.font = .preferredFont(forTextStyle: .headline)
displayNameLabel.adjustsFontForContentSizeCategory = true
baseStackView.addArrangedSubview(accountLabel)
baseStackView.addArrangedSubview(accountStackView)
accountStackView.addArrangedSubview(accountLabel)
accountLabel.numberOfLines = 0
accountLabel.font = .preferredFont(forTextStyle: .subheadline)
accountLabel.adjustsFontForContentSizeCategory = true
accountLabel.textColor = .secondaryLabel
accountLabel.setContentHuggingPriority(.required, for: .horizontal)
accountLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
accountStackView.addArrangedSubview(lockedImageView)
lockedImageView.image = UIImage(
systemName: "lock.fill",
withConfiguration: UIImage.SymbolConfiguration(scale: .small))
lockedImageView.tintColor = .secondaryLabel
lockedImageView.contentMode = .scaleAspectFit
accountStackView.addArrangedSubview(UIView())
baseStackView.addArrangedSubview(fieldsStackView)
fieldsStackView.axis = .vertical