From 98995d82947981db3cc579abf85243f759952aaa Mon Sep 17 00:00:00 2001
From: ahnjuseong <ahnjuseong@ajou.ac.kr>
Date: Wed, 5 Jun 2024 20:13:50 +0900
Subject: [PATCH] =?UTF-8?q?6=EB=8B=A8=EA=B3=84=20=EC=99=84=EB=A3=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../assign/lib/main.dart                      | 49 ++++++++++++++++---
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/flutter_application_1/assign/lib/main.dart b/.github/workflows/flutter_application_1/assign/lib/main.dart
index ce149e5328..4251d2ca81 100644
--- a/.github/workflows/flutter_application_1/assign/lib/main.dart
+++ b/.github/workflows/flutter_application_1/assign/lib/main.dart
@@ -27,11 +27,23 @@ 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 {
@@ -40,6 +52,14 @@ class MyHomePage extends StatelessWidget {
     var appState = context.watch<MyAppState>();
     var pair = appState.current;
 
+    // ↓ Add this.
+    IconData icon;
+    if (appState.favorites.contains(pair)) {
+      icon = Icons.favorite;
+    } else {
+      icon = Icons.favorite_border;
+    }
+
     return Scaffold(
       body: Center(
         child: Column(
@@ -47,13 +67,28 @@ class MyHomePage extends StatelessWidget {
           children: [
             BigCard(pair: pair),
             SizedBox(height: 10),
-            ElevatedButton(
-              onPressed: () {
-                appState.getNext();
-              },
-              child: Text('Next'),
+            Row(
+              mainAxisSize: MainAxisSize.min,
+              children: [
+
+                // ↓ And this.
+                ElevatedButton.icon(
+                  onPressed: () {
+                    appState.toggleFavorite();
+                  },
+                  icon: Icon(icon),
+                  label: Text('Like'),
+                ),
+                SizedBox(width: 10),
+
+                ElevatedButton(
+                  onPressed: () {
+                    appState.getNext();
+                  },
+                  child: Text('Next'),
+                ),
+              ],
             ),
-        
           ],
         ),
       ),
-- 
GitLab