update
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user