show highlight annotation sheet when tapping on note or 'add a note'

This commit is contained in:
Satindar Dhillon
2022-10-05 09:53:56 -07:00
parent cffdfa4342
commit 49e911f023
2 changed files with 24 additions and 5 deletions

View File

@ -1,8 +1,11 @@
import Models
import SwiftUI
import Views
struct HighlightsListCard: View {
@State var isContextMenuOpen = false
@State var annotation = String()
@State var showAnnotationModal = false
let highlight: Highlight
@ -34,6 +37,10 @@ struct HighlightsListCard: View {
Text(highlight.annotation ?? "")
}
.onTapGesture {
annotation = highlight.annotation ?? ""
showAnnotationModal = true
}
}
var addNoteSection: some View {
@ -48,7 +55,8 @@ struct HighlightsListCard: View {
Spacer()
}
.onTapGesture {
print("add a note")
annotation = highlight.annotation ?? ""
showAnnotationModal = true
}
}
@ -96,5 +104,18 @@ struct HighlightsListCard: View {
}
.padding(.bottom, 8)
}
.sheet(isPresented: $showAnnotationModal) {
HighlightAnnotationSheet(
annotation: $annotation,
onSave: {
print("new annotation = \(annotation)")
showAnnotationModal = false
},
onCancel: {
print("cancel annotation")
showAnnotationModal = false
}
)
}
}
}

View File

@ -22,15 +22,13 @@ public struct HighlightAnnotationSheet: View {
HStack {
Button("Cancel", action: onCancel)
Spacer()
HStack {
Image(systemName: "note.text")
Text("Note")
}
Label("Note", systemImage: "note.text")
Spacer()
Button("Save") {
onSave()
}
}
.foregroundColor(.appGrayTextContrast)
ScrollView {
TextEditor(text: $annotation)