SelfieCam/SelfieCam/Features/Settings/ViewModels/SettingsViewModel+Camera.swift
Matt Bruce 84b565cbb5 Reorganize folder structure with consistent Views/ViewModels/Components pattern
Camera:
- Views/: ContentView, CustomCameraScreen, PhotoReviewView
- Components/: All UI components (buttons, overlays, controls)

Settings:
- Views/: SettingsView, AppLicensesView
- ViewModels/: SettingsViewModel + extensions
- Components/: ColorPresetButton, CustomColorPickerButton

Paywall:
- Views/: ProPaywallView

Shared:
- Theme/: SelfieCamTheme, DesignConstants, BrandingConfig
- Extensions/: Color extensions (moved Color+Extensions here)
2026-01-04 18:39:59 -06:00

106 lines
3.7 KiB
Swift

//
// SettingsViewModel+Camera.swift
// SelfieCam
//
// Created by Matt Bruce on 1/4/26.
//
import SwiftUI
import Bedrock
import MijickCamera
// MARK: - Camera Settings
extension SettingsViewModel {
// MARK: - Camera Position
/// Raw camera position string for comparison (avoids MijickCamera enum issues)
var cameraPositionRaw: String {
cloudSync.data.cameraPositionRaw
}
var cameraPosition: CameraPosition {
get {
let raw = cloudSync.data.cameraPositionRaw
let position: CameraPosition = raw == "front" ? .front : .back
Design.debugLog("cameraPosition getter: raw='\(raw)' -> \(position)")
return position
}
set {
let rawValue = newValue == .front ? "front" : "back"
Design.debugLog("cameraPosition setter: \(newValue) -> raw='\(rawValue)'")
updateSettings { $0.cameraPositionRaw = rawValue }
}
}
// MARK: - Flash Mode
var flashMode: CameraFlashMode {
get { CameraFlashMode(rawValue: cloudSync.data.flashModeRaw) ?? .off }
set { updateSettings { $0.flashModeRaw = newValue.rawValue } }
}
/// Whether flash is synced with ring light color (PREMIUM)
var isFlashSyncedWithRingLight: Bool {
get { PremiumGate.get(cloudSync.data.isFlashSyncedWithRingLight, default: false, isPremium: isPremiumUnlocked) }
set {
guard PremiumGate.canSet(isPremium: isPremiumUnlocked) else { return }
updateSettings { $0.isFlashSyncedWithRingLight = newValue }
}
}
// MARK: - HDR Mode (Premium)
/// HDR mode setting (PREMIUM)
var hdrMode: CameraHDRMode {
get {
let stored = CameraHDRMode(rawValue: cloudSync.data.hdrModeRaw) ?? .off
return PremiumGate.get(stored, default: .off, isPremium: isPremiumUnlocked)
}
set {
guard PremiumGate.canSet(isPremium: isPremiumUnlocked) else { return }
updateSettings { $0.hdrModeRaw = newValue.rawValue }
}
}
// MARK: - Photo Quality (High is Premium)
/// Photo quality setting (high is PREMIUM)
var photoQuality: PhotoQuality {
get {
let stored = PhotoQuality(rawValue: cloudSync.data.photoQualityRaw) ?? PhotoQuality.high
return PremiumGate.get(stored, default: .medium, premiumValues: Self.premiumPhotoQualities, isPremium: isPremiumUnlocked)
}
set {
guard PremiumGate.canSet(newValue, premiumValues: Self.premiumPhotoQualities, isPremium: isPremiumUnlocked) else { return }
updateSettings { $0.photoQualityRaw = newValue.rawValue }
}
}
// MARK: - Center Stage (Premium)
/// Whether Center Stage is enabled (PREMIUM)
var isCenterStageEnabled: Bool {
get { PremiumGate.get(cloudSync.data.isCenterStageEnabled, default: false, isPremium: isPremiumUnlocked) }
set {
guard PremiumGate.canSet(isPremium: isPremiumUnlocked) else { return }
updateSettings { $0.isCenterStageEnabled = newValue }
}
}
// MARK: - Timer (5s/10s are Premium)
/// Selected timer option (5s and 10s are PREMIUM)
var selectedTimer: TimerOption {
get {
let stored = TimerOption(rawValue: cloudSync.data.selectedTimerRaw) ?? .off
return PremiumGate.get(stored, default: .three, premiumValues: Self.premiumTimerOptions, isPremium: isPremiumUnlocked)
}
set {
guard PremiumGate.canSet(newValue, premiumValues: Self.premiumTimerOptions, isPremium: isPremiumUnlocked) else { return }
updateSettings { $0.selectedTimerRaw = newValue.rawValue }
}
}
}