Add option to add hint to a card
This commit is contained in:
@@ -17,6 +17,7 @@ struct AddFlashCardView: View {
|
|||||||
@State var selectedDeck: Deck?
|
@State var selectedDeck: Deck?
|
||||||
@State var createDisabled: Bool = true
|
@State var createDisabled: Bool = true
|
||||||
@State var flashcard: Flashcard
|
@State var flashcard: Flashcard
|
||||||
|
@State var hint: String = ""
|
||||||
var edit: Bool = false
|
var edit: Bool = false
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
@@ -25,6 +26,10 @@ struct AddFlashCardView: View {
|
|||||||
TextField("Name", text: $text)
|
TextField("Name", text: $text)
|
||||||
.focused($focus)
|
.focused($focus)
|
||||||
TextField("Description", text: $description, axis: .vertical)
|
TextField("Description", text: $description, axis: .vertical)
|
||||||
|
TextField("Hint", text: $hint, axis: .vertical)
|
||||||
|
.lineLimit(3, reservesSpace: true)
|
||||||
|
}
|
||||||
|
Section(header: Text("Deck details")) {
|
||||||
Picker("Deck", selection: $selectedDeck) {
|
Picker("Deck", selection: $selectedDeck) {
|
||||||
ForEach(decks) { deck in
|
ForEach(decks) { deck in
|
||||||
Text(deck.name ?? "Unknown deck name")
|
Text(deck.name ?? "Unknown deck name")
|
||||||
@@ -70,6 +75,7 @@ struct AddFlashCardView: View {
|
|||||||
flashcard.name = self.text
|
flashcard.name = self.text
|
||||||
flashcard.desc = self.description
|
flashcard.desc = self.description
|
||||||
flashcard.deck = selectedDeck
|
flashcard.deck = selectedDeck
|
||||||
|
flashcard.hint = self.hint
|
||||||
if !edit {
|
if !edit {
|
||||||
flashcard.nextSpacedRepetitionMilestone = 0
|
flashcard.nextSpacedRepetitionMilestone = 0
|
||||||
flashcard.lastSeenOn = nil
|
flashcard.lastSeenOn = nil
|
||||||
|
|||||||
@@ -42,20 +42,20 @@ struct FlashCardView: View {
|
|||||||
} else {
|
} else {
|
||||||
flashcardText
|
flashcardText
|
||||||
}
|
}
|
||||||
if flashcard.hint != nil {
|
if !showDescription && flashcard.hint != nil {
|
||||||
if !showDescription {
|
if showHint {
|
||||||
Button {
|
Text((flashcard.hint != nil) ? "Hint: \(flashcard.hint ?? "")" : "")
|
||||||
showHint.toggle()
|
.padding()
|
||||||
} label: {
|
.font(.footnote)
|
||||||
Text(showHint ? "Hide Hint" : "Show Hint")
|
} else {
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
if showHint {
|
|
||||||
Text((flashcard.hint != nil) ? "Hint: \(flashcard.hint ?? "")" : "")
|
|
||||||
.padding()
|
|
||||||
.font(.footnote)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
showHint.toggle()
|
||||||
|
} label: {
|
||||||
|
Text(showHint ? "Hide Hint" : "Show Hint")
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
// .disabled(flashcard.hint == nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding([.horizontal, .top])
|
.padding([.horizontal, .top])
|
||||||
|
|||||||
Reference in New Issue
Block a user