comparison LazyBear/Views/Home/Helpers/CurrencyItem.swift @ 349:5ccceb527178

Implementing new internal API
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 14 Apr 2021 23:08:26 +0200
parents
children eb97439e46cd
comparison
equal deleted inserted replaced
348:0abb8d5c12ec 349:5ccceb527178
1 //
2 // CurrencyItem.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 12/4/21.
6 //
7
8 import SwiftUI
9
10 struct CurrencyItem: View {
11 var currencySymbol: String
12 var currency: CurrencyModel
13
14 var body: some View {
15 RoundedRectangle(cornerRadius: 8)
16 .foregroundColor(Color(.secondarySystemBackground))
17 .frame(width: 330, height: 50)
18 .overlay(
19 HStack {
20 Color("default")
21 .frame(width: 40)
22 .overlay(
23 Text(currency.flag)
24 )
25 VStack(alignment: .leading) {
26 Text(currencySymbol)
27 .font(.headline)
28
29 Text(currency.name)
30 .font(.callout)
31 }
32
33 Spacer()
34 Text("$ \(currency.rate, specifier: "%.2f")")
35 .padding(.horizontal)
36 }
37 .clipShape(RoundedRectangle(cornerRadius: 8))
38 )
39 }
40 }
41
42 struct CurrencyItem_Previews: PreviewProvider {
43 static var previews: some View {
44 CurrencyItem(currencySymbol: "AUD", currency: CurrencyModel(flag: "🇺🇸", name: "Australian dollar", rate: 1.3116))
45 }
46 }