From 2495701bf5774039d3767eb733163097c5e17cb9 Mon Sep 17 00:00:00 2001 From: NOOBJE <guswp320@gmail.com> Date: Wed, 5 Jun 2024 20:18:33 +0900 Subject: [PATCH] =?UTF-8?q?8=EB=8B=A8=EA=B3=84=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 15f2656..f191069 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({ -- GitLab