wip
This commit is contained in:
parent
3361b828ef
commit
8da928e237
|
@ -388,23 +388,18 @@ struct CameraPicker: UIViewControllerRepresentable {
|
|||
}
|
||||
|
||||
func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
||||
if let mediaType = info[.mediaType] as? UTType {
|
||||
switch mediaType {
|
||||
case .image:
|
||||
if let image = info[.originalImage] as? UIImage {
|
||||
let data = image.jpegData(compressionQuality: 1.0) ?? Data()
|
||||
parent.completionHandler(data, .image)
|
||||
}
|
||||
// swiftlint:disable:next force_cast
|
||||
let mediaType = info[.mediaType] as! String
|
||||
|
||||
case .movie:
|
||||
if let url = info[.mediaURL] as? URL {
|
||||
let data = try? Data(contentsOf: url)
|
||||
parent.completionHandler(data ?? Data(), .movie)
|
||||
}
|
||||
parent.completionHandler(Data(), .movie)
|
||||
|
||||
default:
|
||||
break
|
||||
if mediaType == UTType.image.identifier {
|
||||
if let image = info[.originalImage] as? UIImage {
|
||||
let data = image.jpegData(compressionQuality: 1.0) ?? Data()
|
||||
parent.completionHandler(data, .image)
|
||||
}
|
||||
} else if mediaType == UTType.movie.identifier {
|
||||
if let url = info[.mediaURL] as? URL {
|
||||
let data = try? Data(contentsOf: url)
|
||||
parent.completionHandler(data ?? Data(), .movie)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue