Empty state for the Highlights View

This commit is contained in:
Jackson Harper 2022-10-17 15:13:05 +08:00
parent 9cc180d43b
commit 68a304664c
4 changed files with 31 additions and 19 deletions

View file

@ -12,7 +12,35 @@ struct HighlightsListView: View {
let itemObjectID: NSManagedObjectID
@Binding var hasHighlightMutations: Bool
var emptyView: some View {
Text("""
You have not added any highlights to this page.
""")
.multilineTextAlignment(.center)
.padding(16)
}
var innerBody: some View {
(viewModel.highlightItems.count > 0 ? AnyView(listView) : AnyView(emptyView))
.navigationTitle("Highlights & Notes")
.listStyle(PlainListStyle())
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
dismissButton
}
}
#else
.toolbar {
ToolbarItemGroup {
dismissButton
}
}
#endif
}
var listView: some View {
List {
Section {
ForEach(viewModel.highlightItems) { highlightParams in
@ -38,22 +66,6 @@ struct HighlightsListView: View {
}
}
}
.navigationTitle("Highlights")
.listStyle(PlainListStyle())
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
dismissButton
}
}
#else
.toolbar {
ToolbarItemGroup {
dismissButton
}
}
#endif
}
var dismissButton: some View {

View file

@ -294,7 +294,7 @@ import Views
.contextMenu {
Button(
action: { viewModel.itemForHighlightsView = item },
label: { Label("View Highlights", systemImage: "highlighter") }
label: { Label("View Highlights & Notes", systemImage: "highlighter") }
)
Button(
action: { viewModel.itemUnderTitleEdit = item },

View file

@ -152,7 +152,7 @@ struct WebReaderContainerView: View {
Group {
Button(
action: { showHighlightsView = true },
label: { Label("View Highlights", systemImage: "highlighter") }
label: { Label("View Highlights & Notes", systemImage: "highlighter") }
)
Button(
action: { showTitleEdit = true },

View file

@ -48,7 +48,7 @@ public struct GridCard: View {
Group {
Button(
action: { menuActionHandler(.viewHighlights) },
label: { Label("View Highlights", systemImage: "highlighter") }
label: { Label("View Highlights & Notes", systemImage: "highlighter") }
)
Button(
action: { menuActionHandler(.editTitle) },