Add add button to list view for flashcards and edit to toolbar

This commit is contained in:
2024-05-03 22:20:41 +02:00
parent ecdea1de2f
commit 5a5646648f

View File

@@ -19,8 +19,19 @@ struct FlashCardListView: View {
GeometryReader { geometry in
NavigationStack {
Group {
if !flashcards.isEmpty {
List {
Button(action: {
self.addFlashcard = true
}) {
VStack {
HStack {
Image(systemName: "plus.circle.fill")
.padding(.trailing)
Text("Add new Flashcard")
}
}
.frame(maxHeight: geometry.size.height / 10)
}
ForEach(flashcards) { flashcard in
NavigationLink {
FlashCardView(flashcard: flashcard, showDescription: $showDescription)
@@ -42,16 +53,7 @@ struct FlashCardListView: View {
}
})
}
} else {
Group {
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(maxHeight: .infinity)
.padding(.horizontal)
}
.environment(\.defaultMinListRowHeight, geometry.size.height / 12)
}
.onAppear {
refreshFlashcards()
@@ -64,11 +66,7 @@ struct FlashCardListView: View {
.navigationBarTitle(deck?.name ?? "All Flashcards", displayMode: deck != nil ? .inline : .automatic)
.toolbar {
ToolbarItemGroup(placement: .topBarTrailing) {
Button(action: {
self.addFlashcard = true
}) {
Image(systemName: "plus")
}
EditButton()
}
}
}