Mercurial > public > simoleon
diff Simoleon/ContentView.swift @ 42:d25b02d439d4
Minor updates subscription and legal requirements
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 26 Jul 2021 15:35:06 +0100 |
parents | 98ac88c07ee1 |
children | 2eb05f396fcd |
line wrap: on
line diff
--- a/Simoleon/ContentView.swift Sun Jul 25 10:59:51 2021 +0100 +++ b/Simoleon/ContentView.swift Mon Jul 26 15:35:06 2021 +0100 @@ -6,16 +6,15 @@ // import SwiftUI -import Purchases struct ContentView: View { @State private var tab: Tab = .convert - @StateObject var subscriptionController = SubscriptionController() + @Environment(\.managedObjectContext) private var viewContext + @FetchRequest(sortDescriptors: []) private var defaultCurrency: FetchedResults<DefaultCurrency> var body: some View { TabView(selection: $tab) { - Conversion(fetchUserSettings: true, currencyPair: "USD/GBP") - .environmentObject(subscriptionController) + Conversion(currencyPair: defaultCurrency.first?.pair ?? "USD/GBP") .tabItem { Text("Convert", comment: "Tab bar button to show conversion") Image(systemName: "arrow.counterclockwise.circle") @@ -23,7 +22,6 @@ .tag(Tab.convert) Favourites() - .environmentObject(subscriptionController) .tabItem { Text("Favourites", comment: "Tab bar button to show favourites") Image(systemName: "star") @@ -31,24 +29,12 @@ .tag(Tab.favourites) Settings() - .environmentObject(subscriptionController) .tabItem { Text("Settings", comment: "Tab bar button to show settings") Image(systemName: "gear") } .tag(Tab.settings) } - .onAppear(perform: checkEntitlements) - } - - private func checkEntitlements() { - Purchases.shared.purchaserInfo { (purchaserInfo, error) in - if purchaserInfo?.entitlements["all"]?.isActive == true { - self.subscriptionController.isActive = true - } else { - // User subscription is not active - } - } } private enum Tab { @@ -59,6 +45,5 @@ struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() -// .environment(\.locale, .init(identifier: "es")) } }