SettingPurchaseTopView.swift 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // SettingPurchaseTopView.swift
  3. // AIEmoji
  4. //
  5. // Created by 100Years on 2025/2/4.
  6. //
  7. import SwiftUI
  8. struct SettingPurchaseTopView: View {
  9. var eventPublisher: ListEventPublisher
  10. @Binding var vipType: PremiumPeriod
  11. var body: some View {
  12. let topW = k_ScreenWidth-32
  13. let topH = 134.0
  14. let updateText = vipType == .none ? "Upgrade to PRO".localized : "Upgrade Yearly Pro".localized
  15. let timeString = "Due Date:".localized + " \(PurchaseManager.default.expiredDateString)"
  16. let timeText = vipType == .none ? "Limited Time Discount".localized : timeString
  17. ZStack {
  18. Image(.settingVipBj).resizable().cornerRadius(16.0)
  19. if vipType == .year {
  20. VStack(alignment: .center) {
  21. customGradientText(text: "\(kAppName) pro", font: .font(name: .PoppinsBoldItalic,size: 36))
  22. Spacer().frame(height: 15)
  23. Text(String(format: "Remaining Times: %d".localized, kPurchaseDefault.videoAvailableNum))
  24. .foregroundColor(UIColor.themeColor.color)
  25. .font(.font(size: 16,weight: .regular))
  26. .frame(height: 16)
  27. Spacer().frame(height: 20)
  28. Text(timeString)
  29. .foregroundColor(.white.opacity(0.6))
  30. .font(.font(size: 14,weight: .medium))
  31. .frame(height: 14)
  32. }//.border(Color.blue, width: 1)
  33. }else{
  34. VStack(){
  35. HStack {
  36. VStack(alignment: .leading,spacing: 8) {
  37. customGradientText(text: updateText, font: .font(name: .PoppinsBoldItalic,size: 22),colors: [.white]).frame(width: 230.0*kDesignScale,height: 26,alignment: .leading)
  38. HStack {
  39. Text(timeText)
  40. .font(.font(size: 14))
  41. .frame(height: 14)
  42. .foregroundColor(UIColor.white.withAlphaComponent(0.6).color)
  43. Spacer()
  44. }
  45. }
  46. Spacer()
  47. Text("Save-Vip".localized + " " + vipType.saveString)
  48. .lineLimit(1)
  49. .foregroundColor(Color.white)
  50. .font(.font(size: 12,weight: .semibold))
  51. .frame(width: 82*kDesignScale, height: 28, alignment: .center)
  52. .foregroundColor("#010101".uiColor.color)
  53. .background(Color.hex("#E83E3E"))
  54. .cornerRadius(4.0)
  55. .minimumScaleFactor(0.5)
  56. .rotationEffect(.degrees(15)) // 向右旋转45度
  57. }
  58. Spacer().frame(width: 12)
  59. Text("Upgrade".localized)
  60. .font(.font(size: 14,weight: .medium))
  61. .frame(width: topW-32, height: 38, alignment: .center)
  62. .foregroundColor("#010101".uiColor.color)
  63. .background(UIColor.themeColor.color)
  64. .cornerRadius(8.0) // 圆角
  65. .onTapGesture {
  66. eventPublisher.enterPurchasePublisher.send(true)
  67. }
  68. }.padding(.all,16.0)
  69. }
  70. }.frame(width: topW, height: topH)
  71. }
  72. func customGradientText(text:String,font:Font,colors:[Color] = [.hex("#FA794F"),.hex("#F8C32A"),.hex("#FEFBF4")]) -> some View {
  73. return Text(text)
  74. .lineLimit(1)
  75. .font(font)
  76. .gradientForeground(
  77. colors: colors,
  78. startPoint: UnitPoint.leading,
  79. endPoint: UnitPoint.trailing
  80. )
  81. .minimumScaleFactor(0.5)
  82. // .shadow(color: gorgeousColor.opacity(0.7), radius: 6, x: 0, y: 0)
  83. }
  84. // 定义一个返回 View 的方法
  85. func customTimeText(text:String) -> some View {
  86. Text(text)
  87. .font(.font(size: 14))
  88. .frame(height: 14)
  89. .foregroundColor(UIColor.white.withAlphaComponent(0.6).color)
  90. }
  91. }