Add add button to list view for flashcards and edit to toolbar
This commit is contained in:
@@ -19,8 +19,19 @@ struct FlashCardListView: View {
|
|||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
Group {
|
Group {
|
||||||
if !flashcards.isEmpty {
|
|
||||||
List {
|
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
|
ForEach(flashcards) { flashcard in
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
FlashCardView(flashcard: flashcard, showDescription: $showDescription)
|
FlashCardView(flashcard: flashcard, showDescription: $showDescription)
|
||||||
@@ -42,16 +53,7 @@ struct FlashCardListView: View {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
.environment(\.defaultMinListRowHeight, geometry.size.height / 12)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
refreshFlashcards()
|
refreshFlashcards()
|
||||||
@@ -64,11 +66,7 @@ struct FlashCardListView: View {
|
|||||||
.navigationBarTitle(deck?.name ?? "All Flashcards", displayMode: deck != nil ? .inline : .automatic)
|
.navigationBarTitle(deck?.name ?? "All Flashcards", displayMode: deck != nil ? .inline : .automatic)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItemGroup(placement: .topBarTrailing) {
|
ToolbarItemGroup(placement: .topBarTrailing) {
|
||||||
Button(action: {
|
EditButton()
|
||||||
self.addFlashcard = true
|
|
||||||
}) {
|
|
||||||
Image(systemName: "plus")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user