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 {
|
||||
let cropController = CropViewController(croppingStyle: .default, image: image)
|
||||
cropController.delegate = self
|
||||
self.image = image
|
||||
cropController.setAspectRatioPreset(.presetSquare, animated: true)
|
||||
cropController.aspectRatioLockEnabled = true
|
||||
picker.dismiss(animated: true, completion: {
|
||||
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) {
|
||||
self.image = image
|
||||
self.viewModel.avatarImage.value = image
|
||||
self.photoButton.setImage(image, for: .normal)
|
||||
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 coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
||||
|
||||
// avater image
|
||||
var image: UIImage?
|
||||
|
||||
var viewModel: MastodonRegisterViewModel!
|
||||
|
||||
let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
||||
|
|
|
@ -24,6 +24,7 @@ final class MastodonRegisterViewModel {
|
|||
let email = CurrentValueSubject<String, Never>("")
|
||||
let password = CurrentValueSubject<String, Never>("")
|
||||
let reason = CurrentValueSubject<String, Never>("")
|
||||
let avatarImage = CurrentValueSubject<UIImage?, Never>(nil)
|
||||
|
||||
// output
|
||||
let approvalRequired: Bool
|
||||
|
|
Loading…
Reference in New Issue