Compare commits
3 Commits
815b91f6ca
...
19e17b7051
| Author | SHA1 | Date | |
|---|---|---|---|
| 19e17b7051 | |||
| 4ecdb8fbfe | |||
| a25e414d4e |
@ -28,6 +28,7 @@ struct ContentView: View {
|
|||||||
EquatableView(content: CameraContainerView(
|
EquatableView(content: CameraContainerView(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
sessionKey: cameraSessionKey,
|
sessionKey: cameraSessionKey,
|
||||||
|
cameraPosition: settings.cameraPosition,
|
||||||
onImageCaptured: { image in
|
onImageCaptured: { image in
|
||||||
handlePhotoCaptured(image)
|
handlePhotoCaptured(image)
|
||||||
}
|
}
|
||||||
@ -79,6 +80,10 @@ struct ContentView: View {
|
|||||||
settings.flashMode = settings.isRingLightEnabled ? .on : .off
|
settings.flashMode = settings.isRingLightEnabled ? .on : .off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: settings.cameraPosition) { _, _ in
|
||||||
|
// Force camera session recreation when camera position changes
|
||||||
|
cameraSessionKey = UUID()
|
||||||
|
}
|
||||||
.sheet(isPresented: $showSettings) {
|
.sheet(isPresented: $showSettings) {
|
||||||
SettingsView(viewModel: settings, showPaywall: $showPaywall)
|
SettingsView(viewModel: settings, showPaywall: $showPaywall)
|
||||||
}
|
}
|
||||||
@ -162,6 +167,7 @@ struct ContentView: View {
|
|||||||
struct CameraContainerView: View, Equatable {
|
struct CameraContainerView: View, Equatable {
|
||||||
let settings: SettingsViewModel
|
let settings: SettingsViewModel
|
||||||
let sessionKey: UUID
|
let sessionKey: UUID
|
||||||
|
let cameraPosition: CameraPosition
|
||||||
let onImageCaptured: (UIImage) -> Void
|
let onImageCaptured: (UIImage) -> Void
|
||||||
|
|
||||||
// Only compare sessionKey for equality - ignore settings and callback changes
|
// Only compare sessionKey for equality - ignore settings and callback changes
|
||||||
@ -170,7 +176,7 @@ struct CameraContainerView: View, Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let _ = Design.debugLog("CameraContainerView body evaluated - sessionKey: \(sessionKey)")
|
let _ = Design.debugLog("CameraContainerView body evaluated - sessionKey: \(sessionKey), position: \(cameraPosition)")
|
||||||
MCamera()
|
MCamera()
|
||||||
.setCameraScreen { cameraManager, namespace, closeAction in
|
.setCameraScreen { cameraManager, namespace, closeAction in
|
||||||
CustomCameraScreen(
|
CustomCameraScreen(
|
||||||
@ -182,9 +188,7 @@ struct CameraContainerView: View, Equatable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.setCapturedMediaScreen(nil)
|
.setCapturedMediaScreen(nil)
|
||||||
// Use front camera as default for selfie app - don't read from settings here
|
.setCameraPosition(cameraPosition)
|
||||||
// to avoid triggering @Observable tracking which breaks the camera
|
|
||||||
.setCameraPosition(.front)
|
|
||||||
.startSession()
|
.startSession()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -770,10 +770,7 @@ struct SettingsView: View {
|
|||||||
SettingsToggle(
|
SettingsToggle(
|
||||||
title: "Enable Debug Premium",
|
title: "Enable Debug Premium",
|
||||||
subtitle: "Unlock all premium features for testing",
|
subtitle: "Unlock all premium features for testing",
|
||||||
isOn: Binding(
|
isOn: $viewModel.isDebugPremiumEnabled
|
||||||
get: { viewModel.premiumManager.isDebugPremiumToggleEnabled },
|
|
||||||
set: { viewModel.premiumManager.isDebugPremiumToggleEnabled = $0 }
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.tint(Color.Status.warning)
|
.tint(Color.Status.warning)
|
||||||
// Icon Generator
|
// Icon Generator
|
||||||
|
|||||||
@ -87,10 +87,18 @@ final class SettingsViewModel: RingLightConfigurable {
|
|||||||
// MARK: - Premium Manager
|
// MARK: - Premium Manager
|
||||||
|
|
||||||
/// Premium manager for checking subscription status
|
/// Premium manager for checking subscription status
|
||||||
private let premiumManager = PremiumManager()
|
@ObservationIgnored private let premiumManager = PremiumManager()
|
||||||
|
|
||||||
/// Whether the user has premium access
|
/// Whether the user has premium access (stored property for proper UI updates)
|
||||||
var isPremiumUnlocked: Bool { premiumManager.isPremiumUnlocked }
|
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
|
// MARK: - Cloud Sync Manager
|
||||||
|
|
||||||
@ -335,6 +343,71 @@ final class SettingsViewModel: RingLightConfigurable {
|
|||||||
lightColorId == RingLightColor.customId
|
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)
|
/// Sets the custom color and selects it (PREMIUM)
|
||||||
func selectCustomColor(_ color: Color) {
|
func selectCustomColor(_ color: Color) {
|
||||||
guard PremiumGate.canSet(isPremium: isPremiumUnlocked) else { return }
|
guard PremiumGate.canSet(isPremium: isPremiumUnlocked) else { return }
|
||||||
@ -365,6 +438,8 @@ final class SettingsViewModel: RingLightConfigurable {
|
|||||||
// MARK: - Initialization
|
// MARK: - Initialization
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
// Initialize premium status
|
||||||
|
_isPremiumUnlocked = premiumManager.isPremiumUnlocked
|
||||||
// CloudSyncManager handles syncing automatically
|
// CloudSyncManager handles syncing automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ final class PremiumManager: PremiumManaging {
|
|||||||
// MARK: - Debug Override
|
// MARK: - Debug Override
|
||||||
|
|
||||||
/// Debug premium toggle stored in UserDefaults (only available in DEBUG builds)
|
/// 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.
|
/// Check if debug premium is enabled via UserDefaults toggle or environment variable.
|
||||||
/// The toggle in Settings > Debug takes precedence over environment variables.
|
/// The toggle in Settings > Debug takes precedence over environment variables.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user