Better handling when there are no cards for Flashcards list

This commit is contained in:
2024-04-07 16:54:26 +02:00
parent ceef2c0f8e
commit 9c567c96f6
2 changed files with 33 additions and 20 deletions

View File

@@ -12,7 +12,10 @@ struct FlashCardListView: View {
@State var showDescription = true
@State var addFlashcard = false
var body: some View {
GeometryReader { geometry in
NavigationSplitView {
Group {
if !model.flashcards.isEmpty {
List(model.flashcards) { word in
NavigationLink {
FlashCardView(flashcard: word, showDescription: $showDescription)
@@ -20,6 +23,15 @@ struct FlashCardListView: View {
FlashCardListRowView(flashcard: word)
}
}
}
else {
Text("You currently don't have any flashcards. To add flashcards, either click at the '+' button at the top or you can download them from the store (coming soon)")
.padding()
.background(.purple)
.clipShape(.buttonBorder)
.frame(maxWidth: geometry.size.width - 30)
}
}
.navigationTitle("Word List")
.toolbar {
Button(action: {
@@ -36,6 +48,7 @@ struct FlashCardListView: View {
})
}
}
}
#Preview {
FlashCardListView()

View File

@@ -103,8 +103,8 @@ struct WordAX {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/YYYY"
self.settings = Settings(dateFormatter: dateFormatter)
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.flashcards.append(FlashCard(id: 1, name: "Mesmerising", description: "When something is beautiful", 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.flashcards.append(FlashCard(id: 1, name: "Mesmerising", description: "When something is beautiful", shown: false))
}
}