mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
* feat: Dont show cancel path if lifetime subscription * added variable + tests * add lifetime sub check * nits * remove extra loding path * Renamed isLifetime * Added docs
67 lines
1.5 KiB
Swift
67 lines
1.5 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// ManageSubscriptionsButtonsView.swift
|
|
//
|
|
// Created by Cesar de la Vega on 2/12/24.
|
|
|
|
import Foundation
|
|
import RevenueCat
|
|
import SwiftUI
|
|
|
|
#if os(iOS)
|
|
|
|
@available(iOS 15.0, *)
|
|
@available(macOS, unavailable)
|
|
@available(tvOS, unavailable)
|
|
@available(watchOS, unavailable)
|
|
struct ManageSubscriptionsButtonsView: View {
|
|
|
|
@ObservedObject
|
|
var viewModel: ManageSubscriptionsViewModel
|
|
|
|
var body: some View {
|
|
ForEach(self.viewModel.relevantPathsForPurchase, id: \.id) { path in
|
|
ManageSubscriptionButton(
|
|
path: path,
|
|
viewModel: self.viewModel
|
|
)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
@available(iOS 15.0, *)
|
|
@available(macOS, unavailable)
|
|
@available(tvOS, unavailable)
|
|
@available(watchOS, unavailable)
|
|
private struct ManageSubscriptionButton: View {
|
|
|
|
let path: CustomerCenterConfigData.HelpPath
|
|
|
|
@ObservedObject
|
|
var viewModel: ManageSubscriptionsViewModel
|
|
|
|
var body: some View {
|
|
AsyncButton(action: {
|
|
await self.viewModel.determineFlow(for: path)
|
|
}, label: {
|
|
if self.viewModel.loadingPath?.id == path.id {
|
|
TintedProgressView()
|
|
} else {
|
|
Text(path.title)
|
|
}
|
|
})
|
|
.disabled(self.viewModel.loadingPath != nil)
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|