change package
This commit is contained in:
@@ -57,10 +57,7 @@ class ProductsPage extends ConsumerWidget {
|
||||
backgroundColor: AppColors.danger,
|
||||
textColor: AppColors.white,
|
||||
isLabelVisible: cartItemCount > 0,
|
||||
child: const Icon(
|
||||
Icons.shopping_cart_outlined,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: const Icon(Icons.shopping_cart_outlined, color: Colors.black),
|
||||
),
|
||||
onPressed: () => context.push(RouteNames.cart),
|
||||
),
|
||||
@@ -77,9 +74,7 @@ class ProductsPage extends ConsumerWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
// Search Bar (Expanded)
|
||||
const Expanded(
|
||||
child: ProductSearchBar(),
|
||||
),
|
||||
const Expanded(child: ProductSearchBar()),
|
||||
const SizedBox(width: 8),
|
||||
// Filter Button
|
||||
SizedBox(
|
||||
@@ -90,25 +85,14 @@ class ProductsPage extends ConsumerWidget {
|
||||
Scaffold.of(scaffoldContext).openEndDrawer();
|
||||
},
|
||||
icon: const Icon(Icons.filter_list, size: 20),
|
||||
label: const Text(
|
||||
'Lọc',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
label: const Text('Lọc', style: TextStyle(fontSize: 12)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppColors.grey900,
|
||||
side: const BorderSide(
|
||||
color: AppColors.white,
|
||||
width: 0,
|
||||
),
|
||||
side: const BorderSide(color: AppColors.white, width: 0),
|
||||
backgroundColor: AppColors.white,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
InputFieldSpecs.borderRadius,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(InputFieldSpecs.borderRadius),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -117,15 +101,13 @@ class ProductsPage extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
|
||||
// Category Filter Chips
|
||||
categoriesAsync.when(
|
||||
data: (categories) => CategoryFilterChips(categories: categories),
|
||||
loading: () => const SizedBox(
|
||||
height: 48.0,
|
||||
child: Center(child: CircularProgressIndicator(strokeWidth: 2.0)),
|
||||
),
|
||||
error: (error, stack) => const SizedBox.shrink(),
|
||||
),
|
||||
// Category Filter Chips
|
||||
categoriesAsync.when(
|
||||
data: (categories) => CategoryFilterChips(categories: categories),
|
||||
loading: () =>
|
||||
const SizedBox(height: 48.0, child: Center(child: CircularProgressIndicator(strokeWidth: 2.0))),
|
||||
error: (error, stack) => const SizedBox.shrink(),
|
||||
),
|
||||
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
|
||||
@@ -149,21 +131,16 @@ class ProductsPage extends ConsumerWidget {
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text('${product.name} đã thêm vào giỏ hàng'),
|
||||
content: Text('${product.name} đã thêm vào giỏ hàng'),
|
||||
duration: const Duration(seconds: 2),
|
||||
action: SnackBarAction(
|
||||
label: 'Xem',
|
||||
onPressed: () => context.go(RouteNames.cart),
|
||||
),
|
||||
action: SnackBarAction(label: 'Xem', onPressed: () => context.go(RouteNames.cart)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => _buildLoadingState(),
|
||||
error: (error, stack) =>
|
||||
_buildErrorState(context, l10n, error, ref),
|
||||
error: (error, stack) => _buildErrorState(context, l10n, error, ref),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -179,25 +156,14 @@ class ProductsPage extends ConsumerWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_outlined,
|
||||
size: 80.0,
|
||||
color: AppColors.grey500.withAlpha(128),
|
||||
),
|
||||
Icon(Icons.inventory_2_outlined, size: 80.0, color: AppColors.grey500.withAlpha(128)),
|
||||
const SizedBox(height: AppSpacing.lg),
|
||||
Text(
|
||||
l10n.noProductsFound,
|
||||
style: const TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey900,
|
||||
),
|
||||
style: const TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500, color: AppColors.grey900),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
Text(
|
||||
l10n.noResults,
|
||||
style: const TextStyle(fontSize: 14.0, color: AppColors.grey500),
|
||||
),
|
||||
Text(l10n.noResults, style: const TextStyle(fontSize: 14.0, color: AppColors.grey500)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -205,37 +171,22 @@ class ProductsPage extends ConsumerWidget {
|
||||
|
||||
/// Build loading state
|
||||
Widget _buildLoadingState() {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.primaryBlue),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator(color: AppColors.primaryBlue));
|
||||
}
|
||||
|
||||
/// Build error state
|
||||
Widget _buildErrorState(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
Object error,
|
||||
WidgetRef ref,
|
||||
) {
|
||||
Widget _buildErrorState(BuildContext context, AppLocalizations l10n, Object error, WidgetRef ref) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(AppSpacing.xl),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
size: 80.0,
|
||||
color: AppColors.danger.withAlpha(128),
|
||||
),
|
||||
Icon(Icons.error_outline, size: 80.0, color: AppColors.danger.withAlpha(128)),
|
||||
const SizedBox(height: AppSpacing.lg),
|
||||
Text(
|
||||
l10n.error,
|
||||
style: const TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey900,
|
||||
),
|
||||
style: const TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600, color: AppColors.grey900),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
Text(
|
||||
@@ -253,10 +204,7 @@ class ProductsPage extends ConsumerWidget {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primaryBlue,
|
||||
foregroundColor: AppColors.white,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.lg,
|
||||
vertical: AppSpacing.md,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg, vertical: AppSpacing.md),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -42,6 +42,7 @@ class ProductCard extends ConsumerWidget {
|
||||
|
||||
return Card(
|
||||
elevation: ProductCardSpecs.elevation,
|
||||
margin: const EdgeInsets.all(8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(ProductCardSpecs.borderRadius),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user