Mercurial > public > lazybear
changeset 109:b17adecaad0c
Merge pull request #8 from denniscm190/dennis
Fix frame LineChart
committer: GitHub <noreply@github.com>
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Mon, 01 Feb 2021 13:44:06 +0100 |
parents | ce07ea113225 (current diff) f881b37fa853 (diff) |
children | 9f02fcaf9ed1 |
files | .github/ISSUE_TEMPLATE/--------bug-report.md .github/ISSUE_TEMPLATE/---feature-request.md |
diffstat | 4 files changed, 11 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Mon Feb 01 13:36:28 2021 +0100 +++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Mon Feb 01 13:44:06 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 Mon Feb 01 13:36:28 2021 +0100 +++ b/lazybear/Views/Company.swift Mon Feb 01 13:44:06 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 Mon Feb 01 13:36:28 2021 +0100 +++ b/lazybear/Views/Stock.swift Mon Feb 01 13:44:06 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) } }