Compare commits
3 Commits
815b91f6ca
...
19e17b7051
| Author | SHA1 | Date | |
|---|---|---|---|
| 19e17b7051 | |||
| 4ecdb8fbfe | |||
| a25e414d4e |
@ -28,6 +28,7 @@ struct ContentView: View {
|
||||
EquatableView(content: CameraContainerView(
|
||||
settings: settings,
|
||||
sessionKey: cameraSessionKey,
|
||||
cameraPosition: settings.cameraPosition,
|
||||
onImageCaptured: { image in
|
||||
handlePhotoCaptured(image)
|
||||
}
|
||||
@ -79,6 +80,10 @@ struct ContentView: View {
|
||||
settings.flashMode = settings.isRingLightEnabled ? .on : .off
|
||||
}
|
||||
}
|
||||
.onChange(of: settings.cameraPosition) { _, _ in
|
||||
// Force camera session recreation when camera position changes
|
||||
cameraSessionKey = UUID()
|
||||
}
|
||||
.sheet(isPresented: $showSettings) {
|
||||
SettingsView(viewModel: settings, showPaywall: $showPaywall)
|
||||
}
|
||||
@ -162,6 +167,7 @@ struct ContentView: View {
|
||||
struct CameraContainerView: View, Equatable {
|
||||
let settings: SettingsViewModel
|
||||
let sessionKey: UUID
|
||||
let cameraPosition: CameraPosition
|
||||
let onImageCaptured: (UIImage) -> Void
|
||||
|
||||
// Only compare sessionKey for equality - ignore settings and callback changes
|
||||
@ -170,7 +176,7 @@ struct CameraContainerView: View, Equatable {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let _ = Design.debugLog("CameraContainerView body evaluated - sessionKey: \(sessionKey)")
|
||||
let _ = Design.debugLog("CameraContainerView body evaluated - sessionKey: \(sessionKey), position: \(cameraPosition)")
|
||||
MCamera()
|
||||
.setCameraScreen { cameraManager, namespace, closeAction in
|
||||
CustomCameraScreen(
|
||||
@ -182,9 +188,7 @@ struct CameraContainerView: View, Equatable {
|
||||
)
|
||||
}
|
||||
.setCapturedMediaScreen(nil)
|
||||
// Use front camera as default for selfie app - don't read from settings here
|
||||
// to avoid triggering @Observable tracking which breaks the camera
|
||||
.setCameraPosition(.front)
|
||||
.setCameraPosition(cameraPosition)
|
||||
.startSession()
|
||||
}
|
||||
}
|
||||
|
||||
@ -770,10 +770,7 @@ struct SettingsView: View {
|
||||
SettingsToggle(
|
||||
title: "Enable Debug Premium",
|
||||
subtitle: "Unlock all premium features for testing",
|
||||
isOn: Binding(
|
||||
get: { viewModel.premiumManager.isDebugPremiumToggleEnabled },
|
||||
set: { viewModel.premiumManager.isDebugPremiumToggleEnabled = $0 }
|
||||
)
|
||||
isOn: $viewModel.isDebugPremiumEnabled
|
||||
)
|
||||
.tint(Color.Status.warning)
|
||||
// Icon Generator
|
||||
|
||||
@ -85,12 +85,20 @@ final class SettingsViewModel: RingLightConfigurable {
|
||||
static let defaultRingSize: CGFloat = 40
|
||||
|
||||
// MARK: - Premium Manager
|
||||
|
||||
|
||||
/// Premium manager for checking subscription status
|
||||
private let premiumManager = PremiumManager()
|
||||
|
||||
/// Whether the user has premium access
|
||||
var isPremiumUnlocked: Bool { premiumManager.isPremiumUnlocked }
|
||||
@ObservationIgnored private let premiumManager = PremiumManager()
|
||||
|
||||
/// Whether the user has premium access (stored property for proper UI updates)
|
||||
private var _isPremiumUnlocked: Bool = false
|
||||
|
||||
/// Whether the user has premium access (observable for UI updates)
|
||||
var isPremiumUnlocked: Bool {
|
||||
get { _isPremiumUnlocked }
|
||||
set {
|
||||
_isPremiumUnlocked = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Cloud Sync Manager
|
||||
|
||||
@ -334,6 +342,71 @@ final class SettingsViewModel: RingLightConfigurable {
|
||||
var isCustomColorSelected: Bool {
|
||||
lightColorId == RingLightColor.customId
|
||||
}
|
||||
|
||||
// MARK: - Debug Premium Toggle
|
||||
|
||||
/// Debug premium toggle for testing (DEBUG builds only)
|
||||
var isDebugPremiumEnabled: Bool {
|
||||
get { premiumManager.isDebugPremiumToggleEnabled }
|
||||
set {
|
||||
let wasPremium = premiumManager.isDebugPremiumToggleEnabled
|
||||
premiumManager.isDebugPremiumToggleEnabled = newValue
|
||||
|
||||
// Update premium status for UI refresh
|
||||
isPremiumUnlocked = premiumManager.isPremiumUnlocked
|
||||
|
||||
// Reset premium settings when toggling OFF
|
||||
if wasPremium && !newValue {
|
||||
resetPremiumSettingsToDefaults()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset premium-only settings to their free defaults when debug premium is disabled
|
||||
private func resetPremiumSettingsToDefaults() {
|
||||
// Clear cached values that depend on premium status
|
||||
_cachedRingSize = nil
|
||||
_cachedLightColorId = nil
|
||||
_cachedCustomColor = nil
|
||||
|
||||
// Reset premium settings to defaults (bypass premium gates for direct reset)
|
||||
updateSettings { settings in
|
||||
if settings.lightColorId != Self.defaultFreeColorId {
|
||||
settings.lightColorId = Self.defaultFreeColorId
|
||||
}
|
||||
|
||||
if settings.isMirrorFlipped {
|
||||
settings.isMirrorFlipped = false
|
||||
}
|
||||
|
||||
if settings.isSkinSmoothingEnabled {
|
||||
settings.isSkinSmoothingEnabled = false
|
||||
}
|
||||
|
||||
if settings.isFlashSyncedWithRingLight {
|
||||
settings.isFlashSyncedWithRingLight = false
|
||||
}
|
||||
|
||||
if settings.hdrModeRaw != CameraHDRMode.off.rawValue {
|
||||
settings.hdrModeRaw = CameraHDRMode.off.rawValue
|
||||
}
|
||||
|
||||
if settings.photoQualityRaw != PhotoQuality.medium.rawValue {
|
||||
settings.photoQualityRaw = PhotoQuality.medium.rawValue
|
||||
}
|
||||
|
||||
if settings.selectedTimerRaw != TimerOption.three.rawValue {
|
||||
settings.selectedTimerRaw = TimerOption.three.rawValue
|
||||
}
|
||||
|
||||
if settings.isCenterStageEnabled {
|
||||
settings.isCenterStageEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
// Force sync to ensure changes are saved
|
||||
forceSync()
|
||||
}
|
||||
|
||||
/// Sets the custom color and selects it (PREMIUM)
|
||||
func selectCustomColor(_ color: Color) {
|
||||
@ -363,8 +436,10 @@ final class SettingsViewModel: RingLightConfigurable {
|
||||
var hasCompletedInitialSync: Bool { cloudSync.hasCompletedInitialSync }
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
|
||||
init() {
|
||||
// Initialize premium status
|
||||
_isPremiumUnlocked = premiumManager.isPremiumUnlocked
|
||||
// CloudSyncManager handles syncing automatically
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ final class PremiumManager: PremiumManaging {
|
||||
// MARK: - Debug Override
|
||||
|
||||
/// Debug premium toggle stored in UserDefaults (only available in DEBUG builds)
|
||||
@AppStorage("debugPremiumEnabled") private var debugPremiumEnabled = false
|
||||
@AppStorage("debugPremiumEnabled") @ObservationIgnored private var debugPremiumEnabled = false
|
||||
|
||||
/// Check if debug premium is enabled via UserDefaults toggle or environment variable.
|
||||
/// The toggle in Settings > Debug takes precedence over environment variables.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user