From 6e5a6255a3927c22ffb4f60c43944c60835a2796 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 1 May 2019 23:59:00 +0200 Subject: [PATCH] Move empty text inside the JournalList --- lib/screens/home_screen.dart | 39 +++++++++++------------------------ lib/widgets/journal_list.dart | 14 +++++++++++++ 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index f657e2a5..4b5b8112 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -21,33 +21,18 @@ class HomeScreen extends StatelessWidget { child: Icon(Icons.add), ); - Widget journalList; - if (appState.notes.isNotEmpty) { - journalList = JournalList( - notes: appState.notes, - noteSelectedFunction: (noteIndex) { - var route = MaterialPageRoute( - builder: (context) => NoteBrowsingScreen( - notes: appState.notes, - noteIndex: noteIndex, - ), - ); - Navigator.of(context).push(route); - }, - ); - } else { - journalList = Center( - child: Text( - "Why not add your first\n Journal Entry?", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 28.0, - fontWeight: FontWeight.w300, - color: Colors.grey[350], - ), - ), - ); - } + Widget journalList = JournalList( + notes: appState.notes, + noteSelectedFunction: (noteIndex) { + var route = MaterialPageRoute( + builder: (context) => NoteBrowsingScreen( + notes: appState.notes, + noteIndex: noteIndex, + ), + ); + Navigator.of(context).push(route); + }, + ); bool shouldShowBadge = !appState.remoteGitRepoConfigured && appState.hasJournalEntries; diff --git a/lib/widgets/journal_list.dart b/lib/widgets/journal_list.dart index b67d4b3d..7a32dfc7 100644 --- a/lib/widgets/journal_list.dart +++ b/lib/widgets/journal_list.dart @@ -19,6 +19,20 @@ class JournalList extends StatelessWidget { @override Widget build(BuildContext context) { + if (notes.isEmpty) { + return Center( + child: Text( + "Why not add your first\n Journal Entry?", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 28.0, + fontWeight: FontWeight.w300, + color: Colors.grey[350], + ), + ), + ); + } + return ListView.separated( separatorBuilder: (context, index) { return Divider(