import SwiftUI
import Bedrock

struct ContactAvatarView: View {
    let contact: Contact

    var body: some View {
        if let photoData = contact.photoData, let uiImage = UIImage(data: photoData) {
            Image(uiImage: uiImage)
                .resizable()
                .scaledToFill()
                .frame(width: Design.CardSize.avatarSize, height: Design.CardSize.avatarSize)
                .clipShape(.rect(cornerRadius: Design.CornerRadius.medium))
        } else {
            Image(systemName: contact.avatarSystemName)
                .typography(.title2)
                .foregroundStyle(Color.Accent.red)
                .frame(width: Design.CardSize.avatarSize, height: Design.CardSize.avatarSize)
                .background(Color.AppBackground.accent)
                .clipShape(.rect(cornerRadius: Design.CornerRadius.medium))
        }
    }
}
