From 4022261ff30a9c57bdac1968abc13ff9dccd1cc9 Mon Sep 17 00:00:00 2001 From: oliverhnat Date: Sat, 6 Apr 2024 12:54:33 +0200 Subject: [PATCH] Renamed word to FlashCard --- WordAX/AnkiView.swift | 10 +++++----- WordAX/NextRepetitionButtonView.swift | 2 +- WordAX/WordAX.swift | 11 ++++++----- WordAX/WordAXModelView.swift | 2 +- WordAX/WordListRowView.swift | 8 ++++---- WordAX/WordView.swift | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/WordAX/AnkiView.swift b/WordAX/AnkiView.swift index f5f7011..edc2fab 100644 --- a/WordAX/AnkiView.swift +++ b/WordAX/AnkiView.swift @@ -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 + GeometryReader { geometry in + if word != nil { VStack { WordView(word: word!, showDescription: $showDescription) if showDescription { @@ -57,9 +57,9 @@ struct AnkiView: View { .padding([.bottom, .trailing, .leading]) } } + } else { + Text("There is no word to display, come back later") } - } else { - Text("There is no word to display, come back later") } } } diff --git a/WordAX/NextRepetitionButtonView.swift b/WordAX/NextRepetitionButtonView.swift index c79475b..6080f43 100644 --- a/WordAX/NextRepetitionButtonView.swift +++ b/WordAX/NextRepetitionButtonView.swift @@ -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) diff --git a/WordAX/WordAX.swift b/WordAX/WordAX.swift index 2963456..425eafc 100644 --- a/WordAX/WordAX.swift +++ b/WordAX/WordAX.swift @@ -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)) } } diff --git a/WordAX/WordAXModelView.swift b/WordAX/WordAXModelView.swift index aa3910b..8786419 100644 --- a/WordAX/WordAXModelView.swift +++ b/WordAX/WordAXModelView.swift @@ -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() } diff --git a/WordAX/WordListRowView.swift b/WordAX/WordListRowView.swift index 361f6d9..c9c62d3 100644 --- a/WordAX/WordListRowView.swift +++ b/WordAX/WordListRowView.swift @@ -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()) } } diff --git a/WordAX/WordView.swift b/WordAX/WordView.swift index 2146386..3124f9f 100644 --- a/WordAX/WordView.swift +++ b/WordAX/WordView.swift @@ -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