//
//  SettingPurchaseTopView.swift
//  AIEmoji
//
//  Created by 100Years on 2025/2/4.
//
import SwiftUI
struct SettingPurchaseTopView: View {
    var eventPublisher: ListEventPublisher
    @Binding var isViper: Bool
    var body: some View {
        ZStack {
            if isViper {
                Image(.settingVipBj).resizable().frame(width: 343*kDesignScale, height: 109*kDesignScale)
                HStack {
                    Spacer().frame(width:20)
                    VStack(alignment: .leading,spacing: 16) {
                        HStack {
                            customText(text: " AI Ringtone Pro")
                            Spacer()
                        }
                        
                        HStack {
                            customTimeText(text: "Due Date:".localized + " \(kPurchaseDefault.expiredDateString)")
                            Spacer()
                        }
                    }
                    
                    Spacer()
                    
//                    Image(.vipBigIcon).resizable().frame(width: 88, height: 78)
                }
            }else {
                Image(.settingUnvipBj).resizable().frame(width: 343*kDesignScale, height: 109*kDesignScale)
                HStack {
                    Spacer().frame(width:20)
                    VStack(alignment: .leading,spacing: 16) {
                        HStack {
                            customText(text: " Get Pro")
                            Spacer()
                        }
                        
                        HStack {
                            customTimeText(text: "Limited Time Discount")
                            Spacer()
                        }
                    }
                    
                    Spacer()
                    
                    Text("Upgrade")
                        .font(.font(size: 14,weight: .medium))
                        .padding(EdgeInsets(top: 0, leading: 12, bottom: 0, trailing: 12))
                        .frame(height: 26) // 设置高度
                        .foregroundColor("#FBDAFF".uiColor.color)
                        .background(UIColor.themeColor.color)
                        .cornerRadius(13.0) // 圆角
                        .onTapGesture {
                            if kPurchaseToolShared.isVip {
                                return
                            }
                            eventPublisher.enterPurchasePublisher.send(true)
                        }

                        Spacer().frame(width: 15)
                }
            }
        }
    }
    
    // 定义一个返回 View 的方法
    func customText(text:String) -> some View {
        let gorgeousColor = "#F7B7FF".uiColor.color
        return Text(" AI Ringtone Pro")
            .font(.font(name: .PoppinsBlackItalic,size: 20))
            .gradientForeground(
                colors: [Color.white, gorgeousColor],
                startPoint: UnitPoint.top,
                endPoint: UnitPoint.bottom
            )
            .shadow(color: gorgeousColor.opacity(0.7), radius: 6, x: 0, y: 0)
            .frame(height: 20)
    }


    // 定义一个返回 View 的方法
    func customTimeText(text:String) -> some View {
        Text(text)
            .font(.font(size: 14))
            .frame(height: 14)
            .foregroundColor(UIColor.white.withAlphaComponent(0.6).color)
        
    }
}
