poke-gate 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
|
+
import ServiceManagement
|
|
2
3
|
|
|
3
4
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
4
5
|
var service: GateService?
|
|
@@ -17,13 +18,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
17
18
|
struct Poke_macOS_GateApp: App {
|
|
18
19
|
@StateObject private var service = GateService()
|
|
19
20
|
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
20
|
-
|
|
21
21
|
var body: some Scene {
|
|
22
22
|
MenuBarExtra {
|
|
23
23
|
PopoverContent(service: service)
|
|
24
24
|
.onAppear {
|
|
25
25
|
service.autoStartIfNeeded()
|
|
26
26
|
appDelegate.service = service
|
|
27
|
+
checkLoginItemPrompt()
|
|
27
28
|
}
|
|
28
29
|
} label: {
|
|
29
30
|
Image(systemName: menuBarIcon)
|
|
@@ -51,6 +52,37 @@ struct Poke_macOS_GateApp: App {
|
|
|
51
52
|
.windowResizability(.contentSize)
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
private func checkLoginItemPrompt() {
|
|
56
|
+
let dismissed = UserDefaults.standard.bool(forKey: "loginItemPromptDismissed")
|
|
57
|
+
let alreadyEnabled = SMAppService.mainApp.status == .enabled
|
|
58
|
+
if dismissed || alreadyEnabled { return }
|
|
59
|
+
|
|
60
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
61
|
+
let alert = NSAlert()
|
|
62
|
+
alert.messageText = "Start on login?"
|
|
63
|
+
alert.informativeText = "Would you like Poke Gate to start automatically when you log in?"
|
|
64
|
+
alert.addButton(withTitle: "Enable")
|
|
65
|
+
alert.addButton(withTitle: "Not now")
|
|
66
|
+
alert.addButton(withTitle: "Don't ask again")
|
|
67
|
+
alert.alertStyle = .informational
|
|
68
|
+
|
|
69
|
+
NSApp.activate(ignoringOtherApps: true)
|
|
70
|
+
let response = alert.runModal()
|
|
71
|
+
|
|
72
|
+
switch response {
|
|
73
|
+
case .alertFirstButtonReturn:
|
|
74
|
+
try? SMAppService.mainApp.register()
|
|
75
|
+
UserDefaults.standard.set(true, forKey: "loginItemPromptDismissed")
|
|
76
|
+
case .alertSecondButtonReturn:
|
|
77
|
+
break
|
|
78
|
+
case .alertThirdButtonReturn:
|
|
79
|
+
UserDefaults.standard.set(true, forKey: "loginItemPromptDismissed")
|
|
80
|
+
default:
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
54
86
|
private var menuBarIcon: String {
|
|
55
87
|
switch service.status {
|
|
56
88
|
case .connected: "door.left.hand.open"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
|
+
import ServiceManagement
|
|
2
3
|
|
|
3
4
|
struct SettingsView: View {
|
|
4
5
|
@ObservedObject var service: GateService
|
|
5
6
|
@Environment(\.dismiss) private var dismiss
|
|
7
|
+
@State private var launchAtLogin = SMAppService.mainApp.status == .enabled
|
|
6
8
|
|
|
7
9
|
var body: some View {
|
|
8
10
|
VStack(alignment: .leading, spacing: 16) {
|
|
@@ -86,6 +88,28 @@ struct SettingsView: View {
|
|
|
86
88
|
.cornerRadius(8)
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
VStack(alignment: .leading, spacing: 8) {
|
|
92
|
+
Text("GENERAL")
|
|
93
|
+
.font(.caption2)
|
|
94
|
+
.foregroundStyle(.tertiary)
|
|
95
|
+
.textCase(.uppercase)
|
|
96
|
+
.tracking(0.5)
|
|
97
|
+
|
|
98
|
+
Toggle("Start Poke Gate on login", isOn: $launchAtLogin)
|
|
99
|
+
.font(.subheadline)
|
|
100
|
+
.onChange(of: launchAtLogin) { _, newValue in
|
|
101
|
+
do {
|
|
102
|
+
if newValue {
|
|
103
|
+
try SMAppService.mainApp.register()
|
|
104
|
+
} else {
|
|
105
|
+
try SMAppService.mainApp.unregister()
|
|
106
|
+
}
|
|
107
|
+
} catch {
|
|
108
|
+
launchAtLogin = !newValue
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
89
113
|
HStack {
|
|
90
114
|
Spacer()
|
|
91
115
|
Button("Close") {
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
"@executable_path/../Frameworks",
|
|
268
268
|
);
|
|
269
269
|
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
|
270
|
-
MARKETING_VERSION = 0.1.
|
|
270
|
+
MARKETING_VERSION = 0.1.7;
|
|
271
271
|
PRODUCT_BUNDLE_IDENTIFIER = "dev.fka.Poke-macOS-Gate";
|
|
272
272
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
273
273
|
REGISTER_APP_GROUPS = YES;
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"@executable_path/../Frameworks",
|
|
303
303
|
);
|
|
304
304
|
MACOSX_DEPLOYMENT_TARGET = 26.0;
|
|
305
|
-
MARKETING_VERSION = 0.1.
|
|
305
|
+
MARKETING_VERSION = 0.1.7;
|
|
306
306
|
PRODUCT_BUNDLE_IDENTIFIER = "dev.fka.Poke-macOS-Gate";
|
|
307
307
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
308
308
|
REGISTER_APP_GROUPS = YES;
|