feat: update position table
This commit is contained in:
parent
6afd62b617
commit
6302ea0282
@ -1,4 +1,5 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'dart:ui';
|
||||||
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';
|
||||||
@ -88,4 +89,40 @@ class TableRemoteDataSource {
|
|||||||
return const Left('Unexpected error occurred');
|
return const Left('Unexpected error occurred');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Either<String, bool>> updatePosition({
|
||||||
|
required String tableId,
|
||||||
|
required Offset position,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final url = '${Variables.baseUrl}/api/v1/tables/$tableId';
|
||||||
|
|
||||||
|
final response = await dio.put(
|
||||||
|
url,
|
||||||
|
data: {
|
||||||
|
"position_x": position.dx.round(),
|
||||||
|
"position_y": position.dy.round(),
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
|
return Right(true);
|
||||||
|
} else {
|
||||||
|
return const Left('Failed to create table');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
log("Dio error: ${e.message}");
|
||||||
|
return Left(e.response?.data['message'] ?? 'Gagal membuat table');
|
||||||
|
} catch (e) {
|
||||||
|
log("Unexpected error: $e");
|
||||||
|
return const Left('Unexpected error occurred');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,7 +151,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
create: (context) => CreateTableBloc(TableRemoteDataSource()),
|
create: (context) => CreateTableBloc(TableRemoteDataSource()),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => ChangePositionTableBloc(),
|
create: (context) => ChangePositionTableBloc(TableRemoteDataSource()),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => GetTableBloc(TableRemoteDataSource()),
|
create: (context) => GetTableBloc(TableRemoteDataSource()),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/table_remote_datasource.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
part 'change_position_table_event.dart';
|
part 'change_position_table_event.dart';
|
||||||
@ -10,11 +10,19 @@ part 'change_position_table_bloc.freezed.dart';
|
|||||||
|
|
||||||
class ChangePositionTableBloc
|
class ChangePositionTableBloc
|
||||||
extends Bloc<ChangePositionTableEvent, ChangePositionTableState> {
|
extends Bloc<ChangePositionTableEvent, ChangePositionTableState> {
|
||||||
ChangePositionTableBloc() : super(_Initial()) {
|
final TableRemoteDataSource _tableRemoteDataSource;
|
||||||
|
ChangePositionTableBloc(this._tableRemoteDataSource)
|
||||||
|
: super(ChangePositionTableState.initial()) {
|
||||||
on<_ChangePositionTable>((event, emit) async {
|
on<_ChangePositionTable>((event, emit) async {
|
||||||
emit(_Loading());
|
emit(_Loading());
|
||||||
await ProductLocalDatasource.instance
|
final result = await _tableRemoteDataSource.updatePosition(
|
||||||
.changePositionTable(event.tableId, event.position);
|
tableId: event.tableId,
|
||||||
|
position: event.position,
|
||||||
|
);
|
||||||
|
result.fold(
|
||||||
|
(l) => emit(_Error(l)),
|
||||||
|
(r) => emit(_Success('Generate Success')),
|
||||||
|
);
|
||||||
emit(_Success('Generate Success'));
|
emit(_Success('Generate Success'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,19 +19,20 @@ mixin _$ChangePositionTableEvent {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
required TResult Function(int tableId, Offset position) changePositionTable,
|
required TResult Function(String tableId, Offset position)
|
||||||
|
changePositionTable,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? started,
|
TResult? Function()? started,
|
||||||
TResult? Function(int tableId, Offset position)? changePositionTable,
|
TResult? Function(String tableId, Offset position)? changePositionTable,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? started,
|
TResult Function()? started,
|
||||||
TResult Function(int tableId, Offset position)? changePositionTable,
|
TResult Function(String tableId, Offset position)? changePositionTable,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -120,7 +121,8 @@ class _$StartedImpl implements _Started {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
required TResult Function(int tableId, Offset position) changePositionTable,
|
required TResult Function(String tableId, Offset position)
|
||||||
|
changePositionTable,
|
||||||
}) {
|
}) {
|
||||||
return started();
|
return started();
|
||||||
}
|
}
|
||||||
@ -129,7 +131,7 @@ class _$StartedImpl implements _Started {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? started,
|
TResult? Function()? started,
|
||||||
TResult? Function(int tableId, Offset position)? changePositionTable,
|
TResult? Function(String tableId, Offset position)? changePositionTable,
|
||||||
}) {
|
}) {
|
||||||
return started?.call();
|
return started?.call();
|
||||||
}
|
}
|
||||||
@ -138,7 +140,7 @@ class _$StartedImpl implements _Started {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? started,
|
TResult Function()? started,
|
||||||
TResult Function(int tableId, Offset position)? changePositionTable,
|
TResult Function(String tableId, Offset position)? changePositionTable,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (started != null) {
|
if (started != null) {
|
||||||
@ -189,7 +191,7 @@ abstract class _$$ChangePositionTableImplCopyWith<$Res> {
|
|||||||
$Res Function(_$ChangePositionTableImpl) then) =
|
$Res Function(_$ChangePositionTableImpl) then) =
|
||||||
__$$ChangePositionTableImplCopyWithImpl<$Res>;
|
__$$ChangePositionTableImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({int tableId, Offset position});
|
$Res call({String tableId, Offset position});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -213,7 +215,7 @@ class __$$ChangePositionTableImplCopyWithImpl<$Res>
|
|||||||
tableId: null == tableId
|
tableId: null == tableId
|
||||||
? _value.tableId
|
? _value.tableId
|
||||||
: tableId // ignore: cast_nullable_to_non_nullable
|
: tableId // ignore: cast_nullable_to_non_nullable
|
||||||
as int,
|
as String,
|
||||||
position: null == position
|
position: null == position
|
||||||
? _value.position
|
? _value.position
|
||||||
: position // ignore: cast_nullable_to_non_nullable
|
: position // ignore: cast_nullable_to_non_nullable
|
||||||
@ -229,7 +231,7 @@ class _$ChangePositionTableImpl implements _ChangePositionTable {
|
|||||||
{required this.tableId, required this.position});
|
{required this.tableId, required this.position});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final int tableId;
|
final String tableId;
|
||||||
@override
|
@override
|
||||||
final Offset position;
|
final Offset position;
|
||||||
|
|
||||||
@ -264,7 +266,8 @@ class _$ChangePositionTableImpl implements _ChangePositionTable {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
required TResult Function(int tableId, Offset position) changePositionTable,
|
required TResult Function(String tableId, Offset position)
|
||||||
|
changePositionTable,
|
||||||
}) {
|
}) {
|
||||||
return changePositionTable(tableId, position);
|
return changePositionTable(tableId, position);
|
||||||
}
|
}
|
||||||
@ -273,7 +276,7 @@ class _$ChangePositionTableImpl implements _ChangePositionTable {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? started,
|
TResult? Function()? started,
|
||||||
TResult? Function(int tableId, Offset position)? changePositionTable,
|
TResult? Function(String tableId, Offset position)? changePositionTable,
|
||||||
}) {
|
}) {
|
||||||
return changePositionTable?.call(tableId, position);
|
return changePositionTable?.call(tableId, position);
|
||||||
}
|
}
|
||||||
@ -282,7 +285,7 @@ class _$ChangePositionTableImpl implements _ChangePositionTable {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? started,
|
TResult Function()? started,
|
||||||
TResult Function(int tableId, Offset position)? changePositionTable,
|
TResult Function(String tableId, Offset position)? changePositionTable,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (changePositionTable != null) {
|
if (changePositionTable != null) {
|
||||||
@ -325,10 +328,10 @@ class _$ChangePositionTableImpl implements _ChangePositionTable {
|
|||||||
|
|
||||||
abstract class _ChangePositionTable implements ChangePositionTableEvent {
|
abstract class _ChangePositionTable implements ChangePositionTableEvent {
|
||||||
const factory _ChangePositionTable(
|
const factory _ChangePositionTable(
|
||||||
{required final int tableId,
|
{required final String tableId,
|
||||||
required final Offset position}) = _$ChangePositionTableImpl;
|
required final Offset position}) = _$ChangePositionTableImpl;
|
||||||
|
|
||||||
int get tableId;
|
String get tableId;
|
||||||
Offset get position;
|
Offset get position;
|
||||||
|
|
||||||
/// Create a copy of ChangePositionTableEvent
|
/// Create a copy of ChangePositionTableEvent
|
||||||
@ -345,6 +348,7 @@ mixin _$ChangePositionTableState {
|
|||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(String message) success,
|
required TResult Function(String message) success,
|
||||||
|
required TResult Function(String message) error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -352,6 +356,7 @@ mixin _$ChangePositionTableState {
|
|||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(String message)? success,
|
TResult? Function(String message)? success,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -359,6 +364,7 @@ mixin _$ChangePositionTableState {
|
|||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(String message)? success,
|
TResult Function(String message)? success,
|
||||||
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -367,6 +373,7 @@ mixin _$ChangePositionTableState {
|
|||||||
required TResult Function(_Initial value) initial,
|
required TResult Function(_Initial value) initial,
|
||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Success value) success,
|
required TResult Function(_Success value) success,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -374,6 +381,7 @@ mixin _$ChangePositionTableState {
|
|||||||
TResult? Function(_Initial value)? initial,
|
TResult? Function(_Initial value)? initial,
|
||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Success value)? success,
|
TResult? Function(_Success value)? success,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -381,6 +389,7 @@ mixin _$ChangePositionTableState {
|
|||||||
TResult Function(_Initial value)? initial,
|
TResult Function(_Initial value)? initial,
|
||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Success value)? success,
|
TResult Function(_Success value)? success,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -452,6 +461,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(String message) success,
|
required TResult Function(String message) success,
|
||||||
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return initial();
|
return initial();
|
||||||
}
|
}
|
||||||
@ -462,6 +472,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(String message)? success,
|
TResult? Function(String message)? success,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call();
|
return initial?.call();
|
||||||
}
|
}
|
||||||
@ -472,6 +483,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(String message)? success,
|
TResult Function(String message)? success,
|
||||||
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (initial != null) {
|
if (initial != null) {
|
||||||
@ -486,6 +498,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
required TResult Function(_Initial value) initial,
|
required TResult Function(_Initial value) initial,
|
||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Success value) success,
|
required TResult Function(_Success value) success,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
}) {
|
}) {
|
||||||
return initial(this);
|
return initial(this);
|
||||||
}
|
}
|
||||||
@ -496,6 +509,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? Function(_Initial value)? initial,
|
TResult? Function(_Initial value)? initial,
|
||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Success value)? success,
|
TResult? Function(_Success value)? success,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call(this);
|
return initial?.call(this);
|
||||||
}
|
}
|
||||||
@ -506,6 +520,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult Function(_Initial value)? initial,
|
TResult Function(_Initial value)? initial,
|
||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Success value)? success,
|
TResult Function(_Success value)? success,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (initial != null) {
|
if (initial != null) {
|
||||||
@ -563,6 +578,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(String message) success,
|
required TResult Function(String message) success,
|
||||||
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loading();
|
return loading();
|
||||||
}
|
}
|
||||||
@ -573,6 +589,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(String message)? success,
|
TResult? Function(String message)? success,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call();
|
return loading?.call();
|
||||||
}
|
}
|
||||||
@ -583,6 +600,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(String message)? success,
|
TResult Function(String message)? success,
|
||||||
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loading != null) {
|
if (loading != null) {
|
||||||
@ -597,6 +615,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
required TResult Function(_Initial value) initial,
|
required TResult Function(_Initial value) initial,
|
||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Success value) success,
|
required TResult Function(_Success value) success,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
}) {
|
}) {
|
||||||
return loading(this);
|
return loading(this);
|
||||||
}
|
}
|
||||||
@ -607,6 +626,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? Function(_Initial value)? initial,
|
TResult? Function(_Initial value)? initial,
|
||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Success value)? success,
|
TResult? Function(_Success value)? success,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call(this);
|
return loading?.call(this);
|
||||||
}
|
}
|
||||||
@ -617,6 +637,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult Function(_Initial value)? initial,
|
TResult Function(_Initial value)? initial,
|
||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Success value)? success,
|
TResult Function(_Success value)? success,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loading != null) {
|
if (loading != null) {
|
||||||
@ -701,6 +722,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(String message) success,
|
required TResult Function(String message) success,
|
||||||
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return success(message);
|
return success(message);
|
||||||
}
|
}
|
||||||
@ -711,6 +733,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(String message)? success,
|
TResult? Function(String message)? success,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return success?.call(message);
|
return success?.call(message);
|
||||||
}
|
}
|
||||||
@ -721,6 +744,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(String message)? success,
|
TResult Function(String message)? success,
|
||||||
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (success != null) {
|
if (success != null) {
|
||||||
@ -735,6 +759,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
required TResult Function(_Initial value) initial,
|
required TResult Function(_Initial value) initial,
|
||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Success value) success,
|
required TResult Function(_Success value) success,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
}) {
|
}) {
|
||||||
return success(this);
|
return success(this);
|
||||||
}
|
}
|
||||||
@ -745,6 +770,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult? Function(_Initial value)? initial,
|
TResult? Function(_Initial value)? initial,
|
||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Success value)? success,
|
TResult? Function(_Success value)? success,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
}) {
|
}) {
|
||||||
return success?.call(this);
|
return success?.call(this);
|
||||||
}
|
}
|
||||||
@ -755,6 +781,7 @@ class _$SuccessImpl implements _Success {
|
|||||||
TResult Function(_Initial value)? initial,
|
TResult Function(_Initial value)? initial,
|
||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Success value)? success,
|
TResult Function(_Success value)? success,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (success != null) {
|
if (success != null) {
|
||||||
@ -775,3 +802,155 @@ abstract class _Success implements ChangePositionTableState {
|
|||||||
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$ErrorImplCopyWith<$Res> {
|
||||||
|
factory _$$ErrorImplCopyWith(
|
||||||
|
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
||||||
|
__$$ErrorImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String message});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$ErrorImplCopyWithImpl<$Res>
|
||||||
|
extends _$ChangePositionTableStateCopyWithImpl<$Res, _$ErrorImpl>
|
||||||
|
implements _$$ErrorImplCopyWith<$Res> {
|
||||||
|
__$$ErrorImplCopyWithImpl(
|
||||||
|
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of ChangePositionTableState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? message = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$ErrorImpl(
|
||||||
|
null == message
|
||||||
|
? _value.message
|
||||||
|
: message // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$ErrorImpl implements _Error {
|
||||||
|
const _$ErrorImpl(this.message);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String message;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'ChangePositionTableState.error(message: $message)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$ErrorImpl &&
|
||||||
|
(identical(other.message, message) || other.message == message));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, message);
|
||||||
|
|
||||||
|
/// Create a copy of ChangePositionTableState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||||
|
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() initial,
|
||||||
|
required TResult Function() loading,
|
||||||
|
required TResult Function(String message) success,
|
||||||
|
required TResult Function(String message) error,
|
||||||
|
}) {
|
||||||
|
return error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(String message)? success,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
|
}) {
|
||||||
|
return error?.call(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(String message)? success,
|
||||||
|
TResult Function(String message)? error,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (error != null) {
|
||||||
|
return error(message);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Initial value) initial,
|
||||||
|
required TResult Function(_Loading value) loading,
|
||||||
|
required TResult Function(_Success value) success,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
|
}) {
|
||||||
|
return error(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Success value)? success,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
|
}) {
|
||||||
|
return error?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Success value)? success,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (error != null) {
|
||||||
|
return error(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Error implements ChangePositionTableState {
|
||||||
|
const factory _Error(final String message) = _$ErrorImpl;
|
||||||
|
|
||||||
|
String get message;
|
||||||
|
|
||||||
|
/// Create a copy of ChangePositionTableState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ part of 'change_position_table_bloc.dart';
|
|||||||
class ChangePositionTableEvent with _$ChangePositionTableEvent {
|
class ChangePositionTableEvent with _$ChangePositionTableEvent {
|
||||||
const factory ChangePositionTableEvent.started() = _Started;
|
const factory ChangePositionTableEvent.started() = _Started;
|
||||||
const factory ChangePositionTableEvent.changePositionTable({
|
const factory ChangePositionTableEvent.changePositionTable({
|
||||||
required int tableId,
|
required String tableId,
|
||||||
required Offset position,
|
required Offset position,
|
||||||
}) = _ChangePositionTable;
|
}) = _ChangePositionTable;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,5 @@ class ChangePositionTableState with _$ChangePositionTableState {
|
|||||||
const factory ChangePositionTableState.loading() = _Loading;
|
const factory ChangePositionTableState.loading() = _Loading;
|
||||||
|
|
||||||
const factory ChangePositionTableState.success(String message) = _Success;
|
const factory ChangePositionTableState.success(String message) = _Success;
|
||||||
|
const factory ChangePositionTableState.error(String message) = _Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,12 +110,12 @@ class _TableManagementScreenState extends State<TableManagementScreen> {
|
|||||||
feedback: TableWidget(table: table),
|
feedback: TableWidget(table: table),
|
||||||
childWhenDragging: SizedBox.shrink(),
|
childWhenDragging: SizedBox.shrink(),
|
||||||
onDragEnd: (details) {
|
onDragEnd: (details) {
|
||||||
// context
|
context
|
||||||
// .read<ChangePositionTableBloc>()
|
.read<ChangePositionTableBloc>()
|
||||||
// .add(ChangePositionTableEvent.changePositionTable(
|
.add(ChangePositionTableEvent.changePositionTable(
|
||||||
// tableId: table.id,
|
tableId: table.id ?? "",
|
||||||
// position: details.offset,
|
position: details.offset,
|
||||||
// ));
|
));
|
||||||
},
|
},
|
||||||
child: TableWidget(table: table),
|
child: TableWidget(table: table),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user