diff --git a/components/root/mac/view/RootView.swift b/components/root/mac/view/RootView.swift new file mode 100644 index 0000000..ccd1ea7 --- /dev/null +++ b/components/root/mac/view/RootView.swift @@ -0,0 +1,24 @@ +import SwiftUI + +struct RootView: View { + @ObservedObject var vm: RootVM + + init(_ vm: RootVM) { + self.vm = vm + } + + var body: some View { + VStack(spacing: 16) { + Text("Hello, World!") + .font(.largeTitle) + + Text(vm.countText) + .font(.title3.monospacedDigit()) + + Button("Increment") { + rootSet(F.didClickIncrement, true) + } + } + .padding(40) + } +} diff --git a/components/root/root.swift b/components/root/root.swift new file mode 100644 index 0000000..7f17acd --- /dev/null +++ b/components/root/root.swift @@ -0,0 +1,15 @@ +class RootComponent { + let ctrl = DialectController(RootContext()) + static private(set) weak var singleton: RootComponent? + + init() { + Self.singleton = self + rootRegisterEffects(ctrl) + rootRegisterShoulds(ctrl) + otherSetupConsoleLogging(ctrl, "Root") + } + + func setup() { + rootSet(F.didSetup, true) + } +} diff --git a/components/root/rootVM.swift b/components/root/rootVM.swift new file mode 100644 index 0000000..5823662 --- /dev/null +++ b/components/root/rootVM.swift @@ -0,0 +1,11 @@ +import Combine + +final class RootVM: ObservableObject { + @Published var countText = "" + + static private(set) weak var shared: RootVM? + + init() { + Self.shared = self + } +}