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

View File

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

View File

@@ -8,7 +8,7 @@
import Foundation
struct WordAX {
struct Word: Identifiable, Hashable {
struct FlashCard: Identifiable, Hashable {
var id: Int
var name: String
var description: String
@@ -17,6 +17,7 @@ struct WordAX {
var lastSeenOn: Date?
var shownCount: Int = 0
}
enum FrequencyEnum: Int {
case Daily = 1
case Weekly = 7
@@ -56,7 +57,7 @@ struct WordAX {
var dateFormatter: DateFormatter
}
public mutating func setNextSpacedRepetitionMilestone(word: Word) {
public mutating func setNextSpacedRepetitionMilestone(word: FlashCard) {
if word.nextSpacedRepetitionMilestone != nil {
let current = SpacedRepetitionMilestoneEnum.allCasesSorted.firstIndex(of: word.nextSpacedRepetitionMilestone!) ?? SpacedRepetitionMilestoneEnum.allCases.count
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
init() {
@@ -95,8 +96,8 @@ struct WordAX {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/YYYY"
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(Word(id: 1, name: "Mesmerising", description: "When something is beautiful", 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(FlashCard(id: 1, name: "Mesmerising", description: "When something is beautiful", shown: false))
}
}

View File

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

View File

@@ -9,7 +9,7 @@ import SwiftUI
struct WordListRowView: View {
@EnvironmentObject var model: WordAXModelView
var word: WordAX.Word
var word: WordAX.FlashCard
@State var favorite = true
var body: some View {
HStack {
@@ -47,11 +47,11 @@ struct WordListRowView: View {
#Preview {
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())
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())
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())
}
}

View File

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