Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
fdcb594511
commit
0823e46d72
@ -72,6 +72,14 @@ struct CardEditorView: View {
|
||||
case .logo: return String.localized("Add company logo")
|
||||
}
|
||||
}
|
||||
|
||||
var cropAspectRatio: CropAspectRatio {
|
||||
switch self {
|
||||
case .profile: return .square
|
||||
case .cover: return .banner
|
||||
case .logo: return .square
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var isEditing: Bool { card != nil }
|
||||
@ -250,6 +258,7 @@ struct CardEditorView: View {
|
||||
.fullScreenCover(isPresented: $showingPhotoPicker) {
|
||||
NavigationStack {
|
||||
PhotoPickerWithCropper(
|
||||
aspectRatio: activeImageType?.cropAspectRatio ?? .square,
|
||||
onSave: { croppedData in
|
||||
savePhoto(croppedData, for: activeImageType)
|
||||
showingPhotoPicker = false
|
||||
@ -264,6 +273,7 @@ struct CardEditorView: View {
|
||||
}
|
||||
.fullScreenCover(isPresented: $showingCamera) {
|
||||
CameraWithCropper(
|
||||
aspectRatio: activeImageType?.cropAspectRatio ?? .square,
|
||||
onSave: { croppedData in
|
||||
savePhoto(croppedData, for: activeImageType)
|
||||
showingCamera = false
|
||||
|
||||
@ -7,9 +7,20 @@ import Bedrock
|
||||
struct CameraWithCropper: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
let aspectRatio: CropAspectRatio
|
||||
let onSave: (Data) -> Void
|
||||
let onCancel: () -> Void
|
||||
|
||||
init(
|
||||
aspectRatio: CropAspectRatio = .square,
|
||||
onSave: @escaping (Data) -> Void,
|
||||
onCancel: @escaping () -> Void
|
||||
) {
|
||||
self.aspectRatio = aspectRatio
|
||||
self.onSave = onSave
|
||||
self.onCancel = onCancel
|
||||
}
|
||||
|
||||
@State private var capturedImageData: Data?
|
||||
@State private var showingCropper = false
|
||||
|
||||
@ -31,6 +42,7 @@ struct CameraWithCropper: View {
|
||||
if showingCropper, let capturedImageData {
|
||||
PhotoCropperSheet(
|
||||
imageData: capturedImageData,
|
||||
aspectRatio: aspectRatio,
|
||||
shouldDismissOnComplete: false
|
||||
) { croppedData in
|
||||
if let croppedData {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user