comparison Simoleon/Settings.swift @ 43:2eb05f396fcd v1.2

Fixes NavigationView bugs
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 26 Jul 2021 17:35:57 +0100
parents d25b02d439d4
children ce4eb7416b41
comparison
equal deleted inserted replaced
42:d25b02d439d4 43:2eb05f396fcd
79 Text("Terms of Use", comment: "Button to go to app terms of use") 79 Text("Terms of Use", comment: "Button to go to app terms of use")
80 } 80 }
81 } 81 }
82 } 82 }
83 .onAppear { 83 .onAppear {
84 checkEntitlement()
84 /* 85 /*
85 if selectedDefaultCurrency is empty -> view is appearing for the first time -> set initial default curency for picker 86 if selectedDefaultCurrency is empty -> view is appearing for the first time -> set initial default curency for picker
86 else -> view is appearing after user selected another default currency -> save it to core data 87 else -> view is appearing after user selected another default currency -> save it to core data
87 */ 88 */
88 if selectedDefaultCurrency == "" { 89 if selectedDefaultCurrency == "" {
122 123
123 /* 124 /*
124 Check if user subscription is active 125 Check if user subscription is active
125 */ 126 */
126 private func checkEntitlement() { 127 private func checkEntitlement() {
127 Purchases.shared.purchaserInfo { (purchaserInfo, error) in 128 #if targetEnvironment(simulator)
128 if purchaserInfo?.entitlements["all"]?.isActive == true { 129 // We're in simulator
129 entitlementIsActive = true 130 entitlementIsActive = true
130 print("Entitlement is active") 131 #else
131 } else { 132 Purchases.shared.purchaserInfo { (purchaserInfo, error) in
132 entitlementIsActive = false 133 if purchaserInfo?.entitlements["all"]?.isActive == true {
133 print("Entitlement is NOT active") 134 entitlementIsActive = true
135 print("Entitlement is active")
136 } else {
137 entitlementIsActive = false
138 print("Entitlement is NOT active")
139 }
134 } 140 }
135 } 141 #endif
136 } 142 }
137 } 143 }
138 144
139 struct Settings_Previews: PreviewProvider { 145 struct Settings_Previews: PreviewProvider {
140 static var previews: some View { 146 static var previews: some View {