comparison LazyBear/Views/Home/Helpers/CurrencyRow.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 5385a8f8cc5c
comparison
equal deleted inserted replaced
348:0abb8d5c12ec 349:5ccceb527178
1 //
2 // CurrencyRow.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 14/4/21.
6 //
7
8 import SwiftUI
9 import WaterfallGrid
10
11 struct CurrencyRow: View {
12 var latestCurrencies: [String: CurrencyModel]
13
14 @State private var showExtensiveList = false
15
16 var body: some View {
17 VStack(alignment: .leading) {
18 HStack(alignment: .bottom) {
19 VStack(alignment: .leading) {
20 Text("Currencies")
21 .font(.title3)
22 .fontWeight(.semibold)
23 .padding([.top, .horizontal])
24
25 Text("Updated at 6:00 CET on every working day")
26 .font(.caption)
27 .opacity(0.5)
28 .padding(.horizontal)
29 }
30
31 Spacer()
32 Button("See all", action: { self.showExtensiveList = true })
33 .buttonStyle(BorderlessButtonStyle())
34 .padding(.horizontal)
35 }
36
37 ScrollView(.horizontal, showsIndicators: false) {
38 HStack(spacing: 20) {
39 ForEach(Array(latestCurrencies.keys), id: \.self) { currencySymbol in
40 CurrencyItem(currencySymbol: currencySymbol, currency: latestCurrencies[currencySymbol]!)
41 }
42 }
43 .padding()
44 }
45 }
46 .sheet(isPresented: $showExtensiveList) {
47 ExtensiveList(listName: "Currencies", list: nil, nestedIntradayPrices: nil, latestCurrencies: latestCurrencies)
48 }
49 }
50 }
51
52 struct CurrencyRow_Previews: PreviewProvider {
53 static var previews: some View {
54 CurrencyRow(latestCurrencies: ["AUD": CurrencyModel(flag: "🇺🇸", name: "Australian dollar", rate: 1.3116)])
55 }
56 }