# HG changeset patch # User Dennis Concepción Martín # Date 1627407114 -3600 # Node ID 1303c1e50843ced9dc5100e8f0688667d1058e67 # Parent cdb5ec1127398364bde6d3225d19997da0abeb21 Fixes slow list updates diff -r cdb5ec112739 -r 1303c1e50843 Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r cdb5ec112739 -r 1303c1e50843 Simoleon/Helpers/CurrencySelector.swift --- 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) + ) } }