//
//  View+Extensions.swift
//  LotteryTracker
//
//  Created by aaa on 2026/1/22.
//

import SwiftUI

extension View {
    // 卡片样式
    func cardStyle() -> some View {
        self
            .padding()
            .background(Color(.systemBackground))
            .cornerRadius(12)
            .shadow(color: .black.opacity(0.05), radius: 5, x: 0, y: 2)
    }
    
    // 限制为单行，超出显示...
    func singleLine() -> some View {
        self
            .lineLimit(1)
            .truncationMode(.tail)
    }
    
    // 隐藏列表行分隔符
    func hideRowSeparator() -> some View {
        self
            .listRowSeparator(.hidden)
            .listRowInsets(EdgeInsets())
    }
    
    // 加载中状态
    func loading(_ isLoading: Bool) -> some View {
        self
            .overlay {
                if isLoading {
                    ProgressView()
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.black.opacity(0.1))
                }
            }
    }
}
