From cffdfa4342d3a9129a6029c77d738dc97fe78310 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 4 Oct 2022 22:09:44 -0700 Subject: [PATCH] sort highlights by createdAt --- .../App/Views/Highlights/HighlightsListCard.swift | 14 +++++++++++++- .../Views/Highlights/HighlightsListViewModel.swift | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift index 89cd3a8a2..aa067a6fa 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListCard.swift @@ -37,7 +37,19 @@ struct HighlightsListCard: View { } var addNoteSection: some View { - Text("Tap to add a note") + HStack { + Image(systemName: "note.text.badge.plus").foregroundColor(.appGrayTextContrast) + + Text("Add a Note") + .font(.appSubheadline) + .foregroundColor(.appGrayTextContrast) + .lineLimit(1) + + Spacer() + } + .onTapGesture { + print("add a note") + } } var body: some View { diff --git a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListViewModel.swift index bf6905755..a407be8a2 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Highlights/HighlightsListViewModel.swift @@ -8,7 +8,11 @@ import Views @Published var highlights = [Highlight]() func load(item: LinkedItem) { - highlights = item.highlights.asArray(of: Highlight.self) + let unsortedHighlights = item.highlights.asArray(of: Highlight.self) + + highlights = unsortedHighlights.sorted { + ($0.createdAt ?? Date()) < ($1.createdAt ?? Date()) + } } }