3 готово

This commit is contained in:
GokaPek 2024-09-24 00:19:30 +04:00
parent ee88c0e202
commit 69ccd3d05b

View File

@ -89,7 +89,7 @@ class _CardData {
_CardData({required this.text, required this.info, required this.urlImage});
}
class _Card extends StatelessWidget {
class _Card extends StatefulWidget {
final String text;
final String info;
final String urlImage;
@ -101,6 +101,13 @@ class _Card extends StatelessWidget {
info: data.info,
urlImage: data.urlImage);
@override
State<_Card> createState() => _CardState();
}
class _CardState extends State<_Card> {
bool isLiked = false;
@override
Widget build(BuildContext context) {
return Card(
@ -110,9 +117,10 @@ class _Card extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.network(
urlImage,
widget.urlImage,
fit: BoxFit.cover,
height: 150.0,
width: double.infinity,
),
Padding(
padding: const EdgeInsets.all(10.0),
@ -120,7 +128,7 @@ class _Card extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
text,
widget.text,
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
@ -128,12 +136,28 @@ class _Card extends StatelessWidget {
),
const SizedBox(height: 5.0),
Text(
info,
widget.info,
style: const TextStyle(
fontSize: 14.0,
color: Colors.grey,
),
),
Positioned(
top: 8.0,
right: 8.0,
child: GestureDetector(
onTap: () {
setState(() {
isLiked = !isLiked;
});
},
child: Icon(
Icons.favorite,
color: isLiked ? Colors.red : Colors.blueGrey,
size: 30.0,
),
),
),
],
),
),
@ -141,5 +165,4 @@ class _Card extends StatelessWidget {
),
);
}
}