diff --git a/Gaze/Models/AppSettings.swift b/Gaze/Models/AppSettings.swift index 9f7d27c..64f0eda 100644 --- a/Gaze/Models/AppSettings.swift +++ b/Gaze/Models/AppSettings.swift @@ -49,7 +49,7 @@ struct AppSettings: Codable, Equatable, Hashable { var hasCompletedOnboarding: Bool var launchAtLogin: Bool var playSounds: Bool - + // App Store detection (cached at launch, not persisted) var isAppStoreVersion: Bool @@ -66,7 +66,7 @@ struct AppSettings: Codable, Equatable, Hashable { hasCompletedOnboarding: Bool = false, launchAtLogin: Bool = false, playSounds: Bool = true, - isAppStoreVersion: Bool = false + isAppStoreVersion: Bool = true ) { self.lookAwayTimer = lookAwayTimer self.lookAwayCountdownSeconds = lookAwayCountdownSeconds @@ -105,9 +105,9 @@ struct AppSettings: Codable, Equatable, Hashable { && lhs.launchAtLogin == rhs.launchAtLogin && lhs.playSounds == rhs.playSounds && lhs.isAppStoreVersion == rhs.isAppStoreVersion } - + // MARK: - Custom Codable Implementation - + enum CodingKeys: String, CodingKey { case lookAwayTimer case lookAwayCountdownSeconds @@ -120,7 +120,7 @@ struct AppSettings: Codable, Equatable, Hashable { case playSounds // isAppStoreVersion is intentionally excluded from persistence } - + init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) lookAwayTimer = try container.decode(TimerConfiguration.self, forKey: .lookAwayTimer) @@ -135,7 +135,7 @@ struct AppSettings: Codable, Equatable, Hashable { // isAppStoreVersion is not persisted, will be set at launch isAppStoreVersion = false } - + func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(lookAwayTimer, forKey: .lookAwayTimer) diff --git a/Gaze/Views/Containers/OnboardingContainerView.swift b/Gaze/Views/Containers/OnboardingContainerView.swift index 8afda37..f1d2ce2 100644 --- a/Gaze/Views/Containers/OnboardingContainerView.swift +++ b/Gaze/Views/Containers/OnboardingContainerView.swift @@ -31,8 +31,14 @@ struct OnboardingContainerView: View { @State private var postureIntervalMinutes = 30 @State private var launchAtLogin = false @State private var subtleReminderSize: ReminderSize = .medium + @State private var isAppStoreVersion: Bool @Environment(\.dismiss) private var dismiss + init(settingsManager: SettingsManager) { + self.settingsManager = settingsManager + _isAppStoreVersion = State(initialValue: settingsManager.settings.isAppStoreVersion) + } + var body: some View { ZStack { VisualEffectView(material: .hudWindow, blendingMode: .behindWindow) @@ -78,10 +84,7 @@ struct OnboardingContainerView: View { GeneralSetupView( launchAtLogin: $launchAtLogin, subtleReminderSize: $subtleReminderSize, - isAppStoreVersion: Binding( - get: { settingsManager.settings.isAppStoreVersion }, - set: { _ in } - ), + isAppStoreVersion: .constant(isAppStoreVersion), isOnboarding: true ) .tag(4) @@ -149,7 +152,14 @@ struct OnboardingContainerView: View { } } } - .frame(minWidth: 1000, minHeight: 800) + + .frame( + minWidth: 1000, + minHeight: isAppStoreVersion ? 700 : 900 + ) + .onReceive(settingsManager.$settings) { newSettings in + isAppStoreVersion = newSettings.isAppStoreVersion + } } private func completeOnboarding() { diff --git a/Gaze/Views/Containers/SettingsWindowView.swift b/Gaze/Views/Containers/SettingsWindowView.swift index 864bc04..dfd4180 100644 --- a/Gaze/Views/Containers/SettingsWindowView.swift +++ b/Gaze/Views/Containers/SettingsWindowView.swift @@ -20,6 +20,7 @@ struct SettingsWindowView: View { @State private var launchAtLogin: Bool @State private var subtleReminderSize: ReminderSize @State private var userTimers: [UserTimer] + @State private var isAppStoreVersion: Bool init(settingsManager: SettingsManager, initialTab: Int = 0) { self.settingsManager = settingsManager @@ -40,6 +41,7 @@ struct SettingsWindowView: View { _subtleReminderSize = State( initialValue: settingsManager.settings.subtleReminderSize) _userTimers = State(initialValue: settingsManager.settings.userTimers) + _isAppStoreVersion = State(initialValue: settingsManager.settings.isAppStoreVersion) } var body: some View { @@ -84,10 +86,7 @@ struct SettingsWindowView: View { GeneralSetupView( launchAtLogin: $launchAtLogin, subtleReminderSize: $subtleReminderSize, - isAppStoreVersion: Binding( - get: { settingsManager.settings.isAppStoreVersion }, - set: { _ in } - ), + isAppStoreVersion: .constant(isAppStoreVersion), isOnboarding: false ) .tag(4) @@ -115,7 +114,13 @@ struct SettingsWindowView: View { } .padding() } - .frame(minWidth: 750, minHeight: 850) + .frame( + minWidth: 750, + minHeight: isAppStoreVersion ? 700 : 900 + ) + .onReceive(settingsManager.$settings) { newSettings in + isAppStoreVersion = newSettings.isAppStoreVersion + } .onReceive( NotificationCenter.default.publisher(for: Notification.Name("SwitchToSettingsTab")) ) { notification in @@ -147,7 +152,7 @@ struct SettingsWindowView: View { hasCompletedOnboarding: settingsManager.settings.hasCompletedOnboarding, launchAtLogin: launchAtLogin, playSounds: settingsManager.settings.playSounds, - isAppStoreVersion: settingsManager.settings.isAppStoreVersion + isAppStoreVersion: isAppStoreVersion ) // Assign the entire settings object to trigger didSet and observers