Tusker/Tusker/Screens/Search/SearchTokenSuggestionCollec...

52 lines
1.7 KiB
Swift
Raw Permalink Normal View History

//
// SearchTokenSuggestionCollectionViewCell.swift
// Tusker
//
// Created by Shadowfacts on 10/1/23.
// Copyright © 2023 Shadowfacts. All rights reserved.
//
import UIKit
import Pachyderm
class SearchTokenSuggestionCollectionViewCell: UICollectionViewCell {
private let label = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
label.textColor = .tintColor
contentView.backgroundColor = .tintColor.withAlphaComponent(0.2)
contentView.layer.masksToBounds = true
contentView.layer.cornerRadius = 6
contentView.layer.cornerCurve = .continuous
label.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(label)
NSLayoutConstraint.activate([
label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8),
label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -8),
label.topAnchor.constraint(equalTo: contentView.topAnchor),
label.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
])
addInteraction(UIPointerInteraction(delegate: self))
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setText(_ text: String) {
label.text = text
}
}
extension SearchTokenSuggestionCollectionViewCell: UIPointerInteractionDelegate {
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
let preview = UITargetedPreview(view: self)
return UIPointerStyle(effect: .lift(preview))
}
}