mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-27 07:46:15 +01:00
chore: code format
This commit is contained in:
parent
ea511c153f
commit
211f5dd0e4
@ -5,31 +5,30 @@
|
||||
// Created by sxiaojian on 2021/3/2.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import CropViewController
|
||||
import Foundation
|
||||
import PhotosUI
|
||||
extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerViewControllerDelegate, UINavigationControllerDelegate{
|
||||
import UIKit
|
||||
|
||||
extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerViewControllerDelegate {
|
||||
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
||||
if let itemProvider = results.first?.itemProvider, itemProvider.canLoadObject(ofClass: UIImage.self) {
|
||||
|
||||
itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
|
||||
guard let self = self, let image = image as? UIImage else { return }
|
||||
DispatchQueue.main.async {
|
||||
let cropController = CropViewController(croppingStyle: .default, image: image)
|
||||
cropController.delegate = self
|
||||
self.image = image
|
||||
picker.dismiss(animated: true, completion: {
|
||||
self.present(cropController, animated: true, completion: nil)
|
||||
})
|
||||
}
|
||||
guard let itemProvider = results.first?.itemProvider, itemProvider.canLoadObject(ofClass: UIImage.self) else {
|
||||
picker.dismiss(animated: true, completion: {})
|
||||
return
|
||||
}
|
||||
itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, _ in
|
||||
guard let self = self, let image = image as? UIImage else { return }
|
||||
DispatchQueue.main.async {
|
||||
let cropController = CropViewController(croppingStyle: .default, image: image)
|
||||
cropController.delegate = self
|
||||
self.image = image
|
||||
picker.dismiss(animated: true, completion: {
|
||||
self.present(cropController, animated: true, completion: nil)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
picker.dismiss(animated: true, completion: {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) {
|
||||
self.image = image
|
||||
self.photoButton.setImage(image, for: .normal)
|
||||
@ -39,7 +38,7 @@ extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerVi
|
||||
@objc func avatarButtonPressed(_ sender: UIButton) {
|
||||
var configuration = PHPickerConfiguration()
|
||||
configuration.filter = .images
|
||||
|
||||
|
||||
let imagePicker = PHPickerViewController(configuration: configuration)
|
||||
imagePicker.delegate = self
|
||||
self.present(imagePicker, animated: true, completion: nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user