Created
May 29, 2020 06:51
-
-
Save Dimillian/3dba7320a172f861033d88416d296f05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)! | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Take a look at
package.localizedPriceString
. Maybe theformattedPrice
is not necessary.Thanks a lot for sharing your SubscriptionManager!