comparison Simoleon/UI/CurrencySelector.swift @ 159:35628bac01f5

Fix a bug that selected wrong symbol in pair
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Sat, 28 Aug 2021 19:18:50 +0100
parents 8c3bbd640103
children 0c589138a6f3
comparison
equal deleted inserted replaced
158:82bd84c5973c 159:35628bac01f5
8 import SwiftUI 8 import SwiftUI
9 9
10 struct CurrencySelector: View { 10 struct CurrencySelector: View {
11 @State var currencyPair: CurrencyPairModel 11 @State var currencyPair: CurrencyPairModel
12 @State private var showingList = false 12 @State private var showingList = false
13 @State private var modalSelection: ModalType? = nil 13 @State private var modalSelection: ModalType = .allCurrencies
14 let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json") 14 let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json")
15 15
16 private enum ModalType { 16 private enum ModalType {
17 case allCurrencies, compatibleCurrencies 17 case allCurrencies, compatibleCurrencies
18 } 18 }
19 19
20 var body: some View { 20 var body: some View {
21 HStack { 21 HStack {
22 Button(action: { 22 Button(action: {
23 modalSelection = .allCurrencies
23 showingList = true 24 showingList = true
24 modalSelection = .allCurrencies
25 }) { 25 }) {
26 CurrencyButton(selectedCurrency: currencyPair.baseSymbol) 26 CurrencyButton(selectedCurrency: currencyPair.baseSymbol)
27 } 27 }
28 28
29 Button(action: { 29 Button(action: {
30 modalSelection = .compatibleCurrencies
30 showingList = true 31 showingList = true
31 modalSelection = .compatibleCurrencies
32 }) { 32 }) {
33 CurrencyButton(selectedCurrency: currencyPair.quoteSymbol) 33 CurrencyButton(selectedCurrency: currencyPair.quoteSymbol)
34 } 34 }
35 } 35 }
36 .onChange(of: currencyPair.baseSymbol) { _ in 36 .onChange(of: currencyPair.baseSymbol) { _ in