mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
YAYAYYAAY FIXED THE STUPID STATE ISSUES AND SWITCHING PACKS
updated rootviewcontroller to remove previous trailingvc and add new one added proper reload function that rebuilds the sticker array updated the subtitle for packs, slightly smaller and gray font
This commit is contained in:
7 files changed
+61
-255
No files matched your search
@@ -1,106 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "2700"
|
|
||||||
wasCreatedForAppExtension = "YES"
|
|
||||||
version = "2.0">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES"
|
|
||||||
buildArchitectures = "Automatic">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A9A6A09C2FE15CC700A25B5C"
|
|
||||||
BuildableName = "StickerExtension.appex"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
shouldAutocreateTestPlan = "YES">
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
selectedDebuggerIdentifier = ""
|
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
|
||||||
launchStyle = "0"
|
|
||||||
askForAppToLaunch = "Yes"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
debugServiceExtension = "internal"
|
|
||||||
allowLocationSimulation = "YES"
|
|
||||||
launchAutomaticallySubstyle = "2"
|
|
||||||
queueDebuggingEnabled = "No">
|
|
||||||
<RemoteRunnable
|
|
||||||
runnableDebuggingMode = "1"
|
|
||||||
BundleIdentifier = "com.apple.MobileSMS">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A9A6A09C2FE15CC700A25B5C"
|
|
||||||
BuildableName = "StickerExtension.appex"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</RemoteRunnable>
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
askForAppToLaunch = "Yes"
|
|
||||||
launchAutomaticallySubstyle = "2">
|
|
||||||
<BuildableProductRunnable
|
|
||||||
runnableDebuggingMode = "0">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "2700"
|
|
||||||
wasCreatedForAppExtension = "YES"
|
|
||||||
version = "2.0">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES"
|
|
||||||
buildArchitectures = "Automatic">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A986A6AC2EB658DF00B6E0FA"
|
|
||||||
BuildableName = "StickerSlackiMessageApp.appex"
|
|
||||||
BlueprintName = "StickerSlackiMessageApp"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
shouldAutocreateTestPlan = "YES">
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
selectedDebuggerIdentifier = ""
|
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
|
||||||
launchStyle = "0"
|
|
||||||
askForAppToLaunch = "Yes"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
debugServiceExtension = "internal"
|
|
||||||
allowLocationSimulation = "YES"
|
|
||||||
launchAutomaticallySubstyle = "2"
|
|
||||||
queueDebuggingEnabled = "No">
|
|
||||||
<BuildableProductRunnable
|
|
||||||
runnableDebuggingMode = "0">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
askForAppToLaunch = "Yes"
|
|
||||||
launchAutomaticallySubstyle = "2">
|
|
||||||
<BuildableProductRunnable
|
|
||||||
runnableDebuggingMode = "0">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "A949B1DE2EA04C0B00215164"
|
|
||||||
BuildableName = "StickerSlack.app"
|
|
||||||
BlueprintName = "StickerSlack"
|
|
||||||
ReferencedContainer = "container:StickerSlack.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildableProductRunnable>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
||||||
@@ -44,7 +44,7 @@ class BaseHoarder: Hoarder {
|
|||||||
|
|
||||||
nonisolated func buildDownloadedStickers(for stickerType: String) async {
|
nonisolated func buildDownloadedStickers(for stickerType: String) async {
|
||||||
var newSet: Set<String> = []
|
var newSet: Set<String> = []
|
||||||
let url = await BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
let url = BaseHoarder.library.appendingPathComponent(stickerType, conformingTo: .directory)
|
||||||
|
|
||||||
if let files = try? FileManager.default.contentsOfDirectory(atPath: url.safePath) {
|
if let files = try? FileManager.default.contentsOfDirectory(atPath: url.safePath) {
|
||||||
for file in files {
|
for file in files {
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ class MessagesAppViewController: MSMessagesAppViewController {
|
|||||||
|
|
||||||
// MARK: - Conversation Handling
|
// MARK: - Conversation Handling
|
||||||
|
|
||||||
override func willBecomeActive(with conversation: MSConversation) {
|
override func willBecomeActive(with conversation: MSConversation) {}
|
||||||
|
|
||||||
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
let splitView = MessagesRootViewController(
|
let splitView = MessagesRootViewController(
|
||||||
|
emojiHoarder: emojiHoarder,
|
||||||
leading: MessagesPackListView(hoarder: emojiHoarder),
|
leading: MessagesPackListView(hoarder: emojiHoarder),
|
||||||
trailing: StickerBrowserViewController(emojiHoarder: emojiHoarder, pack: nil)
|
trailing: StickerBrowserViewController(emojiHoarder: emojiHoarder, pack: nil)
|
||||||
)
|
)
|
||||||
@@ -32,7 +35,6 @@ class MessagesAppViewController: MSMessagesAppViewController {
|
|||||||
splitView.view.topAnchor.constraint(equalTo: view.topAnchor),
|
splitView.view.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
splitView.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
splitView.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
||||||
])
|
])
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didResignActive(with conversation: MSConversation) {
|
override func didResignActive(with conversation: MSConversation) {
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ class MessagesPackListView: UITableViewController {
|
|||||||
|
|
||||||
if let pack = packFor(indexPath: indexPath) {
|
if let pack = packFor(indexPath: indexPath) {
|
||||||
config.text = pack.name
|
config.text = pack.name
|
||||||
config.secondaryText = pack.description
|
|
||||||
config.textProperties.font = UIFont.systemFont(ofSize: 14)
|
config.textProperties.font = UIFont.systemFont(ofSize: 14)
|
||||||
config.secondaryTextProperties.font = UIFont.systemFont(ofSize: 14)
|
config.secondaryText = pack.description
|
||||||
|
config.secondaryTextProperties.font = UIFont.systemFont(ofSize: 12)
|
||||||
|
config.secondaryTextProperties.color = .systemGray
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.contentConfiguration = config
|
cell.contentConfiguration = config
|
||||||
|
|||||||
@@ -10,13 +10,35 @@ import UIKit
|
|||||||
import Messages
|
import Messages
|
||||||
|
|
||||||
class MessagesRootViewController: UIViewController {
|
class MessagesRootViewController: UIViewController {
|
||||||
let leadingVC: UIViewController
|
var emojiHoarder: EmojiHoarder
|
||||||
let trailingVC: UIViewController
|
var leadingVC: MessagesPackListView
|
||||||
|
var trailingVC: UIViewController
|
||||||
|
|
||||||
init(leading: UIViewController, trailing: UIViewController) {
|
init(
|
||||||
self.leadingVC = leading
|
emojiHoarder: EmojiHoarder,
|
||||||
|
leading: UIViewController,
|
||||||
|
trailing: UIViewController
|
||||||
|
) {
|
||||||
|
self.emojiHoarder = emojiHoarder
|
||||||
|
self.leadingVC = MessagesPackListView(hoarder: emojiHoarder)
|
||||||
self.trailingVC = trailing
|
self.trailingVC = trailing
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
leadingVC.onSelect = { pack in
|
||||||
|
self.trailingVC.view.removeFromSuperview()
|
||||||
|
self.trailingVC.removeFromParent()
|
||||||
|
self.trailingVC.didMove(toParent: nil)
|
||||||
|
self.trailingVC = StickerBrowserViewController(emojiHoarder: emojiHoarder, pack: pack)
|
||||||
|
self.addChild(self.trailingVC)
|
||||||
|
self.view.addSubview(self.trailingVC.view)
|
||||||
|
self.trailingVC.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
self.trailingVC.view.topAnchor.constraint(equalTo: self.view.topAnchor),
|
||||||
|
self.trailingVC.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
|
||||||
|
self.trailingVC.view.leadingAnchor.constraint(equalTo: self.leadingVC.view.trailingAnchor),
|
||||||
|
self.trailingVC.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
|
||||||
|
])
|
||||||
|
self.trailingVC.didMove(toParent: self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
|||||||
@@ -13,64 +13,49 @@ import SwiftUI
|
|||||||
class StickerBrowserViewController: MSStickerBrowserViewController {
|
class StickerBrowserViewController: MSStickerBrowserViewController {
|
||||||
var emojiHoarder: EmojiHoarder!
|
var emojiHoarder: EmojiHoarder!
|
||||||
var pack: EmojiPack?
|
var pack: EmojiPack?
|
||||||
|
var msStickers: [MSSticker] = []
|
||||||
|
|
||||||
init(emojiHoarder: EmojiHoarder, pack: EmojiPack?) {
|
init(emojiHoarder: EmojiHoarder, pack: EmojiPack?) {
|
||||||
self.emojiHoarder = emojiHoarder
|
self.emojiHoarder = emojiHoarder
|
||||||
self.pack = pack
|
self.pack = pack
|
||||||
|
|
||||||
super.init(stickerSize: .small)
|
super.init(stickerSize: .small)
|
||||||
|
|
||||||
|
reload()
|
||||||
|
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(reload),
|
||||||
|
name: EmojiHoarder.NotifCategory.downloadedEmojis.name,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
@objc func reload() {
|
||||||
|
msStickers = []
|
||||||
|
let names: [String]
|
||||||
if let pack {
|
if let pack {
|
||||||
return emojiHoarder.downloadedStickers.union(pack.items).count
|
names = emojiHoarder.downloadedStickers.intersection(pack.items).sorted()
|
||||||
} else {
|
} else {
|
||||||
return emojiHoarder.downloadedStickers.count
|
names = emojiHoarder.downloadedStickers.sorted()
|
||||||
}
|
}
|
||||||
|
for name in names {
|
||||||
|
guard let emoji = emojiHoarder.trie.dict[name],
|
||||||
|
let msSticker = emoji.msSticker else { continue }
|
||||||
|
msStickers.append(msSticker)
|
||||||
|
}
|
||||||
|
stickerBrowserView.reloadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int {
|
||||||
|
return msStickers.count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker {
|
override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker {
|
||||||
let emojiName: String
|
return msStickers[index]
|
||||||
if let pack {
|
|
||||||
emojiName = emojiHoarder.downloadedStickers.union(pack.items).sorted()[index]
|
|
||||||
} else {
|
|
||||||
emojiName = emojiHoarder.downloadedStickersArr[index]
|
|
||||||
}
|
|
||||||
guard let emoji = emojiHoarder.trie.dict[emojiName],
|
|
||||||
let msSticker = emoji.msSticker else {
|
|
||||||
fatalError()
|
|
||||||
}
|
|
||||||
return msSticker
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
|
|
||||||
// DispatchQueue.main.asyncAfter(deadline: .now()+3) {
|
|
||||||
// self.stickerBrowserView.reloadData()
|
|
||||||
// }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
|
||||||
super.viewWillAppear(animated)
|
|
||||||
stickerBrowserView.reloadData()
|
|
||||||
// guard numberOfStickers(in: self.stickerBrowserView) != 0 else {
|
|
||||||
// let swiftUIView = NoStickersView()
|
|
||||||
// let hostingController = UIHostingController(rootView: swiftUIView)
|
|
||||||
// hostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
// view.addSubview(hostingController.view)
|
|
||||||
//
|
|
||||||
// NSLayoutConstraint.activate([
|
|
||||||
// hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
||||||
// hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
||||||
// hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
|
|
||||||
// hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
||||||
// ])
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||