wip
This commit is contained in:
parent
3361b828ef
commit
8da928e237
|
@ -388,24 +388,19 @@ struct CameraPicker: UIViewControllerRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
||||||
if let mediaType = info[.mediaType] as? UTType {
|
// swiftlint:disable:next force_cast
|
||||||
switch mediaType {
|
let mediaType = info[.mediaType] as! String
|
||||||
case .image:
|
|
||||||
|
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, .image)
|
parent.completionHandler(data, .image)
|
||||||
}
|
}
|
||||||
|
} else if mediaType == UTType.movie.identifier {
|
||||||
case .movie:
|
|
||||||
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(), .movie)
|
parent.completionHandler(data ?? Data(), .movie)
|
||||||
}
|
}
|
||||||
parent.completionHandler(Data(), .movie)
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue