App working again
This commit is contained in:
@@ -24,7 +24,6 @@ struct FlashCardView: View {
|
|||||||
Text("Last seen: " + model.getDateFormatter().string(from: flashcard.lastSeenOn!))
|
Text("Last seen: " + model.getDateFormatter().string(from: flashcard.lastSeenOn!))
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
}
|
}
|
||||||
Text("Next spaced repetition milestone: \(flashcard.nextSpacedRepetitionMilestone)")
|
|
||||||
if showDescription {
|
if showDescription {
|
||||||
flashcardText
|
flashcardText
|
||||||
.textSelection(.enabled)
|
.textSelection(.enabled)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import CoreData
|
||||||
|
|
||||||
struct NextRepetitionButtonView: View {
|
struct NextRepetitionButtonView: View {
|
||||||
let buttonText: String
|
let buttonText: String
|
||||||
@@ -15,14 +16,25 @@ struct NextRepetitionButtonView: View {
|
|||||||
let color: Color
|
let color: Color
|
||||||
let geometry: GeometryProxy
|
let geometry: GeometryProxy
|
||||||
let timeText: String
|
let timeText: String
|
||||||
|
@Environment(\.managedObjectContext) var moc
|
||||||
// { colorScheme == .light ? .cyan : .darkCyan }
|
// { colorScheme == .light ? .cyan : .darkCyan }
|
||||||
@Binding var showDescription: Bool
|
@Binding var showDescription: Bool
|
||||||
@EnvironmentObject var model: WordAXModelView
|
@EnvironmentObject var model: WordAXModelView
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
// TODO: Fix this anki button clicked function
|
let request = NSFetchRequest<Flashcard>(entityName: "Flashcard")
|
||||||
// model.ankiButtonClicked(flashcardId: flashcardId, milestone: nextMilestone)
|
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
|
self.showDescription = false
|
||||||
}) {
|
}) {
|
||||||
VStack {
|
VStack {
|
||||||
|
|||||||
Reference in New Issue
Block a user