diff --git a/lib/main.dart b/lib/main.dart index 15f2656c7e86598452d872ee2179dbd1f0c36302..f1910692f7f7efe7f4d6f715192d0cb43dcf179a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -46,8 +46,6 @@ class MyAppState extends ChangeNotifier { } -// ... - class MyHomePage extends StatefulWidget { @override State<MyHomePage> createState() => _MyHomePageState(); @@ -64,7 +62,7 @@ switch (selectedIndex) { page = GeneratorPage(); break; case 1: - page = Placeholder(); + page = FavoritesPage(); break; default: throw UnimplementedError('no widget for $selectedIndex'); @@ -97,7 +95,7 @@ switch (selectedIndex) { Expanded( child: Container( color: Theme.of(context).colorScheme.primaryContainer, - child: GeneratorPage(), + child: page, ), ), ], @@ -153,6 +151,35 @@ class GeneratorPage extends StatelessWidget { } +// ... +class FavoritesPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + var appState = context.watch<MyAppState>(); + + if (appState.favorites.isEmpty) { + return Center( + child: Text('No favorites yet.'), + ); + } + + return ListView( + children: [ + Padding( + padding: const EdgeInsets.all(20), + child: Text('You have ' + '${appState.favorites.length} favorites:'), + ), + for (var pair in appState.favorites) + ListTile( + leading: Icon(Icons.favorite), + title: Text(pair.asLowerCase), + ), + ], + ); + } +} + class BigCard extends StatelessWidget { const BigCard({