Files
neon443 a3629fe642 masssive changes sob
MUCH faster emojihoarder init, async stuff yaya
faster trie building
and downloaded sticker building
loading spinners if trie.dict is empty
put slack emojis in library/slack and giphy in /giphy
added a lil info thingy to stickerpicker and  a button to open stickerslack if no stickers downloaded
update file.contains to have a . when searching for fule name extensions
more logging for nil stuff in sticker data source
moved picker on browseview out of the overlay
fixed the contentinsets for uikit emoji list
haptic when u click the confetti thingy for having all the emojis lol
consolidated the continue button, added stickerslack icon to welcome view
2026-04-05 22:15:13 +01:00

117 lines
4.2 KiB
Swift

//
// MessagesViewController.swift
// StickerSlackiMessageExtension
//
// Created by neon443 on 18/10/2025.
//
import UIKit
import Messages
import SwiftUI
class MessagesViewController: MSMessagesAppViewController {
let dataSource: StickerBrowserDataSource = StickerBrowserDataSource()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// sleep(5)
}
// MARK: - Conversation Handling
override func willBecomeActive(with conversation: MSConversation) {
let stickerBrowser = MSStickerBrowserView(frame: .zero, stickerSize: .small)
stickerBrowser.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
stickerBrowser.dataSource = dataSource
stickerBrowser.autoresizingMask = [.flexibleWidth]
guard stickerBrowser.dataSource?.numberOfStickers(in: stickerBrowser) != 0 else {
let swiftUIView = NoStickersView()
let hostingController = UIHostingController(rootView: swiftUIView)
addChild(hostingController)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)
let link = UIButton()
link.setTitle("Open StickerSlack", for: .normal)
link.setImage(UIImage(systemName: "arrow.up.right.square"), for: .normal)
link.setTitleColor(.systemBlue, for: .normal)
link.frame = view.frame
link.translatesAutoresizingMaskIntoConstraints = false
link.addTarget(self, action: #selector(openStickerSlack), for: .touchUpInside)
view.addSubview(link)
NSLayoutConstraint.activate([
hostingController.view.centerXAnchor.constraint(equalTo: view.centerXAnchor),
hostingController.view.centerYAnchor.constraint(equalTo: view.centerYAnchor),
hostingController.view.widthAnchor.constraint(equalTo: view.widthAnchor),
hostingController.view.heightAnchor.constraint(equalTo: view.heightAnchor),
link.centerXAnchor.constraint(equalTo: view.centerXAnchor),
link.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
link.heightAnchor.constraint(equalToConstant: 50)
])
return
}
view.addSubview(stickerBrowser)
stickerBrowser.reloadData()
view.bringSubviewToFront(stickerBrowser)
// 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.
// Use this method to configure the extension and restore previously stored state.
}
override func didResignActive(with conversation: MSConversation) {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dismisses the extension, changes to a different
// conversation or quits Messages.
// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
}
override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.
// Use this method to trigger UI updates in response to the message.
}
override func didStartSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user taps the send button.
}
override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user deletes the message without sending it.
// Use this to clean up state related to the deleted message.
}
override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called before the extension transitions to a new presentation style.
// Use this method to prepare for the change in presentation style.
}
override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called after the extension transitions to a new presentation style.
// Use this method to finalize any behaviors associated with the change in presentation style.
}
@objc
func openStickerSlack() {
if let url = URL(string: "stickerslack://") {
self.extensionContext?.open(url) { success in
print("open url: \(success)")
}
}
}
}