2021-03-25 08:56:17 +01:00
|
|
|
//
|
|
|
|
// CustomEmojiPickerItemCollectionViewCell.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-3-24.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2021-07-23 13:10:27 +02:00
|
|
|
import SDWebImage
|
2021-03-25 08:56:17 +01:00
|
|
|
|
|
|
|
final class CustomEmojiPickerItemCollectionViewCell: UICollectionViewCell {
|
|
|
|
|
|
|
|
static let itemSize = CGSize(width: 44, height: 44)
|
2021-06-29 10:41:58 +02:00
|
|
|
|
2021-07-23 13:10:27 +02:00
|
|
|
let emojiImageView: SDAnimatedImageView = {
|
|
|
|
let imageView = SDAnimatedImageView()
|
2021-03-25 08:56:17 +01:00
|
|
|
imageView.contentMode = .scaleAspectFit
|
|
|
|
imageView.layer.masksToBounds = true
|
|
|
|
return imageView
|
|
|
|
}()
|
|
|
|
|
|
|
|
override var isHighlighted: Bool {
|
|
|
|
didSet {
|
|
|
|
emojiImageView.alpha = isHighlighted ? 0.5 : 1.0
|
|
|
|
}
|
|
|
|
}
|
2021-06-29 10:41:58 +02:00
|
|
|
|
|
|
|
override func prepareForReuse() {
|
|
|
|
super.prepareForReuse()
|
|
|
|
}
|
2021-03-25 08:56:17 +01:00
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
_init()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension CustomEmojiPickerItemCollectionViewCell {
|
|
|
|
|
|
|
|
private func _init() {
|
|
|
|
emojiImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
contentView.addSubview(emojiImageView)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
emojiImageView.topAnchor.constraint(equalTo: contentView.topAnchor),
|
|
|
|
emojiImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
|
|
|
emojiImageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
|
|
|
|
emojiImageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
|
|
|
])
|
2021-05-13 08:27:57 +02:00
|
|
|
|
|
|
|
isAccessibilityElement = true
|
|
|
|
accessibilityTraits = .button
|
|
|
|
accessibilityHint = "emoji"
|
2021-03-25 08:56:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|