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

import SwiftUI

/// 宣传页全屏背景，叠加轻量蓝绿色遮罩以贴近参考图。
struct ScenicPromotionSkyBackground: View {
    var body: some View {
        GeometryReader { proxy in
            ZStack(alignment: .bottom) {
                Image("ScenicPromotionBackground")
                    .resizable()
                    .scaledToFill()
                    // 先限定为容器尺寸，再裁剪超出部分（scaledToFill 会放大图片）。
                    .frame(width: proxy.size.width, height: proxy.size.height)
                    .clipped()

                LinearGradient(
                    colors: [
                        Color(hex: 0x1593FF, alpha: 0.16),
                        Color(hex: 0xBFE9FF, alpha: 0.10),
                        Color(hex: 0xEAF8FF, alpha: 0.42)
                    ],
                    startPoint: .top,
                    endPoint: .bottom
                )

                LinearGradient(
                    colors: [Color.clear, Color(hex: 0x62BA4C, alpha: 0.18)],
                    startPoint: .top,
                    endPoint: .bottom
                )
                .frame(height: 260)
            }
            .frame(width: proxy.size.width, height: proxy.size.height)
            .clipped()
        }
    }
}

/// 顶部二维码图片，快速点击三次进入设置页密码弹窗。
struct ScenicPromotionQRCodeView: View {
    var body: some View {
        Image("ScenicPromotionQRCode")
            .resizable()
            .scaledToFit()
    }
}

#if DEBUG
#Preview("宣传页背景") {
    ScenicPromotionSkyBackground()
        .ignoresSafeArea()
}

#Preview("宣传页二维码") {
    ScenicPromotionQRCodeView()
        .frame(width: 56, height: 56)
        .padding()
        .background(.white)
}
#endif
