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

import SwiftUI

/// 设置页素材所属打卡点选择卡片。
struct ScenicPromotionSettingsMaterialPointCard: View {
    @ObservedObject var viewModel: ScenicPromotionSettingsViewModel

    var body: some View {
        ScenicPromotionSettingsCard(
            title: "素材所属打卡点",
            subtitle: "视频和图片上传前必须先选择，和上方排队绑定点分开管理",
            icon: "mappin.and.ellipse",
            tint: Color(hex: 0x22A06B)
        ) {
            Menu {
                ForEach(viewModel.materialPoints) { point in
                    Button {
                        viewModel.selectMaterialPoint(point)
                    } label: {
                        Label(
                            "\(point.name) · \(point.areaName)",
                            systemImage: viewModel.selectedMaterialPointID == point.id ? "checkmark.circle.fill" : "circle"
                        )
                    }
                }
            } label: {
                ScenicPromotionSettingsSelectionField(
                    title: viewModel.selectedMaterialPointName,
                    subtitle: viewModel.selectedMaterialPoint == nil ? "未选择" : "已展示当前点位素材",
                    icon: "chevron.down"
                )
            }
            .buttonStyle(.plain)
        }
    }
}

#if DEBUG
#Preview("素材点卡片") {
    ScenicPromotionSettingsMaterialPointCard(
        viewModel: ScenicPromotionPreviewSupport.settingsViewModel()
    )
    .padding()
    .background(AppDesign.background)
}
#endif
