Mercurial > public > simoleon
comparison Simoleon/Helpers/CurrencySelector.swift @ 47:75c1a05176f6
Refactor code
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 26 Jul 2021 20:08:20 +0100 |
parents | ce4eb7416b41 |
children | 7a6a7c677851 |
comparison
equal
deleted
inserted
replaced
46:ce4eb7416b41 | 47:75c1a05176f6 |
---|---|
28 } | 28 } |
29 } | 29 } |
30 } | 30 } |
31 } | 31 } |
32 .gesture(DragGesture() | 32 .gesture(DragGesture() |
33 .onChanged({ _ in | 33 .onChanged({ _ in |
34 UIApplication.shared.dismissKeyboard() | 34 UIApplication.shared.dismissKeyboard() |
35 }) | 35 }) |
36 ) | 36 ) |
37 .sheet(isPresented: $showingSubscriptionPaywall) { | 37 .sheet(isPresented: $showingSubscriptionPaywall) { |
38 SubscriptionPaywall(showingSubscriptionPaywall: $showingSubscriptionPaywall) | 38 SubscriptionPaywall(showingSubscriptionPaywall: $showingSubscriptionPaywall) |
39 } | 39 } |
40 .navigationTitle(Text("Currencies", comment: "Navigation title")) | 40 .navigationTitle(Text("Currencies", comment: "Navigation title")) |
41 .navigationBarTitleDisplayMode(.inline) | 41 .navigationBarTitleDisplayMode(.inline) |
48 } | 48 } |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 /* | 52 /* |
53 If searched currency string is empty -> show all currencies | 53 If searched currency string is empty: |
54 else -> show filtered list of currencies containing searched currency string | 54 * Show all currencies |
55 else: | |
56 * Show filtered list of currencies containing searched currency string | |
55 */ | 57 */ |
56 private func currencyPairs() -> [String] { | 58 private func currencyPairs() -> [String] { |
57 let currencyPairs: [String] = parseJson("CurrencyPairs.json") | 59 let currencyPairs: [String] = parseJson("CurrencyPairs.json") |
58 | 60 |
59 if searchCurrency.isEmpty { | 61 if searchCurrency.isEmpty { |
63 } | 65 } |
64 } | 66 } |
65 | 67 |
66 | 68 |
67 /* | 69 /* |
68 If user is subscribed -> select currency and dismiss currency selector | 70 If user is subscribed: |
69 else -> show subscription paywall | 71 * Select currency and dismiss currency selector |
72 else: | |
73 * Show subscription paywall | |
70 */ | 74 */ |
71 private func select(_ currencyPair: String) { | 75 private func select(_ currencyPair: String) { |
72 #if targetEnvironment(simulator) | 76 #if targetEnvironment(simulator) |
73 // We're in simulator | 77 // We're in simulator |
74 self.currencyPair = currencyPair | 78 self.currencyPair = currencyPair |
75 showingCurrencySelector = false | 79 showingCurrencySelector = false |
76 #else | 80 #else |
77 // We're in physical device | 81 // We're in physical device |
78 Purchases.shared.purchaserInfo { (purchaserInfo, error) in | 82 Purchases.shared.purchaserInfo { (purchaserInfo, error) in |
79 if purchaserInfo?.entitlements["all"]?.isActive == true { | 83 if purchaserInfo?.entitlements["all"]?.isActive == true { |
80 self.currencyPair = currencyPair | 84 self.currencyPair = currencyPair |
81 showingCurrencySelector = false | 85 showingCurrencySelector = false |
82 } else { | 86 } else { |
83 showingSubscriptionPaywall = true | 87 showingSubscriptionPaywall = true |
84 } | |
85 } | 88 } |
89 } | |
86 #endif | 90 #endif |
87 } | 91 } |
88 } | 92 } |
89 | 93 |
90 | 94 |