From fae76dc5155f6d1cd2c080ab0f8bcb76725e5c8c Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 18 Oct 2025 13:57:38 +0200 Subject: [PATCH] Gesture-based photo access: Tap for library, long-press for camera MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UX improvements: - Tap camera icon → Photo library (common use case) - Long press camera icon (0.3s) → Direct camera (quick photos) - Removed action sheet entirely for cleaner flow - Power users can long-press for instant camera access This is more discoverable and eliminates an extra step in the UI. --- bitchat/Views/ContentView.swift | 47 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index 9ddf05a8..8bd3560c 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -71,7 +71,6 @@ struct ContentView: View { #if os(iOS) @State private var showImagePicker = false @State private var imagePickerSourceType: UIImagePickerController.SourceType = .camera - @State private var showImageSourcePicker = false #endif @ScaledMetric(relativeTo: .body) private var headerHeight: CGFloat = 44 @ScaledMetric(relativeTo: .subheadline) private var headerPeerIconSize: CGFloat = 11 @@ -223,17 +222,6 @@ struct ContentView: View { } } } - .confirmationDialog("Add Photo", isPresented: $showImageSourcePicker, titleVisibility: .visible) { - Button("Take Photo") { - imagePickerSourceType = .camera - showImagePicker = true - } - Button("Choose from Library") { - imagePickerSourceType = .photoLibrary - showImagePicker = true - } - Button("Cancel", role: .cancel) {} - } #endif .sheet(isPresented: Binding( get: { imagePreviewURL != nil }, @@ -1816,18 +1804,29 @@ private extension ContentView { } var attachmentButton: some View { - Button(action: { - #if os(iOS) - showImageSourcePicker = true - #endif - }) { - Image(systemName: "camera.circle.fill") - .font(.bitchatSystem(size: 24)) - .foregroundColor(composerAccentColor) - .frame(width: 36, height: 36) - } - .buttonStyle(.plain) - .accessibilityLabel("Add photo") + #if os(iOS) + Image(systemName: "camera.circle.fill") + .font(.bitchatSystem(size: 24)) + .foregroundColor(composerAccentColor) + .frame(width: 36, height: 36) + .contentShape(Circle()) + .onTapGesture { + // Tap = Photo Library + imagePickerSourceType = .photoLibrary + showImagePicker = true + } + .onLongPressGesture(minimumDuration: 0.3) { + // Long press = Camera + imagePickerSourceType = .camera + showImagePicker = true + } + .accessibilityLabel("Tap for library, long press for camera") + #else + Image(systemName: "camera.circle.fill") + .font(.bitchatSystem(size: 24)) + .foregroundColor(composerAccentColor) + .frame(width: 36, height: 36) + #endif } var sendOrMicButton: some View {