mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
add pull to refresh and made it so addtopacksheet doesnt dismiss after each add
This commit is contained in:
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? {
|
||||
guard self.style == .plainWithMenu else { return nil }
|
||||
|
||||
var menuChildrem: [UIMenuElement] = []
|
||||
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 pack = hoarder.emojiPacks[packIndex]
|
||||
return UIAction(
|
||||
@@ -235,7 +245,8 @@ struct EmojiCollectionView: UIViewRepresentable {
|
||||
]
|
||||
)
|
||||
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
|
||||
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 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
|
||||
Task.detached {
|
||||
@@ -260,9 +272,11 @@ struct EmojiCollectionView: UIViewRepresentable {
|
||||
}
|
||||
}
|
||||
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(
|
||||
identifier: nil,
|
||||
previewProvider: nil) { suggestedActions in
|
||||
|
||||
@@ -94,6 +94,23 @@ struct EmojiTableView: UIViewRepresentable {
|
||||
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) {
|
||||
// <#code#>
|
||||
}
|
||||
|
||||