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
@@ -128,7 +128,7 @@ class CategoryLocalDatasource {
whereArgs.add('%$search%');
}
query += ' ORDER BY name ASC';
// query += ' ORDER BY name ASC';
if (limit > 0) {
query += ' LIMIT ?';
@@ -47,7 +47,7 @@ class CategoryLoaderBloc
final result = await _categoryRepository.getCategories(
page: 1,
limit: 10,
limit: 50,
isActive: event.isActive,
search: event.search,
forceRemote: event.forceRemote,
@@ -59,11 +59,13 @@ class CategoryLoaderBloc
emit(CategoryLoaderState.error(failure));
},
(response) async {
final categories = response.data.categories;
categories.insert(0, CategoryModel.all());
final categories = [
CategoryModel.all(),
...response.data.categories,
];
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');
+32 -20
View File
@@ -54,24 +54,8 @@ class ProductCard extends StatelessWidget {
children: [
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: CachedNetworkImage(
imageUrl: (data.imageUrl ?? "").contains('http')
? data.imageUrl!
: '${Variables.baseUrl}/${data.imageUrl}',
fit: BoxFit.cover,
width: double.infinity,
height: 120,
memCacheHeight: 120,
memCacheWidth: 120,
errorWidget: (context, url, error) {
FirebaseCrashlytics.instance.recordError(
error,
StackTrace.current,
reason:
'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}',
fatal: false,
);
return Container(
child: data.imageUrl == ""
? Container(
width: double.infinity,
height: 120,
decoration: BoxDecoration(
@@ -81,8 +65,36 @@ class ProductCard extends StatelessWidget {
Icons.image,
color: AppColors.grey,
),
);
}),
)
: CachedNetworkImage(
imageUrl: (data.imageUrl ?? "").contains('http')
? data.imageUrl!
: '${Variables.baseUrl}/${data.imageUrl}',
fit: BoxFit.cover,
width: double.infinity,
height: 120,
memCacheHeight: 120,
memCacheWidth: 120,
errorWidget: (context, url, error) {
FirebaseCrashlytics.instance.recordError(
error,
StackTrace.current,
reason:
'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}, dataUrl: ${data.imageUrl}',
fatal: false,
);
return Container(
width: double.infinity,
height: 120,
decoration: BoxDecoration(
color: AppColors.disabled.withOpacity(0.4),
),
child: const Icon(
Icons.image,
color: AppColors.grey,
),
);
}),
),
const Spacer(),
Text(