This commit is contained in:
efrilm 2025-10-23 20:11:16 +07:00
parent 290360674f
commit e585cf4292
4 changed files with 40 additions and 26 deletions

View File

@ -128,7 +128,7 @@ class CategoryLocalDatasource {
whereArgs.add('%$search%'); whereArgs.add('%$search%');
} }
query += ' ORDER BY name ASC'; // query += ' ORDER BY name ASC';
if (limit > 0) { if (limit > 0) {
query += ' LIMIT ?'; query += ' LIMIT ?';

View File

@ -47,7 +47,7 @@ class CategoryLoaderBloc
final result = await _categoryRepository.getCategories( final result = await _categoryRepository.getCategories(
page: 1, page: 1,
limit: 10, limit: 50,
isActive: event.isActive, isActive: event.isActive,
search: event.search, search: event.search,
forceRemote: event.forceRemote, forceRemote: event.forceRemote,
@ -59,11 +59,13 @@ class CategoryLoaderBloc
emit(CategoryLoaderState.error(failure)); emit(CategoryLoaderState.error(failure));
}, },
(response) async { (response) async {
final categories = response.data.categories; final categories = [
categories.insert(0, CategoryModel.all()); CategoryModel.all(),
...response.data.categories,
];
final totalPages = response.data.totalPages; final totalPages = response.data.totalPages;
final hasReachedMax = categories.length < 10 || 1 >= totalPages; final hasReachedMax = categories.length < 50 || 1 >= totalPages;
log('✅ Categories loaded: ${categories.length}, hasReachedMax: $hasReachedMax'); log('✅ Categories loaded: ${categories.length}, hasReachedMax: $hasReachedMax');

View File

@ -54,7 +54,19 @@ class ProductCard extends StatelessWidget {
children: [ children: [
ClipRRect( ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8.0)), borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: CachedNetworkImage( child: data.imageUrl == ""
? Container(
width: double.infinity,
height: 120,
decoration: BoxDecoration(
color: AppColors.disabled.withOpacity(0.4),
),
child: const Icon(
Icons.image,
color: AppColors.grey,
),
)
: CachedNetworkImage(
imageUrl: (data.imageUrl ?? "").contains('http') imageUrl: (data.imageUrl ?? "").contains('http')
? data.imageUrl! ? data.imageUrl!
: '${Variables.baseUrl}/${data.imageUrl}', : '${Variables.baseUrl}/${data.imageUrl}',
@ -68,7 +80,7 @@ class ProductCard extends StatelessWidget {
error, error,
StackTrace.current, StackTrace.current,
reason: reason:
'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}', 'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}, dataUrl: ${data.imageUrl}',
fatal: false, fatal: false,
); );
return Container( return Container(

View File

@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.2+6 version: 1.0.2+7
environment: environment:
sdk: ">=3.2.4 <4.0.0" sdk: ">=3.2.4 <4.0.0"