|
@@ -24,7 +24,7 @@ class MediaPicker: NSObject, UINavigationControllerDelegate, UIImagePickerContro
|
|
minimumSize: CGSize(width: 70, height: 70))
|
|
minimumSize: CGSize(width: 70, height: 70))
|
|
|
|
|
|
let controller = CameraViewController.imagePickerViewController(croppingParameters: croppingParameters,
|
|
let controller = CameraViewController.imagePickerViewController(croppingParameters: croppingParameters,
|
|
- completion: { [weak self] image, asset in
|
|
|
|
|
|
+ completion: { [weak self] image, _ in
|
|
if let image = image {
|
|
if let image = image {
|
|
self?.delegate?.onImageSelected(image: image)
|
|
self?.delegate?.onImageSelected(image: image)
|
|
}
|
|
}
|
|
@@ -33,6 +33,33 @@ class MediaPicker: NSObject, UINavigationControllerDelegate, UIImagePickerContro
|
|
navigationController.present(controller, animated: true, completion: nil)
|
|
navigationController.present(controller, animated: true, completion: nil)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func showCamera(delegate: MediaPickerDelegate) {
|
|
|
|
+ if UIImagePickerController.isSourceTypeAvailable(.camera) {
|
|
|
|
+ let croppingParameters = CroppingParameters(isEnabled: true,
|
|
|
|
+ allowResizing: true,
|
|
|
|
+ allowMoving: true,
|
|
|
|
+ minimumSize: CGSize(width: 70, height: 70))
|
|
|
|
+ let cameraViewController = CameraViewController(croppingParameters: croppingParameters,
|
|
|
|
+ allowsLibraryAccess: false,
|
|
|
|
+ allowsSwapCameraOrientation: true,
|
|
|
|
+ allowVolumeButtonCapture: false,
|
|
|
|
+ completion: { [weak self] image, _ in
|
|
|
|
+ if let image = image {
|
|
|
|
+ self?.delegate?.onImageSelected(image: image)
|
|
|
|
+ }
|
|
|
|
+ self?.navigationController.dismiss(animated: true, completion: self?.delegate?.onDismiss)})
|
|
|
|
+ self.delegate = delegate
|
|
|
|
+ navigationController.present(cameraViewController, animated: true, completion: nil)
|
|
|
|
+ } else {
|
|
|
|
+ let alert = UIAlertController(title: String.localized("chat_camera_unavailable"), message: nil, preferredStyle: .alert)
|
|
|
|
+ alert.addAction(UIAlertAction(title: String.localized("ok"), style: .cancel, handler: { _ in
|
|
|
|
+ self.navigationController.dismiss(animated: true, completion: nil)
|
|
|
|
+ }))
|
|
|
|
+ navigationController.present(alert, animated: true, completion: nil)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
func showPhotoLibrary(delegate: MediaPickerDelegate) {
|
|
func showPhotoLibrary(delegate: MediaPickerDelegate) {
|
|
if PHPhotoLibrary.authorizationStatus() != .authorized {
|
|
if PHPhotoLibrary.authorizationStatus() != .authorized {
|
|
PHPhotoLibrary.requestAuthorization { status in
|
|
PHPhotoLibrary.requestAuthorization { status in
|