Third Laba

This commit is contained in:
Serxiolog 2024-10-02 17:54:28 +04:00
parent 01d2a8701f
commit e802b33fb2

View File

@ -9,12 +9,12 @@ void main() {
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'KozyrevSS'),
@ -25,8 +25,6 @@ class MyApp extends StatelessWidget {
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
@ -34,42 +32,132 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
Color _color = Colors.white;
void _incrementCounter() {
setState(() {
_counter++;
_color = Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
});
@override
Widget build(BuildContext context) {
final data = [
const _CardData(
"First",
description: "SomeText",
),
const _CardData(
"Second",
icon: Icons.gamepad,
description: "ManyText",
imageUrl: "https://i.pinimg.com/originals/21/73/24/217324138d1bbc91663d4943ebe5de60.jpg",
),
const _CardData(
"Third",
icon: Icons.offline_bolt_outlined,
description: "Wow >_<",
),
];
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.purple,
title: Text(widget.title),
),
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: data.map((e) => _Card.fromData(e)).toList(),
),
)));
}
}
class _CardData {
final String text;
final String description;
final IconData icon;
final String imageUrl;
const _CardData(
this.text, {
required this.description,
this.icon = Icons.add_call,
this.imageUrl =
"https://i.pinimg.com/736x/5f/14/b3/5f14b3f14fcd157bc4dffa39085396cc.jpg",
});
}
class _Card extends StatelessWidget {
final String text;
final String description;
final IconData icon;
final String imageUrl;
const _Card(
this.text, {
required this.description,
this.icon = Icons.add_call,
required this.imageUrl,
});
factory _Card.fromData(_CardData data) => _Card(
data.text,
description: data.description,
icon: data.icon,
imageUrl: data.imageUrl,
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: _color,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
return Container(
margin: const EdgeInsets.all(15),
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.green, width: 2),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(.4),
offset: const Offset(0, 5),
blurRadius: 6,
spreadRadius: 3
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
if (_counter > 10)
const Text("Why are you doing this?",)
],
),
]
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), );
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: SizedBox(
height: 140,
width: 100,
child: Image.network(
imageUrl ?? '',
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Placeholder(),
),
),
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
text * 10,
style: Theme.of(context).textTheme.headlineLarge,
),
Text(
description,
style: Theme.of(context).textTheme.bodySmall,
)
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8),
child: Icon(icon),
)
],
),
);
}
}