|
@@ -10,7 +10,7 @@ import SwiftUI
|
|
import SwiftUIX
|
|
import SwiftUIX
|
|
class PurchaseViewModel : ObservableObject{
|
|
class PurchaseViewModel : ObservableObject{
|
|
|
|
|
|
- @Published var selectedType: PremiumPeriod = .month
|
|
|
|
|
|
+ @Published var selectedType: PremiumPeriod = .year
|
|
|
|
|
|
/// 订阅publisher
|
|
/// 订阅publisher
|
|
let buyPublisher = PassthroughSubject<Bool,Never>()
|
|
let buyPublisher = PassthroughSubject<Bool,Never>()
|
|
@@ -41,15 +41,32 @@ class TSPurchaseVC: TSBaseVC {
|
|
return vc
|
|
return vc
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
+ lazy var closeBtn: UIButton = {
|
|
|
|
+ let closeBtn = UIButton.createButton(image: UIImage(named: "close_gray")){ [weak self] in
|
|
|
|
+ guard let self = self else { return }
|
|
|
|
+ closePage()
|
|
|
|
+ }
|
|
|
|
+ return closeBtn
|
|
|
|
+ }()
|
|
override func createView() {
|
|
override func createView() {
|
|
- addNormalNavBarView()
|
|
|
|
- _ = setNavigationItem("", imageName: "close_gray", direction: .left, action: #selector(closePage))
|
|
|
|
|
|
+// addNormalNavBarView()
|
|
|
|
+// _ = setNavigationItem("", imageName: "close_gray", direction: .left, action: #selector(closePage))
|
|
|
|
+
|
|
|
|
+ setNavBarViewHidden(true)
|
|
setViewBgImageNamed(named: "purchase_bj")
|
|
setViewBgImageNamed(named: "purchase_bj")
|
|
|
|
|
|
contentView.addSubview(hostVc.view)
|
|
contentView.addSubview(hostVc.view)
|
|
hostVc.view.snp.makeConstraints { make in
|
|
hostVc.view.snp.makeConstraints { make in
|
|
make.leading.trailing.bottom.top.equalToSuperview()
|
|
make.leading.trailing.bottom.top.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ contentView.addSubview(closeBtn)
|
|
|
|
+ closeBtn.snp.makeConstraints { make in
|
|
|
|
+ make.leading.equalTo(10)
|
|
|
|
+ make.top.equalTo(k_Height_StatusBar + 4)
|
|
|
|
+ make.width.height.equalTo(36)
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
override func dealThings() {
|
|
override func dealThings() {
|
|
@@ -212,7 +229,7 @@ struct PurchaseView :View {
|
|
|
|
|
|
var body: some View {
|
|
var body: some View {
|
|
ScrollView {
|
|
ScrollView {
|
|
-// Spacer().frame(height: 44)
|
|
|
|
|
|
+ Spacer().frame(height:k_Height_StatusBar + 6)
|
|
|
|
|
|
VStack {
|
|
VStack {
|
|
Image("vip_big_icon").resizable().frame(width: 163, height: 163)
|
|
Image("vip_big_icon").resizable().frame(width: 163, height: 163)
|
|
@@ -230,24 +247,25 @@ struct PurchaseView :View {
|
|
|
|
|
|
ZStack {
|
|
ZStack {
|
|
VStack(alignment: .leading,spacing: 20) {
|
|
VStack(alignment: .leading,spacing: 20) {
|
|
-
|
|
|
|
|
|
+ let w = 28.0
|
|
|
|
+ let h = 28.0
|
|
HStack(spacing: 16) {
|
|
HStack(spacing: 16) {
|
|
- Image("vip_ringtone").resizable().frame(width: 32, height: 32)
|
|
|
|
|
|
+ Image("vip_ringtone").resizable().frame(width: w, height: h)
|
|
Text("Unlimited ringtones generation")
|
|
Text("Unlimited ringtones generation")
|
|
}
|
|
}
|
|
|
|
|
|
HStack(spacing: 16) {
|
|
HStack(spacing: 16) {
|
|
- Image("vip_pic").resizable().frame(width: 32, height: 32)
|
|
|
|
|
|
+ Image("vip_pic").resizable().frame(width: w, height: h)
|
|
Text("Generate unlimited contact poster&photo")
|
|
Text("Generate unlimited contact poster&photo")
|
|
}
|
|
}
|
|
|
|
|
|
HStack(spacing: 16) {
|
|
HStack(spacing: 16) {
|
|
- Image("vip_photo").resizable().frame(width: 32, height: 32)
|
|
|
|
|
|
+ Image("vip_photo").resizable().frame(width: w, height: h)
|
|
Text("Unlock all premium calling theme")
|
|
Text("Unlock all premium calling theme")
|
|
}
|
|
}
|
|
|
|
|
|
HStack(spacing: 16) {
|
|
HStack(spacing: 16) {
|
|
- Image("vip_ads").resizable().frame(width: 32, height: 32)
|
|
|
|
|
|
+ Image("vip_ads").resizable().frame(width: w, height: h)
|
|
Text("100% No Ads").multilineTextAlignment(.leading)
|
|
Text("100% No Ads").multilineTextAlignment(.leading)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -256,19 +274,26 @@ struct PurchaseView :View {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- Spacer().frame(height: 48)
|
|
|
|
|
|
+ Spacer().frame(height: 22)
|
|
|
|
|
|
|
|
|
|
VStack(spacing: 12) {
|
|
VStack(spacing: 12) {
|
|
|
|
|
|
|
|
+ ZStack(alignment: .topTrailing) {
|
|
|
|
+ PurchaseItemView(title: "One Year", type: .year, selectedType: $viewModel.selectedType).onTapGesture {
|
|
|
|
+ viewModel.selectedType = .year
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TSVipRecView().offset(y:-14)
|
|
|
|
+ }
|
|
|
|
+
|
|
ZStack(alignment: .topTrailing) {
|
|
ZStack(alignment: .topTrailing) {
|
|
PurchaseItemView(title: "One Month", type: .month, selectedType: $viewModel.selectedType).onTapGesture {
|
|
PurchaseItemView(title: "One Month", type: .month, selectedType: $viewModel.selectedType).onTapGesture {
|
|
viewModel.selectedType = .month
|
|
viewModel.selectedType = .month
|
|
}
|
|
}
|
|
-// TSVipRecView()
|
|
|
|
-// .offset(y:-14)
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// HStack {
|
|
// HStack {
|
|
// PurchaseItemView(title: "One Year", type: .year, selectedType: $viewModel.selectedType).onTapGesture {
|
|
// PurchaseItemView(title: "One Year", type: .year, selectedType: $viewModel.selectedType).onTapGesture {
|
|
// viewModel.selectedType = .year
|
|
// viewModel.selectedType = .year
|
|
@@ -334,27 +359,36 @@ struct PurchaseItemView: View {
|
|
@Binding var selectedType: PremiumPeriod
|
|
@Binding var selectedType: PremiumPeriod
|
|
|
|
|
|
var body: some View {
|
|
var body: some View {
|
|
|
|
+ let themeColor = Color.hex("#E661F6")
|
|
|
|
+ let fontColor = type == selectedType ? UIColor.mainText.color : UIColor.textAssist.color
|
|
|
|
+
|
|
ZStack {
|
|
ZStack {
|
|
- Color.clear
|
|
|
|
|
|
+ if type == selectedType {
|
|
|
|
+ themeColor.opacity(0.1)
|
|
|
|
+ }else{
|
|
|
|
+ Color.white.opacity(0.1)
|
|
|
|
+ }
|
|
|
|
+
|
|
HStack {
|
|
HStack {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
- Text(title).font(.font(size: 14)).foregroundColor(UIColor.textAssist.color)
|
|
|
|
- Text(kPurchaseDefault.price(for: type) ?? "--").font(.font(size: 18,weight: .medium)).foregroundColor(UIColor.mainText.color)
|
|
|
|
|
|
+ Text(title).font(.font(size: 14)).foregroundColor(fontColor)
|
|
|
|
+ Text(kPurchaseDefault.price(for: type) ?? "--").font(.font(size: 18,weight: .medium)).foregroundColor(fontColor)
|
|
}
|
|
}
|
|
Spacer()
|
|
Spacer()
|
|
if type == selectedType {
|
|
if type == selectedType {
|
|
Image(.radioboxSelected)
|
|
Image(.radioboxSelected)
|
|
}
|
|
}
|
|
}.padding(.horizontal)
|
|
}.padding(.horizontal)
|
|
|
|
+
|
|
}
|
|
}
|
|
.frame(height: 74) // 设置高度
|
|
.frame(height: 74) // 设置高度
|
|
.cornerRadius(16.0) // 圆角
|
|
.cornerRadius(16.0) // 圆角
|
|
|
|
|
|
.overlay(
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
RoundedRectangle(cornerRadius: 16)
|
|
- .stroke(Color.hex("#E661F6"), lineWidth: type == selectedType ? 1 : 0) // 边框
|
|
|
|
|
|
+ .stroke(themeColor, lineWidth: type == selectedType ? 1 : 0) // 边框
|
|
)
|
|
)
|
|
- .shadow(color: Color.hex("#E661F6"), radius: 4, x: 0, y: 1)
|
|
|
|
|
|
+ .shadow(color: type == selectedType ? themeColor : Color.clear, radius: 4, x: 0, y: 1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -364,10 +398,10 @@ struct TSVipRecView: View {
|
|
|
|
|
|
HStack(spacing: 4) {
|
|
HStack(spacing: 4) {
|
|
Image("upvote_black").resizable().frame(width: 16, height: 16)
|
|
Image("upvote_black").resizable().frame(width: 16, height: 16)
|
|
- Text("80% Choose").font(.font(size: 12,weight: .medium)).foregroundColor(.hex("#111111"))
|
|
|
|
|
|
+ Text("Save 60%").font(.font(size: 12,weight: .medium)).foregroundColor(.white)
|
|
}
|
|
}
|
|
.padding(EdgeInsets(top: 6, leading: 6, bottom: 6, trailing: 6))
|
|
.padding(EdgeInsets(top: 6, leading: 6, bottom: 6, trailing: 6))
|
|
- .background(Color.hex("#FECB34"))
|
|
|
|
|
|
+ .background(Color.hex("#E661F6"))
|
|
.frame(height: 28) // 设置高度
|
|
.frame(height: 28) // 设置高度
|
|
.cornerRadius([.topLeading, .topTrailing, .bottomLeading], 16.0)
|
|
.cornerRadius([.topLeading, .topTrailing, .bottomLeading], 16.0)
|
|
}
|
|
}
|