diff --git a/WordAX/Views/FlashCardListView.swift b/WordAX/Views/FlashCardListView.swift index 98d3b27..73ac7e8 100644 --- a/WordAX/Views/FlashCardListView.swift +++ b/WordAX/Views/FlashCardListView.swift @@ -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) - }) } } diff --git a/WordAX/WordAX.swift b/WordAX/WordAX.swift index af4294d..ed2a070 100644 --- a/WordAX/WordAX.swift +++ b/WordAX/WordAX.swift @@ -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)) } }