diff --git a/lib/presentation/pages/main/pages/setting/sections/printer/setting_printer_kitchen.dart b/lib/presentation/pages/main/pages/setting/sections/printer/setting_printer_kitchen.dart index bcc87b4..12f739d 100644 --- a/lib/presentation/pages/main/pages/setting/sections/printer/setting_printer_kitchen.dart +++ b/lib/presentation/pages/main/pages/setting/sections/printer/setting_printer_kitchen.dart @@ -29,29 +29,47 @@ class _SettingPrinterKitchenState extends State { @override Widget build(BuildContext context) { - return BlocListener( - 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().add( - const PrinterLoaderEvent.getByCode('kitchen'), - ); - } + return MultiBlocListener( + listeners: [ + BlocListener( + 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().add( + const PrinterLoaderEvent.getByCode('kitchen'), + ); + } - AppFlushbar.showSuccess( - context, - 'Printer kitchen berhasil dihapus', - ); - }, - ), - ); - }, + AppFlushbar.showSuccess( + context, + 'Printer kitchen berhasil dihapus', + ); + }, + ), + ); + }, + ), + BlocListener( + 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 { PrinterFormEvent.deleted(state.printer.id), ); }, + onTestPrint: () { + context.read().add( + PrinterFormEvent.printTest( + code: 'kitchen', + macAccdress: state.printer.address, + ), + ); + }, ), (f) => f.maybeMap( orElse: () => ErrorCard(