Mercurial > public > simoleon
changeset 59:1303c1e50843
Fixes slow list updates
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 27 Jul 2021 18:31:54 +0100 |
parents | cdb5ec112739 |
children | 7b98dd60381c |
files | Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Simoleon/Helpers/CurrencySelector.swift |
diffstat | 2 files changed, 27 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Simoleon/Helpers/CurrencySelector.swift Tue Jul 27 18:16:08 2021 +0100 +++ b/Simoleon/Helpers/CurrencySelector.swift Tue Jul 27 18:31:54 2021 +0100 @@ -18,34 +18,41 @@ @State private var alertMessage = "" @State private var showingAlert = false + let currencyPairs: [String] = parseJson("CurrencyPairs.json") + var body: some View { NavigationView { - Form { + VStack { TextField("Search ...", text: $searchCurrency) - .accessibilityIdentifier("SearchBar") - - Section(header: Text("All currencies", comment: "Section header in currency selector")) { - ForEach(currencyPairs(), id: \.self) { currencyPair in - Button(action: { select(currencyPair) }) { - CurrencyRow(currencyPair: currencyPair) - } + .padding(10) + .background( + RoundedRectangle(cornerRadius: 15) + .foregroundColor(Color(.systemGray6)) + ) + .padding() + + List(searchResults, id: \.self) { currencyPair in + Button(action: { select(currencyPair) }) { + CurrencyRow(currencyPair: currencyPair) } } + .id(UUID()) + .listStyle(PlainListStyle()) + .gesture(DragGesture() + .onChanged({ _ in + UIApplication.shared.dismissKeyboard() + }) + ) } - .gesture(DragGesture() - .onChanged({ _ in - UIApplication.shared.dismissKeyboard() - }) - ) .sheet(isPresented: $showingSubscriptionPaywall) { SubscriptionPaywall(showingSubscriptionPaywall: $showingSubscriptionPaywall) } - .navigationTitle(Text("Currencies", comment: "Navigation title")) + .navigationTitle("Currencies") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .cancellationAction) { Button(action: { showingCurrencySelector = false }) { - Text("Cancel", comment: "Button to dismiss currency selector") + Text("Cancel") } } } @@ -61,9 +68,7 @@ else: * Show filtered list of currencies containing searched currency string */ - private func currencyPairs() -> [String] { - let currencyPairs: [String] = parseJson("CurrencyPairs.json") - + var searchResults: [String] { if searchCurrency.isEmpty { return currencyPairs } else { @@ -71,7 +76,6 @@ } } - /* If user is subscribed: * Select currency and dismiss currency selector @@ -106,6 +110,9 @@ struct CurrencySelector_Previews: PreviewProvider { static var previews: some View { - CurrencySelector(currencyPair: .constant("USD/GBP"), showingCurrencySelector: .constant(false)) + CurrencySelector( + currencyPair: .constant("USD/GBP"), + showingCurrencySelector: .constant(false) + ) } }