App working again

This commit is contained in:
2024-04-10 13:48:04 +02:00
parent 301e545f47
commit 2727467fd9
2 changed files with 14 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ struct FlashCardView: View {
Text("Last seen: " + model.getDateFormatter().string(from: flashcard.lastSeenOn!))
.font(.subheadline)
}
Text("Next spaced repetition milestone: \(flashcard.nextSpacedRepetitionMilestone)")
if showDescription {
flashcardText
.textSelection(.enabled)

View File

@@ -6,6 +6,7 @@
//
import SwiftUI
import CoreData
struct NextRepetitionButtonView: View {
let buttonText: String
@@ -15,14 +16,25 @@ struct NextRepetitionButtonView: View {
let color: Color
let geometry: GeometryProxy
let timeText: String
@Environment(\.managedObjectContext) var moc
// { colorScheme == .light ? .cyan : .darkCyan }
@Binding var showDescription: Bool
@EnvironmentObject var model: WordAXModelView
@Environment(\.colorScheme) var colorScheme
var body: some View {
Button(action: {
// TODO: Fix this anki button clicked function
// model.ankiButtonClicked(flashcardId: flashcardId, milestone: nextMilestone)
let request = NSFetchRequest<Flashcard>(entityName: "Flashcard")
request.predicate = NSPredicate(format: "id == %@", flashcardId as CVarArg)
do {
let result = try moc.fetch(request)
let flashcard = result.first
flashcard?.lastSeenOn = Date()
flashcard?.nextSpacedRepetitionMilestone = nextMilestone?.rawValue ?? 0
flashcard?.shownCount += 1
try moc.save()
} catch {
print("Something went wrong while saving the flashcard info: \(error.localizedDescription)")
}
self.showDescription = false
}) {
VStack {