Mercurial > public > lazybear
changeset 108:f881b37fa853
Fix frame LineChart
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Mon, 01 Feb 2021 13:43:18 +0100 |
parents | eb7e80081672 |
children | b17adecaad0c |
files | LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Views/Company.swift lazybear/Views/Stock.swift |
diffstat | 4 files changed, 11 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Sun Jan 31 19:18:10 2021 +0100 +++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Mon Feb 01 13:43:18 2021 +0100 @@ -2,15 +2,6 @@ "object": { "pins": [ { - "package": "Charts", - "repositoryURL": "https://github.com/danielgindi/Charts.git", - "state": { - "branch": null, - "revision": "9b24868b61a75666355d824eeb97290e7f0dca42", - "version": "4.0.0" - } - }, - { "package": "SDWebImage", "repositoryURL": "https://github.com/SDWebImage/SDWebImage.git", "state": {
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/Views/Company.swift Sun Jan 31 19:18:10 2021 +0100 +++ b/lazybear/Views/Company.swift Mon Feb 01 13:43:18 2021 +0100 @@ -15,10 +15,12 @@ var body: some View { CompanyHeader(name: self.name, symbol: self.symbol) - ScrollView { - VStack(alignment: .leading) { - Stock(name: name, symbol: symbol) - .environment(\.managedObjectContext, persistenceController.container.viewContext) + GeometryReader { geo in + ScrollView { + VStack(alignment: .leading) { + Stock(name: name, symbol: symbol, lineChartHeight: geo.size.height*0.2) + .environment(\.managedObjectContext, persistenceController.container.viewContext) + } } } }
--- a/lazybear/Views/Stock.swift Sun Jan 31 19:18:10 2021 +0100 +++ b/lazybear/Views/Stock.swift Mon Feb 01 13:43:18 2021 +0100 @@ -10,6 +10,7 @@ struct Stock: View { var name: String var symbol: String + var lineChartHeight: CGFloat var period = ["1W", "1M", "3M", "6M", "1Y", "2Y", "5Y"] @State var selectedPeriod = 2 @@ -30,13 +31,12 @@ VStack { Divider() HStack { + Price(symbol: symbol, showVertical: true) + Spacer() let watchSymbols = companies.map { $0.symbol } if !watchSymbols.contains(symbol) { AddWatchlist(name: name, symbol: symbol) } - - Spacer() - Price(symbol: symbol, showVertical: true) } Divider() @@ -49,7 +49,7 @@ if showingLineChart { let normalPrices = normalize(prices) LineChart(dataPoints: normalPrices, lineColor: colorLineChart(prices: prices) ? .green : .red, lineWidth: 2) - .frame(width: 400, height: 300) + .frame(height: lineChartHeight) } } .padding([.leading, .trailing]) @@ -82,6 +82,6 @@ struct Stock_Previews: PreviewProvider { static var previews: some View { - Stock(name: "apple inc", symbol: "aapl") + Stock(name: "apple inc", symbol: "aapl", lineChartHeight: 300) } }