123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // SettingPurchaseTopView.swift
- // AIEmoji
- //
- // Created by 100Years on 2025/2/4.
- //
- import SwiftUI
- struct SettingPurchaseTopView: View {
- var eventPublisher: ListEventPublisher
- @Binding var vipType: PremiumPeriod
- var body: some View {
- let topW = k_ScreenWidth-32
- let topH = 134.0
- let updateText = vipType == .none ? "Upgrade to PRO".localized : "Upgrade Yearly Pro".localized
- let timeString = "Due Date:".localized + " \(PurchaseManager.default.expiredDateString)"
- let timeText = vipType == .none ? "Limited Time Discount".localized : timeString
- ZStack {
- Image(.settingVipBj).resizable().cornerRadius(16.0)
- if vipType == .year {
- VStack(alignment: .center) {
- customGradientText(text: "\(kAppName) pro", font: .font(name: .PoppinsBoldItalic,size: 36))
- Spacer().frame(height: 15)
- Text(String(format: "Remaining Times: %d".localized, kPurchaseDefault.videoAvailableNum))
- .foregroundColor(UIColor.themeColor.color)
- .font(.font(size: 16,weight: .regular))
- .frame(height: 16)
- Spacer().frame(height: 20)
- Text(timeString)
- .foregroundColor(.white.opacity(0.6))
- .font(.font(size: 14,weight: .medium))
- .frame(height: 14)
- }//.border(Color.blue, width: 1)
- }else{
- VStack(){
- HStack {
- VStack(alignment: .leading,spacing: 8) {
- customGradientText(text: updateText, font: .font(name: .PoppinsBoldItalic,size: 22),colors: [.white]).frame(width: 230.0*kDesignScale,height: 26,alignment: .leading)
- HStack {
- Text(timeText)
- .font(.font(size: 14))
- .frame(height: 14)
- .foregroundColor(UIColor.white.withAlphaComponent(0.6).color)
- Spacer()
- }
- }
-
- Spacer()
-
- Text("Save-Vip".localized + " " + vipType.saveString)
- .lineLimit(1)
- .foregroundColor(Color.white)
- .font(.font(size: 12,weight: .semibold))
- .frame(width: 82*kDesignScale, height: 28, alignment: .center)
- .foregroundColor("#010101".uiColor.color)
- .background(Color.hex("#E83E3E"))
- .cornerRadius(4.0)
- .minimumScaleFactor(0.5)
- .rotationEffect(.degrees(15)) // 向右旋转45度
- }
-
- Spacer().frame(width: 12)
-
- Text("Upgrade".localized)
- .font(.font(size: 14,weight: .medium))
- .frame(width: topW-32, height: 38, alignment: .center)
- .foregroundColor("#010101".uiColor.color)
- .background(UIColor.themeColor.color)
- .cornerRadius(8.0) // 圆角
- .onTapGesture {
- eventPublisher.enterPurchasePublisher.send(true)
- }
- }.padding(.all,16.0)
- }
- }.frame(width: topW, height: topH)
- }
- func customGradientText(text:String,font:Font,colors:[Color] = [.hex("#FA794F"),.hex("#F8C32A"),.hex("#FEFBF4")]) -> some View {
- return Text(text)
- .lineLimit(1)
- .font(font)
- .gradientForeground(
- colors: colors,
- startPoint: UnitPoint.leading,
- endPoint: UnitPoint.trailing
- )
- .minimumScaleFactor(0.5)
- // .shadow(color: gorgeousColor.opacity(0.7), radius: 6, x: 0, y: 0)
- }
-
- // 定义一个返回 View 的方法
- func customTimeText(text:String) -> some View {
- Text(text)
- .font(.font(size: 14))
- .frame(height: 14)
- .foregroundColor(UIColor.white.withAlphaComponent(0.6).color)
-
- }
- }
|