//
//  ScenicPromotionMediaToolbarView.swift
//  suixinkan
//
//  Created by Codex on 2026/7/2.
//

import SwiftUI

/// 宣传页视频 / 照片切换工具条。
struct ScenicPromotionMediaToolbarView: View {
    let selectedMode: ScenicPromotionMediaMode
    let onSelectMode: (ScenicPromotionMediaMode) -> Void

    var body: some View {
        HStack(spacing: 14) {
            HStack(spacing: 0) {
                ForEach(ScenicPromotionMediaMode.allCases) { mode in
                    Button {
                        onSelectMode(mode)
                    } label: {
                        HStack(spacing: 6) {
                            Image(systemName: mode.iconName)
                            Text(mode.title)
                        }
                        .font(.system(size: 14, weight: .bold))
                        .foregroundStyle(selectedMode == mode ? .white : Color(hex: 0x1B4D91))
                        .frame(width: 68, height: 34)
                        .background(
                            selectedMode == mode
                            ? Color(hex: 0x0B79FF)
                            : Color.clear
                        )
                        .clipShape(Capsule())
                    }
                    .buttonStyle(.plain)
                }
            }
            .padding(3)
            .background(.white.opacity(0.78), in: Capsule())
            .overlay(Capsule().stroke(.white.opacity(0.9), lineWidth: 1))

            Spacer()

            Label("触屏切换视频/照片，左右滑动查看更多", systemImage: "hand.tap.fill")
                .font(.system(size: 12, weight: .semibold))
                .foregroundStyle(Color(hex: 0x124E97))
                .lineLimit(1)
                .minimumScaleFactor(0.58)
        }
    }
}

#if DEBUG
#Preview("素材切换工具条") {
    ScenicPromotionMediaToolbarView(selectedMode: .video, onSelectMode: { _ in })
        .padding(.horizontal, 20)
}
#endif
