//
//  TravelAlbumCodeSheet.swift
//  suixinkan
//
//  Created by Codex on 2026/6/29.
//

import SwiftUI

/// 旅拍相册小程序码弹窗。
struct TravelAlbumCodeSheet: View {
    let state: TravelAlbumCodeSheetState

    var body: some View {
        NavigationStack {
            VStack(spacing: AppMetrics.Spacing.large) {
                Text(state.albumName)
                    .font(.system(size: AppMetrics.FontSize.title3, weight: .semibold))

                if state.isLoading {
                    ProgressView("加载小程序码…")
                        .frame(height: 220)
                } else if state.qrImageURL.isEmpty {
                    AppContentUnavailableView("暂无小程序码", systemImage: "qrcode")
                        .frame(height: 220)
                } else {
                    RemoteImage(urlString: state.qrImageURL) {
                        Image(systemName: "qrcode")
                            .font(.system(size: 48))
                            .foregroundStyle(AppDesign.placeholder)
                    }
                        .frame(width: 220, height: 220)
                        .clipShape(RoundedRectangle(cornerRadius: 12))
                }

                Text("用户可扫码进入小程序选片")
                    .font(.system(size: AppMetrics.FontSize.subheadline))
                    .foregroundStyle(AppDesign.textSecondary)
            }
            .padding(AppMetrics.Spacing.pageHorizontal)
            .navigationTitle("相册码")
            .navigationBarTitleDisplayMode(.inline)
        }
        .presentationDetents([.medium])
    }
}
