Mercurial > public > lazybear
changeset 129:4ce0ff2a38ae
Add section to Watchlist
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 07 Feb 2021 19:31:49 +0100 |
parents | 57d22236ccbd |
children | 012148730331 |
files | LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Views/HistoryList.swift lazybear/Views/Watchlist.swift |
diffstat | 3 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- 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)
--- 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() }