fixed buttons yay

This commit is contained in:
neon443 committed 2026-04-30 09:55:06 +01:00
1 parent 53aa8fa0ed
commit 1cbe3d7506
4 files changed
+29 -25

No files matched your search

@@ -78,7 +78,8 @@ struct EmojiPackDetailView: View {
pack: pack, pack: pack,
width: 75, width: 75,
style: .full, style: .full,
edit: edit edit: edit,
onRemove: { pack.remove($0) }
) )
GeometryReader { geo in GeometryReader { geo in
@@ -117,6 +117,24 @@ struct EmojiCollectionView: UIViewRepresentable {
case .full: case .full:
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "full", for: indexPath) as! EmojiCollectionViewCell cell = collectionView.dequeueReusableCell(withReuseIdentifier: "full", for: indexPath) as! EmojiCollectionViewCell
(cell as! EmojiCollectionViewCell).setEdit(to: edit) (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 } 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 } guard let emoji = hoarder.trie.dict[emojiName] else { return cell }
cell.configure(with: hoarder, emoji: emoji) cell.configure(with: hoarder, emoji: emoji)
return cell return cell
} }
@objc
func deleteTapped() {
print(UUID())
}
func collectionView( func collectionView(
_ collectionView: UICollectionView, _ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout, layout collectionViewLayout: UICollectionViewLayout,
@@ -11,7 +11,6 @@ import SwiftUI
class EmojiCollectionViewCell: PlainEmojiCollectionViewCell { class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
let label = UILabel() let label = UILabel()
let deleteButton = UIButton(type: .custom)
var edit: Bool = false var edit: Bool = false
override init(frame: CGRect) { override init(frame: CGRect) {
@@ -27,14 +26,6 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), 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) { required init?(coder: NSCoder) {
@@ -48,14 +39,6 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
override func configure(with: EmojiHoarder, emoji: Emoji) { override func configure(with: EmojiHoarder, emoji: Emoji) {
super.configure(with: with, emoji: emoji) super.configure(with: with, emoji: emoji)
label.text = emoji.UIName 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) { func setEdit(to newValue: Bool) {
@@ -29,7 +29,6 @@ class MessagesViewController: MSMessagesAppViewController {
guard stickerBrowser.dataSource?.numberOfStickers(in: stickerBrowser) != 0 else { guard stickerBrowser.dataSource?.numberOfStickers(in: stickerBrowser) != 0 else {
let swiftUIView = NoStickersView() let swiftUIView = NoStickersView()
let hostingController = UIHostingController(rootView: swiftUIView) let hostingController = UIHostingController(rootView: swiftUIView)
addChild(hostingController)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false hostingController.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingController.view) view.addSubview(hostingController.view)
hostingController.didMove(toParent: self) hostingController.didMove(toParent: self)
@@ -38,16 +37,15 @@ class MessagesViewController: MSMessagesAppViewController {
link.setTitle("Open StickerSlack", for: .normal) link.setTitle("Open StickerSlack", for: .normal)
link.setImage(UIImage(systemName: "arrow.up.right.square"), for: .normal) link.setImage(UIImage(systemName: "arrow.up.right.square"), for: .normal)
link.setTitleColor(.systemBlue, for: .normal) link.setTitleColor(.systemBlue, for: .normal)
link.frame = view.frame
link.translatesAutoresizingMaskIntoConstraints = false link.translatesAutoresizingMaskIntoConstraints = false
link.addTarget(self, action: #selector(openStickerSlack), for: .touchUpInside) link.addTarget(self, action: #selector(openStickerSlack), for: .touchUpInside)
view.addSubview(link) view.addSubview(link)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
hostingController.view.centerXAnchor.constraint(equalTo: view.centerXAnchor), hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.centerYAnchor.constraint(equalTo: view.centerYAnchor), hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
hostingController.view.widthAnchor.constraint(equalTo: view.widthAnchor), hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.heightAnchor.constraint(equalTo: view.heightAnchor), hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
link.centerXAnchor.constraint(equalTo: view.centerXAnchor), link.centerXAnchor.constraint(equalTo: view.centerXAnchor),
link.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), link.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
link.heightAnchor.constraint(equalToConstant: 50) link.heightAnchor.constraint(equalToConstant: 50)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.