feat: Tab Category Home

This commit is contained in:
efrilm
2025-08-06 17:41:04 +07:00
parent 7ee7db225c
commit 561aec371d
10 changed files with 1138 additions and 224 deletions
@@ -49,6 +49,7 @@ class ProductLoaderBloc extends Bloc<ProductLoaderEvent, ProductLoaderState> {
final result = await _productRemoteDatasource.getProducts(
page: 1,
limit: 10,
categoryId: event.categoryId,
);
await result.fold(
@@ -93,6 +94,7 @@ class ProductLoaderBloc extends Bloc<ProductLoaderEvent, ProductLoaderState> {
final result = await _productRemoteDatasource.getProducts(
page: nextPage,
limit: 10,
categoryId: event.categoryId,
);
await result.fold(
@@ -18,22 +18,22 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$ProductLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() getProduct,
required TResult Function() loadMore,
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function() refresh,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? getProduct,
TResult? Function()? loadMore,
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function()? refresh,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? getProduct,
TResult Function()? loadMore,
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) =>
@@ -88,6 +88,8 @@ abstract class _$$GetProductImplCopyWith<$Res> {
factory _$$GetProductImplCopyWith(
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
__$$GetProductImplCopyWithImpl<$Res>;
@useResult
$Res call({String? categoryId});
}
/// @nodoc
@@ -100,57 +102,83 @@ class __$$GetProductImplCopyWithImpl<$Res>
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryId = freezed,
}) {
return _then(_$GetProductImpl(
categoryId: freezed == categoryId
? _value.categoryId
: categoryId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$GetProductImpl implements _GetProduct {
const _$GetProductImpl();
const _$GetProductImpl({this.categoryId});
@override
final String? categoryId;
@override
String toString() {
return 'ProductLoaderEvent.getProduct()';
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$GetProductImpl);
(other.runtimeType == runtimeType &&
other is _$GetProductImpl &&
(identical(other.categoryId, categoryId) ||
other.categoryId == categoryId));
}
@override
int get hashCode => runtimeType.hashCode;
int get hashCode => Object.hash(runtimeType, categoryId);
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GetProductImplCopyWith<_$GetProductImpl> get copyWith =>
__$$GetProductImplCopyWithImpl<_$GetProductImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() getProduct,
required TResult Function() loadMore,
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function() refresh,
}) {
return getProduct();
return getProduct(categoryId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? getProduct,
TResult? Function()? loadMore,
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function()? refresh,
}) {
return getProduct?.call();
return getProduct?.call(categoryId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? getProduct,
TResult Function()? loadMore,
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
if (getProduct != null) {
return getProduct();
return getProduct(categoryId);
}
return orElse();
}
@@ -191,7 +219,15 @@ class _$GetProductImpl implements _GetProduct {
}
abstract class _GetProduct implements ProductLoaderEvent {
const factory _GetProduct() = _$GetProductImpl;
const factory _GetProduct({final String? categoryId}) = _$GetProductImpl;
String? get categoryId;
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GetProductImplCopyWith<_$GetProductImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
@@ -199,6 +235,8 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
factory _$$LoadMoreImplCopyWith(
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
__$$LoadMoreImplCopyWithImpl<$Res>;
@useResult
$Res call({String? categoryId});
}
/// @nodoc
@@ -211,57 +249,83 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryId = freezed,
}) {
return _then(_$LoadMoreImpl(
categoryId: freezed == categoryId
? _value.categoryId
: categoryId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$LoadMoreImpl implements _LoadMore {
const _$LoadMoreImpl();
const _$LoadMoreImpl({this.categoryId});
@override
final String? categoryId;
@override
String toString() {
return 'ProductLoaderEvent.loadMore()';
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$LoadMoreImpl);
(other.runtimeType == runtimeType &&
other is _$LoadMoreImpl &&
(identical(other.categoryId, categoryId) ||
other.categoryId == categoryId));
}
@override
int get hashCode => runtimeType.hashCode;
int get hashCode => Object.hash(runtimeType, categoryId);
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LoadMoreImplCopyWith<_$LoadMoreImpl> get copyWith =>
__$$LoadMoreImplCopyWithImpl<_$LoadMoreImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() getProduct,
required TResult Function() loadMore,
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function() refresh,
}) {
return loadMore();
return loadMore(categoryId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? getProduct,
TResult? Function()? loadMore,
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function()? refresh,
}) {
return loadMore?.call();
return loadMore?.call(categoryId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? getProduct,
TResult Function()? loadMore,
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
if (loadMore != null) {
return loadMore();
return loadMore(categoryId);
}
return orElse();
}
@@ -302,7 +366,15 @@ class _$LoadMoreImpl implements _LoadMore {
}
abstract class _LoadMore implements ProductLoaderEvent {
const factory _LoadMore() = _$LoadMoreImpl;
const factory _LoadMore({final String? categoryId}) = _$LoadMoreImpl;
String? get categoryId;
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LoadMoreImplCopyWith<_$LoadMoreImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
@@ -346,8 +418,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() getProduct,
required TResult Function() loadMore,
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function() refresh,
}) {
return refresh();
@@ -356,8 +428,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? getProduct,
TResult? Function()? loadMore,
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function()? refresh,
}) {
return refresh?.call();
@@ -366,8 +438,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? getProduct,
TResult Function()? loadMore,
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
@@ -2,7 +2,8 @@ part of 'product_loader_bloc.dart';
@freezed
class ProductLoaderEvent with _$ProductLoaderEvent {
const factory ProductLoaderEvent.getProduct() = _GetProduct;
const factory ProductLoaderEvent.loadMore() = _LoadMore;
const factory ProductLoaderEvent.getProduct({String? categoryId}) =
_GetProduct;
const factory ProductLoaderEvent.loadMore({String? categoryId}) = _LoadMore;
const factory ProductLoaderEvent.refresh() = _Refresh;
}