diff LazyBear/Views/Home/HomeView.swift @ 326:2fabdc393675

Testing networking in HomeView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Tue, 30 Mar 2021 23:13:14 +0200
parents 3e64824cca3e
children 2dad5828ccf6
line wrap: on
line diff
--- a/LazyBear/Views/Home/HomeView.swift	Mon Mar 29 21:00:03 2021 +0200
+++ b/LazyBear/Views/Home/HomeView.swift	Tue Mar 30 23:13:14 2021 +0200
@@ -8,11 +8,21 @@
 import SwiftUI
 
 struct HomeView: View {
+    @ObservedObject var homeData = HomeData()
+    @State private var showTradingDates = false
+    
+    static let taskDateFormat: DateFormatter = {
+        let formatter = DateFormatter()
+        formatter.dateStyle = .medium
+        return formatter
+        }()
+
+        let dueDate = Date()
     
     var body: some View {
         NavigationView {
             List {
-                SectorRow()
+                SectorRow(sectorPerformance: homeData.sectorPerformance)
                     .listRowInsets(EdgeInsets())
                 
                 let keyTitles = ["Top gainers", "Top losers", "Most active"]
@@ -22,9 +32,26 @@
                 }
                 .listRowInsets(EdgeInsets())
             }
-            .navigationTitle("Home")
+            .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)")
             .navigationBarTitleDisplayMode(.inline)
             .navigationViewStyle(StackNavigationViewStyle())
+            .toolbar {
+                ToolbarItem(placement: .navigationBarTrailing) {
+                    Button(action: { showTradingDates = true }) {
+                        Image(systemName: "calendar.badge.clock")
+                    }
+                }
+                
+                ToolbarItem(placement: .navigationBarLeading) {
+                    Button(action: { homeData.getSectorPerformance() }) {
+                        Text("Test recall")
+                    }
+                }
+            }
+        }
+        .onAppear { homeData.getSectorPerformance() }
+        .sheet(isPresented: $showTradingDates) {
+            TradingDates()
         }
     }
 }