import SwiftUI

struct ImageThumbnailView: View {
    let image: UIImage
    let onRemove: () -> Void

    var body: some View {
        ZStack(alignment: .topTrailing) {
            Image(uiImage: image)
                .resizable()
                .scaledToFill()
                .frame(width: 100, height: 100)
                .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
                .overlay {
                    RoundedRectangle(cornerRadius: 12, style: .continuous)
                        .strokeBorder(.quaternary, lineWidth: 1)
                }
                .accessibilityLabel("Attached photo")
                .accessibilityAddTraits(.isImage)

            Button(action: onRemove) {
                Image(systemName: "xmark.circle.fill")
                    .font(.title3)
                    .foregroundStyle(Color.appTextOnPrimary)
                    .background {
                        Circle()
                            .fill(.black.opacity(0.6))
                            .padding(4)
                    }
            }
            .accessibilityLabel(A11y.Common.removePhoto)
            .offset(x: 8, y: -8)
        }
    }
}
