//
//  LoadingView.swift
//  LotteryTracker
//
//  Created by aaa on 2026/1/22.
//

import SwiftUI

struct LoadingView: View {
    var title: String = "加载中..."
    var subtitle: String? = nil
    
    var body: some View {
        VStack(spacing: 16) {
            ProgressView()
                .scaleEffect(1.2)
                .tint(.blue)
            
            Text(title)
                .font(.headline)
                .foregroundColor(.primary)
            
            if let subtitle = subtitle {
                Text(subtitle)
                    .font(.subheadline)
                    .foregroundColor(.secondary)
                    .multilineTextAlignment(.center)
            }
        }
        .padding(40)
        .background(Color(.systemBackground))
        .cornerRadius(16)
        .shadow(color: .black.opacity(0.1), radius: 10)
    }
}

// 全屏加载视图
struct FullScreenLoadingView: View {
    var body: some View {
        ZStack {
            Color(.systemBackground)
                .ignoresSafeArea()
            
            LoadingView()
        }
    }
}

// 预览
struct LoadingView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            LoadingView()
                .previewLayout(.sizeThatFits)
            
            FullScreenLoadingView()
                .previewLayout(.sizeThatFits)
        }
    }
}
