Mercurial > public > lazybear
comparison LazyBear/Views/Company/Chart.swift @ 405:fd8df65927e9
Implementing CapsuleChart in insiders
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 05 Jun 2021 19:04:44 +0200 |
parents | 8357b101df67 |
children | c804ce7a1560 |
comparison
equal
deleted
inserted
replaced
404:444ec927d62f | 405:fd8df65927e9 |
---|---|
22 var body: some View { | 22 var body: some View { |
23 if company.showChartView { | 23 if company.showChartView { |
24 VStack { | 24 VStack { |
25 DatePicker(ranges: ranges, selectedRange: $selectedRange) | 25 DatePicker(ranges: ranges, selectedRange: $selectedRange) |
26 .onChange(of: selectedRange, perform: { range in | 26 .onChange(of: selectedRange, perform: { range in |
27 let url = "https://api.lazybear.app/company/chart/type=refresh/symbol=\(symbol)/range=\(range.lowercased())" | 27 let url = "https://api.lazybear.app/company/chart/symbol=\(symbol)/type=refresh/range=\(range.lowercased())" |
28 company.request(url, .refresh, "chart") | 28 company.request(url, .refresh, "chart") |
29 }) | 29 }) |
30 | 30 |
31 RoundedRectangle(cornerRadius: 15) | 31 RoundedRectangle(cornerRadius: 15) |
32 .foregroundColor(Color(.secondarySystemBackground)) | 32 .foregroundColor(Color(.secondarySystemBackground)) |
66 } | 66 } |
67 } | 67 } |
68 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } // Start timer | 68 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } // Start timer |
69 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer | 69 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer |
70 .onReceive(timer) { _ in | 70 .onReceive(timer) { _ in |
71 let url = "https://api.lazybear.app/company/chart/type=streaming/symbol=\(symbol)" | 71 let url = "https://api.lazybear.app/company/chart/symbol=\(symbol)/type=streaming" |
72 company.request(url, .streaming, "chart") } // Receive timer notification | 72 company.request(url, .streaming, "chart") } // Receive timer notification |
73 } else { | 73 } else { |
74 ProgressView() | 74 ProgressView() |
75 .onAppear { | 75 .onAppear { |
76 let url = "https://api.lazybear.app/company/chart/type=init/symbol=\(symbol)" | 76 let url = "https://api.lazybear.app/company/chart/symbol=\(symbol)/type=init" |
77 company.request(url, .initial, "chart") | 77 company.request(url, .initial, "chart") |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |