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