From b302388a9b9f45fff1d2aa17bde18eda5805e3e1 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Tue, 10 Nov 2020 16:53:31 -0800 Subject: [PATCH] Locked indicator --- .../Sources/ViewModels/AccountViewModel.swift | 2 ++ Views/AccountHeaderView.swift | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ViewModels/Sources/ViewModels/AccountViewModel.swift b/ViewModels/Sources/ViewModels/AccountViewModel.swift index dd68bf7..8c01244 100644 --- a/ViewModels/Sources/ViewModels/AccountViewModel.swift +++ b/ViewModels/Sources/ViewModels/AccountViewModel.swift @@ -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 } diff --git a/Views/AccountHeaderView.swift b/Views/AccountHeaderView.swift index eef7dda..e8cf292 100644 --- a/Views/AccountHeaderView.swift +++ b/Views/AccountHeaderView.swift @@ -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