From 252578c8eb4ed9e0073f5f37d951b97c9f5c5bb3 Mon Sep 17 00:00:00 2001 From: SomnusVeritas Date: Sat, 21 Oct 2023 00:54:12 +0200 Subject: [PATCH] games buttons page --- lib/pages/games_page.dart | 51 +++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/lib/pages/games_page.dart b/lib/pages/games_page.dart index f9330b5..ed093fd 100644 --- a/lib/pages/games_page.dart +++ b/lib/pages/games_page.dart @@ -4,13 +4,50 @@ class GamesPage extends StatelessWidget { const GamesPage({super.key}); @override Widget build(BuildContext context) { - return Column( - children: [ - Text('Mario Kart'), - Text('Exploding Kittens'), - Text('Twister'), - Text('Mario Party') - ], + final games = [ + 'Mario Kart', + 'Mario Party', + 'Exploding Kittens', + 'Twister', + ]; + return Center( + child: Column( + children: _getWidgets(games, context), + ), + ); + } + + List _getWidgets(List list, BuildContext context) { + final width = MediaQuery.of(context).size.width * 0.8; + List widgets = []; + for (final game in list) { + widgets.add( + Expanded( + child: SizedBox( + width: width, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: _getGamesButton(() {}, game, context)), + ), + ), + ); + } + return widgets; + } + + Text _getText(String text, BuildContext context) { + return Text( + text, + style: Theme.of(context).textTheme.headlineSmall, + ); + } + + ElevatedButton _getGamesButton( + void Function()? onPressed, String title, BuildContext context) { + return ElevatedButton( + style: ElevatedButton.styleFrom(shape: const BeveledRectangleBorder()), + onPressed: onPressed, + child: _getText(title, context), ); } }