Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created May 29, 2020 06:51
Show Gist options
  • Save Dimillian/3dba7320a172f861033d88416d296f05 to your computer and use it in GitHub Desktop.
Save Dimillian/3dba7320a172f861033d88416d296f05 to your computer and use it in GitHub Desktop.
import Purchases
struct SubscribeView: View {
enum Source: String {
case dashboard, turnip, turnipForm, list, musics
}
@EnvironmentObject private var subscriptionManager: SubscriptionManager
@Environment(\.presentationMode) private var presentationMode
let source: Source
@State private var sheetURL: URL?
private var sub: Purchases.Package? {
subscriptionManager.monthlySubscription
}
private var yearlySub: Purchases.Package? {
subscriptionManager.yearlySubscription
}
private var lifetime: Purchases.Package? {
subscriptionManager.lifetime
}
private func formattedPrice(for package: Purchases.Package) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.locale = sub!.product.priceLocale
return formatter.string(from: package.product.price)!
}
@JS1010111
Copy link

Take a look at package.localizedPriceString. Maybe the formattedPrice is not necessary.
Thanks a lot for sharing your SubscriptionManager!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment