comparison Simoleon/Helpers/CurrencyList.swift @ 186:1ebd1c5dd302

finish ConversionView
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Thu, 23 Dec 2021 11:30:38 +0100
parents 2fc95efcb1ee
children 13d5a8deb6c2
comparison
equal deleted inserted replaced
185:2fc95efcb1ee 186:1ebd1c5dd302
17 var body: some View { 17 var body: some View {
18 NavigationView { 18 NavigationView {
19 List { 19 List {
20 let currencies = getCurrencies() 20 let currencies = getCurrencies()
21 ForEach(currencies, id: \.self) { currency in 21 ForEach(currencies, id: \.self) { currency in
22 CurrencyRow(currency: currency) 22 Button(action: { select(currency: currency) }) {
23 CurrencyRow(currency: currency)
24 }
23 } 25 }
24 } 26 }
25 .navigationTitle("Currencies") 27 .navigationTitle("Currencies")
26 .toolbar { 28 .toolbar {
27 ToolbarItem(placement: .destructiveAction) { 29 ToolbarItem(placement: .destructiveAction) {
56 } 58 }
57 59
58 60
59 return supportedCurrencies 61 return supportedCurrencies
60 } 62 }
63
64 // Select currency
65 private func select(currency: SupportedCurrencyResult) {
66 if selecting == .baseCurrency {
67 baseCurrency = currency
68 } else {
69 quoteCurrency = currency
70 }
71
72 dismiss()
73 }
61 } 74 }
62 75
63 struct CurrencyList_Previews: PreviewProvider { 76 struct CurrencyList_Previews: PreviewProvider {
64 static var previews: some View { 77 static var previews: some View {
65 CurrencyList( 78 CurrencyList(