mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add a basic highlights list view
This commit is contained in:
parent
d82ffa4432
commit
397fb5d9f7
4 changed files with 82 additions and 1 deletions
|
|
@ -0,0 +1,60 @@
|
|||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Views
|
||||
|
||||
struct HighlightsListView: View {
|
||||
@EnvironmentObject var dataService: DataService
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
@StateObject var viewModel = HighlightsListViewModel()
|
||||
|
||||
let item: LinkedItem
|
||||
|
||||
var innerBody: some View {
|
||||
List {
|
||||
Section {
|
||||
ForEach(viewModel.highlights, id: \.self) { highlight in
|
||||
Text(highlight.quote ?? "no quote")
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Highlights")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
dismissButton
|
||||
}
|
||||
}
|
||||
#else
|
||||
.toolbar {
|
||||
ToolbarItemGroup {
|
||||
dismissButton
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
var dismissButton: some View {
|
||||
Button(
|
||||
action: { presentationMode.wrappedValue.dismiss() },
|
||||
label: { Text("Done").foregroundColor(.appGrayTextContrast) }
|
||||
)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if os(iOS)
|
||||
NavigationView {
|
||||
innerBody
|
||||
}
|
||||
#elseif os(macOS)
|
||||
innerBody
|
||||
.frame(minWidth: 400, minHeight: 400)
|
||||
#endif
|
||||
}
|
||||
.task {
|
||||
viewModel.load(item: item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import CoreData
|
||||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Views
|
||||
|
||||
@MainActor final class HighlightsListViewModel: ObservableObject {
|
||||
@Published var highlights = [Highlight]()
|
||||
|
||||
func load(item: LinkedItem) {
|
||||
highlights = item.highlights.asArray(of: Highlight.self)
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ import Views
|
|||
LinkedItemTitleEditView(item: item)
|
||||
}
|
||||
.sheet(item: $viewModel.itemForHighlightsView) { item in
|
||||
Text("Highlights view for: \(item.unwrappedTitle)") // TODO: implement view
|
||||
HighlightsListView(item: item)
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .barTrailing) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ struct WebReaderContainerView: View {
|
|||
@State private var showPreferencesPopover = false
|
||||
@State private var showLabelsModal = false
|
||||
@State private var showTitleEdit = false
|
||||
@State private var showHighlightsView = false
|
||||
@State var showHighlightAnnotationModal = false
|
||||
@State var safariWebLink: SafariWebLink?
|
||||
@State private var navBarVisibilityRatio = 1.0
|
||||
|
|
@ -131,6 +132,10 @@ struct WebReaderContainerView: View {
|
|||
Menu(
|
||||
content: {
|
||||
Group {
|
||||
Button(
|
||||
action: { showHighlightsView = true },
|
||||
label: { Label("View Highlights", systemImage: "highlighter") }
|
||||
)
|
||||
Button(
|
||||
action: { showTitleEdit = true },
|
||||
label: { Label("Edit Title/Description", systemImage: "textbox") }
|
||||
|
|
@ -198,6 +203,9 @@ struct WebReaderContainerView: View {
|
|||
.sheet(isPresented: $showTitleEdit) {
|
||||
LinkedItemTitleEditView(item: item)
|
||||
}
|
||||
.sheet(isPresented: $showHighlightsView) {
|
||||
HighlightsListView(item: item)
|
||||
}
|
||||
#if os(macOS)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue