print receipt
This commit is contained in:
@@ -101,6 +101,23 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||
);
|
||||
},
|
||||
),
|
||||
BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) => p.failureOrPrintTest != c.failureOrPrintTest,
|
||||
listener: (context, state) {
|
||||
state.failureOrPrintTest.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(either) {
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer ${widget.code.toTitleCase()} test berhasil',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
child: BlocBuilder<PrinterFormBloc, PrinterFormState>(
|
||||
builder: (context, state) {
|
||||
@@ -187,6 +204,20 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||
),
|
||||
SpaceWidth(12),
|
||||
],
|
||||
Expanded(
|
||||
child: AppElevatedButton.outlined(
|
||||
onPressed: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.printTest(
|
||||
code: widget.code,
|
||||
macAccdress: state.address,
|
||||
),
|
||||
);
|
||||
},
|
||||
label: 'Test Print',
|
||||
),
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
onPressed: () {
|
||||
|
||||
+48
-22
@@ -29,29 +29,47 @@ class _SettingPrinterReceiptState extends State<SettingPrinterReceipt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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'),
|
||||
);
|
||||
}
|
||||
return MultiBlocListener(
|
||||
listeners: [
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer receipt berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
AppFlushbar.showSuccess(
|
||||
context,
|
||||
'Printer receipt berhasil dihapus',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
BlocListener<PrinterFormBloc, PrinterFormState>(
|
||||
listenWhen: (p, c) => p.failureOrPrintTest != c.failureOrPrintTest,
|
||||
listener: (context, state) {
|
||||
state.failureOrPrintTest.fold(
|
||||
() => null,
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(either) {
|
||||
AppFlushbar.showSuccess(context, 'Printer test berhasil');
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
child: Material(
|
||||
color: AppColor.background,
|
||||
child: SingleChildScrollView(
|
||||
@@ -106,6 +124,14 @@ class _SettingPrinterReceiptState extends State<SettingPrinterReceipt> {
|
||||
PrinterFormEvent.deleted(state.printer.id),
|
||||
);
|
||||
},
|
||||
onTestPrint: () {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.printTest(
|
||||
code: state.printer.code,
|
||||
macAccdress: state.printer.address,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
(f) => f.maybeMap(
|
||||
orElse: () => ErrorCard(
|
||||
|
||||
Reference in New Issue
Block a user