mastodon-ios/Mastodon/Scene/Share/View/Button/AvatarBarButtonItem.swift

50 lines
1.3 KiB
Swift
Raw Normal View History

2021-02-04 12:28:16 +01:00
//
// AvatarBarButtonItem.swift
// Mastodon
//
// Created by Cirno MainasuK on 2021-2-4.
//
import UIKit
final class AvatarBarButtonItem: UIBarButtonItem {
static let avatarButtonSize = CGSize(width: 32, height: 32)
let avatarButton: UIButton = {
let button = UIButton(type: .custom)
button.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
button.widthAnchor.constraint(equalToConstant: avatarButtonSize.width).priority(.defaultHigh),
button.heightAnchor.constraint(equalToConstant: avatarButtonSize.height).priority(.defaultHigh),
])
return button
}()
override init() {
super.init()
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
}
}
extension AvatarBarButtonItem {
private func _init() {
customView = avatarButton
}
}
extension AvatarBarButtonItem: AvatarConfigurableView {
static var configurableAvatarImageViewSize: CGSize { return avatarButtonSize }
var configurableAvatarImageView: UIImageView? { return nil }
var configurableAvatarButton: UIButton? { return avatarButton }
var configurableVerifiedBadgeImageView: UIImageView? { return nil }
}