split struct
This commit is contained in:
+55
-38
@@ -3,10 +3,12 @@ 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 '../../../../../injection.dart';
|
||||
import '../../../../components/error/order_loader_error_state_widget.dart';
|
||||
import '../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../components/toast/flushbar.dart';
|
||||
import 'widgets/payment_success_split_bill_left_panel.dart';
|
||||
import 'widgets/payment_success_split_bill_right_panel.dart';
|
||||
|
||||
@@ -18,49 +20,64 @@ class PaymentSuccessSplitBillPage extends StatelessWidget
|
||||
|
||||
@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 state.failureOptionGetById.fold(
|
||||
() => Container(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Left Panel - Success Message & Order Info
|
||||
Expanded(
|
||||
flex: 35,
|
||||
child: PaymentSuccessSplitBillLeftPanel(
|
||||
order: state.order,
|
||||
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 state.failureOptionGetById.fold(
|
||||
() => Container(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Left Panel - Success Message & Order Info
|
||||
Expanded(
|
||||
flex: 35,
|
||||
child: PaymentSuccessSplitBillLeftPanel(
|
||||
order: state.order,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Right Panel - Order Details
|
||||
Expanded(
|
||||
flex: 65,
|
||||
child: PaymentSuccessSplitBillRightPanel(
|
||||
order: state.order,
|
||||
// Right Panel - Order Details
|
||||
Expanded(
|
||||
flex: 65,
|
||||
child: PaymentSuccessSplitBillRightPanel(
|
||||
order: state.order,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
(f) => OrderLoaderErrorStateWidget(
|
||||
failure: f,
|
||||
onRefresh: () {
|
||||
context.read<OrderLoaderBloc>().add(
|
||||
OrderLoaderEvent.getById(orderId),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
(f) => OrderLoaderErrorStateWidget(
|
||||
failure: f,
|
||||
onRefresh: () {
|
||||
context.read<OrderLoaderBloc>().add(
|
||||
OrderLoaderEvent.getById(orderId),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
+5
-16
@@ -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';
|
||||
@@ -166,22 +168,9 @@ class PaymentSuccessSplitBillLeftPanel 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.splitBill(order),
|
||||
);
|
||||
},
|
||||
label: 'Cetak Struk',
|
||||
icon: Icon(Icons.print_rounded, color: AppColor.white),
|
||||
|
||||
+5
-1
@@ -193,7 +193,11 @@ class PaymentSuccessSplitBillRightPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
(order.payments.last.amount).toString().currencyFormatRpV2,
|
||||
order.payments.isNotEmpty
|
||||
? (order.payments.last.amount)
|
||||
.toString()
|
||||
.currencyFormatRpV2
|
||||
: 0.currencyFormatRpV2,
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
|
||||
Reference in New Issue
Block a user