diff --git a/BusinessCard/Views/CardEditorView.swift b/BusinessCard/Views/CardEditorView.swift index 9330d3a..c065d24 100644 --- a/BusinessCard/Views/CardEditorView.swift +++ b/BusinessCard/Views/CardEditorView.swift @@ -775,6 +775,7 @@ private extension CardEditorView { card.theme = selectedTheme card.layoutStyle = selectedLayout card.photoData = photoData + card.coverPhotoData = coverPhotoData card.logoData = logoData // Save contact fields to the model's array diff --git a/BusinessCard/Views/Sheets/PhotoCropperSheet.swift b/BusinessCard/Views/Sheets/PhotoCropperSheet.swift index e5117eb..7183c36 100644 --- a/BusinessCard/Views/Sheets/PhotoCropperSheet.swift +++ b/BusinessCard/Views/Sheets/PhotoCropperSheet.swift @@ -48,11 +48,12 @@ struct PhotoCropperSheet: View { @State private var lastOffset: CGSize = .zero @State private var containerSize: CGSize = .zero - // Base crop dimension - will be adjusted by aspect ratio - private let baseCropWidth: CGFloat = 300 + // Horizontal padding for the crop area + private let horizontalPadding: CGFloat = 20 private var cropWidth: CGFloat { - min(baseCropWidth, containerSize.width - 40) // Leave some padding + // Use almost full width for better cropping experience + max(100, containerSize.width - (horizontalPadding * 2)) } private var cropHeight: CGFloat { @@ -60,7 +61,11 @@ struct PhotoCropperSheet: View { } private var cropSize: CGSize { - CGSize(width: cropWidth, height: cropHeight) + // Guard against zero/invalid sizes + guard containerSize.width > 0, containerSize.height > 0 else { + return CGSize(width: 280, height: 280 / aspectRatio.ratio) + } + return CGSize(width: cropWidth, height: cropHeight) } private var uiImage: UIImage? {