bit smoother

This commit is contained in:
Michael Freno
2026-02-01 11:29:49 -05:00
parent e0a9d16484
commit fc9ab37841
2 changed files with 51 additions and 45 deletions

View File

@@ -28,10 +28,10 @@ final class EnforceModeCalibrationService: ObservableObject {
private var countdownTimer: Timer?
private var sampleTimer: Timer?
private let countdownDuration: TimeInterval = 1.0
private let preCountdownPause: TimeInterval = 0.5
private let sampleInterval: TimeInterval = 0.1
private let samplesPerTarget = 12
private let countdownDuration: TimeInterval = 0.8
private let preCountdownPause: TimeInterval = 0.8
private let sampleInterval: TimeInterval = 0.02
private let samplesPerTarget = 20
private var windowController: NSWindowController?
func start() {
@@ -89,6 +89,7 @@ final class EnforceModeCalibrationService: ObservableObject {
switch currentStep {
case .eyeBox:
currentStep = .targets
// Start countdown immediately when transitioning to targets to avoid first point duplication
startCountdown()
case .targets:
if targetIndex < targets.count - 1 {
@@ -135,13 +136,17 @@ final class EnforceModeCalibrationService: ObservableObject {
guard let self else { return }
Task { @MainActor in
let elapsed = Date().timeIntervalSince(startTime)
let countdownElapsed = max(0, elapsed - self.preCountdownPause)
// Pause before starting the countdown
if elapsed < self.preCountdownPause {
self.countdownProgress = 1.0
return
}
// Start the actual countdown after pause
let countdownElapsed = elapsed - self.preCountdownPause
let remaining = max(0, self.countdownDuration - countdownElapsed)
self.countdownProgress = remaining / self.countdownDuration
if remaining <= 0 {
self.stopCountdown()
self.startSampleCollection()
@@ -153,7 +158,8 @@ final class EnforceModeCalibrationService: ObservableObject {
private func stopCountdown() {
countdownTimer?.invalidate()
countdownTimer = nil
countdownProgress = 1.0
// Only reset to 1.0 when actually stopping, not during transitions
// countdownProgress = 1.0
}
private func startSampleCollection() {

View File

@@ -31,6 +31,7 @@ struct EnforceModeCalibrationOverlayView: View {
private var eyeBoxStep: some View {
ZStack {
VStack(spacing: 20) {
VStack(spacing: 16) {
Text("Adjust Eye Box")
.font(.title2)
@@ -44,7 +45,6 @@ struct EnforceModeCalibrationOverlayView: View {
.foregroundStyle(.white.opacity(0.8))
}
.padding(.horizontal, 40)
.padding(.top, 40)
.frame(maxWidth: 520)
.frame(maxWidth: .infinity, alignment: .top)
@@ -69,10 +69,9 @@ struct EnforceModeCalibrationOverlayView: View {
.background(.black.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 12))
.frame(maxWidth: 420)
.frame(maxHeight: .infinity, alignment: .center)
VStack {
Spacer()
HStack(spacing: 12) {
Button("Cancel") {
calibrationService.dismissOverlay()
@@ -85,10 +84,10 @@ struct EnforceModeCalibrationOverlayView: View {
}
.buttonStyle(.borderedProminent)
}
}
.padding(.bottom, 40)
}
}
}
private var targetStep: some View {
ZStack {
@@ -130,7 +129,7 @@ struct EnforceModeCalibrationOverlayView: View {
Text("Calibration Complete")
.font(.title2)
.foregroundStyle(.white)
Text("You can close this window and start testing.")
Text("Enforce Mode is ready to use.")
.font(.callout)
.foregroundStyle(.white.opacity(0.8))
@@ -163,6 +162,7 @@ struct EnforceModeCalibrationOverlayView: View {
.animation(.linear(duration: 0.02), value: calibrationService.countdownProgress)
}
.position(center)
.animation(.easeInOut(duration: 0.3), value: center)
}
.ignoresSafeArea()
}