print kitchen

This commit is contained in:
efrilm 2025-11-06 18:45:14 +07:00
parent 8923ce737d
commit 3e6dce93fb

View File

@ -29,29 +29,47 @@ class _SettingPrinterKitchenState extends State<SettingPrinterKitchen> {
@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('kitchen'),
);
}
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('kitchen'),
);
}
AppFlushbar.showSuccess(
context,
'Printer kitchen berhasil dihapus',
);
},
),
);
},
AppFlushbar.showSuccess(
context,
'Printer kitchen 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 _SettingPrinterKitchenState extends State<SettingPrinterKitchen> {
PrinterFormEvent.deleted(state.printer.id),
);
},
onTestPrint: () {
context.read<PrinterFormBloc>().add(
PrinterFormEvent.printTest(
code: 'kitchen',
macAccdress: state.printer.address,
),
);
},
),
(f) => f.maybeMap(
orElse: () => ErrorCard(