lab 7 in process
This commit is contained in:
@@ -10,20 +10,20 @@ class _Card extends StatefulWidget {
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const _Card(
|
||||
this.text, {
|
||||
required this.description,
|
||||
this.imgUrl,
|
||||
this.onLike,
|
||||
this.onTap,
|
||||
});
|
||||
this.text, {
|
||||
required this.description,
|
||||
this.imgUrl,
|
||||
this.onLike,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
factory _Card.fromData(CardData data, {OnLikeCallBack onLike, VoidCallback? onTap}) => _Card(
|
||||
data.text,
|
||||
description: data.description,
|
||||
imgUrl: data.imgUrl,
|
||||
onLike: onLike,
|
||||
onTap: onTap,
|
||||
);
|
||||
data.text,
|
||||
description: data.description,
|
||||
imgUrl: data.imgUrl,
|
||||
onLike: onLike,
|
||||
onTap: onTap,
|
||||
);
|
||||
|
||||
@override
|
||||
State<_Card> createState() => _CardState();
|
||||
@@ -38,81 +38,82 @@ class _CardState extends State<_Card> {
|
||||
onTap: widget.onTap,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
spreadRadius: 1,
|
||||
offset: const Offset(0, 0),
|
||||
blurRadius: 15,
|
||||
)
|
||||
]),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
|
||||
child: Image.network(
|
||||
widget.imgUrl ?? '',
|
||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||
height: 370,
|
||||
alignment: Alignment.topCenter,
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
decoration:
|
||||
BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(20), boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
spreadRadius: 1,
|
||||
offset: const Offset(0, 0),
|
||||
blurRadius: 15,
|
||||
)
|
||||
]),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Stack(children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
|
||||
child: Image.network(
|
||||
widget.imgUrl ?? '',
|
||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||
height: 370,
|
||||
alignment: Alignment.topCenter,
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
),
|
||||
),
|
||||
]),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: const TextStyle(
|
||||
color: Color(0xff4c4c4c),
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom:10),
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: const TextStyle(
|
||||
color: Color(0xff4c4c4c),
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.description,
|
||||
style: const TextStyle(
|
||||
color: Color(0xff9c9c9c),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top:10),
|
||||
child: GestureDetector(
|
||||
onTap:(){
|
||||
setState(() {
|
||||
isLiked = !isLiked;
|
||||
});
|
||||
widget.onLike?.call(widget.text, isLiked);
|
||||
},
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: isLiked
|
||||
? const Icon(Icons.favorite, color: Colors.redAccent,key: ValueKey<int>(0),)
|
||||
: const Icon(Icons.favorite_border, key:ValueKey<int>(1),),
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
Text(
|
||||
widget.description,
|
||||
style: const TextStyle(
|
||||
color: Color(0xff9c9c9c),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isLiked = !isLiked;
|
||||
});
|
||||
widget.onLike?.call(widget.text, isLiked);
|
||||
},
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: isLiked
|
||||
? const Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.redAccent,
|
||||
key: ValueKey<int>(0),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.favorite_border,
|
||||
key: ValueKey<int>(1),
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user