From 7a564b2115b141de469fd6bd35654c8eab02a8f8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sun, 4 Jan 2026 12:21:40 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- SelfieCam/Features/Camera/ContentView.swift | 73 +++++++++++++-------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/SelfieCam/Features/Camera/ContentView.swift b/SelfieCam/Features/Camera/ContentView.swift index e607c9f..3594af5 100644 --- a/SelfieCam/Features/Camera/ContentView.swift +++ b/SelfieCam/Features/Camera/ContentView.swift @@ -29,13 +29,36 @@ struct ContentView: View { settings: settings, sessionKey: cameraSessionKey, onImageCaptured: { image in - capturedPhoto = CapturedPhoto(image: image, timestamp: Date()) - showPhotoReview = true - isSavingPhoto = false - saveError = nil + if settings.isAutoSaveEnabled { + // Auto-save enabled: save immediately without showing review screen + Task { + // Small delay to ensure shutter sound plays before saving + try? await Task.sleep(for: .milliseconds(200)) + + let quality = settings.photoQuality + let result = await PhotoLibraryService.savePhotoToLibrary(image, quality: quality) + + switch result { + case .success: + print("Photo auto-saved successfully") + // Don't reset camera session for auto-save to avoid timing issues + case .failure(let error): + print("Failed to auto-save photo: \(error)") + // Don't reset on failure either + } + } + } else { + // Auto-save disabled: show review screen + capturedPhoto = CapturedPhoto(image: image, timestamp: Date()) + showPhotoReview = true + isSavingPhoto = false + saveError = nil + } + print("Photo captured successfully") } ) + .ignoresSafeArea() // Only camera ignores safe area to fill screen } // Photo review overlay @@ -52,33 +75,25 @@ struct ContentView: View { } ) .transition(.opacity) + .ignoresSafeArea() // Photo review also fills screen } - - // Settings button overlay - positioned with safe area consideration - VStack { - HStack { - Spacer() - - Button { - showSettings = true - } label: { - Image(systemName: "gearshape.fill") - .font(.title3) - .foregroundStyle(.white) - .padding(Design.Spacing.medium) - .background(.ultraThinMaterial, in: Circle()) - .shadow(radius: Design.Shadow.radiusSmall) - } - .accessibilityLabel("Settings") - } - .padding(.horizontal, Design.Spacing.large) - .padding(.top, Design.Spacing.small) // Reduced from medium to account for safe area - - Spacer() - } - .safeAreaInset(edge: .top) { Color.clear.frame(height: 0) } // Ensures proper safe area handling } - .ignoresSafeArea() + // Settings button overlay - respects safe area naturally + .overlay(alignment: .topTrailing) { + Button { + showSettings = true + } label: { + Image(systemName: "gearshape.fill") + .font(.title3) + .foregroundStyle(.white) + .padding(Design.Spacing.medium) + .background(.ultraThinMaterial, in: Circle()) + .shadow(radius: Design.Shadow.radiusSmall) + } + .accessibilityLabel("Settings") + .padding(.horizontal, Design.Spacing.large) + .padding(.top, Design.Spacing.small) + } .animation(.easeInOut(duration: Design.Animation.quick), value: showPhotoReview) .onChange(of: settings.isRingLightEnabled) { _, newValue in if settings.isFlashSyncedWithRingLight {