fix: settings nav button bug

This commit is contained in:
Michael Freno
2026-01-14 20:15:24 -05:00
parent 8815315059
commit 8e5f6c6715
4 changed files with 77 additions and 73 deletions

View File

@@ -5,9 +5,9 @@
// Created by Mike Freno on 1/7/26. // Created by Mike Freno on 1/7/26.
// //
import SwiftUI
import AppKit import AppKit
import Combine import Combine
import SwiftUI
@MainActor @MainActor
class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
@@ -75,7 +75,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
.removeDuplicates() .removeDuplicates()
.sink { [weak self] smartMode in .sink { [weak self] smartMode in
self?.idleService?.updateThreshold(minutes: smartMode.idleThresholdMinutes) self?.idleService?.updateThreshold(minutes: smartMode.idleThresholdMinutes)
self?.usageTrackingService?.updateResetThreshold(minutes: smartMode.usageResetAfterMinutes) self?.usageTrackingService?.updateResetThreshold(
minutes: smartMode.usageResetAfterMinutes)
// Force state check when settings change to apply immediately // Force state check when settings change to apply immediately
self?.fullscreenService?.forceUpdate() self?.fullscreenService?.forceUpdate()
@@ -196,7 +197,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
} else { } else {
let sizePercentage = settingsManager.settings.subtleReminderSize.percentage let sizePercentage = settingsManager.settings.subtleReminderSize.percentage
contentView = AnyView( contentView = AnyView(
UserTimerReminderView(timer: timer, sizePercentage: sizePercentage) { [weak self] in UserTimerReminderView(timer: timer, sizePercentage: sizePercentage) {
[weak self] in
self?.timerEngine?.dismissReminder() self?.timerEngine?.dismissReminder()
} }
) )
@@ -332,16 +334,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
let window = NSWindow( let window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 700, height: 700), contentRect: NSRect(x: 0, y: 0, width: 700, height: 700),
styleMask: [.titled, .closable, .miniaturizable, .resizable], styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
backing: .buffered, backing: .buffered,
defer: false defer: false
) )
window.identifier = WindowIdentifiers.settings window.identifier = WindowIdentifiers.settings
window.title = "Settings" window.titleVisibility = .hidden
window.titlebarAppearsTransparent = true
window.toolbarStyle = .unified
window.toolbar = NSToolbar()
window.center() window.center()
window.setFrameAutosaveName("SettingsWindow") window.setFrameAutosaveName("SettingsWindow")
window.isReleasedWhenClosed = false window.isReleasedWhenClosed = false
window.contentView = NSHostingView( window.contentView = NSHostingView(
rootView: SettingsWindowView(settingsManager: settingsManager, initialTab: tab) rootView: SettingsWindowView(settingsManager: settingsManager, initialTab: tab)
) )

View File

@@ -25,20 +25,20 @@ enum EyeTrackingConstants {
/// Pitch threshold for looking UP (above screen). /// Pitch threshold for looking UP (above screen).
/// Since camera is at top, looking at screen is negative pitch. /// Since camera is at top, looking at screen is negative pitch.
/// Values > 0.1 imply looking straight ahead or up (away from screen). /// Values > 0.1 imply looking straight ahead or up (away from screen).
static let pitchUpThreshold: Double = 0.1 static let pitchUpThreshold: Double = 0.5
/// Pitch threshold for looking DOWN (at keyboard/lap). /// Pitch threshold for looking DOWN (at keyboard/lap).
/// Values < -0.45 imply looking too far down. /// Values < -0.45 imply looking too far down.
static let pitchDownThreshold: Double = -0.2 static let pitchDownThreshold: Double = -0.9
// MARK: - Pupil Tracking Thresholds // MARK: - Pupil Tracking Thresholds
/// Minimum horizontal pupil ratio (0.0 = right edge, 1.0 = left edge) /// Minimum horizontal pupil ratio (0.0 = right edge, 1.0 = left edge)
/// Values below this are considered looking right (camera view) /// Values below this are considered looking right (camera view)
/// Tightened from 0.25 to 0.35 /// Tightened from 0.25 to 0.35
static let minPupilRatio: Double = 0.35 static let minPupilRatio: Double = 0.45
/// Maximum horizontal pupil ratio /// Maximum horizontal pupil ratio
/// Values above this are considered looking left (camera view) /// Values above this are considered looking left (camera view)
/// Tightened from 0.75 to 0.65 /// Tightened from 0.75 to 0.65
static let maxPupilRatio: Double = 0.65 static let maxPupilRatio: Double = 0.55
} }

View File

@@ -12,8 +12,8 @@ enum SettingsSection: Int, CaseIterable, Identifiable {
case lookAway = 1 case lookAway = 1
case blink = 2 case blink = 2
case posture = 3 case posture = 3
case enforceMode = 4 case userTimers = 4
case userTimers = 5 case enforceMode = 5
case smartMode = 6 case smartMode = 6
var id: Int { rawValue } var id: Int { rawValue }

View File

@@ -24,12 +24,10 @@ struct SettingsWindowView: View {
Label(section.title, systemImage: section.iconName) Label(section.title, systemImage: section.iconName)
} }
} }
.navigationTitle("Settings")
.listStyle(.sidebar) .listStyle(.sidebar)
} detail: { } detail: {
detailView(for: selectedSection) detailView(for: selectedSection)
} }
.navigationSplitViewColumnWidth(min: 200, ideal: 250, max: 300)
Divider() Divider()