update total price
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/button/button.dart';
|
||||
import '../../../../../components/card/order_menu.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
import '../../../../../components/toast/flushbar.dart';
|
||||
import 'home_right_title.dart';
|
||||
|
||||
class HomeRightPanel extends StatelessWidget {
|
||||
@@ -8,12 +17,168 @@ class HomeRightPanel extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
child: Column(children: [HomeRightTitle()]),
|
||||
),
|
||||
return BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
||||
builder: (context, state) {
|
||||
final price = state.items.isEmpty
|
||||
? 0.0
|
||||
: state.items
|
||||
.map(
|
||||
(e) =>
|
||||
(e.product.price + (e.variant?.priceModifier ?? 0)) *
|
||||
e.quantity,
|
||||
)
|
||||
.reduce((value, element) => value + element);
|
||||
log('🛒 Total Price: $price');
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
HomeRightTitle(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(
|
||||
16.0,
|
||||
).copyWith(bottom: 0, top: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Item',
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 130),
|
||||
SizedBox(
|
||||
width: 50.0,
|
||||
child: Text(
|
||||
'Qty',
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
'Price',
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SpaceHeight(8),
|
||||
const Divider(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: state.items.isEmpty
|
||||
? const Center(child: Text('No Items'))
|
||||
: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemBuilder: (context, index) =>
|
||||
OrderMenu(data: state.items[index]),
|
||||
separatorBuilder: (context, index) =>
|
||||
const SpaceHeight(1.0),
|
||||
itemCount: state.items.length,
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0).copyWith(top: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Divider(),
|
||||
const SpaceHeight(16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Pajak',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${state.tax} %',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SpaceHeight(16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Sub total',
|
||||
style: TextStyle(
|
||||
color: AppColor.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
price.currencyFormatRp,
|
||||
style: const TextStyle(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(16.0),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: AppElevatedButton.filled(
|
||||
borderRadius: 12,
|
||||
elevation: 1,
|
||||
disabled: state.items.isEmpty,
|
||||
onPressed: () {
|
||||
if (state.orderType.name == 'dineIn') {
|
||||
AppFlushbar.showError(
|
||||
context,
|
||||
'Mohon pilih meja terlebih dahulu',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (state.orderType.name == 'delivery' &&
|
||||
state.delivery == null) {
|
||||
AppFlushbar.showError(
|
||||
context,
|
||||
'Mohon pilih pengiriman terlebih dahulu',
|
||||
);
|
||||
return;
|
||||
}
|
||||
// context.push(
|
||||
// ConfirmPaymentPage(
|
||||
// isTable: widget.table == null ? false : true,
|
||||
// table: widget.table,
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
label: 'Lanjutkan Pembayaran',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user