Mercurial > public > simoleon
comparison Simoleon/Settings.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 | 8afba86ab8dd |
comparison
equal
deleted
inserted
replaced
151:bdedd0cc6cd1 | 152:2584fd74235a |
---|---|
24 If searched currency string is empty: | 24 If searched currency string is empty: |
25 * Show all currencies | 25 * Show all currencies |
26 else: | 26 else: |
27 * Show filtered list of currencies containing searched currency string | 27 * Show filtered list of currencies containing searched currency string |
28 */ | 28 */ |
29 var searchResults: [CurrencyPairModel] { | 29 var searchResults: [String] { |
30 let currencyPairs: [CurrencyPairModel] = try! read(json: "CurrencyPairs.json") | 30 let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json") |
31 if searchCurrency.isEmpty { | 31 if searchCurrency.isEmpty { |
32 return currencyPairs.sorted { $0.name < $1.name } | 32 return currencyPairsSupported.sorted() |
33 } else { | 33 } else { |
34 return currencyPairs.filter { $0.name.contains(searchCurrency.uppercased()) } | 34 return currencyPairsSupported.filter { $0.contains(searchCurrency.uppercased()) } |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 var body: some View { | 38 var body: some View { |
39 List { | 39 List { |
41 if entitlementIsActive { | 41 if entitlementIsActive { |
42 Picker("Default currency", selection: $selectedDefaultCurrency) { | 42 Picker("Default currency", selection: $selectedDefaultCurrency) { |
43 SearchBar(placeholder: "Search...", text: $searchCurrency) | 43 SearchBar(placeholder: "Search...", text: $searchCurrency) |
44 .padding(5) | 44 .padding(5) |
45 | 45 |
46 ForEach(searchResults, id: \.self) { currencyPair in | 46 ForEach(searchResults, id: \.self) { currencyPairsSupported in |
47 Text(currencyPair.name) | 47 Text(currencyPairsSupported) |
48 .tag(currencyPair.name) | 48 .tag(currencyPairsSupported) |
49 } | 49 } |
50 } | 50 } |
51 } else { | 51 } else { |
52 LockedCurrencyPicker() | 52 LockedCurrencyPicker() |
53 .contentShape(Rectangle()) | 53 .contentShape(Rectangle()) |