feat: Show annotations button only when article contains annotations
Add conditional visibility for the annotations button in the toolbar based on whether the loaded article contains any rd-annotation tags. Changes: - Add hasAnnotations property to BookmarkDetailViewModel - Check for <rd-annotation tags when processing article content - Conditionally show/hide annotations button in BookmarkDetailView2
This commit is contained in:
parent
b77e4e3e9f
commit
c629894611
@ -270,10 +270,12 @@ struct BookmarkDetailView2: View {
|
|||||||
Image(systemName: "tag")
|
Image(systemName: "tag")
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: {
|
if viewModel.hasAnnotations {
|
||||||
showingAnnotationsSheet = true
|
Button(action: {
|
||||||
}) {
|
showingAnnotationsSheet = true
|
||||||
Image(systemName: "pencil.line")
|
}) {
|
||||||
|
Image(systemName: "pencil.line")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class BookmarkDetailViewModel {
|
|||||||
var settings: Settings?
|
var settings: Settings?
|
||||||
var readProgress: Int = 0
|
var readProgress: Int = 0
|
||||||
var selectedAnnotationId: String?
|
var selectedAnnotationId: String?
|
||||||
|
var hasAnnotations: Bool = false
|
||||||
|
|
||||||
private var factory: UseCaseFactory?
|
private var factory: UseCaseFactory?
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
@ -87,6 +88,9 @@ class BookmarkDetailViewModel {
|
|||||||
.filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }
|
.filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }
|
||||||
|
|
||||||
articleParagraphs = paragraphs
|
articleParagraphs = paragraphs
|
||||||
|
|
||||||
|
// Check if article contains annotations
|
||||||
|
hasAnnotations = articleContent.contains("<rd-annotation")
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user