Mercurial > public > lazybear
changeset 402:8357b101df67
Implementing CompanyView in NavigationLinks
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Fri, 21 May 2021 23:39:40 +0200 |
parents | f843c6382529 |
children | 48b3d2a410d4 |
files | LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/Views/Company/Chart.swift LazyBear/Views/Company/CompanyView.swift LazyBear/Views/Company/Networking/Company.swift LazyBear/Views/Global Helpers/StockItem.swift |
diffstat | 5 files changed, 24 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/Views/Company/Chart.swift Thu May 20 21:04:49 2021 +0200 +++ b/LazyBear/Views/Company/Chart.swift Fri May 21 23:39:40 2021 +0200 @@ -24,8 +24,8 @@ VStack { DatePicker(ranges: ranges, selectedRange: $selectedRange) .onChange(of: selectedRange, perform: { range in -// let url = "https://api.lazybear.app/company/chart/type=init/symbol=\(symbol)/range=\(range)" -// company.request(url, .refresh, "chart") + let url = "https://api.lazybear.app/company/chart/type=refresh/symbol=\(symbol)/range=\(range.lowercased())" + company.request(url, .refresh, "chart") }) RoundedRectangle(cornerRadius: 15)
--- a/LazyBear/Views/Company/CompanyView.swift Thu May 20 21:04:49 2021 +0200 +++ b/LazyBear/Views/Company/CompanyView.swift Fri May 21 23:39:40 2021 +0200 @@ -18,20 +18,16 @@ @State private var showChartView = true var body: some View { - NavigationView { - ScrollView { - VStack { - CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector) - - // Chart View - if showChartView { - Chart(company: company, symbol: symbol) - } + ScrollView { + VStack { + CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector) + + // Chart View + if showChartView { + Chart(company: company, symbol: symbol) } - .padding() } - .navigationTitle("Apple inc") - .navigationBarTitleDisplayMode(.inline) + .padding() } .actionSheet(isPresented: $showViewSelector) { ActionSheet(title: Text("Select an option"), buttons: [
--- a/LazyBear/Views/Company/Networking/Company.swift Thu May 20 21:04:49 2021 +0200 +++ b/LazyBear/Views/Company/Networking/Company.swift Fri May 21 23:39:40 2021 +0200 @@ -18,7 +18,7 @@ case .initial: self.chartData = response case .refresh: - print("refresh") + self.chartData.historicalPrices = response.historicalPrices case .streaming: self.chartData.quote = response.quote }
--- a/LazyBear/Views/Global Helpers/StockItem.swift Thu May 20 21:04:49 2021 +0200 +++ b/LazyBear/Views/Global Helpers/StockItem.swift Fri May 21 23:39:40 2021 +0200 @@ -21,9 +21,20 @@ var body: some View { if orientation == .vertical { - return AnyView(VerticalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices)) + let verticalRow: AnyView = AnyView( + NavigationLink(destination: CompanyView(symbol: symbol)) { + VerticalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices) + } + .buttonStyle(PlainButtonStyle()) + ) + return verticalRow } else { - return AnyView(HorizontalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices, hidePriceView: hidePriceView ?? false)) + let horizontalRow: AnyView = AnyView( + NavigationLink(destination: CompanyView(symbol: symbol)) { + HorizontalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices, hidePriceView: hidePriceView ?? false) + } + ) + return horizontalRow } } }