Mercurial > public > lazybear
comparison LazyBear/Views/Home/HomeView.swift @ 339:e81c18164afb
Fixing backend API Requests
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 03 Apr 2021 13:02:40 +0200 |
parents | 71a9c0e61783 |
children | 4e6c47a81b80 |
comparison
equal
deleted
inserted
replaced
338:71a9c0e61783 | 339:e81c18164afb |
---|---|
26 List { | 26 List { |
27 SectorRow(sectorPerformance: homeData.sectorPerformance) | 27 SectorRow(sectorPerformance: homeData.sectorPerformance) |
28 .listRowInsets(EdgeInsets()) | 28 .listRowInsets(EdgeInsets()) |
29 | 29 |
30 // Get keys of the dictionary list | 30 // Get keys of the dictionary list |
31 ForEach(homeData.list.keys.sorted(), id: \.self) { key in | 31 ForEach(homeData.topLists.keys.sorted(), id: \.self) { listType in |
32 TopStockRow(key: key, list: homeData.list[key] ?? [CompanyRowModel](), intradayPricesDict: homeData.intradayPrices) | 32 if let list = homeData.topLists[listType] { |
33 TopStockRow(listType: listType, list: list) | |
34 } | |
33 } | 35 } |
34 .listRowInsets(EdgeInsets()) | 36 .listRowInsets(EdgeInsets()) |
35 } | 37 } |
36 .onReceive(timer) {_ in homeData.request() } | 38 .onReceive(timer) { _ in homeData.request() } |
37 .onDisappear { timer.upstream.connect().cancel() } | 39 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer |
38 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") | 40 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") |
39 .navigationBarTitleDisplayMode(.inline) | 41 .navigationBarTitleDisplayMode(.inline) |
40 .navigationViewStyle(StackNavigationViewStyle()) | 42 .navigationViewStyle(StackNavigationViewStyle()) |
41 .toolbar { | 43 .toolbar { |
42 ToolbarItem(placement: .navigationBarTrailing) { | 44 ToolbarItem(placement: .navigationBarTrailing) { |
45 } | 47 } |
46 } | 48 } |
47 } | 49 } |
48 } | 50 } |
49 .sheet(isPresented: $showTradingDates) { | 51 .sheet(isPresented: $showTradingDates) { |
50 TradingDates(stringDates: homeData.holidayDates) | 52 TradingDates() |
51 } | 53 } |
52 } else { | 54 } else { |
53 ProgressView() | 55 ProgressView() |
54 .onAppear { homeData.request() } | 56 .onAppear { |
57 homeData.request() | |
58 self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() // Restart timer | |
59 } | |
60 | |
55 } | 61 } |
56 } | 62 } |
57 } | 63 } |
58 | 64 |
59 struct HomeView_Previews: PreviewProvider { | 65 struct HomeView_Previews: PreviewProvider { |