comparison LazyBear/Views/Company/Networking/Company.swift @ 440:01fa77358b82

Fixes #47
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 16:58:36 +0200
parents 7f2a24a774eb
children 4b8031e696e8
comparison
equal deleted inserted replaced
439:aa1f4b614b2b 440:01fa77358b82
8 import SwiftUI 8 import SwiftUI
9 import Bazooka 9 import Bazooka
10 10
11 class Company: ObservableObject { 11 class Company: ObservableObject {
12 @Published var showView = false 12 @Published var showView = false
13 @Published var showChart = true /// To show a ProgressView when the chart is refreshed (Date range selected)
13 @Published var data = CompanyResponse() 14 @Published var data = CompanyResponse()
14 15
15 func request(_ url: String, _ requestType: RequestType) { 16 func request(_ url: String, _ requestType: RequestType) {
17 if requestType == .refresh { self.showChart = false }
16 let bazooka = Bazooka() 18 let bazooka = Bazooka()
17 bazooka.request(url: url, model: CompanyResponse.self) { response in 19 bazooka.request(url: url, model: CompanyResponse.self) { response in
18 switch requestType { 20 switch requestType {
19 case .initial: 21 case .initial:
20 self.data = response 22 self.data = response
23 case .refresh: 25 case .refresh:
24 self.data.historicalPrices = response.historicalPrices 26 self.data.historicalPrices = response.historicalPrices
25 } 27 }
26 28
27 self.showView = true 29 self.showView = true
30 self.showChart = true
28 } 31 }
29 } 32 }
30 } 33 }