Compare commits
No commits in common. "fe92082cebf0363984ef122b4c610f63392bec8e" and "8022fa6b322a82e6fc8ba9ef6d6e40c1910e4bcb" have entirely different histories.
fe92082ceb
...
8022fa6b32
@ -2,9 +2,7 @@ import 'dart:developer';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/setting/models/tax_model.dart';
|
|
||||||
import '../../core/constants/variables.dart';
|
import '../../core/constants/variables.dart';
|
||||||
import 'auth_local_datasource.dart';
|
import 'auth_local_datasource.dart';
|
||||||
|
|
||||||
@ -14,7 +12,6 @@ class OutletRemoteDataSource {
|
|||||||
Future<Either<String, OutletResponse>> getOutlets() async {
|
Future<Either<String, OutletResponse>> getOutlets() async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
|
||||||
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
||||||
|
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
@ -31,8 +28,7 @@ class OutletRemoteDataSource {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = OutletResponse.fromMap(response.data);
|
return Right(OutletResponse.fromMap(response.data));
|
||||||
return Right(data);
|
|
||||||
} else {
|
} else {
|
||||||
return const Left('Failed to get outlets');
|
return const Left('Failed to get outlets');
|
||||||
}
|
}
|
||||||
@ -70,15 +66,7 @@ class OutletRemoteDataSource {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = OutletDetailResponse.fromMap(response.data);
|
return Right(OutletDetailResponse.fromMap(response.data));
|
||||||
await SettingsLocalDatasource().saveTax(
|
|
||||||
TaxModel(
|
|
||||||
name: 'PB1',
|
|
||||||
type: TaxType.pajak,
|
|
||||||
value: data.data?.taxRate ?? 0,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return Right(data);
|
|
||||||
} else {
|
} else {
|
||||||
return const Left('Failed to get outlets');
|
return const Left('Failed to get outlets');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ class ProductRemoteDatasource {
|
|||||||
int page = 1,
|
int page = 1,
|
||||||
int limit = Variables.defaultLimit,
|
int limit = Variables.defaultLimit,
|
||||||
String? categoryId,
|
String? categoryId,
|
||||||
String? search,
|
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
@ -32,10 +31,6 @@ class ProductRemoteDatasource {
|
|||||||
queryParameters['category_id'] = categoryId;
|
queryParameters['category_id'] = categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search != null && search.isNotEmpty) {
|
|
||||||
queryParameters['search'] = search;
|
|
||||||
}
|
|
||||||
|
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
url,
|
url,
|
||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
|
|||||||
@ -30,14 +30,9 @@ class CategoryLoaderBloc
|
|||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
emit(_Loaded(categories, null));
|
emit(_Loaded(categories));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
on<_SetCategoryId>((event, emit) async {
|
|
||||||
var currentState = state as _Loaded;
|
|
||||||
|
|
||||||
emit(_Loaded(currentState.categories, event.categoryId));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,38 +19,32 @@ mixin _$CategoryLoaderEvent {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() get,
|
required TResult Function() get,
|
||||||
required TResult Function(String categoryId) setCategoryId,
|
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? get,
|
TResult? Function()? get,
|
||||||
TResult? Function(String categoryId)? setCategoryId,
|
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? get,
|
TResult Function()? get,
|
||||||
TResult Function(String categoryId)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Get value) get,
|
required TResult Function(_Get value) get,
|
||||||
required TResult Function(_SetCategoryId value) setCategoryId,
|
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Get value)? get,
|
TResult? Function(_Get value)? get,
|
||||||
TResult? Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Get value)? get,
|
TResult Function(_Get value)? get,
|
||||||
TResult Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -117,7 +111,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() get,
|
required TResult Function() get,
|
||||||
required TResult Function(String categoryId) setCategoryId,
|
|
||||||
}) {
|
}) {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
@ -126,7 +119,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? get,
|
TResult? Function()? get,
|
||||||
TResult? Function(String categoryId)? setCategoryId,
|
|
||||||
}) {
|
}) {
|
||||||
return get?.call();
|
return get?.call();
|
||||||
}
|
}
|
||||||
@ -135,7 +127,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? get,
|
TResult Function()? get,
|
||||||
TResult Function(String categoryId)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
@ -148,7 +139,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Get value) get,
|
required TResult Function(_Get value) get,
|
||||||
required TResult Function(_SetCategoryId value) setCategoryId,
|
|
||||||
}) {
|
}) {
|
||||||
return get(this);
|
return get(this);
|
||||||
}
|
}
|
||||||
@ -157,7 +147,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Get value)? get,
|
TResult? Function(_Get value)? get,
|
||||||
TResult? Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
}) {
|
}) {
|
||||||
return get?.call(this);
|
return get?.call(this);
|
||||||
}
|
}
|
||||||
@ -166,7 +155,6 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Get value)? get,
|
TResult Function(_Get value)? get,
|
||||||
TResult Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
@ -180,156 +168,13 @@ abstract class _Get implements CategoryLoaderEvent {
|
|||||||
const factory _Get() = _$GetImpl;
|
const factory _Get() = _$GetImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$SetCategoryIdImplCopyWith<$Res> {
|
|
||||||
factory _$$SetCategoryIdImplCopyWith(
|
|
||||||
_$SetCategoryIdImpl value, $Res Function(_$SetCategoryIdImpl) then) =
|
|
||||||
__$$SetCategoryIdImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({String categoryId});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$SetCategoryIdImplCopyWithImpl<$Res>
|
|
||||||
extends _$CategoryLoaderEventCopyWithImpl<$Res, _$SetCategoryIdImpl>
|
|
||||||
implements _$$SetCategoryIdImplCopyWith<$Res> {
|
|
||||||
__$$SetCategoryIdImplCopyWithImpl(
|
|
||||||
_$SetCategoryIdImpl _value, $Res Function(_$SetCategoryIdImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? categoryId = null,
|
|
||||||
}) {
|
|
||||||
return _then(_$SetCategoryIdImpl(
|
|
||||||
null == categoryId
|
|
||||||
? _value.categoryId
|
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$SetCategoryIdImpl implements _SetCategoryId {
|
|
||||||
const _$SetCategoryIdImpl(this.categoryId);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String categoryId;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'CategoryLoaderEvent.setCategoryId(categoryId: $categoryId)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$SetCategoryIdImpl &&
|
|
||||||
(identical(other.categoryId, categoryId) ||
|
|
||||||
other.categoryId == categoryId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, categoryId);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$SetCategoryIdImplCopyWith<_$SetCategoryIdImpl> get copyWith =>
|
|
||||||
__$$SetCategoryIdImplCopyWithImpl<_$SetCategoryIdImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() get,
|
|
||||||
required TResult Function(String categoryId) setCategoryId,
|
|
||||||
}) {
|
|
||||||
return setCategoryId(categoryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? get,
|
|
||||||
TResult? Function(String categoryId)? setCategoryId,
|
|
||||||
}) {
|
|
||||||
return setCategoryId?.call(categoryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? get,
|
|
||||||
TResult Function(String categoryId)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (setCategoryId != null) {
|
|
||||||
return setCategoryId(categoryId);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Get value) get,
|
|
||||||
required TResult Function(_SetCategoryId value) setCategoryId,
|
|
||||||
}) {
|
|
||||||
return setCategoryId(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Get value)? get,
|
|
||||||
TResult? Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
}) {
|
|
||||||
return setCategoryId?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Get value)? get,
|
|
||||||
TResult Function(_SetCategoryId value)? setCategoryId,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (setCategoryId != null) {
|
|
||||||
return setCategoryId(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _SetCategoryId implements CategoryLoaderEvent {
|
|
||||||
const factory _SetCategoryId(final String categoryId) = _$SetCategoryIdImpl;
|
|
||||||
|
|
||||||
String get categoryId;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$SetCategoryIdImplCopyWith<_$SetCategoryIdImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$CategoryLoaderState {
|
mixin _$CategoryLoaderState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(
|
required TResult Function(List<CategoryModel> categories) loaded,
|
||||||
List<CategoryModel> categories, String? categoryId)
|
|
||||||
loaded,
|
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -337,8 +182,7 @@ mixin _$CategoryLoaderState {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
TResult? Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -346,8 +190,7 @@ mixin _$CategoryLoaderState {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
TResult Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
@ -443,9 +286,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(
|
required TResult Function(List<CategoryModel> categories) loaded,
|
||||||
List<CategoryModel> categories, String? categoryId)
|
|
||||||
loaded,
|
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return initial();
|
return initial();
|
||||||
@ -456,8 +297,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
TResult? Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call();
|
return initial?.call();
|
||||||
@ -468,8 +308,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
TResult Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -564,9 +403,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(
|
required TResult Function(List<CategoryModel> categories) loaded,
|
||||||
List<CategoryModel> categories, String? categoryId)
|
|
||||||
loaded,
|
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loading();
|
return loading();
|
||||||
@ -577,8 +414,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
TResult? Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call();
|
return loading?.call();
|
||||||
@ -589,8 +425,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
TResult Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -648,7 +483,7 @@ abstract class _$$LoadedImplCopyWith<$Res> {
|
|||||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||||
__$$LoadedImplCopyWithImpl<$Res>;
|
__$$LoadedImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({List<CategoryModel> categories, String? categoryId});
|
$Res call({List<CategoryModel> categories});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -665,17 +500,12 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categories = null,
|
Object? categories = null,
|
||||||
Object? categoryId = freezed,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadedImpl(
|
return _then(_$LoadedImpl(
|
||||||
null == categories
|
null == categories
|
||||||
? _value._categories
|
? _value._categories
|
||||||
: categories // ignore: cast_nullable_to_non_nullable
|
: categories // ignore: cast_nullable_to_non_nullable
|
||||||
as List<CategoryModel>,
|
as List<CategoryModel>,
|
||||||
freezed == categoryId
|
|
||||||
? _value.categoryId
|
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,7 +513,7 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$LoadedImpl implements _Loaded {
|
class _$LoadedImpl implements _Loaded {
|
||||||
const _$LoadedImpl(final List<CategoryModel> categories, this.categoryId)
|
const _$LoadedImpl(final List<CategoryModel> categories)
|
||||||
: _categories = categories;
|
: _categories = categories;
|
||||||
|
|
||||||
final List<CategoryModel> _categories;
|
final List<CategoryModel> _categories;
|
||||||
@ -694,12 +524,9 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
return EqualUnmodifiableListView(_categories);
|
return EqualUnmodifiableListView(_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
final String? categoryId;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'CategoryLoaderState.loaded(categories: $categories, categoryId: $categoryId)';
|
return 'CategoryLoaderState.loaded(categories: $categories)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -708,14 +535,12 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$LoadedImpl &&
|
other is _$LoadedImpl &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._categories, _categories) &&
|
.equals(other._categories, _categories));
|
||||||
(identical(other.categoryId, categoryId) ||
|
|
||||||
other.categoryId == categoryId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,
|
int get hashCode => Object.hash(
|
||||||
const DeepCollectionEquality().hash(_categories), categoryId);
|
runtimeType, const DeepCollectionEquality().hash(_categories));
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderState
|
/// Create a copy of CategoryLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -730,12 +555,10 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(
|
required TResult Function(List<CategoryModel> categories) loaded,
|
||||||
List<CategoryModel> categories, String? categoryId)
|
|
||||||
loaded,
|
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loaded(categories, categoryId);
|
return loaded(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -743,11 +566,10 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
TResult? Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loaded?.call(categories, categoryId);
|
return loaded?.call(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -755,13 +577,12 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
TResult Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
return loaded(categories, categoryId);
|
return loaded(categories);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -805,12 +626,9 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Loaded implements CategoryLoaderState {
|
abstract class _Loaded implements CategoryLoaderState {
|
||||||
const factory _Loaded(
|
const factory _Loaded(final List<CategoryModel> categories) = _$LoadedImpl;
|
||||||
final List<CategoryModel> categories, final String? categoryId) =
|
|
||||||
_$LoadedImpl;
|
|
||||||
|
|
||||||
List<CategoryModel> get categories;
|
List<CategoryModel> get categories;
|
||||||
String? get categoryId;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderState
|
/// Create a copy of CategoryLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -889,9 +707,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(
|
required TResult Function(List<CategoryModel> categories) loaded,
|
||||||
List<CategoryModel> categories, String? categoryId)
|
|
||||||
loaded,
|
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return error(message);
|
return error(message);
|
||||||
@ -902,8 +718,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
TResult? Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return error?.call(message);
|
return error?.call(message);
|
||||||
@ -914,8 +729,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
TResult Function(List<CategoryModel> categories)? loaded,
|
||||||
loaded,
|
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@ -3,6 +3,4 @@ part of 'category_loader_bloc.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
class CategoryLoaderEvent with _$CategoryLoaderEvent {
|
class CategoryLoaderEvent with _$CategoryLoaderEvent {
|
||||||
const factory CategoryLoaderEvent.get() = _Get;
|
const factory CategoryLoaderEvent.get() = _Get;
|
||||||
const factory CategoryLoaderEvent.setCategoryId(String categoryId) =
|
|
||||||
_SetCategoryId;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ part of 'category_loader_bloc.dart';
|
|||||||
class CategoryLoaderState with _$CategoryLoaderState {
|
class CategoryLoaderState with _$CategoryLoaderState {
|
||||||
const factory CategoryLoaderState.initial() = _Initial;
|
const factory CategoryLoaderState.initial() = _Initial;
|
||||||
const factory CategoryLoaderState.loading() = _Loading;
|
const factory CategoryLoaderState.loading() = _Loading;
|
||||||
const factory CategoryLoaderState.loaded(
|
const factory CategoryLoaderState.loaded(List<CategoryModel> categories) =
|
||||||
List<CategoryModel> categories, String? categoryId) = _Loaded;
|
_Loaded;
|
||||||
const factory CategoryLoaderState.error(String message) = _Error;
|
const factory CategoryLoaderState.error(String message) = _Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,22 +18,22 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$ProductLoaderEvent {
|
mixin _$ProductLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId, String? search) getProduct,
|
required TResult Function(String? categoryId) getProduct,
|
||||||
required TResult Function(String? categoryId, String? search) loadMore,
|
required TResult Function(String? categoryId) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId, String? search)? getProduct,
|
TResult? Function(String? categoryId)? getProduct,
|
||||||
TResult? Function(String? categoryId, String? search)? loadMore,
|
TResult? Function(String? categoryId)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId, String? search)? getProduct,
|
TResult Function(String? categoryId)? getProduct,
|
||||||
TResult Function(String? categoryId, String? search)? loadMore,
|
TResult Function(String? categoryId)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
@ -89,7 +89,7 @@ abstract class _$$GetProductImplCopyWith<$Res> {
|
|||||||
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
|
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
|
||||||
__$$GetProductImplCopyWithImpl<$Res>;
|
__$$GetProductImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String? categoryId, String? search});
|
$Res call({String? categoryId});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -106,17 +106,12 @@ class __$$GetProductImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categoryId = freezed,
|
Object? categoryId = freezed,
|
||||||
Object? search = freezed,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$GetProductImpl(
|
return _then(_$GetProductImpl(
|
||||||
categoryId: freezed == categoryId
|
categoryId: freezed == categoryId
|
||||||
? _value.categoryId
|
? _value.categoryId
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
search: freezed == search
|
|
||||||
? _value.search
|
|
||||||
: search // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,16 +119,14 @@ class __$$GetProductImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$GetProductImpl implements _GetProduct {
|
class _$GetProductImpl implements _GetProduct {
|
||||||
const _$GetProductImpl({this.categoryId, this.search});
|
const _$GetProductImpl({this.categoryId});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String? categoryId;
|
final String? categoryId;
|
||||||
@override
|
|
||||||
final String? search;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId, search: $search)';
|
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -142,12 +135,11 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$GetProductImpl &&
|
other is _$GetProductImpl &&
|
||||||
(identical(other.categoryId, categoryId) ||
|
(identical(other.categoryId, categoryId) ||
|
||||||
other.categoryId == categoryId) &&
|
other.categoryId == categoryId));
|
||||||
(identical(other.search, search) || other.search == search));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, categoryId, search);
|
int get hashCode => Object.hash(runtimeType, categoryId);
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -160,33 +152,33 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId, String? search) getProduct,
|
required TResult Function(String? categoryId) getProduct,
|
||||||
required TResult Function(String? categoryId, String? search) loadMore,
|
required TResult Function(String? categoryId) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return getProduct(categoryId, search);
|
return getProduct(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId, String? search)? getProduct,
|
TResult? Function(String? categoryId)? getProduct,
|
||||||
TResult? Function(String? categoryId, String? search)? loadMore,
|
TResult? Function(String? categoryId)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return getProduct?.call(categoryId, search);
|
return getProduct?.call(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId, String? search)? getProduct,
|
TResult Function(String? categoryId)? getProduct,
|
||||||
TResult Function(String? categoryId, String? search)? loadMore,
|
TResult Function(String? categoryId)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getProduct != null) {
|
if (getProduct != null) {
|
||||||
return getProduct(categoryId, search);
|
return getProduct(categoryId);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -227,11 +219,9 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _GetProduct implements ProductLoaderEvent {
|
abstract class _GetProduct implements ProductLoaderEvent {
|
||||||
const factory _GetProduct({final String? categoryId, final String? search}) =
|
const factory _GetProduct({final String? categoryId}) = _$GetProductImpl;
|
||||||
_$GetProductImpl;
|
|
||||||
|
|
||||||
String? get categoryId;
|
String? get categoryId;
|
||||||
String? get search;
|
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -246,7 +236,7 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
|
|||||||
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
||||||
__$$LoadMoreImplCopyWithImpl<$Res>;
|
__$$LoadMoreImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String? categoryId, String? search});
|
$Res call({String? categoryId});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -263,17 +253,12 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categoryId = freezed,
|
Object? categoryId = freezed,
|
||||||
Object? search = freezed,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadMoreImpl(
|
return _then(_$LoadMoreImpl(
|
||||||
categoryId: freezed == categoryId
|
categoryId: freezed == categoryId
|
||||||
? _value.categoryId
|
? _value.categoryId
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
search: freezed == search
|
|
||||||
? _value.search
|
|
||||||
: search // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String?,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,16 +266,14 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$LoadMoreImpl implements _LoadMore {
|
class _$LoadMoreImpl implements _LoadMore {
|
||||||
const _$LoadMoreImpl({this.categoryId, this.search});
|
const _$LoadMoreImpl({this.categoryId});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String? categoryId;
|
final String? categoryId;
|
||||||
@override
|
|
||||||
final String? search;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId, search: $search)';
|
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -299,12 +282,11 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$LoadMoreImpl &&
|
other is _$LoadMoreImpl &&
|
||||||
(identical(other.categoryId, categoryId) ||
|
(identical(other.categoryId, categoryId) ||
|
||||||
other.categoryId == categoryId) &&
|
other.categoryId == categoryId));
|
||||||
(identical(other.search, search) || other.search == search));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, categoryId, search);
|
int get hashCode => Object.hash(runtimeType, categoryId);
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -317,33 +299,33 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId, String? search) getProduct,
|
required TResult Function(String? categoryId) getProduct,
|
||||||
required TResult Function(String? categoryId, String? search) loadMore,
|
required TResult Function(String? categoryId) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore(categoryId, search);
|
return loadMore(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId, String? search)? getProduct,
|
TResult? Function(String? categoryId)? getProduct,
|
||||||
TResult? Function(String? categoryId, String? search)? loadMore,
|
TResult? Function(String? categoryId)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore?.call(categoryId, search);
|
return loadMore?.call(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId, String? search)? getProduct,
|
TResult Function(String? categoryId)? getProduct,
|
||||||
TResult Function(String? categoryId, String? search)? loadMore,
|
TResult Function(String? categoryId)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loadMore != null) {
|
if (loadMore != null) {
|
||||||
return loadMore(categoryId, search);
|
return loadMore(categoryId);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@ -384,11 +366,9 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadMore implements ProductLoaderEvent {
|
abstract class _LoadMore implements ProductLoaderEvent {
|
||||||
const factory _LoadMore({final String? categoryId, final String? search}) =
|
const factory _LoadMore({final String? categoryId}) = _$LoadMoreImpl;
|
||||||
_$LoadMoreImpl;
|
|
||||||
|
|
||||||
String? get categoryId;
|
String? get categoryId;
|
||||||
String? get search;
|
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -438,8 +418,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId, String? search) getProduct,
|
required TResult Function(String? categoryId) getProduct,
|
||||||
required TResult Function(String? categoryId, String? search) loadMore,
|
required TResult Function(String? categoryId) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return refresh();
|
return refresh();
|
||||||
@ -448,8 +428,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId, String? search)? getProduct,
|
TResult? Function(String? categoryId)? getProduct,
|
||||||
TResult? Function(String? categoryId, String? search)? loadMore,
|
TResult? Function(String? categoryId)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return refresh?.call();
|
return refresh?.call();
|
||||||
@ -458,8 +438,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId, String? search)? getProduct,
|
TResult Function(String? categoryId)? getProduct,
|
||||||
TResult Function(String? categoryId, String? search)? loadMore,
|
TResult Function(String? categoryId)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@ -2,9 +2,8 @@ part of 'product_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ProductLoaderEvent with _$ProductLoaderEvent {
|
class ProductLoaderEvent with _$ProductLoaderEvent {
|
||||||
const factory ProductLoaderEvent.getProduct(
|
const factory ProductLoaderEvent.getProduct({String? categoryId}) =
|
||||||
{String? categoryId, String? search}) = _GetProduct;
|
_GetProduct;
|
||||||
const factory ProductLoaderEvent.loadMore(
|
const factory ProductLoaderEvent.loadMore({String? categoryId}) = _LoadMore;
|
||||||
{String? categoryId, String? search}) = _LoadMore;
|
|
||||||
const factory ProductLoaderEvent.refresh() = _Refresh;
|
const factory ProductLoaderEvent.refresh() = _Refresh;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,8 +103,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _handleScrollNotification(
|
bool _handleScrollNotification(ScrollNotification notification) {
|
||||||
ScrollNotification notification, String? categoryId) {
|
|
||||||
// Check if the ScrollController is attached before accessing position
|
// Check if the ScrollController is attached before accessing position
|
||||||
if (!scrollController.hasClients) {
|
if (!scrollController.hasClients) {
|
||||||
return false;
|
return false;
|
||||||
@ -112,12 +111,9 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
if (notification is ScrollEndNotification &&
|
if (notification is ScrollEndNotification &&
|
||||||
scrollController.position.extentAfter == 0) {
|
scrollController.position.extentAfter == 0) {
|
||||||
context.read<ProductLoaderBloc>().add(
|
context
|
||||||
ProductLoaderEvent.loadMore(
|
.read<ProductLoaderBloc>()
|
||||||
categoryId: categoryId,
|
.add(const ProductLoaderEvent.loadMore());
|
||||||
search: searchQuery,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -151,46 +147,42 @@ class _HomePageState extends State<HomePage> {
|
|||||||
flex: 3,
|
flex: 3,
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: AlignmentDirectional.topStart,
|
alignment: AlignmentDirectional.topStart,
|
||||||
child: BlocBuilder<CategoryLoaderBloc, CategoryLoaderState>(
|
child: Column(
|
||||||
builder: (context, state) {
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
return state.maybeWhen(
|
children: [
|
||||||
orElse: () => Center(
|
HomeTitle(
|
||||||
child: CircularProgressIndicator(),
|
controller: searchController,
|
||||||
),
|
onChanged: (value) {
|
||||||
loaded: (categories, categoryId) => Column(
|
setState(() {
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
searchQuery = value;
|
||||||
children: [
|
});
|
||||||
HomeTitle(
|
},
|
||||||
controller: searchController,
|
),
|
||||||
onChanged: (value) {
|
BlocBuilder<ProductLoaderBloc, ProductLoaderState>(
|
||||||
setState(() {
|
builder: (context, state) {
|
||||||
searchQuery = value;
|
return NotificationListener<ScrollNotification>(
|
||||||
});
|
onNotification: (notification) {
|
||||||
Future.delayed(Duration(milliseconds: 600), () {
|
return state.maybeWhen(
|
||||||
context.read<ProductLoaderBloc>().add(
|
orElse: () => false,
|
||||||
ProductLoaderEvent.getProduct(
|
loaded: (products, hasReachedMax, currentPage,
|
||||||
categoryId: categoryId,
|
isLoadingMore) {
|
||||||
search: value,
|
return _handleScrollNotification(
|
||||||
),
|
notification);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
},
|
},
|
||||||
),
|
child: Expanded(child: BlocBuilder<
|
||||||
BlocBuilder<ProductLoaderBloc, ProductLoaderState>(
|
CategoryLoaderBloc, CategoryLoaderState>(
|
||||||
builder: (context, state) {
|
builder: (contextCategory, stateCateogry) {
|
||||||
return NotificationListener<ScrollNotification>(
|
return stateCateogry.maybeWhen(
|
||||||
onNotification: (notification) {
|
orElse: () => SizedBox.shrink(),
|
||||||
return state.maybeWhen(
|
loading: () {
|
||||||
orElse: () => false,
|
return const Center(
|
||||||
loaded: (products, hasReachedMax,
|
child: CircularProgressIndicator(),
|
||||||
currentPage, isLoadingMore) {
|
|
||||||
return _handleScrollNotification(
|
|
||||||
notification, categoryId);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Expanded(
|
loaded: (categories) {
|
||||||
child: CategoryTabBar(
|
return CategoryTabBar(
|
||||||
categories: categories,
|
categories: categories,
|
||||||
tabViews: categories.map((category) {
|
tabViews: categories.map((category) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
@ -236,15 +228,15 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
)),
|
||||||
],
|
);
|
||||||
),
|
},
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/category_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/category_response_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/category_loader/category_loader_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -37,9 +36,6 @@ class _CategoryTabBarState extends State<CategoryTabBar>
|
|||||||
context.read<ProductLoaderBloc>().add(
|
context.read<ProductLoaderBloc>().add(
|
||||||
ProductLoaderEvent.getProduct(categoryId: selectedCategoryId),
|
ProductLoaderEvent.getProduct(categoryId: selectedCategoryId),
|
||||||
);
|
);
|
||||||
context
|
|
||||||
.read<CategoryLoaderBloc>()
|
|
||||||
.add(CategoryLoaderEvent.setCategoryId(selectedCategoryId ?? ""));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user