mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardV...

83 lines
2.6 KiB
Swift
Raw Normal View History

//
// FamiliarFollowersDashboardView.swift
//
//
// Created by MainasuK on 2022-5-16.
//
import UIKit
import MastodonAsset
import MetaTextKit
public final class FamiliarFollowersDashboardView: UIView {
let avatarContainerView = UIView()
var avatarContainerViewWidthLayoutConstraint: NSLayoutConstraint!
var avatarContainerViewHeightLayoutConstraint: NSLayoutConstraint!
let descriptionMetaLabel = MetaLabel(style: .profileCardFamiliarFollowerFooter)
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
stackView.alignment = .center
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)
avatarContainerViewHeightLayoutConstraint = avatarContainerView.heightAnchor.constraint(equalToConstant: 32).priority(.required - 1)
NSLayoutConstraint.activate([
avatarContainerViewWidthLayoutConstraint,
avatarContainerViewHeightLayoutConstraint
])
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
}
}
#if DEBUG
import SwiftUI
struct FamiliarFollowersDashboardView_Preview: PreviewProvider {
static var previews: some View {
UIViewPreview {
FamiliarFollowersDashboardView()
}
}
}
#endif