diff --git a/SelfieCam/Features/Camera/ContentView.swift b/SelfieCam/Features/Camera/ContentView.swift index 0871b41..4e68edf 100644 --- a/SelfieCam/Features/Camera/ContentView.swift +++ b/SelfieCam/Features/Camera/ContentView.swift @@ -20,6 +20,9 @@ struct ContentView: View { /// Unique key to force MCamera recreation after photo capture /// Incrementing this value creates a new camera session with fresh AVCapturePhotoOutput @State private var cameraSessionKey = UUID() + + /// Track camera position to detect changes when settings sheet closes + @State private var lastCameraPosition: CameraPosition = .front var body: some View { ZStack { @@ -70,6 +73,10 @@ struct ContentView: View { .padding(.top, Design.Spacing.small) } .animation(.easeInOut(duration: Design.Animation.quick), value: showPhotoReview) + .onAppear { + // Initialize tracking of camera position + lastCameraPosition = settings.cameraPosition + } .onChange(of: settings.isRingLightEnabled) { _, newValue in if settings.isFlashSyncedWithRingLight { settings.flashMode = newValue ? .on : .off @@ -80,11 +87,14 @@ 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) { + .sheet(isPresented: $showSettings, onDismiss: { + // Check if camera position changed while settings was open + if settings.cameraPosition != lastCameraPosition { + lastCameraPosition = settings.cameraPosition + // Force camera session recreation with new position + cameraSessionKey = UUID() + } + }) { SettingsView(viewModel: settings, showPaywall: $showPaywall) } .sheet(isPresented: $showPaywall) {