mv-experiment #1
|
@ -64,6 +64,10 @@ extension ConversationStore {
|
||||||
// await client.uploadMedia(item.url)
|
// await client.uploadMedia(item.url)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendCaptured(_ data: Data, _ type: GalleryMediaType) async {
|
||||||
|
print("captured!", data, type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension ConversationStore {
|
private extension ConversationStore {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import SwiftUI
|
||||||
|
|
||||||
struct CameraCellPreview: View {
|
struct CameraCellPreview: View {
|
||||||
@Environment(\.router) var router
|
@Environment(\.router) var router
|
||||||
|
@EnvironmentObject var conversation: ConversationStore
|
||||||
@EnvironmentObject var store: AttachmentsStore
|
@EnvironmentObject var store: AttachmentsStore
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -24,7 +25,12 @@ struct CameraCellPreview: View {
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
router.showScreen(.fullScreenCover) { _ in
|
router.showScreen(.fullScreenCover) { _ in
|
||||||
CameraPicker()
|
CameraPicker { data, type in
|
||||||
|
Task {
|
||||||
|
await conversation.sendCaptured(data, type)
|
||||||
|
}
|
||||||
|
router.dismissEnvironment()
|
||||||
|
}
|
||||||
.ignoresSafeArea(.all)
|
.ignoresSafeArea(.all)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@ import Photos
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct CameraPicker: UIViewControllerRepresentable {
|
struct CameraPicker: UIViewControllerRepresentable {
|
||||||
// var sourceType: UIImagePickerController.SourceType
|
var completionHandler: (Data, GalleryMediaType) -> Void
|
||||||
// var completionHandler: (Data, SharingCameraMediaType) -> Void
|
|
||||||
|
|
||||||
func makeUIViewController(context: Context) -> UIImagePickerController {
|
func makeUIViewController(context: Context) -> UIImagePickerController {
|
||||||
let picker = UIImagePickerController()
|
let picker = UIImagePickerController()
|
||||||
|
@ -34,17 +33,17 @@ struct CameraPicker: UIViewControllerRepresentable {
|
||||||
// swiftlint:disable:next force_cast
|
// swiftlint:disable:next force_cast
|
||||||
let mediaType = info[.mediaType] as! String
|
let mediaType = info[.mediaType] as! String
|
||||||
|
|
||||||
// if mediaType == UTType.image.identifier {
|
if mediaType == UTType.image.identifier {
|
||||||
// if let image = info[.originalImage] as? UIImage {
|
if let image = info[.originalImage] as? UIImage {
|
||||||
// let data = image.jpegData(compressionQuality: 1.0) ?? Data()
|
let data = image.jpegData(compressionQuality: 1.0) ?? Data()
|
||||||
// parent.completionHandler(data, .photo)
|
parent.completionHandler(data, .photo)
|
||||||
// }
|
}
|
||||||
// } else if mediaType == UTType.movie.identifier {
|
} else if mediaType == UTType.movie.identifier {
|
||||||
// if let url = info[.mediaURL] as? URL {
|
if let url = info[.mediaURL] as? URL {
|
||||||
// let data = try? Data(contentsOf: url)
|
let data = try? Data(contentsOf: url)
|
||||||
// parent.completionHandler(data ?? Data(), .video)
|
parent.completionHandler(data ?? Data(), .video)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue