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
+21
-2
No files matched your search
@@ -105,6 +105,7 @@ class EmojiHoarder: BaseHoarder {
|
||||
}
|
||||
await MainActor.run {
|
||||
downloadedStickers = []
|
||||
downloadedStickersArr = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +210,7 @@ class EmojiHoarder: BaseHoarder {
|
||||
await super.download(emoji: emoji, skipStoreIndex: skipStoreIndex)
|
||||
|
||||
await MainActor.run {
|
||||
emojis.insert(.test, at: emojis.count-2)
|
||||
if !skipStoreIndex {
|
||||
let _ = withAnimation(.snappy) {
|
||||
self.downloadedStickers.insert(emoji.name)
|
||||
|
||||
@@ -30,7 +30,6 @@ struct BrowseView: View {
|
||||
items: emojiHoarder.emojis.map { $0.name }
|
||||
)
|
||||
.padding(.bottom, 10)
|
||||
.id(emojiHoarder.emojis)
|
||||
case .giphyGifs:
|
||||
Button("download all") {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,19 @@ struct EmojiTableView: UIViewRepresentable {
|
||||
|
||||
func updateUIView(_ uiView: UITableView, context: Context) {
|
||||
context.coordinator.hoarder = hoarder
|
||||
|
||||
let itemsBefore = context.coordinator.items
|
||||
let itemsAfter = items
|
||||
context.coordinator.items = items
|
||||
uiView.reloadData()
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
|
||||