diff --git a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings index d82ae5ab..32fba5b7 100644 --- a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings @@ -455,6 +455,7 @@ "status.editor.text.placeholder" = "Пра што вы думаеце?"; "status.editor.visibility" = "Бачнасць допісу"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "Пры загрузцы паведамленняў адбылася памылка, паўтарыце спробу."; "status.error.message" = "Адбылася памылка ў кантэксце гэтай публікацыі, паспрабуйце яшчэ раз."; diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index 971e7c61..cb073c04 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -449,6 +449,7 @@ "status.editor.text.placeholder" = "Què us passa pel cap?"; "status.editor.visibility" = "Visibilitat de la publicació"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "S'ha produït un error en carregar les publicacions, torneu-ho a provar."; "status.error.message" = "S'ha produït un error en el context d'aquesta publicació, torneu-ho a provar."; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 1341a2af..77c4478e 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -444,6 +444,7 @@ "status.editor.text.placeholder" = "Woran denkst du?"; "status.editor.visibility" = "Sichtbarkeit"; "status.editor.photo-library" = "Fotoalbum"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Dateien durchsuchen"; "status.error.loading.message" = "Beim Laden der Beiträge ist ein Fehler aufgetreten. Bitte versuche es erneut."; "status.error.message" = "Es ist ein Fehler aufgetreten. Bitte versuche es erneut."; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 0f83d290..a2bd4ac8 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -450,6 +450,7 @@ "status.editor.text.placeholder" = "What's on your mind?"; "status.editor.visibility" = "Post visibility"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "An error occurred while loading posts, please try again."; "status.error.message" = "An error occurred in the context of this post, please try again."; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index f7b984d4..b2d4597b 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -451,6 +451,7 @@ "status.editor.text.placeholder" = "What's on your mind?"; "status.editor.visibility" = "Post visibility"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "An error occurred while loading posts, please try again."; "status.error.message" = "An error occurred in the context of this post, please try again."; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index 198518d1..d86bcd1c 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -451,6 +451,7 @@ "status.editor.text.placeholder" = "¿En qué estás pensando?"; "status.editor.visibility" = "Visibilidad de la publicación"; "status.editor.photo-library" = "Fototeca"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Archivos"; "status.error.loading.message" = "Ha ocurrido un error al cargar las publicaciones, por favor, vuelve a intentarlo."; "status.error.message" = "Ha ocurrido un error al cargar el contexto de esta publicación, por favor, vuelve a intentarlo."; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index ea80e9c7..e680434f 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -444,6 +444,7 @@ "status.editor.text.placeholder" = "Zer duzu buruan?"; "status.editor.visibility" = "Bidalketaren irismena"; "status.editor.photo-library" = "Argazki-liburutegia"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Arakatu fitxategiak"; "status.error.loading.message" = "Errorea bidalketak kargatzean; saiatu berriro."; "status.error.message" = "Errorea bidalketa honen testuinguruan; saiatu berriro."; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index d8a118c4..0801c19e 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -446,6 +446,7 @@ "status.editor.text.placeholder" = "Qu'est-ce qui vous passe par la tête ?"; "status.editor.visibility" = "Visibilité de la publication"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "Une erreur s'est produite lors du chargement des publications, veuillez réessayer."; "status.error.message" = "Une erreur s'est produite dans le contexte de cette publication, veuillez réessayer."; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index faf8ac89..869271f0 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -450,6 +450,7 @@ "status.editor.text.placeholder" = "A cosa stai pensando?"; "status.editor.visibility" = "Visibilità del post"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "Si è verificato un errore durante il caricamento dei post, per favore riprova."; "status.error.message" = "Si è verificato un errore durante il caricamento del post, per favore riprova."; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index ba09b3b8..08581f2a 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -450,6 +450,7 @@ "status.editor.text.placeholder" = "いま、何を考えているの?"; "status.editor.visibility" = "投稿の公開範囲"; "status.editor.photo-library" = "写真ライブラリ"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "ファイルの参照"; "status.error.loading.message" = "投稿の読み込み中にエラーが発生しました、もう一度試してください"; "status.error.message" = "この投稿のコンテキストでエラーが発生しました、もう一度試してください"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index efd81d4c..f48e0ef1 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -452,6 +452,7 @@ "status.editor.text.placeholder" = "무슨 생각을 하고 계신가요?"; "status.editor.visibility" = "글 공개 범위"; "status.editor.photo-library" = "사진 보관함"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "파일 앱"; "status.error.loading.message" = "글을 불러오지 못했습니다. 다시 시도해주세요."; "status.error.message" = "글의 상세 정보를 불러오지 못했습니다. 다시 시도해주세요."; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 1b8dd9a6..d8e335f0 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -450,6 +450,7 @@ "status.editor.text.placeholder" = "Hva tenker du på?"; "status.editor.visibility" = "Innleggssynlighet"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "Det oppsto en feil under innlasting av innlegg, prøv igjen."; "status.error.message" = "Det oppsto en feil i forbindelse med dette innlegget, prøv igjen."; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index f4e5e003..4db2b2ee 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -444,6 +444,7 @@ "status.editor.text.placeholder" = "Waar denk je aan?"; "status.editor.visibility" = "Zichtbaarheid"; "status.editor.photo-library" = "Fotobibliotheek"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Bestanden"; "status.error.loading.message" = "Er heeft zich een fout voorgedaan tijdens het laden van je posts. Probeer het nogmaals."; "status.error.message" = "Er heeft zich een fout voorgedaan. Probeer het nogmaals."; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index 94cf1f90..9fe116a2 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -446,6 +446,7 @@ "status.editor.text.placeholder" = "Co ci chodzi po głowie?"; "status.editor.visibility" = "Widoczność postu"; "status.editor.photo-library" = "Biblioteka zdjęć"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Przeglądaj pliki"; "status.error.loading.message" = "Wystąpił błąd podczas ładowania postów, spróbuj ponownie."; "status.error.message" = "Wystąpił błąd dotyczący tego postu, proszę spróbuj ponownie."; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 8c8489a5..7ea448b2 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -450,6 +450,7 @@ "status.editor.text.placeholder" = "O que você está pensando?"; "status.editor.visibility" = "Visibilidade da postagem"; "status.editor.photo-library" = "Biblioteca de Fotos"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Procurar Arquivos"; "status.error.loading.message" = "Ocorreu um erro enquanto as postagens eram carregadas, por favor, tente novamente."; "status.error.message" = "Ocorreu um erro com esta postagem, por favor, tente novamente."; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 13a69351..7e09a364 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -446,6 +446,7 @@ "status.editor.text.placeholder" = "Aklında ne var?"; "status.editor.visibility" = "Görüntü görünürlüğü"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "Gönderi yüklenirken bir hata oluştu, lütfen tekrar deneyin."; "status.error.message" = "Bu gönderi bağlamında bir hata oluştu, lütfen tekrar deneyin."; diff --git a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings index fd03e762..f310d1a5 100644 --- a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings @@ -451,6 +451,7 @@ "status.editor.text.placeholder" = "Що у вас на думці?"; "status.editor.visibility" = "Видимість допису"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "An error occurred while loading posts, please try again."; "status.error.message" = "An error occurred in the context of this post, please try again."; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index 26968aca..878a1406 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -449,6 +449,7 @@ "status.editor.text.placeholder" = "在想些什么呢?"; "status.editor.visibility" = "嘟文可见性"; "status.editor.photo-library" = "Photos Library"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "Browse Files"; "status.error.loading.message" = "加载嘟文时发生错误,请重试。"; "status.error.message" = "嘟文的上下文出现了错误,请重试。"; diff --git a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings index 6b39d0fa..dd846a5c 100644 --- a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings @@ -451,6 +451,7 @@ "status.editor.text.placeholder" = "您在想些什麼呢?"; "status.editor.visibility" = "嘟文能見度"; "status.editor.photo-library" = "相片圖庫"; +"status.editor.camera-picker" = "Take Photo"; "status.editor.browse-file" = "瀏覽檔案"; "status.error.loading.message" = "下載嘟文時發生錯誤,請再試一次。"; "status.error.message" = "嘟文上下文發生錯誤,請再試一次。"; diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index caba2305..84f37bae 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -21,6 +21,7 @@ struct StatusEditorAccessoryView: View { @State private var isLoadingAIRequest: Bool = false @State private var isPhotosPickerPresented: Bool = false @State private var isFileImporterPresented: Bool = false + @State private var isCameraPickerPresented: Bool = false var body: some View { VStack(spacing: 0) { @@ -34,6 +35,11 @@ struct StatusEditorAccessoryView: View { } label: { Label("status.editor.photo-library", systemImage: "photo") } + Button { + isCameraPickerPresented = true + } label: { + Label("status.editor.camera-picker", systemImage: "camera") + } Button { isFileImporterPresented = true } label: { @@ -48,6 +54,7 @@ struct StatusEditorAccessoryView: View { } .photosPicker(isPresented: $isPhotosPickerPresented, selection: $viewModel.selectedMedias, + maxSelectionCount: 4, matching: .any(of: [.images, .videos])) .fileImporter(isPresented: $isFileImporterPresented, allowedContentTypes: [.image, .video], @@ -57,6 +64,16 @@ struct StatusEditorAccessoryView: View { viewModel.processURLs(urls: urls) } } + .fullScreenCover(isPresented: $isCameraPickerPresented, content: { + StatusEditorCameraPickerView(selectedImage: .init(get: { + nil + }, set: { image in + if let image { + viewModel.processCameraPhoto(image: image) + } + })) + .background(.black) + }) .accessibilityLabel("accessibility.editor.button.attach-photo") .disabled(viewModel.showPoll) diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorCameraPickerView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorCameraPickerView.swift new file mode 100644 index 00000000..f5a558d7 --- /dev/null +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorCameraPickerView.swift @@ -0,0 +1,35 @@ +import UIKit +import SwiftUI + +struct StatusEditorCameraPickerView: UIViewControllerRepresentable { + @Binding var selectedImage: UIImage? + @Environment(\.presentationMode) var isPresented + + class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { + let picker: StatusEditorCameraPickerView + + init(picker: StatusEditorCameraPickerView) { + self.picker = picker + } + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + guard let selectedImage = info[.originalImage] as? UIImage else { return } + self.picker.selectedImage = selectedImage + self.picker.isPresented.wrappedValue.dismiss() + } + } + + func makeUIViewController(context: Context) -> UIImagePickerController { + let imagePicker = UIImagePickerController() + imagePicker.sourceType = .camera + return imagePicker + } + + func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { + + } + + func makeCoordinator() -> Coordinator { + Coordinator(picker: self) + } +} diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index 04253d75..53af3601 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -371,6 +371,14 @@ public class StatusEditorViewModel: NSObject, ObservableObject { .compactMap { NSItemProvider(contentsOf: $0) } processItemsProvider(items: items) } + + func processCameraPhoto(image: UIImage) { + mediasImages.append(.init(image: image, + movieTransferable: nil, + gifTransferable: nil, + mediaAttachment: nil, + error: nil)) + } private func processItemsProvider(items: [NSItemProvider]) { Task {