iap warning view
This commit is contained in:
62
Shared/views/IAPWarningView.swift
Normal file
62
Shared/views/IAPWarningView.swift
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// PurchaseButtonView.swift
|
||||
// Feels
|
||||
//
|
||||
// Created by Trey Tartt on 7/7/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import StoreKit
|
||||
|
||||
struct IAPWarningView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
||||
|
||||
var iapManager: IAPManager
|
||||
|
||||
private let height: Float
|
||||
private let showManageSubClosure: (() -> Void)?
|
||||
@State private var showSettings = false
|
||||
|
||||
public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil, showCountdownTimer: Bool = false) {
|
||||
self.height = height
|
||||
self.showManageSubClosure = showManageSubClosure
|
||||
self.iapManager = iapManager
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(String(format: String(localized: "iap_warning_view_title"), iapManager.daysLeftBeforeIAP))
|
||||
.font(.body)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
|
||||
Button(action: {
|
||||
showSettings.toggle()
|
||||
}, label: {
|
||||
Text(String(localized: "iap_warning_view_buy_button"))
|
||||
.foregroundColor(.white)
|
||||
.bold()
|
||||
.frame(maxWidth: .infinity)
|
||||
.contentShape(Rectangle())
|
||||
})
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(DefaultMoodTint.color(forMood: .great)))
|
||||
}
|
||||
// .frame(height: CGFloat(height))
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.padding()
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
.sheet(isPresented: $showSettings) {
|
||||
SettingsView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct IAPWarningView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
IAPWarningView(height: 175, iapManager: IAPManager())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user