Mercurial > public > lazybear
view LazyBear/Views/Company/CompanyView.swift @ 412:a7c9dd0c5822
Main insider view implemented
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Tue, 08 Jun 2021 11:46:58 +0200 |
parents | c804ce7a1560 |
children | 5f21f7c23c5e |
line wrap: on
line source
// // CompanyView.swift // LazyBear // // Created by Dennis Concepción Martín on 8/5/21. // import SwiftUI import StockCharts struct CompanyView: View { var symbol: String @ObservedObject var company = Company() @State private var showViewSelector = false // Views @State private var showChartView = true @State private var showInsiderView = false var body: some View { ScrollView { VStack { CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector) .padding(.bottom) // Chart View if showChartView { Chart(company: company, symbol: symbol) } else if showInsiderView { Insiders(company: company, symbol: symbol) } } .padding() } .actionSheet(isPresented: $showViewSelector) { ActionSheet(title: Text("Select an option"), buttons: [ .default(Text("Chart & News")) { resetViews(); showChartView = true }, .default(Text("Insiders")) { resetViews(); showInsiderView = true }, .cancel() ]) } } /* Hide all views to show later the one tapped */ private func resetViews() { showChartView = false showInsiderView = false } } struct CompanyView_Previews: PreviewProvider { static var previews: some View { CompanyView(symbol: "AAPL") } }