Mercurial > public > lazybear
view LazyBear/Views/Home/Helpers/StockRow.swift @ 432:3ca32ff79630
Fixes RenameSheetList bug
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 19 Jun 2021 20:13:25 +0200 |
parents | 8c58ce834d95 |
children | ffbb1dbab531 |
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 companies: [CompanyModel] @State private var showList = false @Environment(\.managedObjectContext) private var moc var body: some View { VStack(alignment: .leading) { HStack(alignment: .bottom) { VStack(alignment: .leading) { Text(adaptListTitle(listName)) .font(.title3) .fontWeight(.semibold) .padding([.top, .horizontal]) Text("Real-time quotes") .font(.caption) .opacity(0.5) .padding(.horizontal) } Spacer() Button("See all", action: { showList = true }) .buttonStyle(BorderlessButtonStyle()) .padding(.horizontal) } ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(companies, id: \.self) { company in StockItem(company: company) } } .padding() } .frame(height: 250) } .padding(.bottom) .sheet(isPresented: $showList) { StockSheet(listName: adaptListTitle(listName), companies: companies) } } /* Get list keys (mostactive, losers, active) and adapt them to diplay */ private func adaptListTitle(_ title: String) -> String { if title == "mostactive" { return "Most active" } else { return title.capitalized } } } struct StockRectangleRow_Previews: PreviewProvider { static var previews: some View { StockRow( listName: "mostactive", companies: [CompanyModel(symbol: "aapl", companyName: "Apple Inc", latestPrice: 120.3, changePercent: 0.03, intradayPrices: [120.3])] ) } }