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 accountName: String { "@".appending(accountService.account.acct) }
var isLocked: Bool { accountService.account.locked }
var fields: [Account.Field] { accountService.account.fields } var fields: [Account.Field] { accountService.account.fields }
var note: NSAttributedString { accountService.account.note.attributed } var note: NSAttributedString { accountService.account.note.attributed }

View File

@ -10,7 +10,9 @@ final class AccountHeaderView: UIView {
let avatarImageView = UIImageView() let avatarImageView = UIImageView()
let avatarButton = UIButton() let avatarButton = UIButton()
let displayNameLabel = UILabel() let displayNameLabel = UILabel()
let accountStackView = UIStackView()
let accountLabel = UILabel() let accountLabel = UILabel()
let lockedImageView = UIImageView()
let fieldsStackView = UIStackView() let fieldsStackView = UIStackView()
let noteTextView = TouchFallthroughTextView() let noteTextView = TouchFallthroughTextView()
let segmentedControl = UISegmentedControl() let segmentedControl = UISegmentedControl()
@ -34,6 +36,7 @@ final class AccountHeaderView: UIView {
} }
accountLabel.text = accountViewModel.accountName accountLabel.text = accountViewModel.accountName
lockedImageView.isHidden = !accountViewModel.isLocked
for view in fieldsStackView.arrangedSubviews { for view in fieldsStackView.arrangedSubviews {
fieldsStackView.removeArrangedSubview(view) fieldsStackView.removeArrangedSubview(view)
@ -141,11 +144,24 @@ private extension AccountHeaderView {
displayNameLabel.font = .preferredFont(forTextStyle: .headline) displayNameLabel.font = .preferredFont(forTextStyle: .headline)
displayNameLabel.adjustsFontForContentSizeCategory = true displayNameLabel.adjustsFontForContentSizeCategory = true
baseStackView.addArrangedSubview(accountLabel) baseStackView.addArrangedSubview(accountStackView)
accountStackView.addArrangedSubview(accountLabel)
accountLabel.numberOfLines = 0 accountLabel.numberOfLines = 0
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)
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) baseStackView.addArrangedSubview(fieldsStackView)
fieldsStackView.axis = .vertical fieldsStackView.axis = .vertical