2022-05-16 13:42:03 +02:00
|
|
|
//
|
|
|
|
// FamiliarFollowersDashboardView.swift
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-5-16.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import MastodonAsset
|
2022-05-17 11:40:19 +02:00
|
|
|
import MetaTextKit
|
2022-05-16 13:42:03 +02:00
|
|
|
|
|
|
|
public final class FamiliarFollowersDashboardView: UIView {
|
|
|
|
|
|
|
|
let avatarContainerView = UIView()
|
|
|
|
var avatarContainerViewWidthLayoutConstraint: NSLayoutConstraint!
|
2022-05-17 11:40:19 +02:00
|
|
|
var avatarContainerViewHeightLayoutConstraint: NSLayoutConstraint!
|
2022-05-16 13:42:03 +02:00
|
|
|
|
2022-05-17 11:40:19 +02:00
|
|
|
let descriptionMetaLabel = MetaLabel(style: .profileCardFamiliarFollowerFooter)
|
2022-05-16 13:42:03 +02:00
|
|
|
|
|
|
|
public private(set) lazy var viewModel: ViewModel = {
|
|
|
|
let viewModel = ViewModel()
|
|
|
|
viewModel.bind(view: self)
|
|
|
|
return viewModel
|
|
|
|
}()
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension FamiliarFollowersDashboardView {
|
|
|
|
|
|
|
|
private func _init() {
|
|
|
|
let stackView = UIStackView()
|
|
|
|
stackView.axis = .horizontal
|
2022-05-17 11:40:19 +02:00
|
|
|
stackView.alignment = .center
|
2022-05-16 13:42:03 +02:00
|
|
|
stackView.spacing = 8
|
|
|
|
|
|
|
|
stackView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
addSubview(stackView)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
stackView.topAnchor.constraint(equalTo: topAnchor),
|
|
|
|
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
|
|
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
|
|
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
|
|
])
|
|
|
|
|
|
|
|
avatarContainerView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
stackView.addArrangedSubview(avatarContainerView)
|
|
|
|
avatarContainerViewWidthLayoutConstraint = avatarContainerView.widthAnchor.constraint(equalToConstant: 32).priority(.required - 1)
|
2022-05-17 11:40:19 +02:00
|
|
|
avatarContainerViewHeightLayoutConstraint = avatarContainerView.heightAnchor.constraint(equalToConstant: 32).priority(.required - 1)
|
2022-05-16 13:42:03 +02:00
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
avatarContainerViewWidthLayoutConstraint,
|
2022-05-17 11:40:19 +02:00
|
|
|
avatarContainerViewHeightLayoutConstraint
|
2022-05-16 13:42:03 +02:00
|
|
|
])
|
2022-05-17 11:40:19 +02:00
|
|
|
stackView.addArrangedSubview(descriptionMetaLabel)
|
|
|
|
descriptionMetaLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
|
|
|
descriptionMetaLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
2022-05-17 12:49:29 +02:00
|
|
|
|
|
|
|
descriptionMetaLabel.isUserInteractionEnabled = false
|
2022-05-16 13:42:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
import SwiftUI
|
|
|
|
struct FamiliarFollowersDashboardView_Preview: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
UIViewPreview {
|
|
|
|
FamiliarFollowersDashboardView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|