Mercurial > public > lazybear
changeset 409:dc8dccd18e86
Minor UI changes
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 06 Jun 2021 19:07:21 +0200 |
parents | f9611c94d636 |
children | e24c9ca71824 |
files | LazyBear/Views/Company/Chart.swift LazyBear/Views/Company/Insiders.swift LazyBear/Views/Global Helpers/PriceView.swift LazyBear/Views/Search/CompanyList.swift |
diffstat | 4 files changed, 26 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/Views/Company/Chart.swift Sun Jun 06 17:39:22 2021 +0200 +++ b/LazyBear/Views/Company/Chart.swift Sun Jun 06 19:07:21 2021 +0200 @@ -39,9 +39,9 @@ let changePercent = quote.changePercent ?? 0 let priceViewStyle = PriceViewStyle( alignment: .leading, - priceFont: .headline, + priceFont: .title3, priceFontWeight: .semibold, - percentFont: .body, + percentFont: .headline, percentFontWeight: .medium ) PriceView(latestPrice: latestPrice, changePercent: changePercent, style: priceViewStyle) @@ -50,11 +50,13 @@ } .padding([.top, .leading, .trailing]) + Spacer() if let historicalPrices = company.chartData.historicalPrices { - if let prices = historicalPrices.compactMap { $0.close } { // Map without nil - LineChartView(data: prices, dates: nil, hours: nil, dragGesture: true) - .padding(.bottom) - } + let prices = historicalPrices.compactMap { $0.close } + let dates = historicalPrices.compactMap { $0.date } +// let hours = historicalPrices.compactMap { $0.minute } + LineChartView(data: prices, dates: dates, hours: nil, dragGesture: true) + .padding(.bottom) } } ) @@ -68,7 +70,7 @@ .padding(.top) } } - .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } // Start timer + .onAppear { print("appeared"); self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } // Start timer .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer .onReceive(timer) { _ in let url = "https://api.lazybear.app/company/chart/symbol=\(symbol)/type=streaming" @@ -81,6 +83,14 @@ } } } + + /* + Price data is cached, so when the view disappears and appears again in a few seconds, the cached data is shown up. But the date range + is incorrect because, always when this view appears, selectedRange is "3M". + */ + private func checkDateRange() { + + } } struct Chart_Previews: PreviewProvider {
--- a/LazyBear/Views/Company/Insiders.swift Sun Jun 06 17:39:22 2021 +0200 +++ b/LazyBear/Views/Company/Insiders.swift Sun Jun 06 19:07:21 2021 +0200 @@ -13,13 +13,12 @@ var body: some View { if company.showInsidersView { - VStack(alignment: .leading) { - Text("Top 10 insiders") - .font(.title3) - .fontWeight(.semibold) + if let insiderSummer = company.insidersData.insiderRoster { + VStack(alignment: .leading) { + Text("Top 10 insiders") + .font(.title3) + .fontWeight(.semibold) - if let insiderSummer = company.insidersData.insiderRoster { - // Get total shares owned by the top 10 insiders let totalPositions = insiderSummer.map { $0.position }.reduce(0, +) VStack(alignment: .leading, spacing: 20) {
--- a/LazyBear/Views/Global Helpers/PriceView.swift Sun Jun 06 17:39:22 2021 +0200 +++ b/LazyBear/Views/Global Helpers/PriceView.swift Sun Jun 06 19:07:21 2021 +0200 @@ -14,7 +14,7 @@ var body: some View { VStack(alignment: style.alignment) { - Text("$\(latestPrice, specifier: "%.2f")") + Text("\(latestPrice, specifier: "%.2f")") .foregroundColor(changePercent < 0 ? .red: .green) .font(style.priceFont) .fontWeight(style.priceFontWeight)
--- a/LazyBear/Views/Search/CompanyList.swift Sun Jun 06 17:39:22 2021 +0200 +++ b/LazyBear/Views/Search/CompanyList.swift Sun Jun 06 19:07:21 2021 +0200 @@ -12,7 +12,9 @@ var body: some View { List(searchResult, id: \.self) { company in - SearchedCompanyItem(company: company) + NavigationLink(destination: CompanyView(symbol: company.symbol!)) { + SearchedCompanyItem(company: company) + } } } }