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")
|
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 }
|
private var isEditing: Bool { card != nil }
|
||||||
@ -250,6 +258,7 @@ struct CardEditorView: View {
|
|||||||
.fullScreenCover(isPresented: $showingPhotoPicker) {
|
.fullScreenCover(isPresented: $showingPhotoPicker) {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
PhotoPickerWithCropper(
|
PhotoPickerWithCropper(
|
||||||
|
aspectRatio: activeImageType?.cropAspectRatio ?? .square,
|
||||||
onSave: { croppedData in
|
onSave: { croppedData in
|
||||||
savePhoto(croppedData, for: activeImageType)
|
savePhoto(croppedData, for: activeImageType)
|
||||||
showingPhotoPicker = false
|
showingPhotoPicker = false
|
||||||
@ -264,6 +273,7 @@ struct CardEditorView: View {
|
|||||||
}
|
}
|
||||||
.fullScreenCover(isPresented: $showingCamera) {
|
.fullScreenCover(isPresented: $showingCamera) {
|
||||||
CameraWithCropper(
|
CameraWithCropper(
|
||||||
|
aspectRatio: activeImageType?.cropAspectRatio ?? .square,
|
||||||
onSave: { croppedData in
|
onSave: { croppedData in
|
||||||
savePhoto(croppedData, for: activeImageType)
|
savePhoto(croppedData, for: activeImageType)
|
||||||
showingCamera = false
|
showingCamera = false
|
||||||
|
|||||||
@ -7,9 +7,20 @@ import Bedrock
|
|||||||
struct CameraWithCropper: View {
|
struct CameraWithCropper: View {
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
|
let aspectRatio: CropAspectRatio
|
||||||
let onSave: (Data) -> Void
|
let onSave: (Data) -> Void
|
||||||
let onCancel: () -> 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 capturedImageData: Data?
|
||||||
@State private var showingCropper = false
|
@State private var showingCropper = false
|
||||||
|
|
||||||
@ -31,6 +42,7 @@ struct CameraWithCropper: View {
|
|||||||
if showingCropper, let capturedImageData {
|
if showingCropper, let capturedImageData {
|
||||||
PhotoCropperSheet(
|
PhotoCropperSheet(
|
||||||
imageData: capturedImageData,
|
imageData: capturedImageData,
|
||||||
|
aspectRatio: aspectRatio,
|
||||||
shouldDismissOnComplete: false
|
shouldDismissOnComplete: false
|
||||||
) { croppedData in
|
) { croppedData in
|
||||||
if let croppedData {
|
if let croppedData {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user