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

import SwiftUI

/// 宣传页正常内容区，组装各业务子模块。
struct ScenicPromotionContentView: View {
    @ObservedObject var viewModel: ScenicPromotionViewModel
    let onQRCodeTap: () -> Void
    let onQRCodeLongPress: () -> Void
    let onVideoTap: () -> Void

    var body: some View {
        VStack(spacing: ScenicPromotionLayout.moduleVerticalSpacing) {
            if let board = viewModel.board {
                ScenicPromotionHeaderView(
                    board: board,
                    onQRCodeTap: onQRCodeTap,
                    onQRCodeLongPress: onQRCodeLongPress
                )
                ScenicPromotionSpotTabsView(
                    spots: board.spots,
                    selectedSpotID: viewModel.selectedSpot?.id,
                    onSelectSpot: viewModel.selectSpot
                )
                ScenicPromotionMetricsGridView(queue: viewModel.queue)
                ScenicPromotionQueuePanelView(queue: viewModel.queue)
                ScenicPromotionMediaToolbarView(
                    selectedMode: viewModel.selectedMode,
                    onSelectMode: viewModel.selectMode
                )
                ScenicPromotionMediaStripView(
                    mediaItems: viewModel.mediaItems,
                    selectedMediaID: viewModel.selectedMedia?.id,
                    emptyMode: viewModel.selectedMode,
                    onSelectMedia: viewModel.selectMedia,
                    onMoveMedia: viewModel.moveMedia
                )
                ScenicPromotionHeroMediaView(
                    selectedMedia: viewModel.selectedMedia,
                    emptyMode: viewModel.selectedMode,
                    onVideoTap: onVideoTap
                )
            }
        }
        .border(.blue)
        .padding(.top, 28)
        .padding(.bottom, 24)
        .border(.red)
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
        .padding(.horizontal, ScenicPromotionLayout.screenEdgePadding)
    }
}

#if DEBUG
#Preview("宣传页内容") {
    ZStack {
        ScenicPromotionSkyBackground().ignoresSafeArea()
        ScenicPromotionContentView(
            viewModel: ScenicPromotionPreviewSupport.mainViewModel(),
            onQRCodeTap: {},
            onQRCodeLongPress: {},
            onVideoTap: {}
        )
    }
}
#endif
