chore: make sure to crop the image into a square
This commit is contained in:
parent
211f5dd0e4
commit
eb2057d14e
|
@ -21,7 +21,8 @@ extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerVi
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let cropController = CropViewController(croppingStyle: .default, image: image)
|
let cropController = CropViewController(croppingStyle: .default, image: image)
|
||||||
cropController.delegate = self
|
cropController.delegate = self
|
||||||
self.image = image
|
cropController.setAspectRatioPreset(.presetSquare, animated: true)
|
||||||
|
cropController.aspectRatioLockEnabled = true
|
||||||
picker.dismiss(animated: true, completion: {
|
picker.dismiss(animated: true, completion: {
|
||||||
self.present(cropController, animated: true, completion: nil)
|
self.present(cropController, animated: true, completion: nil)
|
||||||
})
|
})
|
||||||
|
@ -30,7 +31,7 @@ extension MastodonRegisterViewController: CropViewControllerDelegate, PHPickerVi
|
||||||
}
|
}
|
||||||
|
|
||||||
public func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) {
|
public func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) {
|
||||||
self.image = image
|
self.viewModel.avatarImage.value = image
|
||||||
self.photoButton.setImage(image, for: .normal)
|
self.photoButton.setImage(image, for: .normal)
|
||||||
cropViewController.dismiss(animated: true, completion: nil)
|
cropViewController.dismiss(animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
||||||
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
||||||
|
|
||||||
// avater image
|
|
||||||
var image: UIImage?
|
|
||||||
|
|
||||||
var viewModel: MastodonRegisterViewModel!
|
var viewModel: MastodonRegisterViewModel!
|
||||||
|
|
||||||
let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
||||||
|
|
|
@ -24,6 +24,7 @@ final class MastodonRegisterViewModel {
|
||||||
let email = CurrentValueSubject<String, Never>("")
|
let email = CurrentValueSubject<String, Never>("")
|
||||||
let password = CurrentValueSubject<String, Never>("")
|
let password = CurrentValueSubject<String, Never>("")
|
||||||
let reason = CurrentValueSubject<String, Never>("")
|
let reason = CurrentValueSubject<String, Never>("")
|
||||||
|
let avatarImage = CurrentValueSubject<UIImage?, Never>(nil)
|
||||||
|
|
||||||
// output
|
// output
|
||||||
let approvalRequired: Bool
|
let approvalRequired: Bool
|
||||||
|
|
Loading…
Reference in New Issue