diff --git a/lib/main.dart b/lib/main.dart index 43d05378111e377643876e54d9943b3f30b82c4e..6a0d1becf013632810886a657c60c18867f245be 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,7 +17,7 @@ class MyApp extends StatelessWidget { title: 'Namer App', theme: ThemeData( useMaterial3: true, - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange), + colorScheme: ColorScheme.fromSeed(seedColor: Color.fromARGB(255, 218, 235, 241)), ), home: MyHomePage(), ), @@ -28,33 +28,76 @@ class MyApp extends StatelessWidget { class MyAppState extends ChangeNotifier { var current = WordPair.random(); - // ↓ Add this. void getNext() { current = WordPair.random(); notifyListeners(); } + + // ↓ Add the code below. + var favorites = <WordPair>[]; + + void toggleFavorite() { + if (favorites.contains(current)) { + favorites.remove(current); + } else { + favorites.add(current); + } + notifyListeners(); + } } class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { var appState = context.watch<MyAppState>(); - + var pair = appState.current; + return Scaffold( - body: Column( - children: [ - Text('A random AWESOME idea:'), - Text(appState.current.asLowerCase), - - // ↓ Add this. - ElevatedButton( - onPressed: () { - appState.getNext(); // ← This instead of print(). - }, - child: Text('Next'), - ), - - ], + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + BigCard(pair: pair), + SizedBox(height: 10), + ElevatedButton( + onPressed: () { + appState.getNext(); + }, + child: Text('Next'), + ), + ], + ), + ), + ); + } +} + +class BigCard extends StatelessWidget { + const BigCard({ + super.key, + required this.pair, + }); + + final WordPair pair; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final style = theme.textTheme.displayMedium!.copyWith( + color: theme.colorScheme.onPrimary, + ); + + return Card( + color: theme.colorScheme.primary, + child: Padding( + padding: const EdgeInsets.all(20), + + // ↓ Make the following change. + child: Text( + pair.asLowerCase, + style: style, + semanticsLabel: "${pair.first} ${pair.second}", + ), ), ); }