diff --git a/StickerSlack/Emoji/EmojiHoarder.swift b/StickerSlack/Emoji/EmojiHoarder.swift index d948dcf..0b23fd2 100644 --- a/StickerSlack/Emoji/EmojiHoarder.swift +++ b/StickerSlack/Emoji/EmojiHoarder.swift @@ -246,6 +246,19 @@ class EmojiHoarder: BaseHoarder { self.showWelcome = newValue } + func loadEmojiPacks() { + + } + + func saveEmojiPacks() { + var toStore: [URL] = [] + for pack in emojiPacks { + toStore.append(pack.shareLink()) + } + guard let encoded = try? JSONEncoder().encode(toStore) else { return } + + } + func generateLetterStats() { var result: [EmojiHoarder.LetterStat] = [] for child in trie.root.children { diff --git a/StickerSlack/Emoji/GifView.swift b/StickerSlack/Emoji/GifView.swift index 3d9f16f..64d24ba 100644 --- a/StickerSlack/Emoji/GifView.swift +++ b/StickerSlack/Emoji/GifView.swift @@ -18,6 +18,17 @@ struct GifView: View { @State var timer: Timer? func run() async { + guard url.pathExtension == "gif" else { + if let data = try? await URLSession.shared.data(from: url).0, + let uiImage = UIImage(data: data), + let cgImage = uiImage.cgImage { + withAnimation(.spring) { + self.gif = [(cgImage, 1)] + } + } + return + } + do { if gif.isEmpty { let frames = try await GifManager.gifFrom(url: url) @@ -48,26 +59,30 @@ struct GifView: View { var body: some View { // /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Hello, world!@*/Text("Hello, world!")/*@END_MENU_TOKEN@*/ - TimelineView(.animation) { tl in - VStack { - if gif.isEmpty { - ProgressView() - .controlSize(.large) - .frame(maxWidth: .infinity, maxHeight: .infinity) - } else { + Group { + if gif.isEmpty { + ProgressView() + .controlSize(.large) + .frame(maxWidth: .infinity, maxHeight: .infinity) + } else if url.pathExtension == "gif" { + TimelineView(.animation) { tl in if currentI < gif.count { - let image = Image(uiImage: .init(cgImage: gif[currentI].frame)) - image + Image(uiImage: .init(cgImage: gif[currentI].frame)) .resizable().scaledToFit() } } + .onDisappear { + timer?.invalidate() + timer = nil + } + } else { + if let frame = gif.first { + Image(uiImage: .init(cgImage: frame.frame)) + .resizable().scaledToFit() + } } - .transition(.scale) - } - .onDisappear { - timer?.invalidate() - timer = nil } + .transition(.scale) .onAppear { Task { await run() diff --git a/StickerSlack/Extensions/TestStructures.swift b/StickerSlack/Extensions/TestStructures.swift index f2f54bd..9f85561 100644 --- a/StickerSlack/Extensions/TestStructures.swift +++ b/StickerSlack/Extensions/TestStructures.swift @@ -134,35 +134,36 @@ extension EmojiPack { "loll", "bleh", "uhh", - "communist", - "ufahh", - "uhafh", - "uhgfh", - "uoohh", - "ujyhgghh", - "uhfgh", - "ujg3thh", - "uyhh", - "ughhhh", - "uvhh", - "ujrg3tjthhg", - "ujherh", - "uxhggrh", - "ushgrq3geallh", - "u hrgqh", - "ujjjjjyhgh", - "uherhh", - "uhhesh", - "hhreruhgh", - "u hffh", - "uh h", - "uaugerhh", - "u4h3h", - "u4hh", - "ueyhh ", - "u erthh", - "uhujh", - "ujkkkkhh" + "communist" +// "communist", +// "ufahh", +// "uhafh", +// "uhgfh", +// "uoohh", +// "ujyhgghh", +// "uhfgh", +// "ujg3thh", +// "uyhh", +// "ughhhh", +// "uvhh", +// "ujrg3tjthhg", +// "ujherh", +// "uxhggrh", +// "ushgrq3geallh", +// "u hrgqh", +// "ujjjjjyhgh", +// "uherhh", +// "uhhesh", +// "hhreruhgh", +// "u hffh", +// "uh h", +// "uaugerhh", +// "u4h3h", +// "u4hh", +// "ueyhh ", +// "u erthh", +// "uhujh", +// "ujkkkkhh" ] ) } diff --git a/StickerSlack/SwiftUI/EmojiPacks/EmojiPackDetailView.swift b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackDetailView.swift index 828cbcd..0baa6e7 100644 --- a/StickerSlack/SwiftUI/EmojiPacks/EmojiPackDetailView.swift +++ b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackDetailView.swift @@ -81,6 +81,7 @@ struct EmojiPackDetailView: View { .blur(radius: 5) .shadow(color: .purple, radius: 5) } + .padding() } let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing))) @@ -172,7 +173,7 @@ struct EmojiPackDetailView: View { } } .onDisappear { - print("disappear") + hoarder. } } }