Fix camera position switch - detect change on settings sheet dismiss
- Track lastCameraPosition to detect changes - Use sheet onDismiss callback to check if position changed - Force camera recreation only when position actually changes - Works around @Observable tracking issues with nested cloudSync data
This commit is contained in:
parent
19e17b7051
commit
55c4d7e05a
@ -21,6 +21,9 @@ struct ContentView: View {
|
|||||||
/// Incrementing this value creates a new camera session with fresh AVCapturePhotoOutput
|
/// Incrementing this value creates a new camera session with fresh AVCapturePhotoOutput
|
||||||
@State private var cameraSessionKey = UUID()
|
@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 {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
// Camera view - wrapped in EquatableView to prevent re-evaluation on settings changes
|
// Camera view - wrapped in EquatableView to prevent re-evaluation on settings changes
|
||||||
@ -70,6 +73,10 @@ struct ContentView: View {
|
|||||||
.padding(.top, Design.Spacing.small)
|
.padding(.top, Design.Spacing.small)
|
||||||
}
|
}
|
||||||
.animation(.easeInOut(duration: Design.Animation.quick), value: showPhotoReview)
|
.animation(.easeInOut(duration: Design.Animation.quick), value: showPhotoReview)
|
||||||
|
.onAppear {
|
||||||
|
// Initialize tracking of camera position
|
||||||
|
lastCameraPosition = settings.cameraPosition
|
||||||
|
}
|
||||||
.onChange(of: settings.isRingLightEnabled) { _, newValue in
|
.onChange(of: settings.isRingLightEnabled) { _, newValue in
|
||||||
if settings.isFlashSyncedWithRingLight {
|
if settings.isFlashSyncedWithRingLight {
|
||||||
settings.flashMode = newValue ? .on : .off
|
settings.flashMode = newValue ? .on : .off
|
||||||
@ -80,11 +87,14 @@ struct ContentView: View {
|
|||||||
settings.flashMode = settings.isRingLightEnabled ? .on : .off
|
settings.flashMode = settings.isRingLightEnabled ? .on : .off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: settings.cameraPosition) { _, _ in
|
.sheet(isPresented: $showSettings, onDismiss: {
|
||||||
// Force camera session recreation when camera position changes
|
// Check if camera position changed while settings was open
|
||||||
cameraSessionKey = UUID()
|
if settings.cameraPosition != lastCameraPosition {
|
||||||
}
|
lastCameraPosition = settings.cameraPosition
|
||||||
.sheet(isPresented: $showSettings) {
|
// Force camera session recreation with new position
|
||||||
|
cameraSessionKey = UUID()
|
||||||
|
}
|
||||||
|
}) {
|
||||||
SettingsView(viewModel: settings, showPaywall: $showPaywall)
|
SettingsView(viewModel: settings, showPaywall: $showPaywall)
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $showPaywall) {
|
.sheet(isPresented: $showPaywall) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user