Mercurial > public > lazybear
view LazyBear/Views/Global Helpers/StockRow.swift @ 379:a7e2c5a7b4f6
Implement onDelete in watchlists
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Thu, 22 Apr 2021 23:44:20 +0200 |
parents | f3cb5bdea8e5 |
children | 79c39987aaa4 |
line wrap: on
line source
// // StockRow.swift // LazyBear // // Created by Dennis Concepción Martín on 28/3/21. // import SwiftUI struct StockRow: View { var listName: String var list: [String: QuoteModel] var intradayPrices: [String: [IntradayPriceModel]]? var addOnDelete: Bool @State private var showExtensiveList = false var body: some View { VStack(alignment: .leading) { HStack(alignment: .bottom) { VStack(alignment: .leading) { Text(listName) .font(.title3) .fontWeight(.semibold) .padding([.top, .horizontal]) Text("Real-time quotes") .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(list.keys.sorted()), id: \.self) { companySymbol in StockItem(symbol: companySymbol, company: list[companySymbol]!, intradayPrices: intradayPrices?[companySymbol], orientation: .vertical) } } .padding() } .frame(height: 250) } .padding(.bottom) .sheet(isPresented: $showExtensiveList) { ExtensiveList(listName: listName, list: list, intradayPrices: intradayPrices, latestCurrencies: nil, addOnDelete: addOnDelete) } } } struct StockRectangleRow_Previews: PreviewProvider { static var previews: some View { StockRow( listName: "Gainers", list: ["AAPL": QuoteModel(changePercent: 0.03, companyName: "Apple Inc", latestPrice: 130.3)], intradayPrices: ["AAPL": [IntradayPriceModel(open: 130.2)]], addOnDelete: false ) } }