Mercurial > public > lazybear
comparison LazyBear/Views/Company/Chart.swift @ 424:6dd97877f575
Improve code, reorganize files
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 13 Jun 2021 19:40:42 +0200 |
parents | 5f21f7c23c5e |
children |
comparison
equal
deleted
inserted
replaced
423:bdfdf3a1b34e | 424:6dd97877f575 |
---|---|
34 Show PriceView and Chart | 34 Show PriceView and Chart |
35 */ | 35 */ |
36 VStack { | 36 VStack { |
37 HStack { | 37 HStack { |
38 if let quote = company.chartData.quote![symbol.uppercased()] { | 38 if let quote = company.chartData.quote![symbol.uppercased()] { |
39 let latestPrice = quote.latestPrice ?? 0 | 39 if let latestPrice = quote.latestPrice, let changePercent = quote.changePercent { |
40 let changePercent = quote.changePercent ?? 0 | 40 HStack(alignment: .center) { |
41 let priceViewStyle = PriceViewStyle( /// Define PriceView style | 41 Text("\(latestPrice, specifier: "%.2f")") |
42 horizontalAlignment: .leading, | 42 .foregroundColor(changePercent < 0 ? .red: .green) |
43 verticalAlignment: .center, | 43 .fontWeight(.semibold) |
44 orientation: .HStack, | 44 |
45 priceFont: .title3, | 45 Text("\(changePercent * 100, specifier: "%.2f")%") |
46 priceFontWeight: .semibold, | 46 .foregroundColor(changePercent < 0 ? .red: .green) |
47 percentFont: .body, | 47 .font(.callout) |
48 percentFontWeight: .semibold, | 48 .fontWeight(.semibold) |
49 showBackground: true | 49 } |
50 ) | 50 .padding(.top) |
51 PriceView(latestPrice: latestPrice, changePercent: changePercent, style: priceViewStyle) | 51 } |
52 } | 52 } |
53 Spacer() | 53 Spacer() |
54 | 54 |
55 if let _ = company.chartData.keyStats { /// Check if keyStats is empty -> Hide button | 55 if let _ = company.chartData.keyStats { /// Check if keyStats is empty -> Hide button |
56 Button("See stats", action: { showingStatistics = true }) | 56 Button("See stats", action: { showingStatistics = true }) |