FolderListing: Show the number of notes per folder

This commit is contained in:
Vishesh Handa
2019-12-05 17:48:31 +01:00
parent 199e298903
commit f08d72bb00
2 changed files with 10 additions and 0 deletions

View File

@ -29,6 +29,14 @@ class NotesFolder {
return entities.firstWhere((e) => e.isNote, orElse: () => null) != null; return entities.firstWhere((e) => e.isNote, orElse: () => null) != null;
} }
int get numberOfNotes {
int i = 0;
entities.forEach((e) {
if (e.isNote) i++;
});
return i;
}
// Recurisvely gets all Notes within this folder // Recurisvely gets all Notes within this folder
List<Note> getAllNotes() { List<Note> getAllNotes() {
var notes = <Note>[]; var notes = <Note>[];

View File

@ -70,11 +70,13 @@ class FolderTileState extends State<FolderTile> {
if (folder.parent == null) { if (folder.parent == null) {
folderName = "Notes"; folderName = "Notes";
} }
var subtitle = folder.numberOfNotes.toString() + " Notes";
return Card( return Card(
child: ListTile( child: ListTile(
leading: Icon(Icons.folder), leading: Icon(Icons.folder),
title: Text(folderName), title: Text(folderName),
subtitle: Text(subtitle),
trailing: trailling, trailing: trailling,
), ),
); );