//
//  WiredTransferSelectAllBar.swift
//  suixinkan
//

import SwiftUI

/// 指定上传勾选模式下的全选栏。
struct WiredTransferSelectAllBar: View {
    let selectedCount: Int
    let selectableCount: Int
    let allSelected: Bool
    let onToggleSelectAll: () -> Void

    var body: some View {
        VStack(spacing: 0) {
            Button(action: onToggleSelectAll) {
                HStack(spacing: 8) {
                    WiredTransferSelectIndicator(selected: allSelected, enabled: selectableCount > 0)
                    Text("全选")
                        .font(.system(size: 14))
                        .foregroundStyle(selectableCount > 0 ? WiredTransferDesign.text333 : WiredTransferDesign.text999)
                        .frame(maxWidth: .infinity, alignment: .leading)
                    Text("已选 \(selectedCount) / \(selectableCount)")
                        .font(.system(size: 12))
                        .foregroundStyle(WiredTransferDesign.text666)
                }
                .padding(.horizontal, 16)
                .padding(.vertical, 10)
            }
            .buttonStyle(.plain)
            Divider().background(WiredTransferDesign.borderLight)
        }
        .background(Color.white)
    }
}

/// 勾选指示器。
struct WiredTransferSelectIndicator: View {
    let selected: Bool
    var enabled: Bool = true

    var body: some View {
        Image(systemName: selected ? "checkmark.circle.fill" : "circle")
            .font(.system(size: 20))
            .foregroundStyle(enabled ? (selected ? AppDesign.primary : WiredTransferDesign.text999) : WiredTransferDesign.text999.opacity(0.5))
    }
}
