feat: delivery type

This commit is contained in:
efrilm
2025-08-06 18:47:20 +07:00
parent a46a2cfa7c
commit 6fdaac2c0f
22 changed files with 1560 additions and 679 deletions
@@ -132,16 +132,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) {
return state.maybeWhen(
orElse: () => const SizedBox(),
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) {
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
@@ -221,16 +224,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
orElse: () => const Center(
child: Text('No Items'),
),
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) {
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
if (products.isEmpty) {
return const Center(
child: Text('No Items'),
@@ -263,6 +269,59 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
),
child: Column(
children: [
BlocBuilder<CheckoutBloc, CheckoutState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const SizedBox.shrink(),
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
if (deliveryType == null) {
return const SizedBox.shrink();
}
return Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'Pengiriman',
style: TextStyle(
color: AppColors.black,
fontWeight: FontWeight.w600,
),
),
Text(
deliveryType.name,
style: TextStyle(
color: AppColors.black,
fontWeight: FontWeight.w600,
),
),
],
),
const SpaceHeight(8.0),
DashedDivider(
color: AppColors.grey,
),
const SpaceHeight(8.0),
],
);
});
},
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -277,16 +336,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) {
final price = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
products.fold(
0,
(previousValue, element) =>
@@ -320,30 +382,36 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) {
final tax = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
tax,
);
final price = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
products.fold(
0,
(previousValue, element) =>
@@ -355,16 +423,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) {
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
if (discountModel == null) {
return 0;
}
@@ -410,16 +481,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) {
final price = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
products.fold(
0,
(previousValue, element) =>
@@ -431,16 +505,19 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) {
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
if (discountModel == null) {
return 0;
}
@@ -451,31 +528,37 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final tax = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
tax,
);
final serviceCharge = state.maybeWhen(
orElse: () => 0,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
serviceCharge,
);
@@ -826,31 +909,37 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) {
final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
orderType,
);
List<ProductQuantity> items = state.maybeWhen(
orElse: () => [],
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
loaded: (
products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) =>
products,
);