transfer table

This commit is contained in:
efrilm
2025-10-26 19:36:59 +07:00
parent d5ed3f62ff
commit 5c683eda8d
15 changed files with 736 additions and 54 deletions
@@ -40,7 +40,11 @@ class TableLoaderBloc extends Bloc<TableLoaderEvent, TableLoaderState> {
emit(newState);
}
newState = await _mapFetchedToState(newState, isRefresh: e.isRefresh);
newState = await _mapFetchedToState(
newState,
isRefresh: e.isRefresh,
status: e.status,
);
emit(newState);
},
updatedPostion: (e) async {
@@ -62,6 +66,7 @@ class TableLoaderBloc extends Bloc<TableLoaderEvent, TableLoaderState> {
Future<TableLoaderState> _mapFetchedToState(
TableLoaderState state, {
bool isRefresh = false,
String? status,
}) async {
state = state.copyWith(isFetching: false);
@@ -78,7 +83,10 @@ class TableLoaderBloc extends Bloc<TableLoaderEvent, TableLoaderState> {
);
}
final failureOrTable = await _repository.fetchTables(page: state.page);
final failureOrTable = await _repository.fetchTables(
page: state.page,
status: status,
);
state = failureOrTable.fold(
(f) {
@@ -19,19 +19,19 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$TableLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(bool isRefresh) fetched,
required TResult Function(bool isRefresh, String? status) fetched,
required TResult Function(String id, Offset position) updatedPostion,
required TResult Function(Table? table) setSelectedTable,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(bool isRefresh)? fetched,
TResult? Function(bool isRefresh, String? status)? fetched,
TResult? Function(String id, Offset position)? updatedPostion,
TResult? Function(Table? table)? setSelectedTable,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isRefresh)? fetched,
TResult Function(bool isRefresh, String? status)? fetched,
TResult Function(String id, Offset position)? updatedPostion,
TResult Function(Table? table)? setSelectedTable,
required TResult orElse(),
@@ -86,7 +86,7 @@ abstract class _$$FetchedImplCopyWith<$Res> {
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
@useResult
$Res call({bool isRefresh});
$Res call({bool isRefresh, String? status});
}
/// @nodoc
@@ -102,13 +102,17 @@ class __$$FetchedImplCopyWithImpl<$Res>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? isRefresh = null}) {
$Res call({Object? isRefresh = null, Object? status = freezed}) {
return _then(
_$FetchedImpl(
isRefresh: null == isRefresh
? _value.isRefresh
: isRefresh // ignore: cast_nullable_to_non_nullable
as bool,
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
@@ -117,15 +121,17 @@ class __$$FetchedImplCopyWithImpl<$Res>
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl({this.isRefresh = false});
const _$FetchedImpl({this.isRefresh = false, this.status});
@override
@JsonKey()
final bool isRefresh;
@override
final String? status;
@override
String toString() {
return 'TableLoaderEvent.fetched(isRefresh: $isRefresh)';
return 'TableLoaderEvent.fetched(isRefresh: $isRefresh, status: $status)';
}
@override
@@ -134,11 +140,12 @@ class _$FetchedImpl implements _Fetched {
(other.runtimeType == runtimeType &&
other is _$FetchedImpl &&
(identical(other.isRefresh, isRefresh) ||
other.isRefresh == isRefresh));
other.isRefresh == isRefresh) &&
(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType, isRefresh);
int get hashCode => Object.hash(runtimeType, isRefresh, status);
/// Create a copy of TableLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -151,33 +158,33 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(bool isRefresh) fetched,
required TResult Function(bool isRefresh, String? status) fetched,
required TResult Function(String id, Offset position) updatedPostion,
required TResult Function(Table? table) setSelectedTable,
}) {
return fetched(isRefresh);
return fetched(isRefresh, status);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(bool isRefresh)? fetched,
TResult? Function(bool isRefresh, String? status)? fetched,
TResult? Function(String id, Offset position)? updatedPostion,
TResult? Function(Table? table)? setSelectedTable,
}) {
return fetched?.call(isRefresh);
return fetched?.call(isRefresh, status);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isRefresh)? fetched,
TResult Function(bool isRefresh, String? status)? fetched,
TResult Function(String id, Offset position)? updatedPostion,
TResult Function(Table? table)? setSelectedTable,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(isRefresh);
return fetched(isRefresh, status);
}
return orElse();
}
@@ -218,9 +225,11 @@ class _$FetchedImpl implements _Fetched {
}
abstract class _Fetched implements TableLoaderEvent {
const factory _Fetched({final bool isRefresh}) = _$FetchedImpl;
const factory _Fetched({final bool isRefresh, final String? status}) =
_$FetchedImpl;
bool get isRefresh;
String? get status;
/// Create a copy of TableLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -310,7 +319,7 @@ class _$UpdatedPositionImpl implements _UpdatedPosition {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(bool isRefresh) fetched,
required TResult Function(bool isRefresh, String? status) fetched,
required TResult Function(String id, Offset position) updatedPostion,
required TResult Function(Table? table) setSelectedTable,
}) {
@@ -320,7 +329,7 @@ class _$UpdatedPositionImpl implements _UpdatedPosition {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(bool isRefresh)? fetched,
TResult? Function(bool isRefresh, String? status)? fetched,
TResult? Function(String id, Offset position)? updatedPostion,
TResult? Function(Table? table)? setSelectedTable,
}) {
@@ -330,7 +339,7 @@ class _$UpdatedPositionImpl implements _UpdatedPosition {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isRefresh)? fetched,
TResult Function(bool isRefresh, String? status)? fetched,
TResult Function(String id, Offset position)? updatedPostion,
TResult Function(Table? table)? setSelectedTable,
required TResult orElse(),
@@ -481,7 +490,7 @@ class _$SetSelectedTableImpl implements _SetSelectedTable {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(bool isRefresh) fetched,
required TResult Function(bool isRefresh, String? status) fetched,
required TResult Function(String id, Offset position) updatedPostion,
required TResult Function(Table? table) setSelectedTable,
}) {
@@ -491,7 +500,7 @@ class _$SetSelectedTableImpl implements _SetSelectedTable {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(bool isRefresh)? fetched,
TResult? Function(bool isRefresh, String? status)? fetched,
TResult? Function(String id, Offset position)? updatedPostion,
TResult? Function(Table? table)? setSelectedTable,
}) {
@@ -501,7 +510,7 @@ class _$SetSelectedTableImpl implements _SetSelectedTable {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isRefresh)? fetched,
TResult Function(bool isRefresh, String? status)? fetched,
TResult Function(String id, Offset position)? updatedPostion,
TResult Function(Table? table)? setSelectedTable,
required TResult orElse(),
@@ -2,8 +2,10 @@ part of 'table_loader_bloc.dart';
@freezed
class TableLoaderEvent with _$TableLoaderEvent {
const factory TableLoaderEvent.fetched({@Default(false) bool isRefresh}) =
_Fetched;
const factory TableLoaderEvent.fetched({
@Default(false) bool isRefresh,
String? status,
}) = _Fetched;
const factory TableLoaderEvent.updatedPostion({
required String id,
required Offset position,