//
//  WiredTransferBottomBar.swift
//  suixinkan
//

import SwiftUI

/// 有线传图底部操作栏。
struct WiredTransferBottomBar: View {
    let selectUploadMode: Bool
    let selectedCount: Int
    let onBatchUploadClick: () -> Void
    let onSpecifyUploadClick: () -> Void

    private var batchButtonTitle: String {
        if !selectUploadMode { return "批量上传" }
        if selectedCount > 0 { return "上传选中照片" }
        return "取消选择"
    }

    var body: some View {
        VStack(spacing: 0) {
            Divider().background(WiredTransferDesign.borderLight)
            HStack(spacing: 12) {
                Button(action: onBatchUploadClick) {
                    Text(batchButtonTitle)
                        .font(.system(size: 15))
                        .foregroundStyle(.white)
                        .frame(maxWidth: .infinity)
                        .frame(height: WiredTransferDesign.bottomButtonHeight)
                        .background(AppDesign.primary)
                        .clipShape(RoundedRectangle(cornerRadius: WiredTransferDesign.bottomButtonCornerRadius))
                }
                .buttonStyle(.plain)

                Button(action: onSpecifyUploadClick) {
                    Text("指定上传")
                        .font(.system(size: 15))
                        .foregroundStyle(selectUploadMode ? WiredTransferDesign.text999 : AppDesign.primary)
                        .frame(maxWidth: .infinity)
                        .frame(height: WiredTransferDesign.bottomButtonHeight)
                        .overlay {
                            RoundedRectangle(cornerRadius: WiredTransferDesign.bottomButtonCornerRadius)
                                .stroke(AppDesign.primary, lineWidth: 1)
                        }
                }
                .buttonStyle(.plain)
                .disabled(selectUploadMode)
            }
            .padding(.horizontal, 16)
            .padding(.vertical, 12)
        }
        .background(Color.white)
    }
}
