# HG changeset patch # User Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> # Date 1612722709 -3600 # Node ID 4ce0ff2a38ae61c79e95148fc3e0393be7a0a06f # Parent 57d22236ccbd75c0b47af630c474971c5f02c41a Add section to Watchlist diff -r 57d22236ccbd -r 4ce0ff2a38ae LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r 57d22236ccbd -r 4ce0ff2a38ae lazybear/Views/HistoryList.swift --- a/lazybear/Views/HistoryList.swift Sun Feb 07 19:30:04 2021 +0100 +++ b/lazybear/Views/HistoryList.swift Sun Feb 07 19:31:49 2021 +0100 @@ -25,6 +25,7 @@ .actionSheet(isPresented: $showingActionSheet) { alert() } } ) { + // Sorte array by Date. The new ones come first in the list let sorted = history.sorted { $0.date ?? Date() > $1.date ?? Date() } ForEach(sorted) { company in CompanyRow(history: company) diff -r 57d22236ccbd -r 4ce0ff2a38ae lazybear/Views/Watchlist.swift --- a/lazybear/Views/Watchlist.swift Sun Feb 07 19:30:04 2021 +0100 +++ b/lazybear/Views/Watchlist.swift Sun Feb 07 19:31:49 2021 +0100 @@ -16,10 +16,12 @@ var body: some View { NavigationView { List { - ForEach(companies) { company in - WatchlistRow(company: company) + Section(header: Text("Watchlist")) { + ForEach(companies) { company in + WatchlistRow(company: company) + } + .onDelete { indexSet in deleteWatchlist(indexSet: indexSet) } // Delete from persistent storage } - .onDelete { indexSet in deleteWatchlist(indexSet: indexSet) } // Delete from persistent storage } .navigationBarTitle("Watchlist", displayMode: .inline) .toolbar { EditButton() }