Allow users to buy Bubble+
This commit is contained in:
parent
f64d85204c
commit
049e6b9666
|
@ -6,13 +6,15 @@ import RevenueCat
|
||||||
|
|
||||||
public struct ShopView: View {
|
public struct ShopView: View {
|
||||||
@Environment(AppDelegate.self) private var delegate: AppDelegate
|
@Environment(AppDelegate.self) private var delegate: AppDelegate
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.openURL) private var openURL: OpenURLAction
|
||||||
|
@Environment(\.dismiss) private var dismiss: DismissAction
|
||||||
|
|
||||||
@State private var showSub: Bool = false
|
@State private var showSub: Bool = false
|
||||||
@State private var purchaseError: Bool = false
|
@State private var purchaseError: Bool = false
|
||||||
|
@State private var hasSub: Bool = false
|
||||||
|
|
||||||
private var canPay: Bool {
|
private var canPay: Bool {
|
||||||
#if targetEnvironment(simulator)
|
#if targetEnvironment(simulator) || !DEBUG
|
||||||
return true
|
return true
|
||||||
#else
|
#else
|
||||||
return false
|
return false
|
||||||
|
@ -38,6 +40,7 @@ public struct ShopView: View {
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
|
if !self.hasSub {
|
||||||
VStack(spacing: 20) {
|
VStack(spacing: 20) {
|
||||||
Button {
|
Button {
|
||||||
showSub.toggle()
|
showSub.toggle()
|
||||||
|
@ -76,6 +79,49 @@ public struct ShopView: View {
|
||||||
.padding(.top, 50)
|
.padding(.top, 50)
|
||||||
}
|
}
|
||||||
.padding(.vertical)
|
.padding(.vertical)
|
||||||
|
} else {
|
||||||
|
VStack {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
#if !targetEnvironment(simulator)
|
||||||
|
if let windowScene = self.delegate.window?.windowScene {
|
||||||
|
print("accessing subs natively")
|
||||||
|
try? await AppStore.showManageSubscriptions(in: windowScene)
|
||||||
|
} else {
|
||||||
|
print("accessing subs via deeplink")
|
||||||
|
openURL(URL(string: "itms-apps://apps.apple.com/account/subscriptions")!)
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
print("ACCESS SUBS but Simulator can't")
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
VStack {
|
||||||
|
Text("shop.bubble-plus.owning")
|
||||||
|
.font(.title2.bold())
|
||||||
|
.foregroundStyle(Color(uiColor: UIColor.label))
|
||||||
|
|
||||||
|
Text("shop.bubble-plus.manage")
|
||||||
|
.font(.callout)
|
||||||
|
.foregroundStyle(Color.blue)
|
||||||
|
}
|
||||||
|
.padding(.vertical)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
dismiss()
|
||||||
|
} label: {
|
||||||
|
Text("shop.bubble-plus.dismiss")
|
||||||
|
}
|
||||||
|
.buttonStyle(.borderless)
|
||||||
|
.padding(.top, 50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.task {
|
||||||
|
AppDelegate.hasPlus { subscribed in
|
||||||
|
self.hasSub = subscribed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.frame(width: delegate.windowWidth)
|
.frame(width: delegate.windowWidth)
|
||||||
.background(Color.appBackground)
|
.background(Color.appBackground)
|
||||||
|
@ -99,7 +145,7 @@ public struct ShopView: View {
|
||||||
|
|
||||||
feature(.drafts)
|
feature(.drafts)
|
||||||
|
|
||||||
feature(.analytics)
|
// feature(.analytics)
|
||||||
|
|
||||||
feature(.contentFilter)
|
feature(.contentFilter)
|
||||||
|
|
||||||
|
@ -392,6 +438,7 @@ extension ShopView {
|
||||||
// .environment(\.locale, Locale(identifier: "en-us"))
|
// .environment(\.locale, Locale(identifier: "en-us"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Entitlements
|
||||||
enum PlusEntitlements: String {
|
enum PlusEntitlements: String {
|
||||||
case monthly
|
case monthly
|
||||||
case yearly
|
case yearly
|
||||||
|
|
Loading…
Reference in New Issue