Сданная 3 лабораторная работа #2
169
lib/main.dart
169
lib/main.dart
@ -15,7 +15,7 @@ class MyApp extends StatelessWidget {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
home: const MyHomePage(title: 'Знакомства'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -30,14 +30,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(
|
||||||
@ -45,25 +37,152 @@ 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 MyWidget(),
|
||||||
child: Column(
|
);
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
}
|
||||||
children: <Widget>[
|
}
|
||||||
const Text(
|
|
||||||
'You have pushed the button this many times:',
|
class MyWidget extends StatelessWidget {
|
||||||
),
|
const MyWidget({super.key});
|
||||||
Text(
|
|
||||||
'$_counter',
|
@override
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
Widget build(BuildContext context) {
|
||||||
),
|
final data = [
|
||||||
],
|
const _CardPostData(
|
||||||
|
"Евгения",
|
||||||
|
"Люблю программирование и кататься на скейте",
|
||||||
|
"https://avatar.iran.liara.run/public/girl",
|
||||||
|
true),
|
||||||
|
const _CardPostData("Алекс", "Junior Flutter Engineer",
|
||||||
|
"https://avatar.iran.liara.run/public/36", false),
|
||||||
|
const _CardPostData(
|
||||||
|
"Станислав",
|
||||||
|
"Нет ничего приятнее прогулки на природе!",
|
||||||
|
"https://avatar.iran.liara.run/public/boy",
|
||||||
|
true),
|
||||||
|
const _CardPostData("Вероника", "В свободное время хожу на уроки вокала",
|
||||||
|
"https://avatar.iran.liara.run/public/93", false),
|
||||||
|
];
|
||||||
|
return Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: data.map((e) => _CardPost.fromData(e)).toList(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CardPost extends StatelessWidget {
|
||||||
|
final String description;
|
||||||
|
final String? imageUrl;
|
||||||
|
final bool isLiked;
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
const _CardPost(this.name, this.description, this.imageUrl, this.isLiked);
|
||||||
|
|
||||||
|
factory _CardPost.fromData(_CardPostData data) =>
|
||||||
|
_CardPost(data.name, data.description, data.imageUrl, data.isLiked);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(10),
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
color: Colors.blue,
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.blue,
|
||||||
|
width: 0.5,
|
||||||
),
|
),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black12,
|
||||||
|
offset: Offset(
|
||||||
|
0.0,
|
||||||
|
5.0,
|
||||||
|
),
|
||||||
|
blurRadius: 4.0,
|
||||||
|
spreadRadius: 1.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
child: Column(
|
||||||
onPressed: _incrementCounter,
|
children: [
|
||||||
tooltip: 'Increment',
|
Row(
|
||||||
child: const Icon(Icons.add),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 6.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
description,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (imageUrl != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Image.network(imageUrl!,
|
||||||
|
height: 500, width: double.infinity, fit: BoxFit.fitWidth),
|
||||||
|
),
|
||||||
|
if (isLiked)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(4.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.favorite, color: Colors.red, size: 80),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(4.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.favorite_border, color: Colors.red, size: 80),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _CardPostData extends StatelessWidget {
|
||||||
|
final String name;
|
||||||
|
final String description;
|
||||||
|
final String? imageUrl;
|
||||||
|
final bool isLiked;
|
||||||
|
|
||||||
|
const _CardPostData(this.name, this.description, this.imageUrl, this.isLiked);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Placeholder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user