print order

This commit is contained in:
efrilm
2025-11-07 16:29:26 +07:00
parent 4eece81eb1
commit 93560b85cb
12 changed files with 1154 additions and 49 deletions
@@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../application/order/order_loader/order_loader_bloc.dart';
import '../../../../../application/printer/print_struck/print_struck_bloc.dart';
import '../../../../../common/theme/theme.dart';
import '../../../../../domain/order/order.dart';
import '../../../../../injection.dart';
import '../../../../components/loader/loader_with_text.dart';
import '../../../../components/spaces/space.dart';
import '../../../../components/toast/flushbar.dart';
import 'widgets/success_order_left_panel.dart';
import 'widgets/success_order_right_panel.dart';
@@ -18,32 +20,47 @@ class SuccessOrderPage extends StatelessWidget implements AutoRouteWrapper {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.background,
body: SafeArea(
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
builder: (context, state) {
if (state.isFetchingById) {
return const Center(child: LoaderWithText());
}
return BlocListener<PrintStruckBloc, PrintStruckState>(
listenWhen: (previous, current) =>
previous.failureOrPrintStruck != current.failureOrPrintStruck,
listener: (context, state) {
state.failureOrPrintStruck.fold(
() {},
(either) => either.fold(
(f) => AppFlushbar.showPrinterFailureToast(context, f),
(success) {
AppFlushbar.showSuccess(context, "Struck berhasil dicetak");
},
),
);
},
child: Scaffold(
backgroundColor: AppColor.background,
body: SafeArea(
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
builder: (context, state) {
if (state.isFetchingById) {
return const Center(child: LoaderWithText());
}
return Padding(
padding: const EdgeInsets.all(24.0),
child: Row(
children: [
Expanded(
flex: 35,
child: SuccessOrderLeftPanel(order: state.order),
),
SpaceWidth(16),
Expanded(
flex: 65,
child: SuccessOrderRightPanel(order: state.order),
),
],
),
);
},
return Padding(
padding: const EdgeInsets.all(24.0),
child: Row(
children: [
Expanded(
flex: 35,
child: SuccessOrderLeftPanel(order: state.order),
),
SpaceWidth(16),
Expanded(
flex: 65,
child: SuccessOrderRightPanel(order: state.order),
),
],
),
);
},
),
),
),
);
@@ -1,6 +1,8 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../../application/printer/print_struck/print_struck_bloc.dart';
import '../../../../../../common/extension/extension.dart';
import '../../../../../../common/theme/theme.dart';
import '../../../../../../domain/order/order.dart';
@@ -169,22 +171,9 @@ class SuccessOrderLeftPanel extends StatelessWidget {
Expanded(
child: AppElevatedButton.filled(
onPressed: () {
// onPrintRecipt(
// context,
// order: widget.order,
// paymentMethod: widget.paymentMethod,
// nominalBayar: widget.paymentMethod == "Cash"
// ? widget.nominalBayar
// : widget.order.totalAmount ?? 0,
// kembalian: widget.nominalBayar -
// (widget.order.totalAmount ?? 0),
// productQuantity: widget.productQuantity,
// );
// onPrint(
// context,
// productQuantity: widget.productQuantity,
// order: widget.order,
// );
context.read<PrintStruckBloc>().add(
PrintStruckEvent.order(order),
);
},
label: 'Cetak Struk',
icon: Icon(Icons.print_rounded, color: AppColor.white),