делаю лаб 3

This commit is contained in:
ujijrujijr 2024-10-03 00:05:26 +04:00
parent 83178515c5
commit e97a025ea6

View File

@ -32,14 +32,6 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -47,26 +39,81 @@ class _MyHomePageState extends State<MyHomePage> {
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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<T, U>(Map<T, U> 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 'Хоррор';
}
}
}
}