comparison LazyBear/Views/Home/HomeView.swift @ 349:5ccceb527178

Implementing new internal API
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 14 Apr 2021 23:08:26 +0200
parents 80bfa88c6b0f
children eb97439e46cd
comparison
equal deleted inserted replaced
348:0abb8d5c12ec 349:5ccceb527178
39 StockRectangleRow(listName: listName, list: lists[listName]!, nestedIntradayPrices: nil) 39 StockRectangleRow(listName: listName, list: lists[listName]!, nestedIntradayPrices: nil)
40 } 40 }
41 } 41 }
42 .listRowInsets(EdgeInsets()) 42 .listRowInsets(EdgeInsets())
43 } 43 }
44
45 if let latestCurrencies = home.data.latestCurrencies {
46 CurrencyRow(latestCurrencies: latestCurrencies)
47 .listRowInsets(EdgeInsets())
48 }
44 } 49 }
45 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/streaming") } 50 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/streaming") }
46 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer 51 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer
47 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") 52 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)")
48 .navigationBarTitleDisplayMode(.inline) 53 .navigationBarTitleDisplayMode(.inline)
62 } 67 }
63 } else { 68 } else {
64 ProgressView() 69 ProgressView()
65 .onAppear { 70 .onAppear {
66 home.request("https://api.lazybear.app/home/init") 71 home.request("https://api.lazybear.app/home/init")
72
67 // Restart timer 73 // Restart timer
68 self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() 74 self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect()
69 } 75 }
70 76
71 } 77 }
72 } 78 }
73 } 79 }
74 80
75 struct HomeView_Previews: PreviewProvider { 81 struct HomeView_Previews: PreviewProvider {