fix
This commit is contained in:
@@ -10,7 +10,6 @@ import 'package:intl/intl.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:worker/core/constants/ui_constants.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
import 'package:worker/features/favorites/presentation/providers/favorites_provider.dart';
|
||||
import 'package:worker/features/products/domain/entities/product.dart';
|
||||
import 'package:worker/generated/l10n/app_localizations.dart';
|
||||
|
||||
@@ -38,7 +37,7 @@ class ProductCard extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final isFavorited = ref.watch(isFavoriteProvider(product.productId));
|
||||
// final isFavorited = ref.watch(isFavoriteProvider(product.productId));
|
||||
|
||||
return Card(
|
||||
elevation: ProductCardSpecs.elevation,
|
||||
@@ -135,64 +134,64 @@ class ProductCard extends ConsumerWidget {
|
||||
),
|
||||
|
||||
// Favorite Button (bottom-left corner)
|
||||
Positioned(
|
||||
bottom: AppSpacing.sm,
|
||||
left: AppSpacing.sm,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
// Capture current state before toggle
|
||||
final wasfavorited = isFavorited;
|
||||
|
||||
// Toggle favorite
|
||||
await ref
|
||||
.read(favoritesProvider.notifier)
|
||||
.toggleFavorite(product.productId);
|
||||
|
||||
// Show feedback with correct message
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
wasfavorited
|
||||
? 'Đã xóa khỏi yêu thích'
|
||||
: 'Đã thêm vào yêu thích',
|
||||
),
|
||||
duration: const Duration(seconds: 1),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.15),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
isFavorited
|
||||
? Icons.favorite
|
||||
: Icons.favorite_border,
|
||||
color: isFavorited
|
||||
? AppColors.danger
|
||||
: AppColors.grey500,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Positioned(
|
||||
// bottom: AppSpacing.sm,
|
||||
// left: AppSpacing.sm,
|
||||
// child: Material(
|
||||
// color: Colors.transparent,
|
||||
// child: InkWell(
|
||||
// onTap: () async {
|
||||
// // Capture current state before toggle
|
||||
// final wasfavorited = isFavorited;
|
||||
//
|
||||
// // Toggle favorite
|
||||
// await ref
|
||||
// .read(favoritesProvider.notifier)
|
||||
// .toggleFavorite(product.productId);
|
||||
//
|
||||
// // Show feedback with correct message
|
||||
// if (context.mounted) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(
|
||||
// wasfavorited
|
||||
// ? 'Đã xóa khỏi yêu thích'
|
||||
// : 'Đã thêm vào yêu thích',
|
||||
// ),
|
||||
// duration: const Duration(seconds: 1),
|
||||
// behavior: SnackBarBehavior.floating,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// borderRadius: BorderRadius.circular(20),
|
||||
// child: Container(
|
||||
// width: 36,
|
||||
// height: 36,
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColors.white,
|
||||
// shape: BoxShape.circle,
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withValues(alpha: 0.15),
|
||||
// blurRadius: 6,
|
||||
// offset: const Offset(0, 2),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: Icon(
|
||||
// isFavorited
|
||||
// ? Icons.favorite
|
||||
// : Icons.favorite_border,
|
||||
// color: isFavorited
|
||||
// ? AppColors.danger
|
||||
// : AppColors.grey500,
|
||||
// size: 20,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user