Renamed word to FlashCard in all files
This commit is contained in:
@@ -11,10 +11,10 @@
|
|||||||
6C8185002B88C9660033CF46 /* WordAXModelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */; };
|
6C8185002B88C9660033CF46 /* WordAXModelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */; };
|
||||||
6C8185022B88C9FB0033CF46 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185012B88C9FB0033CF46 /* SettingsView.swift */; };
|
6C8185022B88C9FB0033CF46 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185012B88C9FB0033CF46 /* SettingsView.swift */; };
|
||||||
6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185032B88CA210033CF46 /* AnkiView.swift */; };
|
6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185032B88CA210033CF46 /* AnkiView.swift */; };
|
||||||
6C8185062B8A537F0033CF46 /* WordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185052B8A537F0033CF46 /* WordView.swift */; };
|
6C8185062B8A537F0033CF46 /* FlashCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185052B8A537F0033CF46 /* FlashCardView.swift */; };
|
||||||
6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */; };
|
6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */; };
|
||||||
6C81850A2B8BA5740033CF46 /* WordListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185092B8BA5740033CF46 /* WordListView.swift */; };
|
6C81850A2B8BA5740033CF46 /* FlashCardListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185092B8BA5740033CF46 /* FlashCardListView.swift */; };
|
||||||
6C81850C2B8BA6BC0033CF46 /* WordListRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */; };
|
6C81850C2B8BA6BC0033CF46 /* FlashCardListRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C81850B2B8BA6BC0033CF46 /* FlashCardListRowView.swift */; };
|
||||||
6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439512B83541D004C3543 /* WordAXApp.swift */; };
|
6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439512B83541D004C3543 /* WordAXApp.swift */; };
|
||||||
6CF439542B83541D004C3543 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439532B83541D004C3543 /* MainView.swift */; };
|
6CF439542B83541D004C3543 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439532B83541D004C3543 /* MainView.swift */; };
|
||||||
6CF439562B83541E004C3543 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CF439552B83541E004C3543 /* Assets.xcassets */; };
|
6CF439562B83541E004C3543 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CF439552B83541E004C3543 /* Assets.xcassets */; };
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXModelView.swift; sourceTree = "<group>"; };
|
6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXModelView.swift; sourceTree = "<group>"; };
|
||||||
6C8185012B88C9FB0033CF46 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
6C8185012B88C9FB0033CF46 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||||
6C8185032B88CA210033CF46 /* AnkiView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnkiView.swift; sourceTree = "<group>"; };
|
6C8185032B88CA210033CF46 /* AnkiView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnkiView.swift; sourceTree = "<group>"; };
|
||||||
6C8185052B8A537F0033CF46 /* WordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordView.swift; sourceTree = "<group>"; };
|
6C8185052B8A537F0033CF46 /* FlashCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashCardView.swift; sourceTree = "<group>"; };
|
||||||
6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextRepetitionButtonView.swift; sourceTree = "<group>"; };
|
6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextRepetitionButtonView.swift; sourceTree = "<group>"; };
|
||||||
6C8185092B8BA5740033CF46 /* WordListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordListView.swift; sourceTree = "<group>"; };
|
6C8185092B8BA5740033CF46 /* FlashCardListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashCardListView.swift; sourceTree = "<group>"; };
|
||||||
6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordListRowView.swift; sourceTree = "<group>"; };
|
6C81850B2B8BA6BC0033CF46 /* FlashCardListRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashCardListRowView.swift; sourceTree = "<group>"; };
|
||||||
6CF4394E2B83541D004C3543 /* WordAX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WordAX.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
6CF4394E2B83541D004C3543 /* WordAX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WordAX.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
6CF439512B83541D004C3543 /* WordAXApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXApp.swift; sourceTree = "<group>"; };
|
6CF439512B83541D004C3543 /* WordAXApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXApp.swift; sourceTree = "<group>"; };
|
||||||
6CF439532B83541D004C3543 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
|
6CF439532B83541D004C3543 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
|
||||||
@@ -69,11 +69,11 @@
|
|||||||
children = (
|
children = (
|
||||||
6CF439512B83541D004C3543 /* WordAXApp.swift */,
|
6CF439512B83541D004C3543 /* WordAXApp.swift */,
|
||||||
6CF439532B83541D004C3543 /* MainView.swift */,
|
6CF439532B83541D004C3543 /* MainView.swift */,
|
||||||
6C8185092B8BA5740033CF46 /* WordListView.swift */,
|
6C8185092B8BA5740033CF46 /* FlashCardListView.swift */,
|
||||||
6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */,
|
6C81850B2B8BA6BC0033CF46 /* FlashCardListRowView.swift */,
|
||||||
6C8185012B88C9FB0033CF46 /* SettingsView.swift */,
|
6C8185012B88C9FB0033CF46 /* SettingsView.swift */,
|
||||||
6C8185032B88CA210033CF46 /* AnkiView.swift */,
|
6C8185032B88CA210033CF46 /* AnkiView.swift */,
|
||||||
6C8185052B8A537F0033CF46 /* WordView.swift */,
|
6C8185052B8A537F0033CF46 /* FlashCardView.swift */,
|
||||||
6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */,
|
6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */,
|
||||||
6C8184FD2B88C9580033CF46 /* WordAX.swift */,
|
6C8184FD2B88C9580033CF46 /* WordAX.swift */,
|
||||||
6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */,
|
6C8184FF2B88C9660033CF46 /* WordAXModelView.swift */,
|
||||||
@@ -164,13 +164,13 @@
|
|||||||
6C8185022B88C9FB0033CF46 /* SettingsView.swift in Sources */,
|
6C8185022B88C9FB0033CF46 /* SettingsView.swift in Sources */,
|
||||||
6CF439542B83541D004C3543 /* MainView.swift in Sources */,
|
6CF439542B83541D004C3543 /* MainView.swift in Sources */,
|
||||||
6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */,
|
6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */,
|
||||||
6C8185062B8A537F0033CF46 /* WordView.swift in Sources */,
|
6C8185062B8A537F0033CF46 /* FlashCardView.swift in Sources */,
|
||||||
6C81850A2B8BA5740033CF46 /* WordListView.swift in Sources */,
|
6C81850A2B8BA5740033CF46 /* FlashCardListView.swift in Sources */,
|
||||||
6C8185002B88C9660033CF46 /* WordAXModelView.swift in Sources */,
|
6C8185002B88C9660033CF46 /* WordAXModelView.swift in Sources */,
|
||||||
6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */,
|
6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */,
|
||||||
6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */,
|
6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */,
|
||||||
6C8184FE2B88C9580033CF46 /* WordAX.swift in Sources */,
|
6C8184FE2B88C9580033CF46 /* WordAX.swift in Sources */,
|
||||||
6C81850C2B8BA6BC0033CF46 /* WordListRowView.swift in Sources */,
|
6C81850C2B8BA6BC0033CF46 /* FlashCardListRowView.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ import SwiftUI
|
|||||||
|
|
||||||
struct AnkiView: View {
|
struct AnkiView: View {
|
||||||
@EnvironmentObject var model: WordAXModelView
|
@EnvironmentObject var model: WordAXModelView
|
||||||
@State var showDescription = true
|
@State var showDescription = false
|
||||||
var word: WordAX.FlashCard? {
|
var flashcard: WordAX.FlashCard? {
|
||||||
model.getWordToDisplay()
|
model.getFlashCardsToDisplay()
|
||||||
}
|
}
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
if word != nil {
|
if flashcard != nil {
|
||||||
VStack {
|
VStack {
|
||||||
WordView(word: word!, showDescription: $showDescription)
|
FlashCardView(flashcard: flashcard!, showDescription: $showDescription)
|
||||||
if showDescription {
|
if showDescription {
|
||||||
// Text("How did you do?")
|
// Text("How did you do?")
|
||||||
// .font(.subheadline)
|
// .font(.subheadline)
|
||||||
@@ -25,8 +25,8 @@ struct AnkiView: View {
|
|||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
NextRepetitionButtonView(
|
NextRepetitionButtonView(
|
||||||
buttonText: "Wrong",
|
buttonText: "Wrong",
|
||||||
nextMilestone: word!.nextSpacedRepetitionMilestone,
|
nextMilestone: flashcard!.nextSpacedRepetitionMilestone,
|
||||||
wordId: word!.id,
|
flashcardId: flashcard!.id,
|
||||||
width: geometry.size.width,
|
width: geometry.size.width,
|
||||||
color: .red,
|
color: .red,
|
||||||
geometry: geometry,
|
geometry: geometry,
|
||||||
@@ -35,8 +35,8 @@ struct AnkiView: View {
|
|||||||
)
|
)
|
||||||
NextRepetitionButtonView(
|
NextRepetitionButtonView(
|
||||||
buttonText: "Correct",
|
buttonText: "Correct",
|
||||||
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone),
|
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: flashcard!.nextSpacedRepetitionMilestone),
|
||||||
wordId: word!.id,
|
flashcardId: flashcard!.id,
|
||||||
width:geometry.size.width,
|
width:geometry.size.width,
|
||||||
color: .orange,
|
color: .orange,
|
||||||
geometry: geometry,
|
geometry: geometry,
|
||||||
@@ -45,8 +45,8 @@ struct AnkiView: View {
|
|||||||
)
|
)
|
||||||
NextRepetitionButtonView(
|
NextRepetitionButtonView(
|
||||||
buttonText: "Easy",
|
buttonText: "Easy",
|
||||||
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone)),
|
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: flashcard!.nextSpacedRepetitionMilestone)),
|
||||||
wordId: word!.id,
|
flashcardId: flashcard!.id,
|
||||||
width: geometry.size.width,
|
width: geometry.size.width,
|
||||||
color: .green,
|
color: .green,
|
||||||
geometry: geometry,
|
geometry: geometry,
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct WordListRowView: View {
|
struct FlashCardListRowView: View {
|
||||||
@EnvironmentObject var model: WordAXModelView
|
@EnvironmentObject var model: WordAXModelView
|
||||||
var word: WordAX.FlashCard
|
var flashcard: WordAX.FlashCard
|
||||||
@State var favorite = true
|
@State var favorite = true
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
@@ -30,12 +30,12 @@ struct WordListRowView: View {
|
|||||||
}
|
}
|
||||||
.padding(.trailing)
|
.padding(.trailing)
|
||||||
VStack {
|
VStack {
|
||||||
Text(word.name)
|
Text(flashcard.name)
|
||||||
.bold()
|
.bold()
|
||||||
.font(.system(size: 19))
|
.font(.system(size: 19))
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
Text(word.description)
|
Text(flashcard.description)
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
@@ -47,11 +47,11 @@ struct WordListRowView: View {
|
|||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
Group {
|
Group {
|
||||||
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))
|
FlashCardListRowView(flashcard: 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.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))
|
FlashCardListRowView(flashcard: 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.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))
|
FlashCardListRowView(flashcard: 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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,16 +7,16 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct WordListView: View {
|
struct FlashCardListView: View {
|
||||||
@EnvironmentObject var model: WordAXModelView
|
@EnvironmentObject var model: WordAXModelView
|
||||||
@State var showDescription = true
|
@State var showDescription = true
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
List(model.words) { word in
|
List(model.flashcards) { word in
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
WordView(word: word, showDescription: $showDescription)
|
FlashCardView(flashcard: word, showDescription: $showDescription)
|
||||||
} label: {
|
} label: {
|
||||||
WordListRowView(word: word)
|
FlashCardListRowView(flashcard: word)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("Word List")
|
.navigationTitle("Word List")
|
||||||
@@ -27,6 +27,6 @@ struct WordListView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
WordListView()
|
FlashCardListView()
|
||||||
.environmentObject(WordAXModelView())
|
.environmentObject(WordAXModelView())
|
||||||
}
|
}
|
||||||
@@ -8,32 +8,32 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
struct WordView: View {
|
struct FlashCardView: View {
|
||||||
var word: WordAX.FlashCard
|
var flashcard: 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
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let wordText = Text(word.name)
|
let flashcardText = Text(flashcard.name)
|
||||||
.font(.title)
|
.font(.title)
|
||||||
.bold()
|
.bold()
|
||||||
VStack {
|
VStack {
|
||||||
if word.shown && word.lastSeenOn != nil {
|
if flashcard.shown && flashcard.lastSeenOn != nil {
|
||||||
Text("Last seen: " + model.getDateFormatter().string(from: word.lastSeenOn!))
|
Text("Last seen: " + model.getDateFormatter().string(from: flashcard.lastSeenOn!))
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
}
|
}
|
||||||
if showDescription {
|
if showDescription {
|
||||||
wordText
|
flashcardText
|
||||||
.textSelection(.enabled)
|
.textSelection(.enabled)
|
||||||
Divider()
|
Divider()
|
||||||
.background(colorScheme == .light ? Color.black : Color.white)
|
.background(colorScheme == .light ? Color.black : Color.white)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
Text(word.description)
|
Text(flashcard.description)
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
} else {
|
} else {
|
||||||
wordText
|
flashcardText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding([.horizontal, .top])
|
.padding([.horizontal, .top])
|
||||||
@@ -47,6 +47,6 @@ struct WordView: View {
|
|||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
@State var showDescription = false
|
@State var showDescription = false
|
||||||
return WordView(word: WordAXModelView().getWordToDisplay()!, showDescription: $showDescription)
|
return FlashCardView(flashcard: WordAXModelView().getFlashCardsToDisplay()!, showDescription: $showDescription)
|
||||||
.environmentObject(WordAXModelView())
|
.environmentObject(WordAXModelView())
|
||||||
}
|
}
|
||||||
@@ -22,11 +22,11 @@ struct MainView: View {
|
|||||||
Image(systemName: "star")
|
Image(systemName: "star")
|
||||||
Text("Anki")
|
Text("Anki")
|
||||||
}
|
}
|
||||||
WordListView()
|
FlashCardListView()
|
||||||
.tag("Word List")
|
.tag("Flashcards")
|
||||||
.tabItem {
|
.tabItem {
|
||||||
Image(systemName: "list.bullet")
|
Image(systemName: "list.bullet")
|
||||||
Text("Word List")
|
Text("Flashcards")
|
||||||
}
|
}
|
||||||
SettingsView()
|
SettingsView()
|
||||||
.tag("Settings")
|
.tag("Settings")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import SwiftUI
|
|||||||
struct NextRepetitionButtonView: View {
|
struct NextRepetitionButtonView: View {
|
||||||
let buttonText: String
|
let buttonText: String
|
||||||
let nextMilestone: WordAX.SpacedRepetitionMilestoneEnum?
|
let nextMilestone: WordAX.SpacedRepetitionMilestoneEnum?
|
||||||
let wordId: Int
|
let flashcardId: Int
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let color: Color
|
let color: Color
|
||||||
let geometry: GeometryProxy
|
let geometry: GeometryProxy
|
||||||
@@ -21,7 +21,7 @@ struct NextRepetitionButtonView: View {
|
|||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
model.ankiButtonClicked(wordId: wordId, milestone: nextMilestone)
|
model.ankiButtonClicked(flashcardId: flashcardId, milestone: nextMilestone)
|
||||||
self.showDescription = false
|
self.showDescription = false
|
||||||
}) {
|
}) {
|
||||||
VStack {
|
VStack {
|
||||||
|
|||||||
@@ -26,23 +26,26 @@ struct WordAX {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum SpacedRepetitionMilestoneEnum: Int, CaseIterable {
|
enum SpacedRepetitionMilestoneEnum: Int, CaseIterable {
|
||||||
case OneDay = 1
|
case OneMinute = 60 // 60 * 1
|
||||||
case OneWeek = 7
|
case TenMinutes = 600 // 60 * 10
|
||||||
case TwoWeeks = 14
|
case OneHour = 3600 // 60 * 60
|
||||||
case OneMonth = 30
|
case OneDay = 86_400 // 24 * 60 * 60
|
||||||
case TwoMonths = 60
|
case OneWeek = 604_800 // 24 * 60 * 60 * 7
|
||||||
case FiveMonths = 150
|
case TwoWeeks = 1_209_600 // 24 * 60 * 60 * 14
|
||||||
case OneYear = 365
|
case OneMonth = 2_592_000 // 24 * 60 * 60 * 30
|
||||||
|
case TwoMonths = 5_184_000 // 24 * 60 * 60 * 60
|
||||||
|
case FiveMonths = 12_960_000 // 24 * 60 * 60 * 150
|
||||||
|
case OneYear = 31_536_000 // 24 * 60 * 60 * 365
|
||||||
|
|
||||||
static var allCasesSorted: [SpacedRepetitionMilestoneEnum] {
|
static var allCasesSorted: [SpacedRepetitionMilestoneEnum] {
|
||||||
allCases.sorted {$0.rawValue < $1.rawValue }
|
allCases.sorted {$0.rawValue < $1.rawValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func getNext(milestone: SpacedRepetitionMilestoneEnum?) -> SpacedRepetitionMilestoneEnum? {
|
static func getNext(milestone: SpacedRepetitionMilestoneEnum?) -> SpacedRepetitionMilestoneEnum? {
|
||||||
if milestone == nil {
|
|
||||||
return SpacedRepetitionMilestoneEnum.OneDay
|
|
||||||
}
|
|
||||||
let sorted = WordAX.SpacedRepetitionMilestoneEnum.allCasesSorted
|
let sorted = WordAX.SpacedRepetitionMilestoneEnum.allCasesSorted
|
||||||
|
if milestone == nil {
|
||||||
|
return sorted.first
|
||||||
|
}
|
||||||
let milestoneIndex = sorted.firstIndex(where: {$0.rawValue == milestone!.rawValue})!
|
let milestoneIndex = sorted.firstIndex(where: {$0.rawValue == milestone!.rawValue})!
|
||||||
if milestoneIndex < WordAX.SpacedRepetitionMilestoneEnum.allCasesSorted.count {
|
if milestoneIndex < WordAX.SpacedRepetitionMilestoneEnum.allCasesSorted.count {
|
||||||
return sorted[milestoneIndex + 1]
|
return sorted[milestoneIndex + 1]
|
||||||
@@ -57,47 +60,51 @@ struct WordAX {
|
|||||||
var dateFormatter: DateFormatter
|
var dateFormatter: DateFormatter
|
||||||
}
|
}
|
||||||
|
|
||||||
public mutating func setNextSpacedRepetitionMilestone(word: FlashCard) {
|
public mutating func setNextSpacedRepetitionMilestone(flashcard: FlashCard) {
|
||||||
if word.nextSpacedRepetitionMilestone != nil {
|
if flashcard.nextSpacedRepetitionMilestone != nil {
|
||||||
let current = SpacedRepetitionMilestoneEnum.allCasesSorted.firstIndex(of: word.nextSpacedRepetitionMilestone!) ?? SpacedRepetitionMilestoneEnum.allCases.count
|
let current = SpacedRepetitionMilestoneEnum.allCasesSorted.firstIndex(of: flashcard.nextSpacedRepetitionMilestone!) ?? SpacedRepetitionMilestoneEnum.allCases.count
|
||||||
let index = words.firstIndex(where:{$0.id == word.id}) ?? nil
|
let index = flashcards.firstIndex(where:{$0.id == flashcard.id}) ?? nil
|
||||||
if current + 1 < SpacedRepetitionMilestoneEnum.allCases.count && index != nil {
|
if current + 1 < SpacedRepetitionMilestoneEnum.allCases.count && index != nil {
|
||||||
words[index!].nextSpacedRepetitionMilestone = SpacedRepetitionMilestoneEnum.allCasesSorted[current + 1]
|
flashcards[index!].nextSpacedRepetitionMilestone = SpacedRepetitionMilestoneEnum.allCasesSorted[current + 1]
|
||||||
} else if index != nil {
|
} else if index != nil {
|
||||||
words[index!].nextSpacedRepetitionMilestone = nil
|
flashcards[index!].nextSpacedRepetitionMilestone = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public mutating func setSpacedRepetitionMilestone(wordId: Int, milestone: SpacedRepetitionMilestoneEnum?) {
|
public mutating func setSpacedRepetitionMilestone(flashcardId: Int, milestone: SpacedRepetitionMilestoneEnum?) {
|
||||||
let index = words.firstIndex(where:{$0.id == wordId}) ?? nil
|
let index = flashcards.firstIndex(where:{$0.id == flashcardId}) ?? nil
|
||||||
if index != nil {
|
if index != nil {
|
||||||
words[index!].nextSpacedRepetitionMilestone = milestone
|
flashcards[index!].nextSpacedRepetitionMilestone = milestone
|
||||||
if !words[index!].shown {
|
if !flashcards[index!].shown {
|
||||||
words[index!].shown = true
|
flashcards[index!].shown = true
|
||||||
}
|
}
|
||||||
words[index!].lastSeenOn = Date()
|
flashcards[index!].lastSeenOn = Date()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public mutating func wordShown(wordId: Int) {
|
public mutating func flashcardShown(flashcardId: Int) {
|
||||||
let index = words.firstIndex(where:{$0.id == wordId}) ?? nil
|
let index = flashcards.firstIndex(where:{$0.id == flashcardId}) ?? nil
|
||||||
if index != nil {
|
if index != nil {
|
||||||
words[index!].shownCount += 1
|
flashcards[index!].shownCount += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var words: [FlashCard] = []
|
var flashcards: [FlashCard] = []
|
||||||
var settings: Settings
|
var settings: Settings
|
||||||
|
|
||||||
|
public mutating func add(flashcard: FlashCard) {
|
||||||
|
self.flashcards.append(flashcard)
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.words = []
|
self.flashcards = []
|
||||||
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(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.flashcards.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))
|
self.flashcards.append(FlashCard(id: 1, name: "Mesmerising", description: "When something is beautiful", shown: false))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,37 +9,37 @@ import Foundation
|
|||||||
|
|
||||||
class WordAXModelView: ObservableObject {
|
class WordAXModelView: ObservableObject {
|
||||||
@Published private var model: WordAX
|
@Published private var model: WordAX
|
||||||
typealias Word = WordAX.FlashCard
|
typealias FlashCard = WordAX.FlashCard
|
||||||
init() {
|
init() {
|
||||||
model = WordAX()
|
model = WordAX()
|
||||||
}
|
}
|
||||||
|
|
||||||
public var words: [Word] {
|
public var flashcards: [FlashCard] {
|
||||||
model.words
|
model.flashcards
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getDateFormatter() -> DateFormatter {
|
public func getDateFormatter() -> DateFormatter {
|
||||||
model.settings.dateFormatter
|
model.settings.dateFormatter
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getWordToDisplay() -> Word? {
|
public func getFlashCardsToDisplay() -> FlashCard? {
|
||||||
let words = model.words
|
let flashcards = model.flashcards
|
||||||
|
|
||||||
if words.count > 0 {
|
if flashcards.count > 0 {
|
||||||
let notShownWords = words.filter({!$0.shown})
|
let notShownFlashCards = flashcards.filter({!$0.shown})
|
||||||
if notShownWords.count == 0 {
|
if notShownFlashCards.count == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// if today is the date they're supposed to be shown
|
// if today is the date they're supposed to be shown
|
||||||
|
|
||||||
let displayToday = words.filter({ $0.lastSeenOn != nil && $0.lastSeenOn!.addSpacedRepetitionMilestone(milestone: $0.nextSpacedRepetitionMilestone).isBeforeTodayOrToday()})
|
let displayToday = flashcards.filter({ $0.lastSeenOn != nil && $0.lastSeenOn!.addSpacedRepetitionMilestone(milestone: $0.nextSpacedRepetitionMilestone).isBeforeTodayOrToday()})
|
||||||
if displayToday.count > 0 {
|
if displayToday.count > 0 {
|
||||||
return displayToday.first!
|
return displayToday.first!
|
||||||
}
|
}
|
||||||
|
|
||||||
// let shownWords = words.filter({ $0.shown })
|
// let shownWords = words.filter({ $0.shown })
|
||||||
// if shownWords.count == 0 {
|
// if shownWords.count == 0 {
|
||||||
return notShownWords.sorted(by: {$0.id < $1.id}).first
|
return notShownFlashCards.sorted(by: {$0.id < $1.id}).first
|
||||||
// }
|
// }
|
||||||
// if today is the day to show a new word
|
// if today is the day to show a new word
|
||||||
// let settings = model.settings
|
// let settings = model.settings
|
||||||
@@ -53,9 +53,9 @@ class WordAXModelView: ObservableObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public func ankiButtonClicked(wordId: Int, milestone: WordAX.SpacedRepetitionMilestoneEnum?) {
|
public func ankiButtonClicked(flashcardId: Int, milestone: WordAX.SpacedRepetitionMilestoneEnum?) {
|
||||||
model.setSpacedRepetitionMilestone(wordId: wordId, milestone: milestone)
|
model.setSpacedRepetitionMilestone(flashcardId: flashcardId, milestone: milestone)
|
||||||
model.wordShown(wordId: wordId)
|
model.flashcardShown(flashcardId: flashcardId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user