Mercurial > public > lazybear
view LazyBear/Views/Home/ExtensiveList.swift @ 357:eb97439e46cd
Implement ExtensiveList in HomeView
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Thu, 15 Apr 2021 23:37:25 +0200 |
parents | 5ccceb527178 |
children | f3cb5bdea8e5 |
line wrap: on
line source
// // ExtensiveList.swift // LazyBear // // Created by Dennis Concepción Martín on 14/4/21. // import SwiftUI struct ExtensiveList: View { // General argument var listName: String // Arguments for lists var list: [QuoteModel]? var nestedIntradayPrices: [String: NestedIntradayPricesModel]? // Arguments for currencies var latestCurrencies: [String: CurrencyModel]? @Environment(\.presentationMode) var extensiveListPresent var body: some View { NavigationView { VStack { if let list = list { List(list, id: \.self) { company in if let intradayPrices = nestedIntradayPrices?[company.symbol.uppercased()] { StockItem(company: company, intradayPrices: intradayPrices.nestedIntradayPrices, orientation: .horizontal) } else { StockItem(company: company, intradayPrices: nil, orientation: .horizontal) } } } if let latestCurrencies = latestCurrencies { List(Array(latestCurrencies.keys), id: \.self) { currencySymbol in CurrencyListItem(currencySymbol: currencySymbol, currency: latestCurrencies[currencySymbol]!) } } } .navigationTitle(listName) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: { extensiveListPresent.wrappedValue.dismiss() }) { Image(systemName: "multiply") .imageScale(.large) } } } } } } struct ExtensiveList_Previews: PreviewProvider { static var previews: some View { ExtensiveList(listName: "List name") } }