OnClick anywhere on the screen of the word, the description appears

This commit is contained in:
2024-02-25 11:17:11 +01:00
parent 83deb09425
commit c81eb49364
2 changed files with 15 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ class WordAXModelView: ObservableObject {
if words.count > 0 {
// if today is the date they're supposed to be shown
let displayToday = words.filter({ $0.lastSeenOn != nil && $0.lastSeenOn!.add})
let displayToday = words.filter({ $0.lastSeenOn != nil && $0.lastSeenOn!.addSpacedRepetitionMilestone(milestone: $0.nextSpacedRepetitionMilestone!).isAfterTodayOrToday()})
if displayToday.count > 0 {
return displayToday.first!
}
@@ -72,7 +72,15 @@ extension Date {
self.addingTimeInterval(TimeInterval(frequency.rawValue * 24 * 60 * 60))
}
func addSpacedRepetitionMilestone(milestone: WordAX.SpacedRepetitionMilestoneEnum) -> Date {
self.addingTimeInterval(TimeInterval(milestone.rawValue * 24 * 60 * 60))
}
func isAfterToday() -> Bool {
self.isAfter(Date())
}
func isAfterTodayOrToday() -> Bool {
self.isAfterToday() || self.isToday()
}
}

View File

@@ -10,7 +10,7 @@ import UIKit
struct WordView: View {
var word: WordAX.Word
var showDescription: Bool = true
@State var showDescription: Bool = false
@EnvironmentObject var model: WordAXModelView
@Environment(\.colorScheme) var colorScheme
@@ -31,6 +31,11 @@ struct WordView: View {
}
}
.padding([.horizontal, .top])
.frame(maxWidth: .infinity, maxHeight: .infinity)
.contentShape(Rectangle())
.onTapGesture {
self.showDescription = true
}
}
}