From 6c2a9d855f398281830b91e5d50b9dd917833660 Mon Sep 17 00:00:00 2001 From: Dennis Concepcion Martin Date: Mon, 9 Aug 2021 17:01:24 +0100 Subject: [PATCH] Update code to the newest version --- Trades/Details.swift | 22 ++++++---------------- Trades/Helpers/Company.swift | 21 +++------------------ Trades/Popular.swift | 21 +++------------------ 3 files changed, 12 insertions(+), 52 deletions(-) diff --git a/Trades/Details.swift b/Trades/Details.swift index 96ac60a..5ade852 100644 --- a/Trades/Details.swift +++ b/Trades/Details.swift @@ -29,24 +29,14 @@ struct Details: View { .fontWeight(.semibold) .padding() - let data = randomDataManager.create() - let lineChartStyle = LineChartStyle( - labelColor: Color(.systemBlue), - indicatorPointColor: Color(.systemTeal), - showingIndicatorLineColor: Color(.systemBlue), - flatTrendLineColor: Color(.systemTeal), - uptrendLineColor: Color(.systemGreen), - downtrendLineColor: Color(.systemRed) - ) - LineChartView( - data: data, - dates: nil, - hours: nil, - dragGesture: true, - style: lineChartStyle + lineChartController: + LineChartController( + prices: randomDataManager.create(), + dragGesture: true + ) ) - .padding(.bottom) + .padding(.bottom) } ,alignment: .leading ) diff --git a/Trades/Helpers/Company.swift b/Trades/Helpers/Company.swift index 887c905..800e126 100644 --- a/Trades/Helpers/Company.swift +++ b/Trades/Helpers/Company.swift @@ -37,24 +37,9 @@ struct Company: View { Spacer() - let data = randomDataManager.create() - let lineChartStyle = LineChartStyle( - labelColor: Color(.systemBlue), - indicatorPointColor: Color(.systemTeal), - showingIndicatorLineColor: Color(.systemBlue), - flatTrendLineColor: Color(.systemTeal), - uptrendLineColor: Color(.systemGreen), - downtrendLineColor: Color(.systemRed) - ) - - LineChartView( - data: data, - dates: nil, - hours: nil, - dragGesture: false, - style: lineChartStyle - ) - .padding(.bottom, 5) + let prices = randomDataManager.create() + LineChartView(lineChartController: LineChartController(prices: prices)) + .padding(.bottom, 5) } , alignment: .leading ) diff --git a/Trades/Popular.swift b/Trades/Popular.swift index 78c4289..2f757e5 100644 --- a/Trades/Popular.swift +++ b/Trades/Popular.swift @@ -28,26 +28,11 @@ struct Popular: View { } .padding(.trailing) - let data = randomDataManager.create() - let lineChartStyle = LineChartStyle( - labelColor: Color(.systemBlue), - indicatorPointColor: Color(.systemTeal), - showingIndicatorLineColor: Color(.systemBlue), - flatTrendLineColor: Color(.systemTeal), - uptrendLineColor: Color(.systemGreen), - downtrendLineColor: Color(.systemRed) - ) - Spacer() - LineChartView( - data: data, - dates: nil, - hours: nil, - dragGesture: false, - style: lineChartStyle - ) - .frame(width: 150) + let prices = randomDataManager.create() + LineChartView(lineChartController: LineChartController(prices: prices)) + .frame(width: 150) Text("\(company.price, specifier: "%.2f")") .fontWeight(.semibold)