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")
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
showingAnnotationsSheet = true
|
||||
}) {
|
||||
Image(systemName: "pencil.line")
|
||||
if viewModel.hasAnnotations {
|
||||
Button(action: {
|
||||
showingAnnotationsSheet = true
|
||||
}) {
|
||||
Image(systemName: "pencil.line")
|
||||
}
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
|
||||
@ -20,6 +20,7 @@ class BookmarkDetailViewModel {
|
||||
var settings: Settings?
|
||||
var readProgress: Int = 0
|
||||
var selectedAnnotationId: String?
|
||||
var hasAnnotations: Bool = false
|
||||
|
||||
private var factory: UseCaseFactory?
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
@ -85,8 +86,11 @@ class BookmarkDetailViewModel {
|
||||
let paragraphs = articleContent
|
||||
.components(separatedBy: .newlines)
|
||||
.filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }
|
||||
|
||||
|
||||
articleParagraphs = paragraphs
|
||||
|
||||
// Check if article contains annotations
|
||||
hasAnnotations = articleContent.contains("<rd-annotation")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user