делаю лаб 3
This commit is contained in:
parent
83178515c5
commit
e97a025ea6
103
lib/main.dart
103
lib/main.dart
@ -32,14 +32,6 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -47,26 +39,81 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: const GameWidget(),
|
||||||
child: Column(
|
);
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
}
|
||||||
children: <Widget>[
|
}
|
||||||
const Text(
|
|
||||||
'You have pushed the button this many times:',
|
class GameWidget extends StatelessWidget {
|
||||||
),
|
const GameWidget({super.key});
|
||||||
Text(
|
|
||||||
'$_counter',
|
@override
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
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 {
|
extension GameTypeRus on GameType {
|
||||||
String get rusName {
|
String get rusName {
|
||||||
switch(this) {
|
switch (this) {
|
||||||
case GameType.FMV:
|
case GameType.FMV:
|
||||||
return 'FMV';
|
return 'FMV';
|
||||||
case GameType.Shooter:
|
case GameType.Shooter:
|
||||||
@ -151,4 +198,4 @@ extension GameTypeRus on GameType {
|
|||||||
return 'Хоррор';
|
return 'Хоррор';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user