mirror of
git://jb55.com/damus
synced 2024-09-30 00:40:45 +00:00
picker: upgrade to newer image picker controller
Upgrade the ImagePicker to use PHPickerViewController instead of UIImagePickerController for the photo library since the PHPickerViewController allows for more options for how the user shares their media, such as whether location data should be included. Create a CameraController since PHPickerViewController is only used for the photo library. After capturing media with the camera, it will be saved to the user's photo library and the photo library view will appear for the user to select the media they captured. The user can then toggle whether they would like apple to strip their media of location data before handing it off to Damus. Lightning-address: kernelkind@getalby.com Signed-off-by: kernelkind <kernelkind@gmail.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
8d815fe4d6
commit
904ae6c24d
@ -625,6 +625,7 @@
|
|||||||
D7EDED342B12ACAE0018B19C /* DamusUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7EDED322B12ACAE0018B19C /* DamusUserDefaults.swift */; };
|
D7EDED342B12ACAE0018B19C /* DamusUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7EDED322B12ACAE0018B19C /* DamusUserDefaults.swift */; };
|
||||||
D7FB10A72B0C371A00FA8D42 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C2B10272A7B0F5C008AA43E /* Log.swift */; };
|
D7FB10A72B0C371A00FA8D42 /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C2B10272A7B0F5C008AA43E /* Log.swift */; };
|
||||||
D7FF94002AC7AC5300FD969D /* RelayURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */; };
|
D7FF94002AC7AC5300FD969D /* RelayURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */; };
|
||||||
|
E02429952B7E97740088B16C /* CameraController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02429942B7E97740088B16C /* CameraController.swift */; };
|
||||||
E02B54182B4DFADA0077FF42 /* Bech32ObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */; };
|
E02B54182B4DFADA0077FF42 /* Bech32ObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */; };
|
||||||
E04A37C62B544F090029650D /* URIParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = E04A37C52B544F090029650D /* URIParsing.swift */; };
|
E04A37C62B544F090029650D /* URIParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = E04A37C52B544F090029650D /* URIParsing.swift */; };
|
||||||
E0E024112B7C19C20075735D /* TranslationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E024102B7C19C20075735D /* TranslationTests.swift */; };
|
E0E024112B7C19C20075735D /* TranslationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0E024102B7C19C20075735D /* TranslationTests.swift */; };
|
||||||
@ -1403,6 +1404,7 @@
|
|||||||
D7EDED2D2B128E8A0018B19C /* CollectionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionExtension.swift; sourceTree = "<group>"; };
|
D7EDED2D2B128E8A0018B19C /* CollectionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionExtension.swift; sourceTree = "<group>"; };
|
||||||
D7EDED322B12ACAE0018B19C /* DamusUserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusUserDefaults.swift; sourceTree = "<group>"; };
|
D7EDED322B12ACAE0018B19C /* DamusUserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusUserDefaults.swift; sourceTree = "<group>"; };
|
||||||
D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayURL.swift; sourceTree = "<group>"; };
|
D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayURL.swift; sourceTree = "<group>"; };
|
||||||
|
E02429942B7E97740088B16C /* CameraController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraController.swift; sourceTree = "<group>"; };
|
||||||
E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bech32ObjectTests.swift; sourceTree = "<group>"; };
|
E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bech32ObjectTests.swift; sourceTree = "<group>"; };
|
||||||
E04A37C52B544F090029650D /* URIParsing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URIParsing.swift; sourceTree = "<group>"; };
|
E04A37C52B544F090029650D /* URIParsing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URIParsing.swift; sourceTree = "<group>"; };
|
||||||
E0E024102B7C19C20075735D /* TranslationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslationTests.swift; sourceTree = "<group>"; };
|
E0E024102B7C19C20075735D /* TranslationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslationTests.swift; sourceTree = "<group>"; };
|
||||||
@ -2653,6 +2655,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
BA3759962ABCCF360018D73B /* CameraPreview.swift */,
|
BA3759962ABCCF360018D73B /* CameraPreview.swift */,
|
||||||
|
E02429942B7E97740088B16C /* CameraController.swift */,
|
||||||
);
|
);
|
||||||
path = Camera;
|
path = Camera;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -3143,6 +3146,7 @@
|
|||||||
4C7D09592A05BEAD00943473 /* KeyboardVisible.swift in Sources */,
|
4C7D09592A05BEAD00943473 /* KeyboardVisible.swift in Sources */,
|
||||||
4CEE2AF7280B2DEA00AB5EEF /* ProfileName.swift in Sources */,
|
4CEE2AF7280B2DEA00AB5EEF /* ProfileName.swift in Sources */,
|
||||||
4CC7AAEB297F0AEC00430951 /* BuilderEventView.swift in Sources */,
|
4CC7AAEB297F0AEC00430951 /* BuilderEventView.swift in Sources */,
|
||||||
|
E02429952B7E97740088B16C /* CameraController.swift in Sources */,
|
||||||
31D2E847295218AF006D67F8 /* Shimmer.swift in Sources */,
|
31D2E847295218AF006D67F8 /* Shimmer.swift in Sources */,
|
||||||
D7CB5D3E2B116DAD00AD4105 /* NotificationsManager.swift in Sources */,
|
D7CB5D3E2B116DAD00AD4105 /* NotificationsManager.swift in Sources */,
|
||||||
50A16FFF2AA76A0900DFEC1F /* VideoController.swift in Sources */,
|
50A16FFF2AA76A0900DFEC1F /* VideoController.swift in Sources */,
|
||||||
|
66
damus/Views/Camera/CameraController.swift
Normal file
66
damus/Views/Camera/CameraController.swift
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
//
|
||||||
|
// CameraController.swift
|
||||||
|
// damus
|
||||||
|
//
|
||||||
|
// Created by KernelKind on 2/15/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct CameraController: UIViewControllerRepresentable {
|
||||||
|
|
||||||
|
@Environment(\.presentationMode)
|
||||||
|
@Binding private var presentationMode
|
||||||
|
|
||||||
|
let uploader: MediaUploader
|
||||||
|
let done: () -> Void
|
||||||
|
var imagesOnly: Bool = false
|
||||||
|
|
||||||
|
final class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
|
||||||
|
let parent: CameraController
|
||||||
|
|
||||||
|
init(_ parent: CameraController) {
|
||||||
|
self.parent = parent
|
||||||
|
}
|
||||||
|
|
||||||
|
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
|
||||||
|
if !parent.imagesOnly, let videoURL = info[UIImagePickerController.InfoKey.mediaURL] as? URL {
|
||||||
|
// Handle the selected video
|
||||||
|
UISaveVideoAtPathToSavedPhotosAlbum(videoURL.relativePath, nil, nil, nil)
|
||||||
|
} else if let cameraImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
|
||||||
|
let orientedImage = cameraImage.fixOrientation()
|
||||||
|
UIImageWriteToSavedPhotosAlbum(orientedImage, nil, nil, nil)
|
||||||
|
} else if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
|
||||||
|
let orientedImage = editedImage.fixOrientation()
|
||||||
|
UIImageWriteToSavedPhotosAlbum(orientedImage, nil, nil, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
||||||
|
parent.presentationMode.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCoordinator() -> Coordinator {
|
||||||
|
return Coordinator(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeUIViewController(context: UIViewControllerRepresentableContext<CameraController>) -> UIImagePickerController {
|
||||||
|
let picker = UIImagePickerController()
|
||||||
|
picker.sourceType = .camera
|
||||||
|
picker.mediaTypes = ["public.image", "com.compuserve.gif"]
|
||||||
|
if uploader.supportsVideo && !imagesOnly {
|
||||||
|
picker.mediaTypes.append("public.movie")
|
||||||
|
}
|
||||||
|
picker.delegate = context.coordinator
|
||||||
|
return picker
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIViewController(_ uiViewController: UIImagePickerController,
|
||||||
|
context: UIViewControllerRepresentableContext<CameraController>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -7,61 +7,52 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import PhotosUI
|
||||||
|
|
||||||
struct ImagePicker: UIViewControllerRepresentable {
|
struct ImagePicker: UIViewControllerRepresentable {
|
||||||
|
|
||||||
@Environment(\.presentationMode)
|
@Environment(\.presentationMode)
|
||||||
private var presentationMode
|
@Binding private var presentationMode
|
||||||
|
|
||||||
let uploader: MediaUploader
|
|
||||||
let sourceType: UIImagePickerController.SourceType
|
|
||||||
let pubkey: Pubkey
|
|
||||||
@Binding var image_upload_confirm: Bool
|
@Binding var image_upload_confirm: Bool
|
||||||
var imagesOnly: Bool = false
|
var imagesOnly: Bool = false
|
||||||
let onImagePicked: (URL) -> Void
|
let onMediaPicked: (MediaUpload) -> Void
|
||||||
let onVideoPicked: (URL) -> Void
|
|
||||||
|
|
||||||
final class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
|
final class Coordinator: NSObject, PHPickerViewControllerDelegate {
|
||||||
@Binding private var presentationMode: PresentationMode
|
let parent: ImagePicker
|
||||||
private let onImagePicked: (URL) -> Void
|
|
||||||
private let onVideoPicked: (URL) -> Void
|
|
||||||
@Binding var image_upload_confirm: Bool
|
|
||||||
|
|
||||||
init(presentationMode: Binding<PresentationMode>,
|
init(_ parent: ImagePicker) {
|
||||||
onImagePicked: @escaping (URL) -> Void,
|
self.parent = parent
|
||||||
onVideoPicked: @escaping (URL) -> Void,
|
|
||||||
image_upload_confirm: Binding<Bool>) {
|
|
||||||
_presentationMode = presentationMode
|
|
||||||
self.onImagePicked = onImagePicked
|
|
||||||
self.onVideoPicked = onVideoPicked
|
|
||||||
self._image_upload_confirm = image_upload_confirm
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
|
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
||||||
if let videoURL = info[UIImagePickerController.InfoKey.mediaURL] as? URL {
|
if results.isEmpty {
|
||||||
// Handle the selected video
|
self.parent.presentationMode.dismiss()
|
||||||
onVideoPicked(videoURL)
|
}
|
||||||
} else if let imageURL = info[UIImagePickerController.InfoKey.imageURL] as? URL {
|
|
||||||
// Handle the selected image
|
for result in results {
|
||||||
onImagePicked(imageURL)
|
if result.itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) {
|
||||||
} else if let cameraImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
|
result.itemProvider.loadObject(ofClass: UIImage.self) { (image, error) in
|
||||||
let orientedImage = cameraImage.fixOrientation()
|
guard let image = image as? UIImage, error == nil else { return }
|
||||||
if let imageURL = saveImageToTemporaryFolder(image: orientedImage, imageType: "jpeg") {
|
let fixedImage = image.fixOrientation()
|
||||||
onImagePicked(imageURL)
|
|
||||||
}
|
if let savedURL = self.saveImageToTemporaryFolder(image: fixedImage) {
|
||||||
} else if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
|
self.parent.onMediaPicked(.image(savedURL))
|
||||||
let orientedImage = editedImage.fixOrientation()
|
self.parent.image_upload_confirm = true
|
||||||
if let editedImageURL = saveImageToTemporaryFolder(image: orientedImage, imageType: "jpeg") {
|
}
|
||||||
onImagePicked(editedImageURL)
|
}
|
||||||
|
} else if result.itemProvider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
|
||||||
|
result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { (url, error) in
|
||||||
|
guard let url, error == nil else { return }
|
||||||
|
|
||||||
|
guard let url = self.saveVideoToTemporaryFolder(videoURL: url) else { return }
|
||||||
|
self.parent.onMediaPicked(.video(url))
|
||||||
|
self.parent.image_upload_confirm = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
image_upload_confirm = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
|
||||||
presentationMode.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
func saveImageToTemporaryFolder(image: UIImage, imageType: String = "png") -> URL? {
|
func saveImageToTemporaryFolder(image: UIImage, imageType: String = "png") -> URL? {
|
||||||
// Convert UIImage to Data
|
// Convert UIImage to Data
|
||||||
let imageData: Data?
|
let imageData: Data?
|
||||||
@ -90,34 +81,38 @@ struct ImagePicker: UIViewControllerRepresentable {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func saveVideoToTemporaryFolder(videoURL: URL) -> URL? {
|
||||||
|
let temporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||||
|
let fileExtension = videoURL.pathExtension
|
||||||
|
let uniqueFileName = UUID().uuidString + (fileExtension.isEmpty ? "" : ".\(fileExtension)")
|
||||||
|
let destinationURL = temporaryDirectoryURL.appendingPathComponent(uniqueFileName)
|
||||||
|
|
||||||
|
do {
|
||||||
|
try FileManager.default.copyItem(at: videoURL, to: destinationURL)
|
||||||
|
return destinationURL
|
||||||
|
} catch {
|
||||||
|
print("Error copying file: \(error.localizedDescription)")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeCoordinator() -> Coordinator {
|
func makeCoordinator() -> Coordinator {
|
||||||
return Coordinator(presentationMode: presentationMode,
|
Coordinator(self)
|
||||||
onImagePicked: { url in
|
|
||||||
// Handle the selected image URL
|
|
||||||
onImagePicked(url)
|
|
||||||
},
|
|
||||||
onVideoPicked: { videoURL in
|
|
||||||
// Handle the selected video URL
|
|
||||||
onVideoPicked(videoURL)
|
|
||||||
}, image_upload_confirm: $image_upload_confirm)
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
|
|
||||||
let picker = UIImagePickerController()
|
|
||||||
picker.sourceType = sourceType
|
|
||||||
picker.mediaTypes = ["public.image", "com.compuserve.gif"]
|
|
||||||
if uploader.supportsVideo && !imagesOnly {
|
|
||||||
picker.mediaTypes.append("public.movie")
|
|
||||||
}
|
}
|
||||||
picker.delegate = context.coordinator
|
|
||||||
|
func makeUIViewController(context: Context) -> PHPickerViewController {
|
||||||
|
var configuration = PHPickerConfiguration(photoLibrary: .shared())
|
||||||
|
configuration.selectionLimit = 1
|
||||||
|
configuration.filter = imagesOnly ? .images : .any(of: [.images, .videos])
|
||||||
|
|
||||||
|
let picker = PHPickerViewController(configuration: configuration)
|
||||||
|
picker.delegate = context.coordinator as any PHPickerViewControllerDelegate
|
||||||
return picker
|
return picker
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_ uiViewController: UIImagePickerController,
|
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {
|
||||||
context: UIViewControllerRepresentableContext<ImagePicker>) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,10 +420,8 @@ struct PostView: View {
|
|||||||
}
|
}
|
||||||
.background(DamusColors.adaptableWhite.edgesIgnoringSafeArea(.all))
|
.background(DamusColors.adaptableWhite.edgesIgnoringSafeArea(.all))
|
||||||
.sheet(isPresented: $attach_media) {
|
.sheet(isPresented: $attach_media) {
|
||||||
ImagePicker(uploader: damus_state.settings.default_media_uploader, sourceType: .photoLibrary, pubkey: damus_state.pubkey, image_upload_confirm: $image_upload_confirm) { img in
|
ImagePicker(image_upload_confirm: $image_upload_confirm) { media in
|
||||||
self.mediaToUpload = .image(img)
|
self.mediaToUpload = media
|
||||||
} onVideoPicked: { url in
|
|
||||||
self.mediaToUpload = .video(url)
|
|
||||||
}
|
}
|
||||||
.alert(NSLocalizedString("Are you sure you want to upload this media?", comment: "Alert message asking if the user wants to upload media."), isPresented: $image_upload_confirm) {
|
.alert(NSLocalizedString("Are you sure you want to upload this media?", comment: "Alert message asking if the user wants to upload media."), isPresented: $image_upload_confirm) {
|
||||||
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
||||||
@ -436,20 +434,9 @@ struct PostView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $attach_camera) {
|
.sheet(isPresented: $attach_camera) {
|
||||||
|
CameraController(uploader: damus_state.settings.default_media_uploader) {
|
||||||
ImagePicker(uploader: damus_state.settings.default_media_uploader, sourceType: .camera, pubkey: damus_state.pubkey, image_upload_confirm: $image_upload_confirm) { img in
|
self.attach_camera = false
|
||||||
self.mediaToUpload = .image(img)
|
self.attach_media = true
|
||||||
} onVideoPicked: { url in
|
|
||||||
self.mediaToUpload = .video(url)
|
|
||||||
}
|
|
||||||
.alert(NSLocalizedString("Are you sure you want to upload this media?", comment: "Alert message asking if the user wants to upload media."), isPresented: $image_upload_confirm) {
|
|
||||||
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
|
||||||
if let mediaToUpload {
|
|
||||||
self.handle_upload(media: mediaToUpload)
|
|
||||||
self.attach_camera = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button(NSLocalizedString("Cancel", comment: "Button to cancel the upload."), role: .cancel) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear() {
|
.onAppear() {
|
||||||
|
@ -61,10 +61,8 @@ struct EditPictureControl: View {
|
|||||||
}
|
}
|
||||||
.sheet(isPresented: $show_camera) {
|
.sheet(isPresented: $show_camera) {
|
||||||
|
|
||||||
ImagePicker(uploader: uploader, sourceType: .camera, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
|
ImagePicker(image_upload_confirm: $image_upload_confirm, imagesOnly: true) { media in
|
||||||
self.mediaToUpload = .image(img)
|
self.mediaToUpload = media
|
||||||
} onVideoPicked: { url in
|
|
||||||
print("Cannot upload videos as profile image")
|
|
||||||
}
|
}
|
||||||
.alert(NSLocalizedString("Are you sure you want to upload this image?", comment: "Alert message asking if the user wants to upload an image."), isPresented: $image_upload_confirm) {
|
.alert(NSLocalizedString("Are you sure you want to upload this image?", comment: "Alert message asking if the user wants to upload an image."), isPresented: $image_upload_confirm) {
|
||||||
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
||||||
@ -77,11 +75,12 @@ struct EditPictureControl: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $show_library) {
|
.sheet(isPresented: $show_library) {
|
||||||
ImagePicker(uploader: uploader, sourceType: .photoLibrary, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
|
ImagePicker(image_upload_confirm: $image_upload_confirm, imagesOnly: true) { media in
|
||||||
self.mediaToUpload = .image(img)
|
if case .image = media {
|
||||||
|
self.mediaToUpload = media
|
||||||
} onVideoPicked: { url in
|
} else {
|
||||||
print("Cannot upload videos as profile image")
|
print("Cannot upload videos as profile image")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.alert(NSLocalizedString("Are you sure you want to upload this image?", comment: "Alert message asking if the user wants to upload an image."), isPresented: $image_upload_confirm) {
|
.alert(NSLocalizedString("Are you sure you want to upload this image?", comment: "Alert message asking if the user wants to upload an image."), isPresented: $image_upload_confirm) {
|
||||||
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
Button(NSLocalizedString("Upload", comment: "Button to proceed with uploading."), role: .none) {
|
||||||
|
Loading…
Reference in New Issue
Block a user