# HG changeset patch # User Dennis Concepcion Martin # Date 1630174730 -3600 # Node ID 35628bac01f581d6b208c2221b03d2152db63f8d # Parent 82bd84c5973c1c4d8449da94050afd00960d5a59 Fix a bug that selected wrong symbol in pair diff -r 82bd84c5973c -r 35628bac01f5 Simoleon/ConversionView.swift --- a/Simoleon/ConversionView.swift Sat Aug 28 19:17:55 2021 +0100 +++ b/Simoleon/ConversionView.swift Sat Aug 28 19:18:50 2021 +0100 @@ -21,7 +21,10 @@ var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading) { - CurrencySelector(currencyPair: currencyPair) + HStack { + CurrencySelector(currencyPair: currencyPair) + FavoriteButton(currencyPair: currencyPair) + } } .padding() } @@ -61,8 +64,8 @@ } -//struct ConversionView_Previews: PreviewProvider { -// static var previews: some View { -// ConversionView() -// } -//} +struct ConversionView_Previews: PreviewProvider { + static var previews: some View { + ConversionView(showNavigationView: true, currencyPair: CurrencyPairModel(baseSymbol: "USD", quoteSymbol: "EUR")) + } +} diff -r 82bd84c5973c -r 35628bac01f5 Simoleon/Helpers/Persistence.swift --- a/Simoleon/Helpers/Persistence.swift Sat Aug 28 19:17:55 2021 +0100 +++ b/Simoleon/Helpers/Persistence.swift Sat Aug 28 19:18:50 2021 +0100 @@ -15,8 +15,8 @@ let viewContext = result.container.viewContext for _ in 0..<10 { - let favorite = Favorite(context: viewContext) - favorite.currencyPair = "GBP/USD" +// let favorite = Favorite(context: viewContext) +// favorite.currencyPair = "GBP/USD" } do { try viewContext.save() diff -r 82bd84c5973c -r 35628bac01f5 Simoleon/UI/CurrencySelector.swift --- a/Simoleon/UI/CurrencySelector.swift Sat Aug 28 19:17:55 2021 +0100 +++ b/Simoleon/UI/CurrencySelector.swift Sat Aug 28 19:18:50 2021 +0100 @@ -10,7 +10,7 @@ struct CurrencySelector: View { @State var currencyPair: CurrencyPairModel @State private var showingList = false - @State private var modalSelection: ModalType? = nil + @State private var modalSelection: ModalType = .allCurrencies let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json") private enum ModalType { @@ -20,15 +20,15 @@ var body: some View { HStack { Button(action: { + modalSelection = .allCurrencies showingList = true - modalSelection = .allCurrencies }) { CurrencyButton(selectedCurrency: currencyPair.baseSymbol) } Button(action: { + modalSelection = .compatibleCurrencies showingList = true - modalSelection = .compatibleCurrencies }) { CurrencyButton(selectedCurrency: currencyPair.quoteSymbol) }