TokamakUI / Tokamak

SwiftUI-compatible framework for building browser apps with WebAssembly and native apps for other platforms
Apache License 2.0
2.62k stars 111 forks source link

Add configuration options to `App` to choose reconciler #495

Closed carson-katri closed 2 years ago

carson-katri commented 2 years ago

This PR enables support for App + Scene in the Fiber reconciler, and provides a way for apps to specify whether they want to use the FiberReconciler, and if they want to enable custom layout.

@main
struct MyApp: App {
  static let _configuration: _AppConfiguration = .init(
    reconciler: .fiber(useDynamicLayout: true)
  )

  var body: some Scene {
    WindowGroup {
      Text("Hello, world!")
    }
  }
}
ezraberch commented 2 years ago

I'd prefer this interface:

  static let _configuration: _AppConfiguration = .init(
    useReconciler: .fiber,
    shouldLayout: true
  )
carson-katri commented 2 years ago

I updated it to this:

static let _configuration: _AppConfiguration = .init(
  reconciler: .fiber(shouldLayout: true)
)

Reconciler options are:

.stack
.fiber()
.fiber(shouldLayout: true)

You can also pass the root environment in the configuration. Let me know what you think.

carson-katri commented 2 years ago

App should now properly handle @State.