import AVFoundation import SwiftUI struct CameraCellPreview: View { @Environment(\.router) var router @EnvironmentObject var conversation: ConversationStore @EnvironmentObject var attachments: AttachmentsStore var body: some View { Group { if attachments.cameraAccessGranted { ZStack { CameraView() .aspectRatio(1, contentMode: .fit) .frame(maxWidth: .infinity) Image(systemName: "camera") .resizable() .aspectRatio(contentMode: .fit) .frame(width: 40, height: 40) .foregroundColor(.white) .padding(8) .background(Color.black.opacity(0.5)) .clipShape(Circle()) .padding(8) } .onTapGesture { router.showScreen(.fullScreenCover) { _ in CameraPicker { data, type in Task { await conversation.sendCaptured(data, type) } router.dismissEnvironment() } .ignoresSafeArea(.all) } } } else { Button { openAppSettings() } label: { ZStack { Rectangle() .fill(Color.Material.Background.light) .overlay { VStack { Image(systemName: "camera") .foregroundColor(.Material.Elements.active) .font(.system(size: 30)) Text("Allow camera access") .foregroundColor(.Material.Text.main) .font(.body3) } } .frame(height: 100) } } } } .task { await attachments.checkCameraAuthorization() } } }