add auth, format
This commit is contained in:
@@ -27,7 +27,11 @@ class FavoritesPage extends ConsumerWidget {
|
||||
const FavoritesPage({super.key});
|
||||
|
||||
/// Show confirmation dialog before clearing all favorites
|
||||
Future<void> _showClearAllDialog(BuildContext context, WidgetRef ref, int count) async {
|
||||
Future<void> _showClearAllDialog(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
int count,
|
||||
) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -185,10 +189,7 @@ class _EmptyState extends StatelessWidget {
|
||||
// Subtext
|
||||
Text(
|
||||
'Thêm sản phẩm vào danh sách yêu thích để xem lại sau',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: TextStyle(fontSize: 14.0, color: AppColors.grey500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
@@ -213,10 +214,7 @@ class _EmptyState extends StatelessWidget {
|
||||
),
|
||||
child: const Text(
|
||||
'Khám phá sản phẩm',
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -351,10 +349,7 @@ class _ErrorState extends StatelessWidget {
|
||||
final Object error;
|
||||
final VoidCallback onRetry;
|
||||
|
||||
const _ErrorState({
|
||||
required this.error,
|
||||
required this.onRetry,
|
||||
});
|
||||
const _ErrorState({required this.error, required this.onRetry});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -389,10 +384,7 @@ class _ErrorState extends StatelessWidget {
|
||||
// Error message
|
||||
Text(
|
||||
error.toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
style: const TextStyle(fontSize: 14.0, color: AppColors.grey500),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -417,10 +409,7 @@ class _ErrorState extends StatelessWidget {
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text(
|
||||
'Thử lại',
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -440,9 +429,7 @@ class _ErrorState extends StatelessWidget {
|
||||
class _FavoritesGrid extends StatelessWidget {
|
||||
final List<Product> products;
|
||||
|
||||
const _FavoritesGrid({
|
||||
required this.products,
|
||||
});
|
||||
const _FavoritesGrid({required this.products});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -457,9 +444,7 @@ class _FavoritesGrid extends StatelessWidget {
|
||||
itemCount: products.length,
|
||||
itemBuilder: (context, index) {
|
||||
final product = products[index];
|
||||
return RepaintBoundary(
|
||||
child: FavoriteProductCard(product: product),
|
||||
);
|
||||
return RepaintBoundary(child: FavoriteProductCard(product: product));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,9 @@ Future<List<Product>> favoriteProducts(Ref ref) async {
|
||||
final allProducts = await getProductsUseCase();
|
||||
|
||||
// Filter to only include favorited products
|
||||
return allProducts.where((product) => favoriteIds.contains(product.productId)).toList();
|
||||
return allProducts
|
||||
.where((product) => favoriteIds.contains(product.productId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -22,10 +22,7 @@ import 'package:worker/features/products/domain/entities/product.dart';
|
||||
class FavoriteProductCard extends ConsumerWidget {
|
||||
final Product product;
|
||||
|
||||
const FavoriteProductCard({
|
||||
super.key,
|
||||
required this.product,
|
||||
});
|
||||
const FavoriteProductCard({super.key, required this.product});
|
||||
|
||||
String _formatPrice(double price) {
|
||||
final formatter = NumberFormat('#,###', 'vi_VN');
|
||||
@@ -60,7 +57,9 @@ class FavoriteProductCard extends ConsumerWidget {
|
||||
|
||||
if (confirmed == true && context.mounted) {
|
||||
// Remove from favorites
|
||||
await ref.read(favoritesProvider.notifier).removeFavorite(product.productId);
|
||||
await ref
|
||||
.read(favoritesProvider.notifier)
|
||||
.removeFavorite(product.productId);
|
||||
|
||||
// Show snackbar
|
||||
if (context.mounted) {
|
||||
@@ -103,9 +102,7 @@ class FavoriteProductCard extends ConsumerWidget {
|
||||
placeholder: (context, url) => Shimmer.fromColors(
|
||||
baseColor: AppColors.grey100,
|
||||
highlightColor: AppColors.grey50,
|
||||
child: Container(
|
||||
color: AppColors.grey100,
|
||||
),
|
||||
child: Container(color: AppColors.grey100),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
color: AppColors.grey100,
|
||||
|
||||
Reference in New Issue
Block a user