From 4fbda99bb65a4e9b857f88ce31a83ce8ca54e3dc Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Thu, 28 Jan 2021 18:50:48 -0800 Subject: [PATCH] Visibility icon on expanded posts --- Views/Status/StatusView.swift | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Views/Status/StatusView.swift b/Views/Status/StatusView.swift index b349d12..38f0802 100644 --- a/Views/Status/StatusView.swift +++ b/Views/Status/StatusView.swift @@ -16,7 +16,7 @@ final class StatusView: UIView { let timeLabel = UILabel() let bodyView = StatusBodyView() let contextParentTimeLabel = UILabel() - let timeApplicationDividerLabel = UILabel() + let visibilityImageView = UIImageView() let applicationButton = UIButton(type: .system) let rebloggedByButton = UIButton() let favoritedByButton = UIButton() @@ -33,6 +33,8 @@ final class StatusView: UIView { private let nameAccountContainerStackView = UIStackView() private let nameAccountTimeStackView = UIStackView() private let contextParentTimeApplicationStackView = UIStackView() + private let timeVisibilityDividerLabel = UILabel() + private let visibilityApplicationDividerLabel = UILabel() private let contextParentTopNameAccountSpacingView = UIView() private let contextParentBottomNameAccountSpacingView = UIView() private let interactionsDividerView = UIView() @@ -173,7 +175,6 @@ private extension StatusView { mainStackView.addArrangedSubview(nameAccountContainerStackView) mainStackView.addArrangedSubview(bodyView) - bodyView.tag = 666 contextParentTimeLabel.font = .preferredFont(forTextStyle: .footnote) contextParentTimeLabel.adjustsFontForContentSizeCategory = true @@ -181,12 +182,21 @@ private extension StatusView { contextParentTimeLabel.setContentHuggingPriority(.required, for: .horizontal) contextParentTimeApplicationStackView.addArrangedSubview(contextParentTimeLabel) - timeApplicationDividerLabel.font = .preferredFont(forTextStyle: .footnote) - timeApplicationDividerLabel.adjustsFontForContentSizeCategory = true - timeApplicationDividerLabel.textColor = .secondaryLabel - timeApplicationDividerLabel.text = "•" - timeApplicationDividerLabel.setContentHuggingPriority(.required, for: .horizontal) - contextParentTimeApplicationStackView.addArrangedSubview(timeApplicationDividerLabel) + for label in [timeVisibilityDividerLabel, visibilityApplicationDividerLabel] { + label.font = .preferredFont(forTextStyle: .footnote) + label.adjustsFontForContentSizeCategory = true + label.textColor = .secondaryLabel + label.text = "•" + label.setContentHuggingPriority(.required, for: .horizontal) + } + + contextParentTimeApplicationStackView.addArrangedSubview(timeVisibilityDividerLabel) + + contextParentTimeApplicationStackView.addArrangedSubview(visibilityImageView) + visibilityImageView.contentMode = .scaleAspectFit + visibilityImageView.tintColor = .secondaryLabel + + contextParentTimeApplicationStackView.addArrangedSubview(visibilityApplicationDividerLabel) applicationButton.titleLabel?.font = .preferredFont(forTextStyle: .footnote) applicationButton.titleLabel?.adjustsFontForContentSizeCategory = true @@ -380,7 +390,8 @@ private extension StatusView { bodyView.viewModel = viewModel contextParentTimeLabel.text = viewModel.contextParentTime - timeApplicationDividerLabel.isHidden = viewModel.applicationName == nil + visibilityImageView.image = UIImage(systemName: viewModel.visibility.systemImageName) + visibilityApplicationDividerLabel.isHidden = viewModel.applicationName == nil applicationButton.isHidden = viewModel.applicationName == nil applicationButton.setTitle(viewModel.applicationName, for: .normal) applicationButton.isEnabled = viewModel.applicationURL != nil