-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlankieApp.swift
79 lines (69 loc) · 2 KB
/
BlankieApp.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// BlankieApp.swift
// Blankie
//
// Created by Cody Bromley on 12/30/24.
//
import SwiftData
import SwiftUI
@main
struct BlankieApp: App {
@StateObject private var audioManager = AudioManager.shared
@StateObject private var windowObserver = WindowObserver.shared
@State private var showingAbout = false
@State private var showingShortcuts = false
@State private var showingNewPresetPopover = false
@State private var presetName = ""
var body: some Scene {
WindowGroup {
WindowDefaults.defaultContentView(
showingAbout: $showingAbout,
showingShortcuts: $showingShortcuts,
showingNewPresetPopover: $showingNewPresetPopover,
presetName: $presetName
)
}
.defaultSize(width: WindowDefaults.defaultWidth, height: WindowDefaults.defaultHeight)
.windowToolbarStyle(.unified)
.commands {
AppCommands(showingAbout: $showingAbout, hasWindow: $windowObserver.hasVisibleWindow)
}
MenuBarExtra("Blankie", systemImage: "waveform") {
Button("Show Main Window") {
NSApp.activate(ignoringOtherApps: true)
}
Divider()
Button("About Blankie") {
NSApp.activate(ignoringOtherApps: true)
showingAbout = true
}
Divider()
Button("Quit Blankie") {
NSApplication.shared.terminate(nil)
}
}
Settings {
PreferencesView()
}
}
}
#if DEBUG
struct BlankieApp_Previews: PreviewProvider {
static var previews: some View {
Group {
ForEach(["Light Mode", "Dark Mode"], id: \.self) { scheme in
WindowDefaults.defaultContentView(
showingAbout: .constant(false),
showingShortcuts: .constant(false),
showingNewPresetPopover: .constant(false),
presetName: .constant("")
)
.frame(width: 450, height: 450)
.preferredColorScheme(scheme == "Dark Mode" ? .dark : .light)
.previewDisplayName(scheme)
}
}
.previewLayout(.sizeThatFits)
}
}
#endif