fix split bill
This commit is contained in:
+9
-3
@@ -5,6 +5,7 @@ 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/error/order_loader_error_state_widget.dart';
|
||||
import '../../../../components/loader/loader_with_text.dart';
|
||||
@@ -16,7 +17,12 @@ import 'widgets/payment_success_split_bill_right_panel.dart';
|
||||
class PaymentSuccessSplitBillPage extends StatelessWidget
|
||||
implements AutoRouteWrapper {
|
||||
final String orderId;
|
||||
const PaymentSuccessSplitBillPage({super.key, required this.orderId});
|
||||
final List<OrderItem> orderItems;
|
||||
const PaymentSuccessSplitBillPage({
|
||||
super.key,
|
||||
required this.orderId,
|
||||
required this.orderItems,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -51,7 +57,7 @@ class PaymentSuccessSplitBillPage extends StatelessWidget
|
||||
Expanded(
|
||||
flex: 35,
|
||||
child: PaymentSuccessSplitBillLeftPanel(
|
||||
order: state.order,
|
||||
order: state.order.copyWith(orderItems: orderItems),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -61,7 +67,7 @@ class PaymentSuccessSplitBillPage extends StatelessWidget
|
||||
Expanded(
|
||||
flex: 65,
|
||||
child: PaymentSuccessSplitBillRightPanel(
|
||||
order: state.order,
|
||||
order: state.order.copyWith(orderItems: orderItems),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
+146
-42
@@ -23,10 +23,10 @@ class PaymentSuccessSplitBillRightPanel extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
itemCount: order.payments.length,
|
||||
itemCount: order.orderItems.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildPaymentCard(index);
|
||||
return _buildProductCard(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -36,6 +36,110 @@ class PaymentSuccessSplitBillRightPanel extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProductCard(int index) {
|
||||
final item = order.orderItems[index];
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
border: Border.all(color: AppColor.border, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Enhanced Product Image
|
||||
Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primaryWithOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.restaurant_rounded,
|
||||
color: AppColor.primary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceWidth(16),
|
||||
|
||||
// Product Details
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName,
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SpaceHeight(6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
item.unitPrice.currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceWidth(16),
|
||||
|
||||
// Quantity and Total
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColor.primary,
|
||||
AppColor.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'${item.quantity}x',
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SpaceHeight(8),
|
||||
Text(
|
||||
item.totalPrice.toString().currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSummaryFooter() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
@@ -212,47 +316,47 @@ class PaymentSuccessSplitBillRightPanel extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Row _buildPaymentCard(int index) {
|
||||
final payment = order.payments[index];
|
||||
// Row _buildPaymentCard(int index) {
|
||||
// final payment = order.payments[index];
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.payments, color: AppColor.primary, size: 16),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
payment.paymentMethodName,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w500),
|
||||
),
|
||||
if ((payment.splitTotal) > 1)
|
||||
Text(
|
||||
'Split ${payment.splitNumber} of ${payment.splitTotal}',
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(payment.amount).currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
// return Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// width: 32,
|
||||
// height: 32,
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.primary.withOpacity(0.1),
|
||||
// borderRadius: BorderRadius.circular(4),
|
||||
// ),
|
||||
// child: const Icon(Icons.payments, color: AppColor.primary, size: 16),
|
||||
// ),
|
||||
// const SizedBox(width: 12),
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// payment.paymentMethodName,
|
||||
// style: AppStyle.md.copyWith(fontWeight: FontWeight.w500),
|
||||
// ),
|
||||
// if ((payment.splitTotal) > 1)
|
||||
// Text(
|
||||
// 'Split ${payment.splitNumber} of ${payment.splitTotal}',
|
||||
// style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// (payment.amount).currencyFormatRpV2,
|
||||
// style: AppStyle.md.copyWith(
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: AppColor.primary,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
Container _header() {
|
||||
return Container(
|
||||
|
||||
@@ -63,7 +63,10 @@ class PaymentPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
(data) {
|
||||
if (context.mounted) {
|
||||
context.router.replace(
|
||||
PaymentSuccessSplitBillRoute(orderId: order.id),
|
||||
PaymentSuccessSplitBillRoute(
|
||||
orderId: order.id,
|
||||
orderItems: order.orderItems,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user