printer delete
This commit is contained in:
parent
4ed7721bbe
commit
896ea6c28c
@ -90,6 +90,20 @@ class PrinterFormBloc extends Bloc<PrinterFormEvent, PrinterFormState> {
|
||||
),
|
||||
);
|
||||
},
|
||||
deleted: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrPrinter;
|
||||
|
||||
emit(state.copyWith(isDeleting: true, failureOrDeleteSuccess: none()));
|
||||
|
||||
failureOrPrinter = await _printerRepository.deletePrinter(e.id);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isDeleting: false,
|
||||
failureOrDeleteSuccess: optionOf(failureOrPrinter),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ mixin _$PrinterFormEvent {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
@ -36,6 +37,7 @@ mixin _$PrinterFormEvent {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
@ -46,6 +48,7 @@ mixin _$PrinterFormEvent {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@ -57,6 +60,7 @@ mixin _$PrinterFormEvent {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
@ -67,6 +71,7 @@ mixin _$PrinterFormEvent {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
@ -77,6 +82,7 @@ mixin _$PrinterFormEvent {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -180,6 +186,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return codeChanged(code);
|
||||
}
|
||||
@ -194,6 +201,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return codeChanged?.call(code);
|
||||
}
|
||||
@ -208,6 +216,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (codeChanged != null) {
|
||||
@ -226,6 +235,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return codeChanged(this);
|
||||
}
|
||||
@ -240,6 +250,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return codeChanged?.call(this);
|
||||
}
|
||||
@ -254,6 +265,7 @@ class _$CodeChangedImpl implements _CodeChanged {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (codeChanged != null) {
|
||||
@ -352,6 +364,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return nameChanged(name);
|
||||
}
|
||||
@ -366,6 +379,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return nameChanged?.call(name);
|
||||
}
|
||||
@ -380,6 +394,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (nameChanged != null) {
|
||||
@ -398,6 +413,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return nameChanged(this);
|
||||
}
|
||||
@ -412,6 +428,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return nameChanged?.call(this);
|
||||
}
|
||||
@ -426,6 +443,7 @@ class _$NameChangedImpl implements _NameChanged {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (nameChanged != null) {
|
||||
@ -527,6 +545,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return addressChanged(address);
|
||||
}
|
||||
@ -541,6 +560,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return addressChanged?.call(address);
|
||||
}
|
||||
@ -555,6 +575,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addressChanged != null) {
|
||||
@ -573,6 +594,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return addressChanged(this);
|
||||
}
|
||||
@ -587,6 +609,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return addressChanged?.call(this);
|
||||
}
|
||||
@ -601,6 +624,7 @@ class _$AddressChangedImpl implements _AddressChanged {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addressChanged != null) {
|
||||
@ -699,6 +723,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return typeChanged(type);
|
||||
}
|
||||
@ -713,6 +738,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return typeChanged?.call(type);
|
||||
}
|
||||
@ -727,6 +753,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (typeChanged != null) {
|
||||
@ -745,6 +772,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return typeChanged(this);
|
||||
}
|
||||
@ -759,6 +787,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return typeChanged?.call(this);
|
||||
}
|
||||
@ -773,6 +802,7 @@ class _$TypeChangedImpl implements _TypeChanged {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (typeChanged != null) {
|
||||
@ -871,6 +901,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return paperChanged(paper);
|
||||
}
|
||||
@ -885,6 +916,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return paperChanged?.call(paper);
|
||||
}
|
||||
@ -899,6 +931,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (paperChanged != null) {
|
||||
@ -917,6 +950,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return paperChanged(this);
|
||||
}
|
||||
@ -931,6 +965,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return paperChanged?.call(this);
|
||||
}
|
||||
@ -945,6 +980,7 @@ class _$PaperChangedImpl implements _PaperChanged {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (paperChanged != null) {
|
||||
@ -1016,6 +1052,7 @@ class _$CreatedImpl implements _Created {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return created();
|
||||
}
|
||||
@ -1030,6 +1067,7 @@ class _$CreatedImpl implements _Created {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return created?.call();
|
||||
}
|
||||
@ -1044,6 +1082,7 @@ class _$CreatedImpl implements _Created {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (created != null) {
|
||||
@ -1062,6 +1101,7 @@ class _$CreatedImpl implements _Created {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return created(this);
|
||||
}
|
||||
@ -1076,6 +1116,7 @@ class _$CreatedImpl implements _Created {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return created?.call(this);
|
||||
}
|
||||
@ -1090,6 +1131,7 @@ class _$CreatedImpl implements _Created {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (created != null) {
|
||||
@ -1180,6 +1222,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return updated(id);
|
||||
}
|
||||
@ -1194,6 +1237,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return updated?.call(id);
|
||||
}
|
||||
@ -1208,6 +1252,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updated != null) {
|
||||
@ -1226,6 +1271,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return updated(this);
|
||||
}
|
||||
@ -1240,6 +1286,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return updated?.call(this);
|
||||
}
|
||||
@ -1254,6 +1301,7 @@ class _$UpdatedImpl implements _Updated {
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updated != null) {
|
||||
@ -1275,6 +1323,184 @@ abstract class _Updated implements PrinterFormEvent {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$DeletedImplCopyWith<$Res> {
|
||||
factory _$$DeletedImplCopyWith(
|
||||
_$DeletedImpl value,
|
||||
$Res Function(_$DeletedImpl) then,
|
||||
) = __$$DeletedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({int id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$DeletedImplCopyWithImpl<$Res>
|
||||
extends _$PrinterFormEventCopyWithImpl<$Res, _$DeletedImpl>
|
||||
implements _$$DeletedImplCopyWith<$Res> {
|
||||
__$$DeletedImplCopyWithImpl(
|
||||
_$DeletedImpl _value,
|
||||
$Res Function(_$DeletedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PrinterFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? id = null}) {
|
||||
return _then(
|
||||
_$DeletedImpl(
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$DeletedImpl implements _Deleted {
|
||||
const _$DeletedImpl(this.id);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterFormEvent.deleted(id: $id)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DeletedImpl &&
|
||||
(identical(other.id, id) || other.id == id));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id);
|
||||
|
||||
/// Create a copy of PrinterFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DeletedImplCopyWith<_$DeletedImpl> get copyWith =>
|
||||
__$$DeletedImplCopyWithImpl<_$DeletedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String code) codeChanged,
|
||||
required TResult Function(String name) nameChanged,
|
||||
required TResult Function(String address) addressChanged,
|
||||
required TResult Function(String type) typeChanged,
|
||||
required TResult Function(String paper) paperChanged,
|
||||
required TResult Function() created,
|
||||
required TResult Function(int id) updated,
|
||||
required TResult Function(int id) deleted,
|
||||
}) {
|
||||
return deleted(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String code)? codeChanged,
|
||||
TResult? Function(String name)? nameChanged,
|
||||
TResult? Function(String address)? addressChanged,
|
||||
TResult? Function(String type)? typeChanged,
|
||||
TResult? Function(String paper)? paperChanged,
|
||||
TResult? Function()? created,
|
||||
TResult? Function(int id)? updated,
|
||||
TResult? Function(int id)? deleted,
|
||||
}) {
|
||||
return deleted?.call(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String code)? codeChanged,
|
||||
TResult Function(String name)? nameChanged,
|
||||
TResult Function(String address)? addressChanged,
|
||||
TResult Function(String type)? typeChanged,
|
||||
TResult Function(String paper)? paperChanged,
|
||||
TResult Function()? created,
|
||||
TResult Function(int id)? updated,
|
||||
TResult Function(int id)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (deleted != null) {
|
||||
return deleted(id);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_CodeChanged value) codeChanged,
|
||||
required TResult Function(_NameChanged value) nameChanged,
|
||||
required TResult Function(_AddressChanged value) addressChanged,
|
||||
required TResult Function(_TypeChanged value) typeChanged,
|
||||
required TResult Function(_PaperChanged value) paperChanged,
|
||||
required TResult Function(_Created value) created,
|
||||
required TResult Function(_Updated value) updated,
|
||||
required TResult Function(_Deleted value) deleted,
|
||||
}) {
|
||||
return deleted(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_CodeChanged value)? codeChanged,
|
||||
TResult? Function(_NameChanged value)? nameChanged,
|
||||
TResult? Function(_AddressChanged value)? addressChanged,
|
||||
TResult? Function(_TypeChanged value)? typeChanged,
|
||||
TResult? Function(_PaperChanged value)? paperChanged,
|
||||
TResult? Function(_Created value)? created,
|
||||
TResult? Function(_Updated value)? updated,
|
||||
TResult? Function(_Deleted value)? deleted,
|
||||
}) {
|
||||
return deleted?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_CodeChanged value)? codeChanged,
|
||||
TResult Function(_NameChanged value)? nameChanged,
|
||||
TResult Function(_AddressChanged value)? addressChanged,
|
||||
TResult Function(_TypeChanged value)? typeChanged,
|
||||
TResult Function(_PaperChanged value)? paperChanged,
|
||||
TResult Function(_Created value)? created,
|
||||
TResult Function(_Updated value)? updated,
|
||||
TResult Function(_Deleted value)? deleted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (deleted != null) {
|
||||
return deleted(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Deleted implements PrinterFormEvent {
|
||||
const factory _Deleted(final int id) = _$DeletedImpl;
|
||||
|
||||
int get id;
|
||||
|
||||
/// Create a copy of PrinterFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DeletedImplCopyWith<_$DeletedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PrinterFormState {
|
||||
String get code => throw _privateConstructorUsedError;
|
||||
@ -1286,8 +1512,11 @@ mixin _$PrinterFormState {
|
||||
throw _privateConstructorUsedError;
|
||||
Option<Either<PrinterFailure, Unit>> get failureOrUpdateSuccess =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<Either<PrinterFailure, Unit>> get failureOrDeleteSuccess =>
|
||||
throw _privateConstructorUsedError;
|
||||
dynamic get isCreating => throw _privateConstructorUsedError;
|
||||
dynamic get isUpdate => throw _privateConstructorUsedError;
|
||||
dynamic get isDeleting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PrinterFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@ -1311,8 +1540,10 @@ abstract class $PrinterFormStateCopyWith<$Res> {
|
||||
String type,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess,
|
||||
dynamic isCreating,
|
||||
dynamic isUpdate,
|
||||
dynamic isDeleting,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1338,8 +1569,10 @@ class _$PrinterFormStateCopyWithImpl<$Res, $Val extends PrinterFormState>
|
||||
Object? type = null,
|
||||
Object? failureOrCreateSuccess = null,
|
||||
Object? failureOrUpdateSuccess = null,
|
||||
Object? failureOrDeleteSuccess = null,
|
||||
Object? isCreating = freezed,
|
||||
Object? isUpdate = freezed,
|
||||
Object? isDeleting = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
@ -1371,6 +1604,10 @@ class _$PrinterFormStateCopyWithImpl<$Res, $Val extends PrinterFormState>
|
||||
? _value.failureOrUpdateSuccess
|
||||
: failureOrUpdateSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, Unit>>,
|
||||
failureOrDeleteSuccess: null == failureOrDeleteSuccess
|
||||
? _value.failureOrDeleteSuccess
|
||||
: failureOrDeleteSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, Unit>>,
|
||||
isCreating: freezed == isCreating
|
||||
? _value.isCreating
|
||||
: isCreating // ignore: cast_nullable_to_non_nullable
|
||||
@ -1379,6 +1616,10 @@ class _$PrinterFormStateCopyWithImpl<$Res, $Val extends PrinterFormState>
|
||||
? _value.isUpdate
|
||||
: isUpdate // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
isDeleting: freezed == isDeleting
|
||||
? _value.isDeleting
|
||||
: isDeleting // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
@ -1402,8 +1643,10 @@ abstract class _$$PrinterFormStateImplCopyWith<$Res>
|
||||
String type,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
|
||||
Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess,
|
||||
dynamic isCreating,
|
||||
dynamic isUpdate,
|
||||
dynamic isDeleting,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1428,8 +1671,10 @@ class __$$PrinterFormStateImplCopyWithImpl<$Res>
|
||||
Object? type = null,
|
||||
Object? failureOrCreateSuccess = null,
|
||||
Object? failureOrUpdateSuccess = null,
|
||||
Object? failureOrDeleteSuccess = null,
|
||||
Object? isCreating = freezed,
|
||||
Object? isUpdate = freezed,
|
||||
Object? isDeleting = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$PrinterFormStateImpl(
|
||||
@ -1461,8 +1706,13 @@ class __$$PrinterFormStateImplCopyWithImpl<$Res>
|
||||
? _value.failureOrUpdateSuccess
|
||||
: failureOrUpdateSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, Unit>>,
|
||||
failureOrDeleteSuccess: null == failureOrDeleteSuccess
|
||||
? _value.failureOrDeleteSuccess
|
||||
: failureOrDeleteSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, Unit>>,
|
||||
isCreating: freezed == isCreating ? _value.isCreating! : isCreating,
|
||||
isUpdate: freezed == isUpdate ? _value.isUpdate! : isUpdate,
|
||||
isDeleting: freezed == isDeleting ? _value.isDeleting! : isDeleting,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -1479,8 +1729,10 @@ class _$PrinterFormStateImpl implements _PrinterFormState {
|
||||
required this.type,
|
||||
required this.failureOrCreateSuccess,
|
||||
required this.failureOrUpdateSuccess,
|
||||
required this.failureOrDeleteSuccess,
|
||||
this.isCreating = false,
|
||||
this.isUpdate = false,
|
||||
this.isDeleting = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -1498,15 +1750,20 @@ class _$PrinterFormStateImpl implements _PrinterFormState {
|
||||
@override
|
||||
final Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess;
|
||||
@override
|
||||
final Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess;
|
||||
@override
|
||||
@JsonKey()
|
||||
final dynamic isCreating;
|
||||
@override
|
||||
@JsonKey()
|
||||
final dynamic isUpdate;
|
||||
@override
|
||||
@JsonKey()
|
||||
final dynamic isDeleting;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterFormState(code: $code, name: $name, address: $address, paper: $paper, type: $type, failureOrCreateSuccess: $failureOrCreateSuccess, failureOrUpdateSuccess: $failureOrUpdateSuccess, isCreating: $isCreating, isUpdate: $isUpdate)';
|
||||
return 'PrinterFormState(code: $code, name: $name, address: $address, paper: $paper, type: $type, failureOrCreateSuccess: $failureOrCreateSuccess, failureOrUpdateSuccess: $failureOrUpdateSuccess, failureOrDeleteSuccess: $failureOrDeleteSuccess, isCreating: $isCreating, isUpdate: $isUpdate, isDeleting: $isDeleting)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1523,11 +1780,17 @@ class _$PrinterFormStateImpl implements _PrinterFormState {
|
||||
other.failureOrCreateSuccess == failureOrCreateSuccess) &&
|
||||
(identical(other.failureOrUpdateSuccess, failureOrUpdateSuccess) ||
|
||||
other.failureOrUpdateSuccess == failureOrUpdateSuccess) &&
|
||||
(identical(other.failureOrDeleteSuccess, failureOrDeleteSuccess) ||
|
||||
other.failureOrDeleteSuccess == failureOrDeleteSuccess) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other.isCreating,
|
||||
isCreating,
|
||||
) &&
|
||||
const DeepCollectionEquality().equals(other.isUpdate, isUpdate));
|
||||
const DeepCollectionEquality().equals(other.isUpdate, isUpdate) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other.isDeleting,
|
||||
isDeleting,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1540,8 +1803,10 @@ class _$PrinterFormStateImpl implements _PrinterFormState {
|
||||
type,
|
||||
failureOrCreateSuccess,
|
||||
failureOrUpdateSuccess,
|
||||
failureOrDeleteSuccess,
|
||||
const DeepCollectionEquality().hash(isCreating),
|
||||
const DeepCollectionEquality().hash(isUpdate),
|
||||
const DeepCollectionEquality().hash(isDeleting),
|
||||
);
|
||||
|
||||
/// Create a copy of PrinterFormState
|
||||
@ -1565,8 +1830,10 @@ abstract class _PrinterFormState implements PrinterFormState {
|
||||
required final String type,
|
||||
required final Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
|
||||
required final Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
|
||||
required final Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess,
|
||||
final dynamic isCreating,
|
||||
final dynamic isUpdate,
|
||||
final dynamic isDeleting,
|
||||
}) = _$PrinterFormStateImpl;
|
||||
|
||||
@override
|
||||
@ -1584,9 +1851,13 @@ abstract class _PrinterFormState implements PrinterFormState {
|
||||
@override
|
||||
Option<Either<PrinterFailure, Unit>> get failureOrUpdateSuccess;
|
||||
@override
|
||||
Option<Either<PrinterFailure, Unit>> get failureOrDeleteSuccess;
|
||||
@override
|
||||
dynamic get isCreating;
|
||||
@override
|
||||
dynamic get isUpdate;
|
||||
@override
|
||||
dynamic get isDeleting;
|
||||
|
||||
/// Create a copy of PrinterFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@ -10,4 +10,5 @@ class PrinterFormEvent with _$PrinterFormEvent {
|
||||
const factory PrinterFormEvent.paperChanged(String paper) = _PaperChanged;
|
||||
const factory PrinterFormEvent.created() = _Created;
|
||||
const factory PrinterFormEvent.updated(int id) = _Updated;
|
||||
const factory PrinterFormEvent.deleted(int id) = _Deleted;
|
||||
}
|
||||
|
||||
@ -10,8 +10,10 @@ class PrinterFormState with _$PrinterFormState {
|
||||
required String type,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess,
|
||||
@Default(false) isCreating,
|
||||
@Default(false) isUpdate,
|
||||
@Default(false) isDeleting,
|
||||
}) = _PrinterFormState;
|
||||
|
||||
factory PrinterFormState.initial() => PrinterFormState(
|
||||
@ -22,5 +24,6 @@ class PrinterFormState with _$PrinterFormState {
|
||||
type: 'Bluetooth',
|
||||
failureOrCreateSuccess: none(),
|
||||
failureOrUpdateSuccess: none(),
|
||||
failureOrDeleteSuccess: none(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../../application/printer/printer_form/printer_form_bloc.dart';
|
||||
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/card/error_card.dart';
|
||||
import '../../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../../components/toast/flushbar.dart';
|
||||
import '../../widgets/printer_card.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
@ -27,75 +29,101 @@ class _SettingPrinterBarState extends State<SettingPrinterBar> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrDeleteSuccess != c.failureOrDeleteSuccess,
|
||||
listener: (context, state) {
|
||||
state.failureOrDeleteSuccess.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(_) {
|
||||
if (context.mounted) {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
const PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
}
|
||||
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'bar',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
AppFlushbar.showSuccess(context, 'Printer bar berhasil dihapus');
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'bar',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'bar',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'bar',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
onDelete: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
code: 'bar',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('bar'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../../application/printer/printer_form/printer_form_bloc.dart';
|
||||
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/card/error_card.dart';
|
||||
import '../../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../../components/toast/flushbar.dart';
|
||||
import '../../widgets/printer_card.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
@ -27,75 +29,104 @@ class _SettingPrinterCheckerState extends State<SettingPrinterChecker> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrDeleteSuccess != c.failureOrDeleteSuccess,
|
||||
listener: (context, state) {
|
||||
state.failureOrDeleteSuccess.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(_) {
|
||||
if (context.mounted) {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
const PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
}
|
||||
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'checker',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer checker berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'checker',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'checker',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'checker',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
onDelete: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
code: 'checker',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('checker'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../../application/printer/printer_form/printer_form_bloc.dart';
|
||||
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/card/error_card.dart';
|
||||
import '../../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../../components/toast/flushbar.dart';
|
||||
import '../../widgets/printer_card.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
@ -27,75 +29,104 @@ class _SettingPrinterKitchenState extends State<SettingPrinterKitchen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrDeleteSuccess != c.failureOrDeleteSuccess,
|
||||
listener: (context, state) {
|
||||
state.failureOrDeleteSuccess.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(_) {
|
||||
if (context.mounted) {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
const PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
}
|
||||
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'kitchen',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer kitchen berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'kitchen',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'kitchen',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'kitchen',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
onDelete: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
code: 'kitchen',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('kitchen'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../../application/printer/printer_form/printer_form_bloc.dart';
|
||||
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/card/error_card.dart';
|
||||
import '../../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../../components/toast/flushbar.dart';
|
||||
import '../../widgets/printer_card.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
@ -27,75 +29,104 @@ class _SettingPrinterReceiptState extends State<SettingPrinterReceipt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrDeleteSuccess != c.failureOrDeleteSuccess,
|
||||
listener: (context, state) {
|
||||
state.failureOrDeleteSuccess.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(_) {
|
||||
if (context.mounted) {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
const PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
}
|
||||
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'receipt',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer receipt berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'receipt',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: "Error",
|
||||
message: "Terjadi kesalahan saat memuat printer",
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'receipt',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'receipt',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
onDelete: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: "Error",
|
||||
message: "Terjadi kesalahan saat memuat printer",
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
code: 'receipt',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('receipt'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../../application/printer/printer_form/printer_form_bloc.dart';
|
||||
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/card/error_card.dart';
|
||||
import '../../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../../components/toast/flushbar.dart';
|
||||
import '../../widgets/printer_card.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
@ -27,75 +29,103 @@ class _SettingPrinterTicketState extends State<SettingPrinterTicket> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrDeleteSuccess != c.failureOrDeleteSuccess,
|
||||
listener: (context, state) {
|
||||
state.failureOrDeleteSuccess.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(_) {
|
||||
if (context.mounted) {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
const PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
}
|
||||
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'ticket',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer ticket berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetching) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'ticket',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
if (state.printer.code == '') {
|
||||
return SettingPrinterForm(
|
||||
code: 'ticket',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return state.failureOption.fold(
|
||||
() => isEdit
|
||||
? SettingPrinterForm(
|
||||
code: 'ticket',
|
||||
printer: state.printer,
|
||||
onCancel: () {
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
setState(() {
|
||||
isEdit = false;
|
||||
});
|
||||
},
|
||||
)
|
||||
: PrinterCard(
|
||||
printer: state.printer,
|
||||
onEdit: () {
|
||||
setState(() {
|
||||
isEdit = true;
|
||||
});
|
||||
},
|
||||
|
||||
onDelete: () => context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
),
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
title: 'Error',
|
||||
message: 'Terjadi Kesalahan',
|
||||
onTap: () {},
|
||||
),
|
||||
empty: (value) => SettingPrinterForm(
|
||||
code: 'ticket',
|
||||
onSuccess: () {
|
||||
context.read<PrinterLoaderBloc>().add(
|
||||
PrinterLoaderEvent.getByCode('ticket'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user