From 7d4de7d3521eb8e9f0ca2abcfb509aaa0b331d70 Mon Sep 17 00:00:00 2001 From: KeiHara <84754523+KeiHara@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:30:35 +1200 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9787bc..b6ae24a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mobile Development Workshop 2022 +# Mobile Development Workshop 2023 ## Prerequisities From 2c45d9aa0fc6a44701daa497f1217b2a2bc6d541 Mon Sep 17 00:00:00 2001 From: KeiHara <84754523+KeiHara@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:45:45 +1300 Subject: [PATCH 2/3] removing widgets --- mem_game/lib/main.dart | 97 --------------------------- mem_game/lib/widgets/custom_card.dart | 32 --------- mem_game/lib/widgets/header.dart | 15 ----- 3 files changed, 144 deletions(-) diff --git a/mem_game/lib/main.dart b/mem_game/lib/main.dart index 54b48c4..e4f2a42 100644 --- a/mem_game/lib/main.dart +++ b/mem_game/lib/main.dart @@ -38,101 +38,4 @@ class _HomeScreenState extends State { super.initState(); game.initGame(); } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFF3A405A), - body: Column( - children: [ - const SizedBox( - height: 30, - ), - const Header(), - Expanded( - child: Center( - child: AspectRatio( - aspectRatio: 9 / 10, - child: GridView.builder( - itemCount: game.cardPaths.length, - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 4, - crossAxisSpacing: 16.0, - mainAxisSpacing: 16.0, - ), - padding: const EdgeInsets.all(16.0), - itemBuilder: (context, index) { - return GestureDetector( - onTap: () { - setState(() { - turns += 1; - game.selectedCards.add(index); - }); - - // Player selected two cards - if (game.selectedCards.length == 2) { - int firstCard = game.selectedCards.elementAt(0); - int secondCard = game.selectedCards.elementAt(1); - - if (game.cardPaths[firstCard] == - game.cardPaths[secondCard] && - firstCard != secondCard) { - // The two cards match! - - game.isCardFlipped[firstCard] = true; - game.isCardFlipped[secondCard] = true; - pairsFound += 1; - - if (pairsFound == 8) { - game.initGame(); - pairsFound = 0; - turns = 0; - } - - game.selectedCards.clear(); - } else { - Future.delayed(const Duration(milliseconds: 250), - () { - setState(() { - game.selectedCards.clear(); - }); - }); - } - } - }, - child: Container( - decoration: BoxDecoration( - color: const Color(0xFF99B2DD), - borderRadius: BorderRadius.circular(12.0), - image: DecorationImage( - image: AssetImage((() { - if (game.isCardFlipped[index] == true || - game.selectedCards.contains(index)) { - return game.cardPaths[index]; - } else { - return game.questionCardPath; - } - })()), - fit: BoxFit.cover, - ), - ), - ), - ); - }), - ), - ), - ), - Row( - //mainAxisAlignment: MainAxisAlignment.spaceAround, - //crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CustomCard("Turns", "$turns"), - CustomCard("Pairs Found", "$pairsFound"), - ], - ), - ], - ), - ); - } } diff --git a/mem_game/lib/widgets/custom_card.dart b/mem_game/lib/widgets/custom_card.dart index eca9f89..c44d61b 100644 --- a/mem_game/lib/widgets/custom_card.dart +++ b/mem_game/lib/widgets/custom_card.dart @@ -5,36 +5,4 @@ class CustomCard extends StatelessWidget { final String value; const CustomCard(this.title, this.value, {Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Expanded( - child: Container( - margin: const EdgeInsets.all(15.0), - child: Column( - children: [ - Text( - title, - style: const TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - const SizedBox( - height: 5.0, - ), - Text( - value, - style: const TextStyle( - fontSize: 50.0, - fontWeight: FontWeight.w900, - color: Colors.white, - ), - ), - ], - ), - ), - ); - } } diff --git a/mem_game/lib/widgets/header.dart b/mem_game/lib/widgets/header.dart index 6a5216e..b43c901 100644 --- a/mem_game/lib/widgets/header.dart +++ b/mem_game/lib/widgets/header.dart @@ -2,19 +2,4 @@ import 'package:flutter/material.dart'; class Header extends StatelessWidget { const Header({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const Center( - child: Text( - "Mem Game", - style: TextStyle( - fontSize: 40.0, - fontWeight: FontWeight.bold, - color: Colors.white, - fontFamily: 'Pacifico', - ), - ), - ); - } } From 5b88acb4db0e5908b3d57dbdb8950c74ff6066bf Mon Sep 17 00:00:00 2001 From: KeiHara <84754523+KeiHara@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:41:34 +1300 Subject: [PATCH 3/3] removing few implementation --- mem_game/lib/main.dart | 20 +------------------- mem_game/lib/widgets/custom_card.dart | 7 +------ mem_game/lib/widgets/header.dart | 4 +--- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/mem_game/lib/main.dart b/mem_game/lib/main.dart index e4f2a42..2fd5a72 100644 --- a/mem_game/lib/main.dart +++ b/mem_game/lib/main.dart @@ -11,13 +11,6 @@ class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return const MaterialApp( - title: 'Flutter Demo', - home: HomeScreen(), - ); - } } class HomeScreen extends StatefulWidget { @@ -27,15 +20,4 @@ class HomeScreen extends StatefulWidget { State createState() => _HomeScreenState(); } -class _HomeScreenState extends State { - Game game = Game(); - - int turns = 0; - int pairsFound = 0; - - @override - void initState() { - super.initState(); - game.initGame(); - } -} +class _HomeScreenState extends State {} diff --git a/mem_game/lib/widgets/custom_card.dart b/mem_game/lib/widgets/custom_card.dart index c44d61b..97e4f9b 100644 --- a/mem_game/lib/widgets/custom_card.dart +++ b/mem_game/lib/widgets/custom_card.dart @@ -1,8 +1,3 @@ import 'package:flutter/material.dart'; -class CustomCard extends StatelessWidget { - final String title; - final String value; - - const CustomCard(this.title, this.value, {Key? key}) : super(key: key); -} +class CustomCard extends StatelessWidget {} diff --git a/mem_game/lib/widgets/header.dart b/mem_game/lib/widgets/header.dart index b43c901..70a1ebc 100644 --- a/mem_game/lib/widgets/header.dart +++ b/mem_game/lib/widgets/header.dart @@ -1,5 +1,3 @@ import 'package:flutter/material.dart'; -class Header extends StatelessWidget { - const Header({Key? key}) : super(key: key); -} +class Header extends StatelessWidget {}