From e97a025ea6dd9e725fa2559123ac2446c1f97118 Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Thu, 3 Oct 2024 00:05:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D1=8E=20=D0=BB=D0=B0?= =?UTF-8?q?=D0=B1=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 103 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 28 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 612665b..1454149 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,14 +32,6 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - _counter++; - }); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -47,26 +39,81 @@ class _MyHomePageState extends State { backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, + body: const GameWidget(), + ); + } +} + +class GameWidget extends StatelessWidget { + const GameWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Center( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _GameCard(name: 'Late Shift', price: 399,), + ], + ) + ) + ); + } +} + +class _GameCard extends StatelessWidget { + final String name; + final int price; + // final GameType type; + // final String? description; + //для image можно задать default значение (через = в констркуторе) + // final String image; + + const _GameCard({ + super.key, required this.name, required this.price, + }); + + // const _GameCard({ + // super.key, required this.name, required this.price, required this.type, this.description, required this.image, + // }); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(top: 16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.lightBlue, + borderRadius: BorderRadius.circular(5), + ), + child: + //ПЫТАЕТСЯ РАСТЯНУТЬСЯ НА ВЕСЬ ЭКРАН, ИСПРАВИТЬ + Row( + children: [ + //ЗДЕСЬ ДО СТОЛБЦА БУДЕТ ФОТО (ОНО ДОЛЖНО БЫТЬ СЛЕВА) + Column( + children: [ + //название игры + Text( + name, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + //цена игры + Text( + price.toString()+' руб.', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ], ), ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), - ); + )); } } @@ -140,7 +187,7 @@ void printMapValues(Map map) { extension GameTypeRus on GameType { String get rusName { - switch(this) { + switch (this) { case GameType.FMV: return 'FMV'; case GameType.Shooter: @@ -151,4 +198,4 @@ extension GameTypeRus on GameType { return 'Хоррор'; } } -} \ No newline at end of file +}