//
//  WiredTransferStatusBadge.swift
//  suixinkan
//

import SwiftUI

/// 有线传图上传状态 Badge。
struct WiredTransferStatusBadge: View {
    let status: WiredTransferUploadStatus

    var body: some View {
        Text(status.displayLabel)
            .font(.system(size: 9))
            .foregroundStyle(textColor)
            .padding(.horizontal, 4)
            .padding(.vertical, 1)
            .background(backgroundColor)
            .clipShape(RoundedRectangle(cornerRadius: 3))
    }

    private var textColor: Color {
        switch status {
        case .uploaded: WiredTransferDesign.success
        case .pending: WiredTransferDesign.text666
        case .transferring, .uploading: AppDesign.primary
        case .failed: WiredTransferDesign.danger
        }
    }

    private var backgroundColor: Color {
        switch status {
        case .uploaded: WiredTransferDesign.success.opacity(0.12)
        case .pending: WiredTransferDesign.pageBackground
        case .transferring, .uploading: AppDesign.primary.opacity(0.12)
        case .failed: WiredTransferDesign.danger.opacity(0.12)
        }
    }
}
