comparison LazyBear/Views/Home/HomeView.swift @ 343:ab909fc9ce55

Implement batch requests HomeView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Tue, 06 Apr 2021 11:04:21 +0200
parents a6c49f1409f3
children 80bfa88c6b0f
comparison
equal deleted inserted replaced
342:a6c49f1409f3 343:ab909fc9ce55
8 import SwiftUI 8 import SwiftUI
9 9
10 struct HomeView: View { 10 struct HomeView: View {
11 @ObservedObject var homeData = HomeData() 11 @ObservedObject var homeData = HomeData()
12 @State private var showTradingDates = false 12 @State private var showTradingDates = false
13
13 // Set recurrent price request 14 // Set recurrent price request
14 @State private var timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() 15 @State private var timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect()
15 16
16 static let taskDateFormat: DateFormatter = { 17 static let taskDateFormat: DateFormatter = {
17 let formatter = DateFormatter() 18 let formatter = DateFormatter()
27 List { 28 List {
28 SectorRow(sectorPerformance: homeData.sectorPerformance) 29 SectorRow(sectorPerformance: homeData.sectorPerformance)
29 .listRowInsets(EdgeInsets()) 30 .listRowInsets(EdgeInsets())
30 31
31 // Get keys of the dictionary list 32 // Get keys of the dictionary list
32 ForEach(homeData.topLists.keys.sorted(), id: \.self) { listType in 33 let listTypes = ["mostactive", "losers", "gainers"]
34 ForEach(listTypes.sorted(), id: \.self) { listType in
33 if let list = homeData.topLists[listType] { 35 if let list = homeData.topLists[listType] {
34 TopStockRow(listType: listType, list: list) 36 StockRectangleRow(listType: listType, list: list, intradayPrices: homeData.intradayPrices)
37
35 } 38 }
36 } 39 }
37 .listRowInsets(EdgeInsets()) 40 .listRowInsets(EdgeInsets())
38 } 41 }
39 .onReceive(timer) { _ in homeData.get() } 42 .onReceive(timer) { _ in homeData.get() }