mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
trying to redo sizeforitemat, figuring out better tableview reloads
This commit is contained in:
4 files changed
+20
-1
No files matched your search
@@ -105,6 +105,7 @@ class EmojiHoarder: BaseHoarder {
|
|||||||
}
|
}
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
downloadedStickers = []
|
downloadedStickers = []
|
||||||
|
downloadedStickersArr = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +210,7 @@ class EmojiHoarder: BaseHoarder {
|
|||||||
await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex)
|
await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex)
|
||||||
|
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
|
emojis.insert(.test, at: emojis.count-2)
|
||||||
if !skipStoreIndex {
|
if !skipStoreIndex {
|
||||||
let _ = withAnimation(.snappy) {
|
let _ = withAnimation(.snappy) {
|
||||||
self.downloadedStickers.insert(emoji.name)
|
self.downloadedStickers.insert(emoji.name)
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ struct BrowseView: View {
|
|||||||
items: emojiHoarder.emojis.map { $0.name }
|
items: emojiHoarder.emojis.map { $0.name }
|
||||||
)
|
)
|
||||||
.padding(.bottom, 10)
|
.padding(.bottom, 10)
|
||||||
.id(emojiHoarder.emojis)
|
|
||||||
case .giphyGifs:
|
case .giphyGifs:
|
||||||
Button("download all") {
|
Button("download all") {
|
||||||
for gif in gifHoarder.trendingGifs {
|
for gif in gifHoarder.trendingGifs {
|
||||||
|
|||||||
@@ -196,6 +196,13 @@ struct EmojiCollectionView: UIViewRepresentable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let font = UIFont.preferredFont(forTextStyle: .caption1)
|
||||||
|
let rect = (emojiName as NSString).boundingRect(
|
||||||
|
with: CGSize(width: itemWidth, height: .greatestFiniteMagnitude),
|
||||||
|
options: [.usesLineFragmentOrigin, .usesFontLeading],
|
||||||
|
attributes: [.font: font],
|
||||||
|
context: nil
|
||||||
|
)
|
||||||
return CGSize(width: itemWidth, height: itemWidth+labelHeight+4)
|
return CGSize(width: itemWidth, height: itemWidth+labelHeight+4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,20 @@ struct EmojiTableView: UIViewRepresentable {
|
|||||||
|
|
||||||
func updateUIView(_ uiView: UITableView, context: Context) {
|
func updateUIView(_ uiView: UITableView, context: Context) {
|
||||||
context.coordinator.hoarder = hoarder
|
context.coordinator.hoarder = hoarder
|
||||||
|
|
||||||
|
let itemsBefore = context.coordinator.items
|
||||||
|
let itemsAfter = items
|
||||||
context.coordinator.items = items
|
context.coordinator.items = items
|
||||||
|
if itemsAfter.count > itemsBefore.count {
|
||||||
|
var indexPaths: [IndexPath] = []
|
||||||
|
for i in (itemsBefore.count-1)...(itemsAfter.count-1) {
|
||||||
|
indexPaths.append(IndexPath(row: i, section: 0))
|
||||||
|
}
|
||||||
|
uiView.insertRows(at: indexPaths, with: .fade)
|
||||||
|
} else {
|
||||||
uiView.reloadData()
|
uiView.reloadData()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func makeCoordinator() -> Coordinator {
|
func makeCoordinator() -> Coordinator {
|
||||||
Coordinator(hoarder: hoarder, items: items)
|
Coordinator(hoarder: hoarder, items: items)
|
||||||
|
|||||||