feat: update split bill
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:enaklo_pos/core/components/flushbar.dart';
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/data/models/response/customer_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
@@ -176,6 +177,50 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
],
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total terbayar',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Rp ${_formatCurrency(widget.order.totalPaid ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Sisa Tagihan',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Rp ${_formatCurrency(widget.order.remainingAmount ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -313,48 +358,103 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
Widget _buildOrderItem(OrderItem item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.productVariantName != null &&
|
||||
item.productVariantName!.isNotEmpty)
|
||||
Text(
|
||||
item.productVariantName!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textSecondary,
|
||||
fontStyle: FontStyle.italic,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Qty: ${item.quantity} x Rp ${_formatCurrency(item.unitPrice ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textSecondary,
|
||||
if (item.productVariantName != null &&
|
||||
item.productVariantName!.isNotEmpty)
|
||||
Text(
|
||||
item.productVariantName!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textSecondary,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Qty: ${item.quantity} x Rp ${_formatCurrency(item.unitPrice ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Rp ${_formatCurrency(item.totalPrice ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if ((item.paidQuantity ?? 0) > 1) ...[
|
||||
SpaceHeight(6),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColorSplitBill.primary.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColorSplitBill.primary),
|
||||
),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${item.paidQuantity} ',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'dari ',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColorSplitBill.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${item.quantity} ',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'kuantiti telah dibayar.',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColorSplitBill.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Rp ${_formatCurrency(item.totalPrice ?? 0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColorSplitBill.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -468,7 +568,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
|
||||
Widget _buildProductSplitItem(OrderItem item) {
|
||||
int selectedQty = selectedProducts[item.id] ?? 0;
|
||||
int maxQty = item.quantity ?? 0;
|
||||
int maxQty = (item.quantity ?? 0) - (item.paidQuantity ?? 0);
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 12),
|
||||
|
||||
Reference in New Issue
Block a user