fix: fix keyboard input detection bug on look away reminder
This commit is contained in:
@@ -161,7 +161,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
private func showReminderWindow(_ content: AnyView) {
|
||||
guard let screen = NSScreen.main else { return }
|
||||
|
||||
let window = NSWindow(
|
||||
let window = KeyableWindow(
|
||||
contentRect: screen.frame,
|
||||
styleMask: [.borderless, .fullSizeContentView],
|
||||
backing: .buffered,
|
||||
@@ -181,6 +181,7 @@ private func showReminderWindow(_ content: AnyView) {
|
||||
windowController.showWindow(nil)
|
||||
// Make sure the window is brought to front and made key for key events
|
||||
window.makeKeyAndOrderFront(nil)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
|
||||
reminderWindowController = windowController
|
||||
}
|
||||
@@ -273,3 +274,14 @@ private func showReminderWindow(_ content: AnyView) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom window class that can become key to receive keyboard events
|
||||
class KeyableWindow: NSWindow {
|
||||
override var canBecomeKey: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override var canBecomeMain: Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ struct AppSettings: Codable, Equatable, Hashable {
|
||||
postureTimer: TimerConfiguration = TimerConfiguration(
|
||||
enabled: true, intervalSeconds: 30 * 60),
|
||||
userTimers: [UserTimer] = [],
|
||||
subtleReminderSize: ReminderSize = .large,
|
||||
subtleReminderSize: ReminderSize = .medium,
|
||||
hasCompletedOnboarding: Bool = false,
|
||||
launchAtLogin: Bool = false,
|
||||
playSounds: Bool = true
|
||||
@@ -82,7 +82,7 @@ struct AppSettings: Codable, Equatable, Hashable {
|
||||
blinkTimer: TimerConfiguration(enabled: false, intervalSeconds: 7 * 60),
|
||||
postureTimer: TimerConfiguration(enabled: true, intervalSeconds: 30 * 60),
|
||||
userTimers: [],
|
||||
subtleReminderSize: .large,
|
||||
subtleReminderSize: .medium,
|
||||
hasCompletedOnboarding: false,
|
||||
launchAtLogin: false,
|
||||
playSounds: true
|
||||
|
||||
@@ -30,7 +30,7 @@ struct OnboardingContainerView: View {
|
||||
@State private var postureEnabled = true
|
||||
@State private var postureIntervalMinutes = 30
|
||||
@State private var launchAtLogin = false
|
||||
@State private var subtleReminderSize: ReminderSize = .large
|
||||
@State private var subtleReminderSize: ReminderSize = .medium
|
||||
@State private var isAnimatingOut = false
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ struct SettingsOnboardingView: View {
|
||||
.padding()
|
||||
.glassEffect(.regular, in: .rect(cornerRadius: 12))
|
||||
|
||||
// Subtle Reminder Size Configuration
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Subtle Reminder Size")
|
||||
.font(.headline)
|
||||
@@ -134,7 +133,7 @@ struct SettingsOnboardingView: View {
|
||||
|
||||
if !AppStoreDetector.isAppStoreVersion {
|
||||
Button(action: {
|
||||
if let url = URL(string: "https://buymeacoffee.com/placeholder") {
|
||||
if let url = URL(string: "https://buymeacoffee.com/mikefreno") {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
}) {
|
||||
@@ -198,7 +197,7 @@ struct SettingsOnboardingView: View {
|
||||
#Preview("Settings Onboarding - Launch Disabled") {
|
||||
SettingsOnboardingView(
|
||||
launchAtLogin: .constant(false),
|
||||
subtleReminderSize: .constant(.large),
|
||||
subtleReminderSize: .constant(.medium),
|
||||
isOnboarding: true
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user