mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-03-11 13:26:17 +00:00
the emojipicker works!
added stickerbrowserdatasorce to give msstickerbrowserview stikcers update messagesviewcontroller to add the msstickerbrowser added Emoji.sticker to get MSSticker from Emoji
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */; };
|
A969D6AE2EA3F1AF00399C05 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */; };
|
||||||
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */; };
|
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */; };
|
||||||
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; };
|
A9773C2F2EA54AF000F3B753 /* EmojiPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */; };
|
||||||
|
A9B9A81C2EB2BCE4004C9245 /* StickerBrowserDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B9A81B2EB2BCE4004C9245 /* StickerBrowserDataSource.swift */; };
|
||||||
|
A9B9A81E2EB2BEF1004C9245 /* StickerBroswerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B9A81D2EB2BEF1004C9245 /* StickerBroswerViewController.swift */; };
|
||||||
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F72EA04F2300215164 /* EmojiHoarder.swift */; };
|
||||||
A9BE06DC2EA657C70033B213 /* ApiEmoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A940FE3C2EA232590016870B /* ApiEmoji.swift */; };
|
A9BE06DC2EA657C70033B213 /* ApiEmoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = A940FE3C2EA232590016870B /* ApiEmoji.swift */; };
|
||||||
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1FA2EA0518800215164 /* SlackResponse.swift */; };
|
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1FA2EA0518800215164 /* SlackResponse.swift */; };
|
||||||
@@ -75,6 +77,8 @@
|
|||||||
A969D6A82EA3F1AF00399C05 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
A969D6A82EA3F1AF00399C05 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||||
A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
|
A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
|
||||||
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPreview.swift; sourceTree = "<group>"; };
|
A9773C2E2EA54AF000F3B753 /* EmojiPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPreview.swift; sourceTree = "<group>"; };
|
||||||
|
A9B9A81B2EB2BCE4004C9245 /* StickerBrowserDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerBrowserDataSource.swift; sourceTree = "<group>"; };
|
||||||
|
A9B9A81D2EB2BEF1004C9245 /* StickerBroswerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerBroswerViewController.swift; sourceTree = "<group>"; };
|
||||||
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
|
A9D15B892EB1142C00404792 /* EmojiPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPack.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@@ -176,6 +180,8 @@
|
|||||||
A969D6A72EA3F1AF00399C05 /* Info.plist */,
|
A969D6A72EA3F1AF00399C05 /* Info.plist */,
|
||||||
A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */,
|
A969D6A92EA3F1AF00399C05 /* MainInterface.storyboard */,
|
||||||
A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */,
|
A969D6AA2EA3F1AF00399C05 /* MessagesViewController.swift */,
|
||||||
|
A9B9A81B2EB2BCE4004C9245 /* StickerBrowserDataSource.swift */,
|
||||||
|
A9B9A81D2EB2BEF1004C9245 /* StickerBroswerViewController.swift */,
|
||||||
);
|
);
|
||||||
path = StickerSlackiMessageExtension;
|
path = StickerSlackiMessageExtension;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -307,11 +313,13 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
A9B9A81E2EB2BEF1004C9245 /* StickerBroswerViewController.swift in Sources */,
|
||||||
A924C3722EA9127200F20781 /* Emoji.swift in Sources */,
|
A924C3722EA9127200F20781 /* Emoji.swift in Sources */,
|
||||||
A9BE06DC2EA657C70033B213 /* ApiEmoji.swift in Sources */,
|
A9BE06DC2EA657C70033B213 /* ApiEmoji.swift in Sources */,
|
||||||
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */,
|
A9BE06DB2EA656B80033B213 /* EmojiHoarder.swift in Sources */,
|
||||||
A935437C2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */,
|
A935437C2EB2A3C800BB80A4 /* FilterCategory.swift in Sources */,
|
||||||
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */,
|
A969D6AF2EA3F1AF00399C05 /* MessagesViewController.swift in Sources */,
|
||||||
|
A9B9A81C2EB2BCE4004C9245 /* StickerBrowserDataSource.swift in Sources */,
|
||||||
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */,
|
A9BE06DD2EA657CF0033B213 /* SlackResponse.swift in Sources */,
|
||||||
A9D15B8A2EB1142C00404792 /* EmojiPack.swift in Sources */,
|
A9D15B8A2EB1142C00404792 /* EmojiPack.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Messages
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
struct Emoji: Codable, Identifiable, Hashable {
|
struct Emoji: Codable, Identifiable, Hashable {
|
||||||
@@ -26,6 +27,13 @@ struct Emoji: Codable, Identifiable, Hashable {
|
|||||||
return (try? Data(contentsOf: localImageURL)) != nil
|
return (try? Data(contentsOf: localImageURL)) != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sticker: MSSticker {
|
||||||
|
guard isLocal else {
|
||||||
|
fatalError("sticker \(name) isnt local")
|
||||||
|
}
|
||||||
|
return try! MSSticker(contentsOfFileURL: localImageURL, localizedDescription: name)
|
||||||
|
}
|
||||||
|
|
||||||
var image: UIImage? {
|
var image: UIImage? {
|
||||||
if let data = try? Data(contentsOf: localImageURL),
|
if let data = try? Data(contentsOf: localImageURL),
|
||||||
let img = UIImage(data: data) {
|
let img = UIImage(data: data) {
|
||||||
|
|||||||
@@ -9,23 +9,30 @@ import UIKit
|
|||||||
import Messages
|
import Messages
|
||||||
|
|
||||||
class MessagesViewController: MSMessagesAppViewController {
|
class MessagesViewController: MSMessagesAppViewController {
|
||||||
var hoard: EmojiHoarder = EmojiHoarder()
|
let dataSource: StickerBrowserDataSource = StickerBrowserDataSource()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
|
// sleep(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Conversation Handling
|
// MARK: - Conversation Handling
|
||||||
|
|
||||||
override func willBecomeActive(with conversation: MSConversation) {
|
override func willBecomeActive(with conversation: MSConversation) {
|
||||||
print(hoard.emojis.count)
|
|
||||||
let l = UILabel()
|
let l = UILabel()
|
||||||
l.frame = CGRect(x: 20, y: 20, width: 1000, height: 40)
|
l.frame = CGRect(x: 20, y: 20, width: 200, height: 40)
|
||||||
l.textColor = .systemOrange
|
l.textColor = .systemOrange
|
||||||
l.text = "\(hoard.emojis.count)"
|
l.text = "hii!"
|
||||||
view.addSubview(l)
|
view.addSubview(l)
|
||||||
view.bringSubviewToFront(l)
|
view.bringSubviewToFront(l)
|
||||||
|
|
||||||
|
let stickerBrowser = MSStickerBrowserView(frame: .zero, stickerSize: .regular)
|
||||||
|
stickerBrowser.frame = CGRect(x: 60, y: 20, width: 200, height: 600)
|
||||||
|
stickerBrowser.dataSource = dataSource
|
||||||
|
view.addSubview(stickerBrowser)
|
||||||
|
stickerBrowser.reloadData()
|
||||||
|
view.bringSubviewToFront(stickerBrowser)
|
||||||
// Called when the extension is about to move from the inactive to active state.
|
// 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.
|
// This will happen when the extension is about to present UI.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// StickerBroswerViewController.swift
|
||||||
|
// StickerSlackiMessageExtension
|
||||||
|
//
|
||||||
|
// Created by neon443 on 29/10/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import Messages
|
||||||
|
|
||||||
|
class StickerBroswerViewController: MSStickerBrowserViewController {
|
||||||
|
var hoarder: EmojiHoarder = EmojiHoarder()
|
||||||
|
|
||||||
|
var emojis: [Emoji] = []
|
||||||
|
|
||||||
|
override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
||||||
|
emojis = hoarder.emojis.filter { $0.isLocal }
|
||||||
|
return emojis.count
|
||||||
|
}
|
||||||
|
|
||||||
|
override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker {
|
||||||
|
return emojis[index].sticker
|
||||||
|
}
|
||||||
|
}
|
||||||
21
StickerSlackiMessageExtension/StickerBrowserDataSource.swift
Normal file
21
StickerSlackiMessageExtension/StickerBrowserDataSource.swift
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// StickerBrowserDataSource.swift
|
||||||
|
// StickerSlackiMessageExtension
|
||||||
|
//
|
||||||
|
// Created by neon443 on 29/10/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Messages
|
||||||
|
|
||||||
|
class StickerBrowserDataSource: NSObject, MSStickerBrowserViewDataSource {
|
||||||
|
var hoarder: EmojiHoarder = EmojiHoarder()
|
||||||
|
|
||||||
|
func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
||||||
|
return hoarder.emojis.filter { $0.isLocal }.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker {
|
||||||
|
return hoarder.emojis.filter { $0.isLocal }[index].sticker
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user