Better handling when there are no cards for Flashcards list
This commit is contained in:
@@ -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: {
|
||||
@@ -35,6 +47,7 @@ struct FlashCardListView: View {
|
||||
AddFlashCard(isShowing: $addFlashcard, addFlashCard: model.addFlashCard)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user