lab 3 + p.s. устал
This commit is contained in:
parent
5e4d0b72f9
commit
074eba0fe6
106
lib/main.dart
106
lib/main.dart
@ -29,7 +29,17 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: Text(widget.title),
|
||||||
|
),
|
||||||
|
body: const MyWidget(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
final List<FortniteSkin> skins = [
|
final List<FortniteSkin> skins = [
|
||||||
FortniteSkin(
|
FortniteSkin(
|
||||||
imageUrl: 'assets/images/shark.png',
|
imageUrl: 'assets/images/shark.png',
|
||||||
@ -44,46 +54,92 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
rarity: Rarity.legendary,
|
rarity: Rarity.legendary,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
class MyWidget extends StatelessWidget{
|
||||||
|
const MyWidget({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Center(
|
||||||
appBar: AppBar(
|
child: SingleChildScrollView(
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
child: Column(
|
||||||
title: Text(widget.title),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
for (var skin in skins)
|
||||||
|
_Card(
|
||||||
|
name: skin.name,
|
||||||
|
description: skin.description,
|
||||||
|
imageUrl: skin.imageUrl,
|
||||||
),
|
),
|
||||||
body: ListView.builder(
|
],
|
||||||
itemCount: skins.length,
|
),
|
||||||
itemBuilder: (context, index) {
|
),
|
||||||
final skin = skins[index];
|
);
|
||||||
return Padding(
|
}
|
||||||
padding: const EdgeInsets.all(8.0),
|
}
|
||||||
|
|
||||||
|
class _Card extends StatelessWidget {
|
||||||
|
final String name;
|
||||||
|
final String imageUrl;
|
||||||
|
final String description;
|
||||||
|
|
||||||
|
const _Card({
|
||||||
|
required this.name,
|
||||||
|
required this.description,
|
||||||
|
required this.imageUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(16),
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.greenAccent,
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.black,
|
||||||
|
width: 3,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 150,
|
||||||
|
width: 120,
|
||||||
|
child: Image.asset(
|
||||||
|
imageUrl,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder: (_,__,___) => const Placeholder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
|
||||||
skin.imageUrl,
|
|
||||||
height: 150,
|
|
||||||
width: 150,
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
skin.name,
|
name,
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Text(skin.description),
|
Text(
|
||||||
Text('Редкость: ${getRarityString(skin.rarity)}'),
|
description,
|
||||||
const SizedBox(height: 20),
|
style: const TextStyle(fontSize: 15),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FortniteSkin {
|
class FortniteSkin {
|
||||||
final String imageUrl;
|
final String imageUrl;
|
||||||
final String name;
|
final String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user