Skip to content

Commit 6aa695d

Browse files
committed
Added initial window content
1 parent 048678a commit 6aa695d

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed
Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
11
import AppKit
2+
import SwiftUI
23

34
@main
45
class AppDelegate: NSObject, NSApplicationDelegate {
6+
7+
private lazy var window: NSWindow = {
8+
let window = NSWindow(
9+
contentRect: .zero,
10+
styleMask: [.titled, .closable, .miniaturizable],
11+
backing: .buffered,
12+
defer: false
13+
)
14+
15+
window.title = "InterposeKit Example"
16+
window.contentViewController = self.hostingController
17+
18+
return window
19+
}()
20+
21+
private lazy var hostingController: NSViewController = {
22+
return NSHostingController(rootView: ContentView())
23+
}()
24+
25+
func applicationDidFinishLaunching(_ notification: Notification) {
26+
Task { @MainActor in
27+
self.window.center()
28+
self.window.makeKeyAndOrderFront(nil)
29+
}
30+
}
31+
32+
func applicationShouldTerminateAfterLastWindowClosed(
33+
_ sender: NSApplication
34+
) -> Bool {
35+
return true
36+
}
37+
38+
}
539

6-
func applicationDidFinishLaunching(_ notification: Notification) {}
7-
40+
fileprivate struct ContentView: View {
41+
fileprivate var body: some View {
42+
Text("Hello from InterposeKit!")
43+
.font(.title)
44+
.fixedSize()
45+
.padding(200)
46+
}
847
}

0 commit comments

Comments
 (0)