Mercurial > public > lazybear
comparison LazyBear/Views/Home/HomeView.swift @ 337:31f2838b2de7
Improving API requests with DispatchGroup
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Thu, 01 Apr 2021 16:34:45 +0200 |
parents | 6f904b166564 |
children | 71a9c0e61783 |
comparison
equal
deleted
inserted
replaced
336:6f904b166564 | 337:31f2838b2de7 |
---|---|
19 }() | 19 }() |
20 | 20 |
21 let dueDate = Date() | 21 let dueDate = Date() |
22 | 22 |
23 var body: some View { | 23 var body: some View { |
24 NavigationView { | 24 if homeData.showView { |
25 List { | 25 NavigationView { |
26 SectorRow(sectorPerformance: homeData.sectorPerformance) | 26 List { |
27 SectorRow(sectorPerformance: homeData.sectorPerformance) | |
28 .listRowInsets(EdgeInsets()) | |
29 | |
30 // Get keys of the dictionary list | |
31 ForEach(homeData.list.keys.sorted(), id: \.self) { key in | |
32 TopStockRow(key: key, list: homeData.list[key] ?? [CompanyRowModel](), intradayPricesDict: homeData.intradayPrices) | |
33 } | |
27 .listRowInsets(EdgeInsets()) | 34 .listRowInsets(EdgeInsets()) |
28 | |
29 // Get keys of the dictionary list | |
30 ForEach(homeData.list.keys.sorted(), id: \.self) { key in | |
31 TopStockRow(key: key, list: homeData.list[key] ?? [CompanyRowModel](), intradayPricesDict: homeData.intradayPrices) | |
32 } | 35 } |
33 .listRowInsets(EdgeInsets()) | 36 .onReceive(timer) {_ in homeData.request() } |
34 } | 37 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") |
35 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") | 38 .navigationBarTitleDisplayMode(.inline) |
36 .navigationBarTitleDisplayMode(.inline) | 39 .navigationViewStyle(StackNavigationViewStyle()) |
37 .navigationViewStyle(StackNavigationViewStyle()) | 40 .toolbar { |
38 .toolbar { | 41 ToolbarItem(placement: .navigationBarTrailing) { |
39 ToolbarItem(placement: .navigationBarTrailing) { | 42 Button(action: { showTradingDates = true }) { |
40 Button(action: { showTradingDates = true }) { | 43 Image(systemName: "calendar.badge.clock") |
41 Image(systemName: "calendar.badge.clock") | 44 } |
42 } | 45 } |
43 } | 46 } |
44 } | 47 } |
45 } | 48 .sheet(isPresented: $showTradingDates) { |
46 .onAppear { homeData.get() } | 49 // TradingDates(stringDates: homeData.holidayDates) |
47 .onReceive(timer) {_ in homeData.get() } | 50 } |
48 .sheet(isPresented: $showTradingDates) { | 51 } else { |
49 TradingDates(stringDates: homeData.holidayDates) | 52 ProgressView() |
53 .onAppear { homeData.request() } | |
50 } | 54 } |
51 } | 55 } |
52 } | 56 } |
53 | 57 |
54 struct HomeView_Previews: PreviewProvider { | 58 struct HomeView_Previews: PreviewProvider { |