Mercurial > public > simoleon
comparison Simoleon/Helpers/CurrencyRow.swift @ 6:3d6f56b0d4ed
Implementing first UI layout
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 11 Jul 2021 18:03:56 +0100 |
parents | |
children | ed35ef4738b9 |
comparison
equal
deleted
inserted
replaced
5:115fbbbee06f | 6:3d6f56b0d4ed |
---|---|
1 // | |
2 // CurrencyRow.swift | |
3 // Simoleon | |
4 // | |
5 // Created by Dennis Concepción Martín on 11/07/2021. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct CurrencyRow: View { | |
11 var currencyQuote: CurrencyQuoteModel | |
12 let currencies: [String: CurrencyModel] = parseJson("Currencies.json") | |
13 | |
14 var body: some View { | |
15 VStack { | |
16 RoundedRectangle(cornerRadius: 10) | |
17 .rectangleModifier(Color("Bone"), 100) | |
18 | |
19 RoundedRectangle(cornerRadius: 10) | |
20 .rectangleModifier(Color(.systemBackground), 100) | |
21 .overlay( | |
22 HStack { | |
23 let symbols = currencyQuote.symbol.split(separator: "/") | |
24 let mainCurrencyFlag = currencies[String(symbols[0])]!.flag | |
25 let SecondaryCurrencyFlag = currencies[String(symbols[1])]!.flag | |
26 | |
27 SmallFlagsPair(mainCurrencyFlag: mainCurrencyFlag, secondaryCurrencyFlag: SecondaryCurrencyFlag) | |
28 | |
29 VStack(alignment: .leading) { | |
30 Text("\(String(symbols[0]))") | |
31 .fontWeight(.semibold) | |
32 | |
33 Text("\(String(symbols[1]))") | |
34 .fontWeight(.semibold) | |
35 } | |
36 .padding(.horizontal) | |
37 | |
38 VStack(alignment: .leading) { | |
39 Text("Bid") | |
40 Text("\(currencyQuote.bid, specifier: "%.4f")") | |
41 .fontWeight(.semibold) | |
42 | |
43 } | |
44 .padding(.trailing) | |
45 | |
46 VStack(alignment: .leading) { | |
47 Text("Ask") | |
48 Text("\(currencyQuote.ask, specifier: "%.4f")") | |
49 .fontWeight(.semibold) | |
50 | |
51 } | |
52 } | |
53 ) | |
54 .offset(x: -10.0, y: -120.0) | |
55 .padding(.bottom, -120) | |
56 } | |
57 .padding(.leading, 10) | |
58 .padding(.horizontal) | |
59 } | |
60 } | |
61 | |
62 struct CurrencyRow_Previews: PreviewProvider { | |
63 static var previews: some View { | |
64 let currencyQuote: CurrencyQuoteModel = parseJson("CurrencyQuoteData.json") | |
65 | |
66 CurrencyRow(currencyQuote: currencyQuote) | |
67 } | |
68 } |