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,28 +12,41 @@ struct FlashCardListView: View {
@State var showDescription = true
@State var addFlashcard = false
var body: some View {
NavigationSplitView {
List(model.flashcards) { word in
NavigationLink {
FlashCardView(flashcard: word, showDescription: $showDescription)
} label: {
FlashCardListRowView(flashcard: word)
GeometryReader { geometry in
NavigationSplitView {
Group {
if !model.flashcards.isEmpty {
List(model.flashcards) { word in
NavigationLink {
FlashCardView(flashcard: word, showDescription: $showDescription)
} label: {
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: {
self.addFlashcard = true
}) {
Image(systemName: "plus")
.navigationTitle("Word List")
.toolbar {
Button(action: {
self.addFlashcard = true
}) {
Image(systemName: "plus")
}
}
} detail: {
Text("Select word to get details about")
}
} detail: {
Text("Select word to get details about")
.sheet(isPresented: $addFlashcard, content: {
AddFlashCard(isShowing: $addFlashcard, addFlashCard: model.addFlashCard)
})
}
.sheet(isPresented: $addFlashcard, content: {
AddFlashCard(isShowing: $addFlashcard, addFlashCard: model.addFlashCard)
})
}
}

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))
}
}