From 5e5a04abf8c5a6196ebadbf6f7e57c9d74d735a3 Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Mon, 27 Apr 2026 12:43:51 +0100 Subject: [PATCH] added a menu --- StickerSlack.xcodeproj/project.pbxproj | 6 ++++ .../CollectionView/EmojiCollectionView.swift | 29 ++++++++++++++++--- ...PlainWithMenuEmojiCollectionViewCell.swift | 13 +++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 StickerSlack/UIKit/CollectionView/PlainWithMenuEmojiCollectionViewCell.swift diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 6b5cdac..28da083 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ A957C17E2ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; }; A957C17F2ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; }; A957C1802ECFAA1100EA3EE9 /* GifView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A957C17D2ECFAA1100EA3EE9 /* GifView.swift */; }; + A975F9162F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A975F9152F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift */; }; + A975F9172F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A975F9152F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift */; }; A9773C2F2EA54AF000F3B753 /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; }; A97BFFBC2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; }; A97BFFBD2F9E6092000441E5 /* EmptyEmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */; }; @@ -209,6 +211,7 @@ A957C1792ECE542D00EA3EE9 /* GifManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifManager.swift; sourceTree = ""; }; A957C17D2ECFAA1100EA3EE9 /* GifView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifView.swift; sourceTree = ""; }; A969D6932EA3E86500399C05 /* Messages.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Messages.framework; path = Library/Frameworks/Messages.framework; sourceTree = DEVELOPER_DIR; }; + A975F9152F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlainWithMenuEmojiCollectionViewCell.swift; sourceTree = ""; }; A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPreview.swift; sourceTree = ""; }; A97BFFBB2F9E6092000441E5 /* EmptyEmojiPackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyEmojiPackView.swift; sourceTree = ""; }; A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCollectionViewCell.swift; sourceTree = ""; }; @@ -432,6 +435,7 @@ A917BACD2F9B787B008DB31E /* EmojiCollectionView.swift */, A917BAD02F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift */, A97BFFBE2F9E745C000441E5 /* EmojiCollectionViewCell.swift */, + A975F9152F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift */, ); path = CollectionView; sourceTree = ""; @@ -703,6 +707,7 @@ A949B1FB2EA0518800215164 /* SlackResponse.swift in Sources */, A957C17A2ECE542D00EA3EE9 /* GifManager.swift in Sources */, A9C52F6F2F89A22000078588 /* Wiggle.metal in Sources */, + A975F9162F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift in Sources */, A9BDEADE2F82BC93002798DF /* NoStickersView.swift in Sources */, A955B3F52EC22EE900E1732D /* SearchView.swift in Sources */, A935437B2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */, @@ -780,6 +785,7 @@ A9A7A4462F68360900BB84C6 /* Pagination.swift in Sources */, A957C17C2ECE542D00EA3EE9 /* GifManager.swift in Sources */, A9104C7F2EB4022500D160EA /* MSSticker.swift in Sources */, + A975F9172F9F800A00A5C62E /* PlainWithMenuEmojiCollectionViewCell.swift in Sources */, A9C52F762F89A93D00078588 /* URL.swift in Sources */, A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */, A9C52F702F89A22000078588 /* Wiggle.metal in Sources */, diff --git a/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift b/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift index bb925f0..be9242c 100644 --- a/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift +++ b/StickerSlack/UIKit/CollectionView/EmojiCollectionView.swift @@ -18,8 +18,9 @@ struct EmojiCollectionView: UIViewRepresentable { func makeUIView(context: Context) -> UICollectionView { let collectionView = context.coordinator as UICollectionViewController - collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plainCell") - collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "cell") + collectionView.collectionView.register(PlainEmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plain") + collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "plainWithMenu") + collectionView.collectionView.register(EmojiCollectionViewCell.self, forCellWithReuseIdentifier: "full") collectionView.collectionView.dataSource = context.coordinator collectionView.collectionView.delegate = context.coordinator return collectionView.collectionView @@ -43,6 +44,7 @@ struct EmojiCollectionView: UIViewRepresentable { enum Style { case plain + case plainWithMenu case full } @@ -95,9 +97,12 @@ struct EmojiCollectionView: UIViewRepresentable { let cell: PlainEmojiCollectionViewCell switch style { case .plain: - cell = collectionView.dequeueReusableCell(withReuseIdentifier: "plainCell", for: indexPath) as! PlainEmojiCollectionViewCell + cell = collectionView.dequeueReusableCell(withReuseIdentifier: "plain", for: indexPath) as! PlainEmojiCollectionViewCell + case .plainWithMenu: + fatalError() +// cell = collectionView.dequeueReusableCell(withReuseIdentifier: "plainWithMenu", for: <#T##IndexPath#>) case .full: - cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! EmojiCollectionViewCell + cell = collectionView.dequeueReusableCell(withReuseIdentifier: "full", for: indexPath) as! EmojiCollectionViewCell } guard !hoarder.trie.dict.isEmpty else { return cell } @@ -128,6 +133,22 @@ struct EmojiCollectionView: UIViewRepresentable { return CGSize(width: width, height: width+labelHeight) } + + override func collectionView( + _ collectionView: UICollectionView, + contextMenuConfigurationForItemAt indexPath: IndexPath, + point: CGPoint + ) -> UIContextMenuConfiguration? { + return UIContextMenuConfiguration( + identifier: nil, + previewProvider: nil) { suggestedActions in + let emojiName = self.pack.items[indexPath.row] + let label = UIAction(title: "idk", image: UIImage(systemName: "plus")) { action in + print("idk") + } + return UIMenu(title: emojiName, children: [label]) + } + } } } diff --git a/StickerSlack/UIKit/CollectionView/PlainWithMenuEmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/PlainWithMenuEmojiCollectionViewCell.swift new file mode 100644 index 0000000..582ead1 --- /dev/null +++ b/StickerSlack/UIKit/CollectionView/PlainWithMenuEmojiCollectionViewCell.swift @@ -0,0 +1,13 @@ +// +// PlainWithMenuEmojiCollectionViewCell.swift +// StickerSlack +// +// Created by neon443 on 27/04/2026. +// + +import Foundation +import UIKit + +class PlainWithMenuEmojiCollectionViewCell: PlainEmojiCollectionViewCell { +// override func +}