From 074974ecb8072fa73a0a78177dd6bb888ae6fb33 Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:42:16 +0530 Subject: [PATCH] tweak drag setup --- .../CollectionView/DragAndDropDelegate.swift | 1 - .../CollectionView/EmojiCollectionViewCell.swift | 15 +++++++++++++++ StickerSlack/UIKit/DownloadedViewController.swift | 1 + StickerSlack/UIKit/SearchViewController.swift | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/StickerSlack/UIKit/CollectionView/DragAndDropDelegate.swift b/StickerSlack/UIKit/CollectionView/DragAndDropDelegate.swift index 54b46ce..1051ebd 100644 --- a/StickerSlack/UIKit/CollectionView/DragAndDropDelegate.swift +++ b/StickerSlack/UIKit/CollectionView/DragAndDropDelegate.swift @@ -16,7 +16,6 @@ extension EmojiCollectionView: UICollectionViewDragDelegate { at indexPath: IndexPath ) -> [UIDragItem] { let emojiName = items[indexPath.row] - guard let emoji = hoarder.trie.dict[emojiName] else { return [] } let item = NSItemProvider(item: emojiName as NSSecureCoding, typeIdentifier: UTType.utf8PlainText.identifier) diff --git a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift index fafa75b..22ac182 100644 --- a/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift +++ b/StickerSlack/UIKit/CollectionView/EmojiCollectionViewCell.swift @@ -115,4 +115,19 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell { button.isUserInteractionEnabled = false edit = false } + + override func dragStateDidChange(_ dragState: UICollectionViewCell.DragState) { + self.transform = .identity + + switch dragState { + case .none: + self.setEdit(to: edit, animated: false) + case .lifting: + button.alpha = 0 + case .dragging: + button.alpha = 0 + @unknown default: + fatalError() + } + } } diff --git a/StickerSlack/UIKit/DownloadedViewController.swift b/StickerSlack/UIKit/DownloadedViewController.swift index 5456cbf..e36a4bb 100644 --- a/StickerSlack/UIKit/DownloadedViewController.swift +++ b/StickerSlack/UIKit/DownloadedViewController.swift @@ -21,6 +21,7 @@ class DownloadedViewController: UINavigationController, UINavigationControllerDe style: .plainWithMenu ) downloadedView.navigationItem.title = "Downloaded" + downloadedView.collectionView.dragInteractionEnabled = false super.init(rootViewController: downloadedView) refreshUI() diff --git a/StickerSlack/UIKit/SearchViewController.swift b/StickerSlack/UIKit/SearchViewController.swift index 217a07c..173d860 100644 --- a/StickerSlack/UIKit/SearchViewController.swift +++ b/StickerSlack/UIKit/SearchViewController.swift @@ -35,6 +35,7 @@ class SearchViewController: UINavigationController, UISearchControllerDelegate, width: 75, style: .plainWithLabel ) + (self.resultsView as! EmojiCollectionView).collectionView.dragInteractionEnabled = false } else { self.resultsView = EmojiTableView(hoarder: emojiHoarder, items: []) }