forked from aparoksha/adwaita-swift
fixed stored @State properties on App
This commit is contained in:
parent
7ac57d8a59
commit
8f9ff393fd
@ -24,7 +24,8 @@
|
||||
public protocol App {
|
||||
|
||||
/// The app's application ID.
|
||||
var id: String { get }
|
||||
static var id: String { get }
|
||||
|
||||
/// The app's windows.
|
||||
@SceneBuilder var scene: Scene { get }
|
||||
// swiftlint:disable implicitly_unwrapped_optional
|
||||
@ -39,8 +40,12 @@ public protocol App {
|
||||
|
||||
extension App {
|
||||
|
||||
@available(*, deprecated, message: "The 'id' property is removed. Please use the new static id instead.")
|
||||
var id: String { Self.id }
|
||||
|
||||
/// The application's entry point.
|
||||
public static func main() {
|
||||
GTUIApp.appID = Self.id
|
||||
let app = setupApp()
|
||||
app.run()
|
||||
}
|
||||
@ -50,7 +55,7 @@ extension App {
|
||||
/// To run the app, call the ``GTUIApp/run(automaticSetup:manualSetup:)`` function.
|
||||
public static func setupApp() -> GTUIApp {
|
||||
var appInstance = self.init()
|
||||
appInstance.app = GTUIApp(appInstance.id) { appInstance }
|
||||
appInstance.app = GTUIApp(Self.id) { appInstance }
|
||||
GTUIApp.updateHandlers.append { force in
|
||||
var removeIndices: [Int] = []
|
||||
for (index, window) in appInstance.app.sceneStorage.enumerated() {
|
||||
@ -64,7 +69,6 @@ extension App {
|
||||
appInstance.app.sceneStorage.remove(at: index)
|
||||
}
|
||||
}
|
||||
GTUIApp.appID = appInstance.id
|
||||
return appInstance.app
|
||||
}
|
||||
|
||||
|
||||
@ -13,8 +13,7 @@ public class GTUIApp {
|
||||
/// The handlers which are called when a state changes.
|
||||
static var updateHandlers: [(Bool) -> Void] = []
|
||||
/// The app's id for the file name for storing the data.
|
||||
static var appID = "temporary"
|
||||
|
||||
static var appID: String!
|
||||
/// The pointer to the application.
|
||||
public var pointer: UnsafeMutablePointer<GtkApplication>?
|
||||
/// Fields for additional information.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user