damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 81683f980ad6b772c48e2060569b2d6e51a6b0dd
parent b9fc3f90d17539be175b8d54c1e083052106e42d
Author: Joel Klabo <joelklabo@gmail.com>
Date:   Wed, 29 Mar 2023 20:04:20 -0700

Allow Uploading Photos and Videos from Camera

Changelog-Added: Upload Photos and Videos from Camera
Closes: #840

Diffstat:
Mdamus/Info.plist | 4++++
Mdamus/Views/PostView.swift | 19++++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/damus/Info.plist b/damus/Info.plist @@ -46,5 +46,9 @@ <key>NSAllowsArbitraryLoads</key> <true/> </dict> + <key>NSCameraUsageDescription</key> + <string>Damus needs access to your camera if you want to upload photos from it</string> + <key>NSMicrophoneUsageDescription</key> + <string>Damus needs access to your microphone if you want to upload recorded videos from it</string> </dict> </plist> diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift @@ -19,6 +19,7 @@ struct PostView: View { @FocusState var focus: Bool @State var showPrivateKeyWarning: Bool = false @State var attach_media: Bool = false + @State var attach_camera: Bool = false @State var error: String? = nil @StateObject var image_upload: ImageUploadModel = ImageUploadModel() @@ -80,11 +81,20 @@ struct PostView: View { }) } + var CameraButton: some View { + Button(action: { + attach_camera = true + }, label: { + Image(systemName: "camera") + }) + } + var AttachmentBar: some View { HStack(alignment: .center) { ImageButton - .disabled(image_upload.progress != nil) + CameraButton } + .disabled(image_upload.progress != nil) } var PostButton: some View { @@ -221,6 +231,13 @@ struct PostView: View { handle_upload(media: .video(url)) } } + .sheet(isPresented: $attach_camera) { + ImagePicker(sourceType: .camera, damusState: damus_state) { img in + handle_upload(media: .image(img)) + } onVideoPicked: { url in + handle_upload(media: .video(url)) + } + } .onAppear() { if let replying_to { if damus_state.drafts.replies[replying_to] == nil {