Merge branch 'iap-improvements'

Pull a few patches from v1.7-rc1

purple: show welcome sheet after ln payment
iap: add loading spinner to purchase actions
This commit is contained in:
William Casarin
2024-02-26 10:22:26 -08:00
4 changed files with 162 additions and 16 deletions

View File

@@ -47,6 +47,7 @@ struct DamusPurpleVerifyNpubView: View {
Button(action: {
Task {
try await damus_state.purple.verify_npub_for_checkout(checkout_id: checkout_id)
damus_state.purple.checkout_ids_in_progress.insert(checkout_id)
verified = true
}
}, label: {

View File

@@ -21,20 +21,32 @@ extension DamusPurpleView {
let subscribe: (Product) async throws -> Void
@State var show_manage_subscriptions = false
@State var subscription_purchase_loading = false
var body: some View {
switch self.products {
case .failed:
PurpleViewPrimitives.ProductLoadErrorView()
case .loaded(let products):
if let purchased {
PurchasedView(purchased)
} else {
ProductsView(products)
}
case .loading:
if subscription_purchase_loading {
HStack(spacing: 10) {
Text(NSLocalizedString("Purchasing", comment: "Loading label indicating the purchase action is in progress"))
.foregroundStyle(.white)
ProgressView()
.progressViewStyle(.circular)
.tint(.white)
}
}
else {
switch self.products {
case .failed:
PurpleViewPrimitives.ProductLoadErrorView()
case .loaded(let products):
if let purchased {
PurchasedView(purchased)
} else {
ProductsView(products)
}
case .loading:
ProgressView()
.progressViewStyle(.circular)
}
}
}
@@ -107,7 +119,9 @@ extension DamusPurpleView {
Button(action: {
Task { @MainActor in
do {
subscription_purchase_loading = true
try await subscribe(product)
subscription_purchase_loading = false
} catch {
print(error.localizedDescription)
}