Mercurial > public > lazybear
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Home/Helpers/CurrencyRow.swift Wed Apr 14 23:08:26 2021 +0200 @@ -0,0 +1,56 @@ +// +// CurrencyRow.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 14/4/21. +// + +import SwiftUI +import WaterfallGrid + +struct CurrencyRow: View { + var latestCurrencies: [String: CurrencyModel] + + @State private var showExtensiveList = false + + var body: some View { + VStack(alignment: .leading) { + HStack(alignment: .bottom) { + VStack(alignment: .leading) { + Text("Currencies") + .font(.title3) + .fontWeight(.semibold) + .padding([.top, .horizontal]) + + Text("Updated at 6:00 CET on every working day") + .font(.caption) + .opacity(0.5) + .padding(.horizontal) + } + + Spacer() + Button("See all", action: { self.showExtensiveList = true }) + .buttonStyle(BorderlessButtonStyle()) + .padding(.horizontal) + } + + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 20) { + ForEach(Array(latestCurrencies.keys), id: \.self) { currencySymbol in + CurrencyItem(currencySymbol: currencySymbol, currency: latestCurrencies[currencySymbol]!) + } + } + .padding() + } + } + .sheet(isPresented: $showExtensiveList) { + ExtensiveList(listName: "Currencies", list: nil, nestedIntradayPrices: nil, latestCurrencies: latestCurrencies) + } + } +} + +struct CurrencyRow_Previews: PreviewProvider { + static var previews: some View { + CurrencyRow(latestCurrencies: ["AUD": CurrencyModel(flag: "🇺🇸", name: "Australian dollar", rate: 1.3116)]) + } +}