mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fixed buttons yay
This commit is contained in:
4 files changed
+29
-25
No files matched your search
@@ -78,7 +78,8 @@ struct EmojiPackDetailView: View {
|
||||
pack: pack,
|
||||
width: 75,
|
||||
style: .full,
|
||||
edit: edit
|
||||
edit: edit,
|
||||
onRemove: { pack.remove($0) }
|
||||
)
|
||||
|
||||
GeometryReader { geo in
|
||||
|
||||
@@ -117,6 +117,24 @@ struct EmojiCollectionView: UIViewRepresentable {
|
||||
case .full:
|
||||
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "full", for: indexPath) as! EmojiCollectionViewCell
|
||||
(cell as! EmojiCollectionViewCell).setEdit(to: edit)
|
||||
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(UIImage(systemName: "minus.circle.fill"), for: .normal)
|
||||
button.imageView?.contentMode = .scaleAspectFit
|
||||
button.contentHorizontalAlignment = .fill
|
||||
button.contentVerticalAlignment = .fill
|
||||
button.addTarget(self, action: #selector(deleteTapped), for: .touchUpInside)
|
||||
button.tintColor = .systemRed
|
||||
button.clipsToBounds = false
|
||||
button.translatesAutoresizingMaskIntoConstraints = false
|
||||
collectionView.addSubview(button)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
button.topAnchor.constraint(equalTo: cell.topAnchor, constant: -12),
|
||||
button.leadingAnchor.constraint(equalTo: cell.leadingAnchor, constant: -12),
|
||||
button.heightAnchor.constraint(equalToConstant: 24),
|
||||
button.widthAnchor.constraint(equalToConstant: 24)
|
||||
])
|
||||
}
|
||||
|
||||
guard !hoarder.trie.dict.isEmpty else { return cell }
|
||||
@@ -124,10 +142,14 @@ struct EmojiCollectionView: UIViewRepresentable {
|
||||
guard let emoji = hoarder.trie.dict[emojiName] else { return cell }
|
||||
|
||||
cell.configure(with: hoarder, emoji: emoji)
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
@objc
|
||||
func deleteTapped() {
|
||||
print(UUID())
|
||||
}
|
||||
|
||||
func collectionView(
|
||||
_ collectionView: UICollectionView,
|
||||
layout collectionViewLayout: UICollectionViewLayout,
|
||||
|
||||
@@ -11,7 +11,6 @@ import SwiftUI
|
||||
|
||||
class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
||||
let label = UILabel()
|
||||
let deleteButton = UIButton(type: .custom)
|
||||
var edit: Bool = false
|
||||
|
||||
override init(frame: CGRect) {
|
||||
@@ -27,14 +26,6 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
||||
label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
||||
label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
|
||||
])
|
||||
|
||||
deleteButton.setImage(UIImage(systemName: "minus.circle.fill"), for: .normal)
|
||||
deleteButton.imageView?.contentMode = .scaleAspectFit
|
||||
deleteButton.configuration = .plain()
|
||||
contentView.addSubview(deleteButton)
|
||||
deleteButton.tintColor = .systemRed
|
||||
deleteButton.clipsToBounds = false
|
||||
deleteButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -48,14 +39,6 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
||||
override func configure(with: EmojiHoarder, emoji: Emoji) {
|
||||
super.configure(with: with, emoji: emoji)
|
||||
label.text = emoji.UIName
|
||||
contentView.bringSubviewToFront(deleteButton)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
deleteButton.topAnchor.constraint(equalTo: hostingController!.view.topAnchor, constant: -16),
|
||||
deleteButton.leadingAnchor.constraint(equalTo: hostingController!.view.leadingAnchor, constant: -16),
|
||||
deleteButton.heightAnchor.constraint(equalToConstant: 32),
|
||||
deleteButton.widthAnchor.constraint(equalToConstant: 32)
|
||||
])
|
||||
}
|
||||
|
||||
func setEdit(to newValue: Bool) {
|
||||
|
||||