From 99500e7b08e8cc654aeaf32e78bef4f9815f5e92 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Fri, 10 Apr 2026 16:58:04 +0100 Subject: [PATCH] importing packs added emojipack importer view added stuff to contentview to handle incoming urls --- StickerSlack.xcodeproj/project.pbxproj | 6 ++ StickerSlack/StickerSlackApp.swift | 19 +++++- StickerSlack/SwiftUI/ContentView.swift | 6 +- .../EmojiPacks/EmojiPackImporterView.swift | 60 +++++++++++++++++++ .../SwiftUI/EmojiPacks/EmojiPackManager.swift | 4 +- 5 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 StickerSlack/SwiftUI/EmojiPacks/EmojiPackImporterView.swift diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 1165026..d3ec57d 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -127,6 +127,8 @@ A9EB72502EB94FAD00658CEB /* StickerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* StickerPreview.swift */; }; A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30FD2F5FA47100A57668 /* Hoarder.swift */; }; A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */; }; + A9F7B3802F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; }; + A9F7B3812F8951210071F198 /* EmojiPackImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -220,6 +222,7 @@ A9EB72382EB93FDB00658CEB /* EmojiTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiTableView.swift; sourceTree = ""; }; A9EB72462EB948C400658CEB /* StickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerRow.swift; sourceTree = ""; }; A9EB724C2EB94A6B00658CEB /* TrieTestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrieTestingView.swift; sourceTree = ""; }; + A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackImporterView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -296,6 +299,7 @@ children = ( A9CD6C342EDDE22800B7F421 /* EmojiPackDetailView.swift */, A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */, + A9F7B37F2F8951210071F198 /* EmojiPackImporterView.swift */, ); path = EmojiPacks; sourceTree = ""; @@ -647,6 +651,7 @@ A955B3F52EC22EE900E1732D /* SearchView.swift in Sources */, A935437B2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */, A9CD6C352EDDE22800B7F421 /* EmojiPackDetailView.swift in Sources */, + A9F7B3812F8951210071F198 /* EmojiPackImporterView.swift in Sources */, A9A7A44E2F68383900BB84C6 /* GiphyImages.swift in Sources */, A9C172DD2EB8C9AC008A7885 /* Trie.swift in Sources */, A955B3F22EC22E9700E1732D /* BrowseView.swift in Sources */, @@ -713,6 +718,7 @@ A9B9A8302EB2CD0B004C9245 /* Emoji.swift in Sources */, A955B3F12EC22E9700E1732D /* BrowseView.swift in Sources */, A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */, + A9F7B3802F8951210071F198 /* EmojiPackImporterView.swift in Sources */, A9BE30F72F5B011A00A57668 /* StickerProtocol.swift in Sources */, A9BE30FC2F5B03F400A57668 /* Sticker.swift in Sources */, A9EC46AE2F6D9E5800E066E6 /* StickerType.swift in Sources */, diff --git a/StickerSlack/StickerSlackApp.swift b/StickerSlack/StickerSlackApp.swift index 6859a52..0271333 100644 --- a/StickerSlack/StickerSlackApp.swift +++ b/StickerSlack/StickerSlackApp.swift @@ -9,12 +9,27 @@ import SwiftUI @main struct StickerSlackApp: App { + @ObservedObject var emojiHoarder: EmojiHoarder = EmojiHoarder() + @ObservedObject var gifhoarder: GifHoarder = GifHoarder() + + @State var importingEmojiPack: Bool = false + @State var pack: EmojiPack = .new() + var body: some Scene { WindowGroup { - ContentView() + ContentView(emojiHoarder: emojiHoarder, gifhoarder: gifhoarder) .onOpenURL { url in - print(EmojiPack(fromShareLink: url)) + importingEmojiPack = true + pack = EmojiPack(fromShareLink: url) + NotificationCenter.default.post(name: .didImportPack, object: pack) + } + .sheet(isPresented: $importingEmojiPack) { + EmojiPackImporterView(emojiHoarder: emojiHoarder, pack: $pack) } } } } + +extension Notification.Name { + static let didImportPack = Self("didImportNote") +} diff --git a/StickerSlack/SwiftUI/ContentView.swift b/StickerSlack/SwiftUI/ContentView.swift index f7b6056..2cddaba 100644 --- a/StickerSlack/SwiftUI/ContentView.swift +++ b/StickerSlack/SwiftUI/ContentView.swift @@ -9,8 +9,8 @@ import SwiftUI import Haptics struct ContentView: View { - @ObservedObject var emojiHoarder: EmojiHoarder = EmojiHoarder() - @ObservedObject var gifhoarder: GifHoarder = GifHoarder() + @ObservedObject var emojiHoarder: EmojiHoarder + @ObservedObject var gifhoarder: GifHoarder var body: some View { Group { @@ -75,5 +75,5 @@ struct ContentView: View { } #Preview { - ContentView(emojiHoarder: EmojiHoarder(localOnly: false)) + ContentView(emojiHoarder: EmojiHoarder(localOnly: false), gifhoarder: GifHoarder(localOnly: false)) } diff --git a/StickerSlack/SwiftUI/EmojiPacks/EmojiPackImporterView.swift b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackImporterView.swift new file mode 100644 index 0000000..86be823 --- /dev/null +++ b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackImporterView.swift @@ -0,0 +1,60 @@ +// +// EmojiPackImporterView.swift +// StickerSlack +// +// Created by neon443 on 10/04/2026. +// + +import SwiftUI + +struct EmojiPackImporterView: View { + @ObservedObject var emojiHoarder: EmojiHoarder + @Binding var pack: EmojiPack + @Environment(\.dismiss) var dismiss + + var body: some View { + EmojiPackDetailView(hoarder: emojiHoarder, pack: $pack) + .overlay(alignment: .bottomLeading) { + Button { + withAnimation { + emojiHoarder.emojiPacks.append(pack) + dismiss() + } + } label: { + Text("Cancel") + .font(.title3) + .padding(5) + } + .modifier(glassButtonIfAv()) + .padding(.leading) + .tint(.gray) + } + .overlay(alignment: .bottomTrailing) { + Button { + withAnimation { + emojiHoarder.emojiPacks.append(pack) + dismiss() + } + } label: { + Text("Add") + .font(.title3) + .bold() + .padding(5) + } + .modifier(glassButtonIfAv()) + .padding(.trailing) + .tint(.purple) + } + } +} + +#Preview { + Color.orange + .ignoresSafeArea(.all) + .sheet(isPresented: .constant(true)) { + EmojiPackImporterView( + emojiHoarder: EmojiHoarder(localOnly: true, skipIndex: true), + pack: .constant(.test) + ) + } +} diff --git a/StickerSlack/SwiftUI/EmojiPacks/EmojiPackManager.swift b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackManager.swift index b38e467..4768b99 100644 --- a/StickerSlack/SwiftUI/EmojiPacks/EmojiPackManager.swift +++ b/StickerSlack/SwiftUI/EmojiPacks/EmojiPackManager.swift @@ -42,7 +42,9 @@ struct EmojiPackManager: View { .toolbar { ToolbarItem { Button { - hoarder.emojiPacks.append(.new()) + withAnimation { + hoarder.emojiPacks.append(.new()) + } } label: { Image(systemName: "plus") }