feat: update

This commit is contained in:
efrilm
2025-08-08 10:53:46 +07:00
parent e19d788f47
commit 2eceb0bc0c
5 changed files with 87 additions and 32 deletions
@@ -39,6 +39,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
// Per Amount Split Data
TextEditingController amountController = TextEditingController();
int splitAmount = 0;
int remainingAmount = 0;
List<OrderItem> getOrderItemPending() =>
widget.order.orderItems
@@ -46,9 +47,24 @@ class _SplitBillPageState extends State<SplitBillPage> {
.toList() ??
[];
init() {
setState(() {
remainingAmount =
(widget.order.totalAmount ?? 0) - (widget.order.totalPaid ?? 0);
selectedSplitType = widget.order.splitType == 'AMOUNT' ? 1 : 0;
});
}
@override
void initState() {
init();
super.initState();
}
@override
void dispose() {
amountController.dispose();
super.dispose();
}
@@ -210,13 +226,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
SizedBox(height: 24),
// Split Type Selection
Row(
children: [
_buildSplitTypeButton('Per Produk', 0),
SizedBox(width: 16),
_buildSplitTypeButton('Per Jumlah', 1),
],
),
_buildRowButtonSplit(),
SizedBox(height: 32),
@@ -263,6 +273,23 @@ class _SplitBillPageState extends State<SplitBillPage> {
);
}
Widget _buildRowButtonSplit() {
switch (widget.order.splitType) {
case 'AMOUNT':
return _buildSplitTypeButton('Per Jumlah', 1);
case 'ITEM':
return _buildSplitTypeButton('Per Produk', 0);
default:
return Row(
children: [
_buildSplitTypeButton('Per Produk', 0),
SizedBox(width: 16),
_buildSplitTypeButton('Per Jumlah', 1),
],
);
}
}
Widget _buildCustomer(BuildContext context) {
return Container(
padding: EdgeInsets.all(16),
@@ -681,7 +708,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
),
),
Text(
'Rp ${_formatCurrency((widget.order.totalAmount ?? 0) - splitAmount)}',
'Rp ${_formatCurrency((remainingAmount) - splitAmount)}',
style: TextStyle(
fontSize: 14,
color: AppColorSplitBill.textSecondary,
@@ -797,7 +824,8 @@ class _SplitBillPageState extends State<SplitBillPage> {
}
} else {
// Per Amount Split
int totalAmount = widget.order.totalAmount ?? 0;
int totalAmount =
(widget.order.totalAmount ?? 0) - (widget.order.totalPaid ?? 0);
if (splitAmount > 0 && splitAmount <= totalAmount) {
// Create split order object with the specified amount