forked from zelo72/mastodon-ios
feature: add visibility indicator for post
This commit is contained in:
parent
0427beb7d3
commit
b428eb6e01
|
@ -178,6 +178,20 @@ extension StatusSection {
|
|||
// set text
|
||||
cell.statusView.activeTextLabel.configure(content: (status.reblog ?? status).content)
|
||||
|
||||
// set visibility
|
||||
if let visibility = (status.reblog ?? status).visibility {
|
||||
cell.statusView.updateVisibility(visibility: visibility)
|
||||
|
||||
cell.statusView.revealContentWarningButton.publisher(for: \.isHidden)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak cell] isHidden in
|
||||
cell?.statusView.visibilityImageView.isHidden = !isHidden
|
||||
}
|
||||
.store(in: &cell.disposeBag)
|
||||
} else {
|
||||
cell.statusView.visibilityImageView.isHidden = true
|
||||
}
|
||||
|
||||
// prepare media attachments
|
||||
let mediaAttachments = Array((status.reblog ?? status).mediaAttachments ?? []).sorted { $0.index.compare($1.index) == .orderedAscending }
|
||||
|
||||
|
|
|
@ -181,6 +181,15 @@ extension ComposeToolbarView {
|
|||
}
|
||||
}
|
||||
|
||||
func imageNameForTimeline() -> String {
|
||||
switch self {
|
||||
case .public: return "person.3"
|
||||
case .unlisted: return "eye.slash"
|
||||
case .private: return "person.crop.circle.badge.plus"
|
||||
case .direct: return "at"
|
||||
}
|
||||
}
|
||||
|
||||
var visibility: Mastodon.Entity.Status.Visibility {
|
||||
switch self {
|
||||
case .public: return .public
|
||||
|
|
|
@ -126,6 +126,13 @@ final class StatusView: UIView {
|
|||
return button
|
||||
}()
|
||||
|
||||
let visibilityImageView: UIImageView = {
|
||||
let imageView = UIImageView()
|
||||
imageView.tintColor = Asset.Colors.Label.secondary.color
|
||||
imageView.contentMode = .scaleAspectFit
|
||||
return imageView
|
||||
}()
|
||||
|
||||
let statusContainerStackView = UIStackView()
|
||||
let statusMosaicImageViewContainer = MosaicImageViewContainer()
|
||||
|
||||
|
@ -321,6 +328,10 @@ extension StatusView {
|
|||
authorContainerStackView.addArrangedSubview(revealContentWarningButton)
|
||||
revealContentWarningButton.setContentHuggingPriority(.required - 2, for: .horizontal)
|
||||
|
||||
// visibility ImageView
|
||||
authorContainerStackView.addArrangedSubview(visibilityImageView)
|
||||
visibilityImageView.setContentHuggingPriority(.required - 2, for: .horizontal)
|
||||
|
||||
authorContainerStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
authorContainerView.addSubview(authorContainerStackView)
|
||||
NSLayoutConstraint.activate([
|
||||
|
@ -483,6 +494,11 @@ extension StatusView {
|
|||
// TODO: a11y
|
||||
}
|
||||
|
||||
func updateVisibility(visibility: String) {
|
||||
guard let visibility = ComposeToolbarView.VisibilitySelectionType(rawValue: visibility) else { return }
|
||||
visibilityImageView.image = UIImage(systemName: visibility.imageNameForTimeline(), withConfiguration: UIImage.SymbolConfiguration(pointSize: 13, weight: .regular))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension StatusView {
|
||||
|
|
Loading…
Reference in New Issue