view LazyBear/Views/Home/Helpers/StockSheet.swift @ 443:ffbb1dbab531

InsiderRosterHelper implemented
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 21 Jun 2021 20:17:46 +0200
parents 4effac4733b0
children 37c13ebda381
line wrap: on
line source

//
//  StockSheet.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 13/6/21.
//

import SwiftUI

struct StockSheet: View {
    var listName: String
    var companies: [CompanyModel]
    
    @Environment(\.presentationMode) private var stockSheetPresentation
    
    var body: some View {
        NavigationView {
            VStack {
                List(companies, id: \.self) { company in
                    NavigationLink(destination:
                        CompanyView(symbol: company.symbol, name: company.companyName)
                            .navigationTitle(company.symbol.uppercased())
                    ) {
                        StockSheetRow(company: company)
                    }
                }
            }
            .navigationTitle(listName)
            .toolbar {
                ToolbarItem(placement: .navigationBarLeading) {
                    Button(action: {stockSheetPresentation.wrappedValue.dismiss()}) {
                        Image(systemName: "multiply")
                    }
                }
            }
        }
    }
}

struct StockSheet_Previews: PreviewProvider {
    static var previews: some View {
        StockSheet(
            listName: "Most active",
            companies: [CompanyModel(symbol: "aapl", companyName: "Apple Inc", latestPrice: 120.3, changePercent: 0.03, intradayPrices: [120.3])]
        )
    }
}