Убрал неиспользуемую функцию

This commit is contained in:
Никита Потапов 2024-11-26 16:45:23 +04:00
parent f4573584d0
commit 27dbca35f6

View File

@ -8,7 +8,6 @@ typedef OnLikeCallback = void Function(String title, bool isLiked)?;
const double NORMAL_ICON_SCALE = 2.0;
const double SCALED_ICON_SCALE = 2.5;
class CardPost extends StatefulWidget {
final String description;
final String? imageUrl;
@ -21,10 +20,10 @@ class CardPost extends StatefulWidget {
const CardPost(this.name, this.description, this.imageUrl, this.isLiked,
this.onLike, this.onTap);
factory CardPost.fromData(CardPostData data, {OnLikeCallback onLike,
VoidCallback? onTap}) =>
CardPost(data.name, data.description, data.imageUrl, data.isLiked,
onLike, onTap);
factory CardPost.fromData(CardPostData data,
{OnLikeCallback onLike, VoidCallback? onTap}) =>
CardPost(data.name, data.description, data.imageUrl, data.isLiked, onLike,
onTap);
@override
State<CardPost> createState() => _CardPostState();
@ -35,20 +34,6 @@ class _CardPostState extends State<CardPost> {
double iconScale = NORMAL_ICON_SCALE;
void _onLikeTap() {
setState(() {
isLiked = !isLiked;
iconScale = SCALED_ICON_SCALE; // Increase scale temporarily
});
// Reset the scale back to normal after 250 milliseconds
Timer(const Duration(milliseconds: 110), () {
setState(() {
iconScale = NORMAL_ICON_SCALE;
});
});
}
@override
Widget build(BuildContext context) {
return GestureDetector(
@ -123,8 +108,7 @@ class _CardPostState extends State<CardPost> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () =>
{
onTap: () => {
setState(() {
isLiked = !isLiked;
iconScale = SCALED_ICON_SCALE;
@ -137,30 +121,25 @@ class _CardPostState extends State<CardPost> {
widget.onLike?.call(widget.name, isLiked);
})
},
child: AnimatedScale(scale: iconScale,
child: AnimatedScale(
scale: iconScale,
duration: const Duration(milliseconds: 250),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
child: isLiked
? const Icon(
Icons.favorite, color: Colors.red,
key: ValueKey(
1),)
: const Icon(
Icons.favorite_border, color: Colors.black,
key: ValueKey(1)
)
)
),
Icons.favorite,
color: Colors.red,
key: ValueKey(1),
)
: const Icon(Icons.favorite_border,
color: Colors.black, key: ValueKey(1)))),
),
],
),
)
],
),
)
);
));
}
}