fix(wizard): enable Plan My Trip button with default values
- Add debug toggle in Settings to override Pro subscription status (DEBUG builds only, defaults to true) - Auto-validate wizard step flags on appear so button enables without explicit user interaction: - DatesStep: calls updateHasSetDates() on appear - RoutePreferenceStep: sets hasSetRoutePreference on appear - RepeatCitiesStep: sets hasSetRepeatCities on appear Previously, canPlanTrip required all flags to be explicitly set by user interaction, even when valid defaults were showing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,10 +31,30 @@ final class StoreManager {
|
||||
private(set) var isLoading = false
|
||||
private(set) var error: StoreError?
|
||||
|
||||
// MARK: - Debug Override (DEBUG builds only)
|
||||
|
||||
#if DEBUG
|
||||
private static let debugProOverrideKey = "debugProOverride"
|
||||
|
||||
/// When true, isPro returns true regardless of actual subscription status.
|
||||
/// Defaults to true in debug builds. Only compiled in DEBUG configuration.
|
||||
var debugProOverride: Bool {
|
||||
get {
|
||||
UserDefaults.standard.object(forKey: Self.debugProOverrideKey) as? Bool ?? true
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: Self.debugProOverrideKey)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - Computed Properties
|
||||
|
||||
var isPro: Bool {
|
||||
!purchasedProductIDs.intersection(Self.proProductIDs).isEmpty
|
||||
#if DEBUG
|
||||
if debugProOverride { return true }
|
||||
#endif
|
||||
return !purchasedProductIDs.intersection(Self.proProductIDs).isEmpty
|
||||
}
|
||||
|
||||
var monthlyProduct: Product? {
|
||||
|
||||
@@ -260,6 +260,13 @@ struct SettingsView: View {
|
||||
#if DEBUG
|
||||
private var debugSection: some View {
|
||||
Section {
|
||||
Toggle(isOn: Binding(
|
||||
get: { StoreManager.shared.debugProOverride },
|
||||
set: { StoreManager.shared.debugProOverride = $0 }
|
||||
)) {
|
||||
Label("Override Pro Status", systemImage: "star.fill")
|
||||
}
|
||||
|
||||
Button {
|
||||
showOnboardingPaywall = true
|
||||
} label: {
|
||||
|
||||
@@ -43,6 +43,10 @@ struct DatesStep: View {
|
||||
RoundedRectangle(cornerRadius: Theme.CornerRadius.large)
|
||||
.stroke(Theme.surfaceGlow(colorScheme), lineWidth: 1)
|
||||
}
|
||||
.onAppear {
|
||||
// Auto-validate if dates are already valid (e.g., defaults)
|
||||
updateHasSetDates()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateHasSetDates() {
|
||||
|
||||
@@ -48,6 +48,12 @@ struct RepeatCitiesStep: View {
|
||||
RoundedRectangle(cornerRadius: Theme.CornerRadius.large)
|
||||
.stroke(Theme.surfaceGlow(colorScheme), lineWidth: 1)
|
||||
}
|
||||
.onAppear {
|
||||
// Auto-select the default if not already set (enables button with defaults)
|
||||
if !hasSetRepeatCities {
|
||||
hasSetRepeatCities = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,12 @@ struct RoutePreferenceStep: View {
|
||||
RoundedRectangle(cornerRadius: Theme.CornerRadius.large)
|
||||
.stroke(Theme.surfaceGlow(colorScheme), lineWidth: 1)
|
||||
}
|
||||
.onAppear {
|
||||
// Auto-select the default if not already set (enables button with defaults)
|
||||
if !hasSetRoutePreference {
|
||||
hasSetRoutePreference = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user