opssii 😭

This commit is contained in:
cranci1 2025-06-11 20:51:15 +02:00
parent 3901010309
commit 2fc8e1205e
2 changed files with 6 additions and 51 deletions

View file

@ -6,51 +6,9 @@
//
import SwiftUI
import UIKit
class OrientationManager: ObservableObject {
static let shared = OrientationManager()
@Published var isLocked = false
private var lockedOrientation: UIInterfaceOrientationMask = .all
private init() {}
func lockOrientation() {
let currentOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? .portrait
switch currentOrientation {
case .portrait, .portraitUpsideDown:
lockedOrientation = .portrait
case .landscapeLeft, .landscapeRight:
lockedOrientation = .landscape
default:
lockedOrientation = .portrait
}
isLocked = true
UIDevice.current.setValue(currentOrientation.rawValue, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}
func unlockOrientation(after delay: TimeInterval = 0.0) {
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
self.isLocked = false
self.lockedOrientation = .all
UIViewController.attemptRotationToDeviceOrientation()
}
}
func supportedOrientations() -> UIInterfaceOrientationMask {
return isLocked ? lockedOrientation : .all
}
}
@main
struct SoraApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var settings = Settings()
@StateObject private var moduleManager = ModuleManager()
@StateObject private var librarykManager = LibraryManager()
@ -140,7 +98,9 @@ struct SoraApp: App {
}
}
class AppInfo: NSObject {
@objc class AppInfo: NSObject {
@objc static let shared = AppInfo()
@objc func getBundleIdentifier() -> String {
return Bundle.main.bundleIdentifier ?? "me.cranci.sulfur"
}
@ -159,9 +119,3 @@ class AppInfo: NSObject {
return hasValidBundleId && hasValidDisplayName
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return OrientationManager.shared.supportedOrientations()
}
}

View file

@ -10,7 +10,9 @@ import JavaScriptCore
extension JSContext {
func setupConsoleLogging() {
let consoleObject = JSValue(newObjectIn: self)
let appInfoBridge = AppInfo()
let appInfoBridge = AppInfo.shared
self.setObject(appInfoBridge, forKeyedSubscript: "AppInfo" as NSString)
let consoleLogFunction: @convention(block) (String) -> Void = { message in
Logger.shared.log(message, type: "Debug")
@ -28,7 +30,6 @@ extension JSContext {
Logger.shared.log("JavaScript log: \(message)", type: "Debug")
}
self.setObject(logFunction, forKeyedSubscript: "log" as NSString)
self.setObject(appInfoBridge, forKeyedSubscript: "AppInfo" as NSString)
}
func setupNativeFetch() {