mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fix "not using scene lifecycle" crash
This commit is contained in:
5 files changed
+102
-60
No files matched your search
@@ -19,6 +19,9 @@
|
||||
A9104C7C2EB3AE6300D160EA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A949B1EF2EA04E8200215164 /* Assets.xcassets */; };
|
||||
A9104C7F2EB4022500D160EA /* MSSticker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9104C7D2EB4022500D160EA /* MSSticker.swift */; };
|
||||
A9104C802EB4022500D160EA /* MSSticker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9104C7D2EB4022500D160EA /* MSSticker.swift */; };
|
||||
A9164993307F8B3F008D1B9D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9164991307F8B3F008D1B9D /* SceneDelegate.swift */; };
|
||||
A91649953080BA3D008D1B9D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9164991307F8B3F008D1B9D /* SceneDelegate.swift */; };
|
||||
A91649983080BA69008D1B9D /* StickerSlackApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949B1F12EA04E8200215164 /* StickerSlackApp.swift */; };
|
||||
A917BACE2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917BACD2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift */; };
|
||||
A917BACF2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917BACD2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift */; };
|
||||
A917BAD12F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917BAD02F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift */; };
|
||||
@@ -213,6 +216,7 @@
|
||||
A9104C722EB3AE4700D160EA /* Icon.pxd */ = {isa = PBXFileReference; lastKnownFileType = file; path = Icon.pxd; sourceTree = "<group>"; };
|
||||
A9104C732EB3AE4700D160EA /* StickerSlack.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = StickerSlack.icon; sourceTree = "<group>"; };
|
||||
A9104C7D2EB4022500D160EA /* MSSticker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MSSticker.swift; sourceTree = "<group>"; };
|
||||
A9164991307F8B3F008D1B9D /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
A917BACD2F9B787B008DB31E /* EmojiCollectionViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiCollectionViewRepresentable.swift; sourceTree = "<group>"; };
|
||||
A917BAD02F9B7B68008DB31E /* PlainEmojiCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlainEmojiCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
A921C2DE2ED067BB00E57B1A /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
|
||||
@@ -443,6 +447,7 @@
|
||||
A9A7A4502F68447F00BB84C6 /* Models */,
|
||||
A924C3742EA9134C00F20781 /* StickerSlack.entitlements */,
|
||||
A949B1F12EA04E8200215164 /* StickerSlackApp.swift */,
|
||||
A9164991307F8B3F008D1B9D /* SceneDelegate.swift */,
|
||||
A9BE30EB2F5AFE1E00A57668 /* StickerType.swift */,
|
||||
A9BE30F42F5B011400A57668 /* Stickers */,
|
||||
A9E8C7942FF72550009A38B5 /* EmojiHoarder */,
|
||||
@@ -794,6 +799,7 @@
|
||||
A9034533301F42DB00EFFFDF /* UIColor.swift in Sources */,
|
||||
A9E8C78F2FF71D8C009A38B5 /* DownloadedViewController.swift in Sources */,
|
||||
A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */,
|
||||
A91649953080BA3D008D1B9D /* SceneDelegate.swift in Sources */,
|
||||
A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */,
|
||||
A9E8C7A92FF95FEC009A38B5 /* SearchViewController.swift in Sources */,
|
||||
A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */,
|
||||
@@ -843,6 +849,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A91649983080BA69008D1B9D /* StickerSlackApp.swift in Sources */,
|
||||
A9DB1DCB303DBAF30007C177 /* CGFloat.swift in Sources */,
|
||||
A99C4B8E2FF2E8D30070CBA5 /* TabbedContentView.swift in Sources */,
|
||||
A9034536301FC41600EFFFDF /* EmojiPackImporterViewController.swift in Sources */,
|
||||
@@ -876,6 +883,7 @@
|
||||
A955B3ED2EC22C4A00E1732D /* DownloadedView.swift in Sources */,
|
||||
A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */,
|
||||
A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */,
|
||||
A9164993307F8B3F008D1B9D /* SceneDelegate.swift in Sources */,
|
||||
A97322A22FA7B9C8004B657D /* JumboMoji.swift in Sources */,
|
||||
A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */,
|
||||
A98FA65B2FF3B29700D50212 /* EmojiTableView.swift in Sources */,
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.neon443.stickerslack</string>
|
||||
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>stickerslack</string>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// SceneDelegate.swift
|
||||
// StickerSlack
|
||||
//
|
||||
// Created by neon443 on 14/10/2026.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
guard let windowScene = scene as? UIWindowScene else { return }
|
||||
window = UIWindow(windowScene: windowScene)
|
||||
|
||||
window?.rootViewController = TabbedContentView()
|
||||
(window?.rootViewController! as! TabbedContentView).setupTabs(with: StickerSlackApp.emojiHoarder)
|
||||
window?.makeKeyAndVisible()
|
||||
|
||||
if StickerSlackApp.emojiHoarder.showWelcome {
|
||||
let welcomeView = UIHostingController(rootView: WelcomeView(emojiHoarder: StickerSlackApp.emojiHoarder))
|
||||
if welcomeView.sheetPresentationController != nil {
|
||||
self.window?.rootViewController?.present(welcomeView, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
||||
guard let context = URLContexts.first else { return }
|
||||
|
||||
guard UIApplication.shared.canOpenURL(context.url) else { return }
|
||||
guard let rootViewController = window?.rootViewController else { return }
|
||||
|
||||
guard var imported = EmojiPack(fromShareLink: context.url) else { return }
|
||||
let importView = EmojiPackImporterViewController(emojiHoarder: StickerSlackApp.emojiHoarder, pack: imported)
|
||||
|
||||
if let sheet = importView.sheetPresentationController {
|
||||
sheet.detents = [.large()]
|
||||
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
|
||||
sheet.prefersEdgeAttachedInCompactHeight = true
|
||||
sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
|
||||
sheet.prefersGrabberVisible = true
|
||||
}
|
||||
|
||||
rootViewController.present(importView, animated: true)
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// <#code#>
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// <#code#>
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// <#code#>
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// <#code#>
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// <#code#>
|
||||
}
|
||||
}
|
||||
@@ -5,72 +5,30 @@
|
||||
// Created by neon443 on 15/10/2025.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
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(emojiHoarder: emojiHoarder, gifhoarder: gifhoarder)
|
||||
// .onOpenURL { url in
|
||||
// if let imported = EmojiPack(fromShareLink: url) {
|
||||
// importingEmojiPack = true
|
||||
// pack = imported
|
||||
// }
|
||||
// }
|
||||
// .sheet(isPresented: $importingEmojiPack) {
|
||||
// EmojiPackImporterView(emojiHoarder: emojiHoarder, pack: $pack)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@main
|
||||
class StickerSlackApp: UIResponder, UIApplicationDelegate {
|
||||
var emojiHoarder: EmojiHoarder = .init()
|
||||
static var emojiHoarder: EmojiHoarder = .init()
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window?.rootViewController = TabbedContentView()
|
||||
(window?.rootViewController! as! TabbedContentView).setupTabs(with: emojiHoarder)
|
||||
window?.makeKeyAndVisible()
|
||||
|
||||
if emojiHoarder.showWelcome {
|
||||
let welcomeView = UIHostingController(rootView: WelcomeView(emojiHoarder: emojiHoarder))
|
||||
if welcomeView.sheetPresentationController != nil {
|
||||
self.window?.rootViewController?.present(welcomeView, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?
|
||||
) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
||||
guard app.canOpenURL(url) else { return false }
|
||||
guard let rootViewController = window?.rootViewController else { return false }
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
configurationForConnecting connectingSceneSession: UISceneSession,
|
||||
options: UIScene.ConnectionOptions
|
||||
) -> UISceneConfiguration {
|
||||
let config = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
config.delegateClass = SceneDelegate.self
|
||||
|
||||
guard let imported = EmojiPack(fromShareLink: url) else { return false }
|
||||
// let importView = EmojiPackDetailViewController(with: emojiHoarder, andPack: imported)
|
||||
let importView = EmojiPackImporterViewController(emojiHoarder: emojiHoarder, pack: imported)
|
||||
// let importView = UIHostingController(rootView: EmojiPackImporterView(emojiHoarder: emojiHoarder, pack: .constant(imported)))
|
||||
|
||||
if let sheet = importView.sheetPresentationController {
|
||||
sheet.detents = [.large()]
|
||||
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
|
||||
sheet.prefersEdgeAttachedInCompactHeight = true
|
||||
sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
|
||||
sheet.prefersGrabberVisible = true
|
||||
}
|
||||
|
||||
rootViewController.present(importView, animated: true)
|
||||
return true
|
||||
return config
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,8 @@ class EmojiPackDetailViewController: UIViewController {
|
||||
|
||||
var searchView: SearchViewController
|
||||
|
||||
var importing: Bool = false
|
||||
|
||||
init(with hoarder: EmojiHoarder, andPack pack: EmojiPack) {
|
||||
self.hoarder = hoarder
|
||||
self.pack = pack
|
||||
@@ -138,6 +140,8 @@ class EmojiPackDetailViewController: UIViewController {
|
||||
self.setToolbar()
|
||||
|
||||
collectionView.onEditChange = { self.setToolbar() }
|
||||
|
||||
refreshUI()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
@@ -160,16 +164,13 @@ class EmojiPackDetailViewController: UIViewController {
|
||||
textField.text = self.pack.name
|
||||
textField.placeholder = self.pack.name
|
||||
}
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
|
||||
self.dismiss(animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
||||
guard let textField = alert.textFields?.first,
|
||||
let text = textField.text else { return }
|
||||
self.pack.name = text
|
||||
self.hoarder.updateEmojiPack(self.pack)
|
||||
self.refreshUI()
|
||||
self.dismiss(animated: true)
|
||||
}))
|
||||
alert.preferredAction = alert.actions.last
|
||||
self.present(alert, animated: true)
|
||||
@@ -260,8 +261,10 @@ class EmojiPackDetailViewController: UIViewController {
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
if !importing {
|
||||
guard let updatedPack = hoarder.emojiPacks.first(where: { $0.id == pack.id }) else { return }
|
||||
self.pack = updatedPack
|
||||
}
|
||||
refreshUI()
|
||||
}
|
||||
|
||||
|
||||