Renamed word to FlashCard

This commit is contained in:
2024-04-06 12:54:33 +02:00
parent 20621c495d
commit 4022261ff3
6 changed files with 18 additions and 17 deletions

View File

@@ -10,12 +10,12 @@ import SwiftUI
struct AnkiView: View { struct AnkiView: View {
@EnvironmentObject var model: WordAXModelView @EnvironmentObject var model: WordAXModelView
@State var showDescription = true @State var showDescription = true
var word: WordAX.Word? { var word: WordAX.FlashCard? {
model.getWordToDisplay() model.getWordToDisplay()
} }
var body: some View { var body: some View {
if word != nil {
GeometryReader { geometry in GeometryReader { geometry in
if word != nil {
VStack { VStack {
WordView(word: word!, showDescription: $showDescription) WordView(word: word!, showDescription: $showDescription)
if showDescription { if showDescription {
@@ -57,12 +57,12 @@ struct AnkiView: View {
.padding([.bottom, .trailing, .leading]) .padding([.bottom, .trailing, .leading])
} }
} }
}
} else { } else {
Text("There is no word to display, come back later") Text("There is no word to display, come back later")
} }
} }
} }
}
#Preview { #Preview {
AnkiView() AnkiView()

View File

@@ -31,7 +31,7 @@ struct NextRepetitionButtonView: View {
.bold() .bold()
} }
.padding(.vertical, geometry.size.height / 80) .padding(.vertical, geometry.size.height / 80)
.foregroundColor(colorScheme == .light ? .black : .white) .foregroundColor(.black)
.frame(maxWidth: width) .frame(maxWidth: width)
} }
.background(color) .background(color)

View File

@@ -8,7 +8,7 @@
import Foundation import Foundation
struct WordAX { struct WordAX {
struct Word: Identifiable, Hashable { struct FlashCard: Identifiable, Hashable {
var id: Int var id: Int
var name: String var name: String
var description: String var description: String
@@ -17,6 +17,7 @@ struct WordAX {
var lastSeenOn: Date? var lastSeenOn: Date?
var shownCount: Int = 0 var shownCount: Int = 0
} }
enum FrequencyEnum: Int { enum FrequencyEnum: Int {
case Daily = 1 case Daily = 1
case Weekly = 7 case Weekly = 7
@@ -56,7 +57,7 @@ struct WordAX {
var dateFormatter: DateFormatter var dateFormatter: DateFormatter
} }
public mutating func setNextSpacedRepetitionMilestone(word: Word) { public mutating func setNextSpacedRepetitionMilestone(word: FlashCard) {
if word.nextSpacedRepetitionMilestone != nil { if word.nextSpacedRepetitionMilestone != nil {
let current = SpacedRepetitionMilestoneEnum.allCasesSorted.firstIndex(of: word.nextSpacedRepetitionMilestone!) ?? SpacedRepetitionMilestoneEnum.allCases.count let current = SpacedRepetitionMilestoneEnum.allCasesSorted.firstIndex(of: word.nextSpacedRepetitionMilestone!) ?? SpacedRepetitionMilestoneEnum.allCases.count
let index = words.firstIndex(where:{$0.id == word.id}) ?? nil let index = words.firstIndex(where:{$0.id == word.id}) ?? nil
@@ -87,7 +88,7 @@ struct WordAX {
} }
var words: [Word] = [] var words: [FlashCard] = []
var settings: Settings var settings: Settings
init() { init() {
@@ -95,8 +96,8 @@ struct WordAX {
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/YYYY" dateFormatter.dateFormat = "dd/MM/YYYY"
self.settings = Settings(dateFormatter: dateFormatter) self.settings = Settings(dateFormatter: dateFormatter)
self.words.append(Word(id: 0, name: "Magnificent", description: "When something is awesome. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", shown: false)) self.words.append(FlashCard(id: 0, name: "Magnificent", description: "When something is awesome. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", shown: false))
self.words.append(Word(id: 1, name: "Mesmerising", description: "When something is beautiful", shown: false)) self.words.append(FlashCard(id: 1, name: "Mesmerising", description: "When something is beautiful", shown: false))
} }
} }

View File

@@ -9,7 +9,7 @@ import Foundation
class WordAXModelView: ObservableObject { class WordAXModelView: ObservableObject {
@Published private var model: WordAX @Published private var model: WordAX
typealias Word = WordAX.Word typealias Word = WordAX.FlashCard
init() { init() {
model = WordAX() model = WordAX()
} }

View File

@@ -9,7 +9,7 @@ import SwiftUI
struct WordListRowView: View { struct WordListRowView: View {
@EnvironmentObject var model: WordAXModelView @EnvironmentObject var model: WordAXModelView
var word: WordAX.Word var word: WordAX.FlashCard
@State var favorite = true @State var favorite = true
var body: some View { var body: some View {
HStack { HStack {
@@ -47,11 +47,11 @@ struct WordListRowView: View {
#Preview { #Preview {
Group { Group {
WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) WordListRowView(word: WordAX.FlashCard(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1))
.environmentObject(WordAXModelView()) .environmentObject(WordAXModelView())
WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) WordListRowView(word: WordAX.FlashCard(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1))
.environmentObject(WordAXModelView()) .environmentObject(WordAXModelView())
WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) WordListRowView(word: WordAX.FlashCard(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1))
.environmentObject(WordAXModelView()) .environmentObject(WordAXModelView())
} }
} }

View File

@@ -9,7 +9,7 @@ import SwiftUI
import UIKit import UIKit
struct WordView: View { struct WordView: View {
var word: WordAX.Word var word: WordAX.FlashCard
@Binding var showDescription: Bool @Binding var showDescription: Bool
@EnvironmentObject var model: WordAXModelView @EnvironmentObject var model: WordAXModelView
@Environment(\.colorScheme) var colorScheme @Environment(\.colorScheme) var colorScheme