diff Simoleon/Helpers/CurrencySelector.swift @ 152:2584fd74235a

Add new currencies
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 23 Aug 2021 17:14:14 +0100
parents 6eac99e99b96
children
line wrap: on
line diff
--- a/Simoleon/Helpers/CurrencySelector.swift	Thu Aug 19 19:13:04 2021 +0100
+++ b/Simoleon/Helpers/CurrencySelector.swift	Mon Aug 23 17:14:14 2021 +0100
@@ -25,12 +25,12 @@
      else:
      * Show filtered list of currencies containing searched currency string
      */
-    var searchResults: [CurrencyPairModel] {
-        let currencyPairs: [CurrencyPairModel] = try! read(json: "CurrencyPairs.json")
+    var searchResults: [String] {
+        let currencyPairsSupported: [String] = try! read(json: "CurrencyPairs.json")
         if searchCurrency.isEmpty {
-            return currencyPairs.sorted { !$0.isLocked && $1.isLocked }
+            return currencyPairsSupported.sorted()
         } else {
-            return currencyPairs.filter { $0.name.contains(searchCurrency.uppercased()) }
+            return currencyPairsSupported.filter { $0.contains(searchCurrency.uppercased()) }
         }
     }
     
@@ -43,18 +43,18 @@
                 
                 List {
                     if entitlementIsActive {
-                        ForEach(searchResults, id: \.self) { currencyPair in
+                        ForEach(searchResults, id: \.self) { currencyPairsSupported in
                             Button(action: {
-                                self.currencyPair = currencyPair.name
+                                self.currencyPair = currencyPairsSupported
                                 showingCurrencySelector = false
                             }) {
-                                CurrencyRow(currencyPairName: currencyPair.name)
+                                CurrencyRow(currencyPairName: currencyPairsSupported)
                             }
                         }
                     } else {
-                        ForEach(searchResults, id: \.self) { currencyPair in
-                            Button(action: { select(currencyPair) }) {
-                                CurrencyRow(currencyPairName: currencyPair.name, isLocked: currencyPair.isLocked)
+                        ForEach(searchResults, id: \.self) { currencyPairsSupported in
+                            Button(action: { select(currencyPairsSupported) }) {
+                                CurrencyRow(currencyPairName: currencyPairsSupported, isLocked: false)
                             }
                         }
                     }
@@ -86,13 +86,13 @@
      else:
      * Show subscription paywall
      */
-    private func select(_ currencyPair: CurrencyPairModel) {
-        if currencyPair.isLocked {
-            showingSubscriptionPaywall = true
-        } else {
-            self.currencyPair = currencyPair.name
-            showingCurrencySelector = false
-        }
+    private func select(_ currencyPair: String) {
+//        if currencyPair.isLocked {
+//            showingSubscriptionPaywall = true
+//        } else {
+//            self.currencyPair = currencyPair.name
+//            showingCurrencySelector = false
+//        }
     }
     
     // Check if user subscription is active