add pull to refresh and made it so addtopacksheet doesnt dismiss after each add

This commit is contained in:
neon443 committed 2026-06-12 21:47:45 +01:00
1 parent d5e9fc3764
commit ef1aa61728
3 files changed
+44 -4

No files matched your search

@@ -0,0 +1,9 @@
{
"id" : "f788be3f-ea78-49e8-a73f-06a26b2c4e3a",
"targets" : [
{
"id" : "C05654F5-CD40-44E4-80B8-2A14F2CD10BA",
"name" : "StickerSlack"
}
]
}
@@ -210,7 +210,17 @@ struct EmojiCollectionView: UIViewRepresentable {
) -> UIContextMenuConfiguration? { ) -> UIContextMenuConfiguration? {
guard self.style == .plainWithMenu else { return nil } guard self.style == .plainWithMenu else { return nil }
var menuChildrem: [UIMenuElement] = []
let emojiName = self.items[indexPath.row] let emojiName = self.items[indexPath.row]
// if let localImagePath = hoarder.trie.dict[emojiName]?.localImageURLString,
// let attrs = try? FileManager.default.attributesOfItem(atPath: localImagePath),
// let size = attrs[FileAttributeKey("NSFileSize")] {
// print(size, "bytes")
// let sizeLabel = UIAction(title: "\(size as! Int/1000) KB", image: nil, identifier: nil, discoverabilityTitle: nil, attributes: .disabled) { _ in }
// menuChildrem.append(sizeLabel)
// }
let packMenuItem: (EmojiHoarder, Int) -> UIAction = { hoarder, packIndex in let packMenuItem: (EmojiHoarder, Int) -> UIAction = { hoarder, packIndex in
let pack = hoarder.emojiPacks[packIndex] let pack = hoarder.emojiPacks[packIndex]
return UIAction( return UIAction(
@@ -235,7 +245,8 @@ struct EmojiCollectionView: UIViewRepresentable {
] ]
) )
packMenuItems.append(createNewPackMenu) packMenuItems.append(createNewPackMenu)
let addToPackMenu = UIMenu(title: "Add to Pack", image: UIImage(systemName: "square.stack.3d.up.fill"), children: packMenuItems) // let addToPackMenu = UIMenu(title: "Add to Pack", image: UIImage(systemName: "square.stack.3d.up.fill"), children: packMenuItems)
menuChildrem.append(UIMenu(title: "Add to Pack", image: UIImage(systemName: "square.stack.3d.up.fill"), children: packMenuItems))
let copyName = UIAction(title: "Copy Name", image: UIImage(systemName: "doc.on.clipboard")) { action in let copyName = UIAction(title: "Copy Name", image: UIImage(systemName: "doc.on.clipboard")) { action in
UIPasteboard.general.string = emojiName UIPasteboard.general.string = emojiName
@@ -248,7 +259,8 @@ struct EmojiCollectionView: UIViewRepresentable {
let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in let share = UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up")) { action in
} }
let sharingMenu = UIMenu(options: .displayInline, children: [copyName, copyImage, share]) // let sharingMenu = UIMenu(options: .displayInline, children: [copyName, copyImage, share])
menuChildrem.append(UIMenu(options: .displayInline, children: [copyName, copyImage, share]))
let delete = UIAction(title: "Delete", image: UIImage(systemName: "trash")) { action in let delete = UIAction(title: "Delete", image: UIImage(systemName: "trash")) { action in
Task.detached { Task.detached {
@@ -260,9 +272,11 @@ struct EmojiCollectionView: UIViewRepresentable {
} }
} }
delete.attributes.update(with: .destructive) delete.attributes.update(with: .destructive)
let destructiveMenu = UIMenu(options: .displayInline, children: [delete]) // let destructiveMenu = UIMenu(options: .displayInline, children: [delete])
menuChildrem.append(UIMenu(options: .displayInline, children: [delete]))
let menu = UIMenu(title: emojiName, children: [addToPackMenu, sharingMenu, destructiveMenu]) // let menu = UIMenu(title: emojiName, children: [addToPackMenu, sharingMenu, destructiveMenu])
let menu = UIMenu(title: emojiName, children: menuChildrem)
return UIContextMenuConfiguration( return UIContextMenuConfiguration(
identifier: nil, identifier: nil,
previewProvider: nil) { suggestedActions in previewProvider: nil) { suggestedActions in
@@ -94,6 +94,23 @@ struct EmojiTableView: UIViewRepresentable {
return items.count return items.count
} }
override func viewDidLoad() {
super.viewDidLoad()
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refresh(_:)), for: .valueChanged)
if #available(iOS 10, *) {
tableView.refreshControl = refreshControl
} else {
tableView.backgroundView = refreshControl
}
}
@objc func refresh(_ refreshControl: UIRefreshControl) {
hoarder.startLoading(localOnly: false, skipIndex: false)
refreshControl.endRefreshing()
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// <#code#> // <#code#>
} }
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.