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}); _CardData({required this.text, required this.info, required this.urlImage});
} }
class _Card extends StatelessWidget { class _Card extends StatefulWidget {
final String text; final String text;
final String info; final String info;
final String urlImage; final String urlImage;
@ -101,6 +101,13 @@ class _Card extends StatelessWidget {
info: data.info, info: data.info,
urlImage: data.urlImage); urlImage: data.urlImage);
@override
State<_Card> createState() => _CardState();
}
class _CardState extends State<_Card> {
bool isLiked = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
@ -110,9 +117,10 @@ class _Card extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Image.network( Image.network(
urlImage, widget.urlImage,
fit: BoxFit.cover, fit: BoxFit.cover,
height: 150.0, height: 150.0,
width: double.infinity,
), ),
Padding( Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
@ -120,7 +128,7 @@ class _Card extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
text, widget.text,
style: const TextStyle( style: const TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -128,12 +136,28 @@ class _Card extends StatelessWidget {
), ),
const SizedBox(height: 5.0), const SizedBox(height: 5.0),
Text( Text(
info, widget.info,
style: const TextStyle( style: const TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.grey, 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 {
), ),
); );
} }
} }