comparison Simoleon/UI/CurrencyButton.swift @ 156:84137052813d

Refactor code
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Sat, 28 Aug 2021 11:15:25 +0100
parents
children 0c589138a6f3
comparison
equal deleted inserted replaced
155:681f2cbe8c7f 156:84137052813d
1 //
2 // CurrencyButton.swift
3 // Simoleon
4 //
5 // Created by Dennis Concepción Martín on 24/8/21.
6 //
7
8 import SwiftUI
9
10 struct CurrencyButton: View {
11 var selectedCurrency: String
12 let currencyDetails: [String: CurrencyModel] = try! read(json: "Currencies.json")
13
14 var body: some View {
15 let currency = currencyDetails[selectedCurrency]!
16 RoundedRectangle(cornerRadius: 15)
17 .foregroundColor(Color(.secondarySystemBackground))
18 .frame(height: 60)
19 .overlay(
20 HStack {
21 Flag(flag: currency.flag)
22 Text(currency.symbol)
23 .foregroundColor(.primary)
24 .font(.headline)
25 }
26 )
27 }
28 }
29
30 struct CurrencyButton_Previews: PreviewProvider {
31 static var previews: some View {
32 CurrencyButton(selectedCurrency: "USD")
33 }
34 }