Show visibility icon also in notification view

This commit is contained in:
Natalia Ossipova 2023-05-17 14:07:43 +02:00
parent 00a8c7523b
commit e397191773
2 changed files with 42 additions and 4 deletions

View File

@ -42,6 +42,8 @@ extension NotificationView {
@Published public var timestamp: Date?
@Published public var visibility: MastodonVisibility = .public
@Published public var followRequestState = MastodonFollowRequestState(state: .none)
@Published public var transientFollowRequestState = MastodonFollowRequestState(state: .none)
@ -121,6 +123,12 @@ extension NotificationView.ViewModel {
}
.store(in: &disposeBag)
$visibility
.sink { visibility in
notificationView.visibilityIconImageView.image = visibility.image
}
.store(in: &disposeBag)
// notification type indicator
$notificationIndicatorText
.sink { text in

View File

@ -91,6 +91,20 @@ public final class NotificationView: UIView {
// timestamp
public let dateLabel = MetaLabel(style: .statusUsername)
public let dateTrailingDotLabel: MetaLabel = {
let label = MetaLabel(style: .statusUsername)
label.configure(content: PlaintextMetaContent(string: "·"))
return label
}()
let visibilityIconImageView: UIImageView = {
let imageView = UIImageView()
imageView.tintColor = Asset.Colors.Label.secondary.color
imageView.contentMode = .scaleAspectFit
imageView.image = Asset.Scene.Compose.earth.image.withRenderingMode(.alwaysTemplate)
return imageView
}()
public let menuButton: UIButton = {
let button = HitTestExpandedButton(type: .system)
button.tintColor = Asset.Colors.Label.secondary.color
@ -272,16 +286,32 @@ extension NotificationView {
authrMetaContainer.setCustomSpacing(4, after: authorSecondaryMetaContainer)
authorSecondaryMetaContainer.addArrangedSubview(authorUsernameLabel)
authorUsernameLabel.setContentHuggingPriority(.required - 8, for: .horizontal)
authorUsernameLabel.setContentCompressionResistancePriority(.required - 8, for: .horizontal)
authorUsernameLabel.setContentHuggingPriority(.required - 1, for: .vertical)
authorUsernameLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
authorSecondaryMetaContainer.addArrangedSubview(usernameTrialingDotLabel)
usernameTrialingDotLabel.setContentHuggingPriority(.required - 2, for: .horizontal)
usernameTrialingDotLabel.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
usernameTrialingDotLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
authorSecondaryMetaContainer.addArrangedSubview(dateLabel)
dateLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
dateLabel.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
authorSecondaryMetaContainer.addArrangedSubview(dateTrailingDotLabel)
dateTrailingDotLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
authorSecondaryMetaContainer.addArrangedSubview(dateTrailingDotLabel)
dateTrailingDotLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
authorSecondaryMetaContainer.addArrangedSubview(visibilityIconImageView)
NSLayoutConstraint.activate([
visibilityIconImageView.heightAnchor.constraint(equalTo: authorUsernameLabel.heightAnchor),
visibilityIconImageView.widthAnchor.constraint(equalTo: visibilityIconImageView.heightAnchor),
])
authorSecondaryMetaContainer.addArrangedSubview(UIView())
authorSecondaryMetaContainer.setCustomSpacing(0, after: visibilityIconImageView)
// authorContainerViewBottomPaddingView
authorContainerViewBottomPaddingView.translatesAutoresizingMaskIntoConstraints = false
containerStackView.addArrangedSubview(authorContainerViewBottomPaddingView)