From a10b7c37ddecb305d2496bfc723082cdfa5a50ce Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 20 Oct 2025 13:19:07 +0100 Subject: [PATCH] added sticker count to the corner ps: finally got proof that ts project will work!!!!! "The sticker browser presents the stickers provided by its dataSource property. The data source can dynamically change the list of stickers at runtime." https://developer.apple.com/documentation/messages/msstickerbrowserview#:~:text=The%20data%20source%20can%20dynamically%20change%20the%20list%20of%20stickers%20at%20runtime. --- StickerSlack.xcodeproj/project.pbxproj | 6 ++++++ StickerSlack/EmojiHoarder.swift | 21 ------------------- .../Base.lproj/MainInterface.storyboard | 20 ++++++++++++------ .../MessagesViewController.swift | 10 ++++++++- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index c8b5e0b..2028849 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -20,6 +20,9 @@ A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */; }; A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */; }; A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; }; + A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; }; + A9BE06DC2EA657C70033B213 /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A940FE3C2EA232590016870B /* Emoji.swift */; }; + A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1FA2EA0518800215164 /* SlackResponse.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -280,7 +283,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A9BE06DC2EA657C70033B213 /* Emoji.swift in Sources */, + A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */, A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */, + A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/StickerSlack/EmojiHoarder.swift b/StickerSlack/EmojiHoarder.swift index f1591ba..454e61f 100644 --- a/StickerSlack/EmojiHoarder.swift +++ b/StickerSlack/EmojiHoarder.swift @@ -15,29 +15,8 @@ class EmojiHoarder: ObservableObject { @Published var emojis: [Emoji] init() { -// guard let testURL = Bundle.main.url(forResource: "testData", withExtension: "json") else { -// fatalError("") -// } -// guard let data = try? Data(contentsOf: testURL) else { -// self.testBundle = SlackResponse(ok: false, emoji: [:]) -// return -// } -// guard let decoded = try? JSONDecoder().decode(SlackResponse.self, from: data) else { -// fatalError("couldnt decode :sob:") -// } -// self.testBundle = decoded - let data = try! Data(contentsOf: endpoint) let decoded: [SlackResponse] = try! JSONDecoder().decode([SlackResponse].self, from: data) self.emojis = decoded.map { Emoji(name: $0.name, url: $0.imageUrl) } -// Task { -// for i in emojis.indices { -// let newEmoji = await emojis[i].grabImage() -// DispatchQueue.main.async { -// self.emojis[i] = newEmoji -// self.emojis = self.emojis -// } -// } -// } } } diff --git a/StickerSlackiMessageExtension/Base.lproj/MainInterface.storyboard b/StickerSlackiMessageExtension/Base.lproj/MainInterface.storyboard index 36e2d49..f2cbcc0 100644 --- a/StickerSlackiMessageExtension/Base.lproj/MainInterface.storyboard +++ b/StickerSlackiMessageExtension/Base.lproj/MainInterface.storyboard @@ -1,37 +1,45 @@ - + + - + + - + - + + - + + + + + + diff --git a/StickerSlackiMessageExtension/MessagesViewController.swift b/StickerSlackiMessageExtension/MessagesViewController.swift index ebd9f72..ef1dfb8 100644 --- a/StickerSlackiMessageExtension/MessagesViewController.swift +++ b/StickerSlackiMessageExtension/MessagesViewController.swift @@ -9,7 +9,8 @@ import UIKit import Messages class MessagesViewController: MSMessagesAppViewController { - + var hoard: EmojiHoarder = EmojiHoarder() + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. @@ -18,6 +19,13 @@ class MessagesViewController: MSMessagesAppViewController { // MARK: - Conversation Handling override func willBecomeActive(with conversation: MSConversation) { + print(hoard.emojis.count) + let l = UILabel() + l.frame = CGRect(x: 20, y: 20, width: 1000, height: 40) + l.textColor = .systemOrange + l.text = "\(hoard.emojis.count)" + view.addSubview(l) + view.bringSubviewToFront(l) // Called when the extension is about to move from the inactive to active state. // This will happen when the extension is about to present UI.