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 showDescription = true
@State var addFlashcard = false @State var addFlashcard = false
var body: some View { var body: some View {
NavigationSplitView { GeometryReader { geometry in
List(model.flashcards) { word in NavigationSplitView {
NavigationLink { Group {
FlashCardView(flashcard: word, showDescription: $showDescription) if !model.flashcards.isEmpty {
} label: { List(model.flashcards) { word in
FlashCardListRowView(flashcard: word) 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")
.navigationTitle("Word List") .toolbar {
.toolbar { Button(action: {
Button(action: { self.addFlashcard = true
self.addFlashcard = true }) {
}) { Image(systemName: "plus")
Image(systemName: "plus") }
} }
} detail: {
Text("Select word to get details about")
} }
} detail: { .sheet(isPresented: $addFlashcard, content: {
Text("Select word to get details about") 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() let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/YYYY" dateFormatter.dateFormat = "dd/MM/YYYY"
self.settings = Settings(dateFormatter: dateFormatter) 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: 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: 1, name: "Mesmerising", description: "When something is beautiful", shown: false))
} }
} }