dev #1

Merged
aefril merged 128 commits from dev into main 2025-08-13 17:19:48 +00:00
22 changed files with 1560 additions and 679 deletions
Showing only changes of commit 6fdaac2c0f - Show all commits

BIN
assets/images/gojek.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
assets/images/grab.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

View File

@ -186,6 +186,12 @@ class $AssetsImagesGen {
/// File path: assets/images/drink7.png /// File path: assets/images/drink7.png
AssetGenImage get drink7 => const AssetGenImage('assets/images/drink7.png'); AssetGenImage get drink7 => const AssetGenImage('assets/images/drink7.png');
/// File path: assets/images/gojek.png
AssetGenImage get gojek => const AssetGenImage('assets/images/gojek.png');
/// File path: assets/images/grab.png
AssetGenImage get grab => const AssetGenImage('assets/images/grab.png');
/// File path: assets/images/logo.png /// File path: assets/images/logo.png
AssetGenImage get logo => const AssetGenImage('assets/images/logo.png'); AssetGenImage get logo => const AssetGenImage('assets/images/logo.png');
@ -265,6 +271,8 @@ class $AssetsImagesGen {
drink5, drink5,
drink6, drink6,
drink7, drink7,
gojek,
grab,
logo, logo,
managePrinter, managePrinter,
manageProduct, manageProduct,

View File

@ -0,0 +1,15 @@
import 'package:enaklo_pos/core/assets/assets.gen.dart';
import 'package:enaklo_pos/data/models/response/delivery_response_model.dart';
List<DeliveryModel> deliveries = [
DeliveryModel(
id: 'gojek',
name: 'Gojek',
imageUrl: Assets.images.gojek.path,
),
DeliveryModel(
id: 'grab',
name: 'Grab',
imageUrl: Assets.images.grab.path,
),
];

View File

@ -0,0 +1,11 @@
class DeliveryModel {
String id;
String name;
String imageUrl;
DeliveryModel({
required this.id,
required this.name,
required this.imageUrl,
});
}

View File

@ -2,6 +2,7 @@ import 'dart:developer';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart'; import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
import 'package:enaklo_pos/data/models/response/delivery_response_model.dart';
import 'package:enaklo_pos/data/models/response/discount_response_model.dart'; import 'package:enaklo_pos/data/models/response/discount_response_model.dart';
import 'package:enaklo_pos/presentation/table/models/draft_order_item.dart'; import 'package:enaklo_pos/presentation/table/models/draft_order_item.dart';
import 'package:enaklo_pos/presentation/table/models/draft_order_model.dart'; import 'package:enaklo_pos/presentation/table/models/draft_order_model.dart';
@ -58,7 +59,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_RemoveItem>((event, emit) { on<_RemoveItem>((event, emit) {
@ -91,7 +93,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_DeleteItem>((event, emit) { on<_DeleteItem>((event, emit) {
@ -116,7 +119,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_Started>((event, emit) async { on<_Started>((event, emit) async {
@ -126,12 +130,24 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
final tax = await settingsLocalDatasource.getTax(); final tax = await settingsLocalDatasource.getTax();
final serviceCharge = await settingsLocalDatasource.getServiceCharge(); final serviceCharge = await settingsLocalDatasource.getServiceCharge();
emit(_Loaded([], null, 0, 0, tax.value, serviceCharge, 0, 0, '', emit(_Loaded(
OrderType.dineIn)); [],
null,
0,
0,
tax.value,
serviceCharge,
0,
0,
'',
OrderType.dineIn,
null,
));
} catch (e) { } catch (e) {
// If loading fails, use default values // If loading fails, use default values
log('Failed to load settings: $e'); log('Failed to load settings: $e');
emit(const _Loaded([], null, 0, 0, 10, 5, 0, 0, '', OrderType.dineIn)); emit(const _Loaded(
[], null, 0, 0, 10, 5, 0, 0, '', OrderType.dineIn, null));
} }
}); });
@ -148,7 +164,7 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType, currentState.orderType,
)); currentState.deliveryType));
}); });
on<_RemoveDiscount>((event, emit) { on<_RemoveDiscount>((event, emit) {
@ -163,7 +179,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_AddTax>((event, emit) { on<_AddTax>((event, emit) {
@ -178,7 +195,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_AddServiceCharge>((event, emit) { on<_AddServiceCharge>((event, emit) {
@ -194,6 +212,7 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType, currentState.orderType,
currentState.deliveryType,
)); ));
}); });
@ -209,7 +228,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_RemoveServiceCharge>((event, emit) { on<_RemoveServiceCharge>((event, emit) {
@ -224,7 +244,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_UpdateOrderType>((event, emit) { on<_UpdateOrderType>((event, emit) {
@ -239,7 +260,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
event.orderType)); event.orderType,
currentState.deliveryType));
}); });
on<_UpdateItemNotes>((event, emit) { on<_UpdateItemNotes>((event, emit) {
@ -260,7 +282,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
currentState.totalQuantity, currentState.totalQuantity,
currentState.totalPrice, currentState.totalPrice,
currentState.draftName, currentState.draftName,
currentState.orderType)); currentState.orderType,
currentState.deliveryType));
}); });
on<_SaveDraftOrder>((event, emit) async { on<_SaveDraftOrder>((event, emit) async {
@ -310,7 +333,26 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
draftOrder.totalQuantity, draftOrder.totalQuantity,
draftOrder.totalPrice, draftOrder.totalPrice,
draftOrder.draftName, draftOrder.draftName,
OrderType.dineIn)); OrderType.dineIn,
null,
));
});
on<_UpdateDeliveryType>((event, emit) {
var currentState = state as _Loaded;
emit(_Loaded(
currentState.items,
currentState.discountModel,
currentState.discount,
currentState.discountAmount,
currentState.tax,
currentState.serviceCharge,
currentState.totalQuantity,
currentState.totalPrice,
currentState.draftName,
currentState.orderType,
event.delivery,
));
}); });
} }
} }

View File

@ -42,4 +42,8 @@ class CheckoutEvent with _$CheckoutEvent {
//load draft order //load draft order
const factory CheckoutEvent.loadDraftOrder(DraftOrderModel data) = const factory CheckoutEvent.loadDraftOrder(DraftOrderModel data) =
_LoadDraftOrder; _LoadDraftOrder;
// Update delivery type
const factory CheckoutEvent.updateDeliveryType(DeliveryModel delivery) =
_UpdateDeliveryType;
} }

View File

@ -14,7 +14,9 @@ class CheckoutState with _$CheckoutState {
int totalQuantity, int totalQuantity,
int totalPrice, int totalPrice,
String draftName, String draftName,
OrderType orderType) = _Loaded; OrderType orderType,
DeliveryModel? deliveryType,
) = _Loaded;
const factory CheckoutState.error(String message) = _Error; const factory CheckoutState.error(String message) = _Error;
//save draft order //save draft order

View File

@ -0,0 +1,114 @@
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
import 'package:enaklo_pos/core/components/spaces.dart';
import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/data/datasources/delivery_local_datasource.dart';
import 'package:enaklo_pos/data/models/response/delivery_response_model.dart';
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class DeliveryDialog extends StatefulWidget {
const DeliveryDialog({super.key});
@override
State<DeliveryDialog> createState() => _DeliveryDialogState();
}
class _DeliveryDialogState extends State<DeliveryDialog> {
@override
Widget build(BuildContext context) {
return CustomModalDialog(
title: 'Pilih Pengiriman',
subtitle: 'Silahkan pilih pengiriman yang sesuai',
contentPadding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
child: BlocBuilder<CheckoutBloc, CheckoutState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const SizedBox.shrink(),
loaded: (items,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType) {
return Column(
children: List.generate(deliveries.length, (index) {
return _buildItem(
context,
deliveries[index],
selectedType: deliveryType,
);
}),
);
});
},
),
);
}
Widget _buildItem(BuildContext context, DeliveryModel delivery,
{DeliveryModel? selectedType}) {
return GestureDetector(
onTap: () {
context.read<CheckoutBloc>().add(
CheckoutEvent.updateDeliveryType(delivery),
);
Navigator.pop(context);
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
margin: const EdgeInsets.only(bottom: 8.0),
decoration: BoxDecoration(
color: selectedType?.id == delivery.id
? AppColors.primary
: AppColors.white,
borderRadius: BorderRadius.circular(8.0),
border: Border.all(
color: selectedType?.id == delivery.id
? AppColors.primary
: AppColors.grey,
width: 1.0,
),
),
child: Row(
children: [
Image.asset(
delivery.imageUrl,
width: 40.0,
height: 40.0,
fit: BoxFit.contain,
),
SpaceWidth(12.0),
Expanded(
child: Text(
delivery.name,
style: TextStyle(
fontSize: 16,
color: selectedType?.id == delivery.id
? AppColors.white
: AppColors.black,
fontWeight: FontWeight.bold,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
SpaceWidth(12.0),
Icon(
Icons.check_circle,
color: selectedType?.id == delivery.id
? AppColors.green
: Colors.transparent,
),
],
),
),
);
}
}

View File

@ -56,7 +56,19 @@ class ServiceDialog extends StatelessWidget {
return state.maybeWhen( return state.maybeWhen(
initial: () => const SizedBox(), initial: () => const SizedBox(),
loading: () => const Center(child: CircularProgressIndicator()), loading: () => const Center(child: CircularProgressIndicator()),
loaded: (data, a, b, c, d, service, e, f, g, orderType) => loaded: (
data,
a,
b,
c,
d,
service,
e,
f,
g,
orderType,
deliveryType,
) =>
_buildServiceItem(context, service), _buildServiceItem(context, service),
orElse: () => const SizedBox(), orElse: () => const SizedBox(),
); );

View File

@ -44,7 +44,20 @@ class TaxDialog extends StatelessWidget {
return state.maybeWhen( return state.maybeWhen(
initial: () => const SizedBox(), initial: () => const SizedBox(),
loading: () => const Center(child: CircularProgressIndicator()), loading: () => const Center(child: CircularProgressIndicator()),
loaded: (data, a, b, c, tax, d, e, f, g, orderType) => ListTile( loaded: (
data,
a,
b,
c,
tax,
d,
e,
f,
g,
orderType,
deliveryType,
) =>
ListTile(
title: const Text('PB1'), title: const Text('PB1'),
subtitle: Text('tarif pajak ($tax%)'), subtitle: Text('tarif pajak ($tax%)'),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,

View File

@ -52,7 +52,8 @@ class _TypeDialogState extends State<TypeDialog> {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox.shrink(), orElse: () => const SizedBox.shrink(),
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -61,7 +62,9 @@ class _TypeDialogState extends State<TypeDialog> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return Column( return Column(
children: List.generate(types.length, (index) { children: List.generate(types.length, (index) {
return _buildItem( return _buildItem(

View File

@ -198,7 +198,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
orElse: () => const Center( orElse: () => const Center(
child: Text('No Items'), child: Text('No Items'),
), ),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -207,7 +208,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (products.isEmpty) { if (products.isEmpty) {
return const Center( return const Center(
child: Text('No Items'), child: Text('No Items'),
@ -240,7 +243,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -249,7 +253,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -280,7 +286,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -289,7 +296,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -300,7 +309,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final subTotal = state.maybeWhen( final subTotal = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -309,7 +319,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -343,7 +355,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -352,12 +365,15 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -366,7 +382,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -378,7 +396,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -387,7 +406,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -425,7 +446,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -434,13 +456,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -449,7 +474,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -491,7 +518,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -500,7 +528,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -512,7 +542,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -521,7 +552,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -532,7 +565,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -541,13 +575,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -556,7 +593,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
@ -1220,7 +1259,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1229,7 +1269,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -1240,7 +1282,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1249,7 +1292,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -1261,7 +1306,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1270,13 +1316,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderTyp,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1285,13 +1334,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final orderType = state.maybeWhen( final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn, orElse: () => OrderType.dineIn,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1300,7 +1352,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
orderType, orderType,
); );
@ -1315,7 +1369,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
List<ProductQuantity> items = List<ProductQuantity> items =
state.maybeWhen( state.maybeWhen(
orElse: () => [], orElse: () => [],
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1324,7 +1379,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products, products,
); );
final totalQty = items.fold( final totalQty = items.fold(

View File

@ -132,7 +132,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox(), orElse: () => const SizedBox(),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -141,7 +142,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0), borderRadius: BorderRadius.circular(8.0),
@ -221,7 +224,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
orElse: () => const Center( orElse: () => const Center(
child: Text('No Items'), child: Text('No Items'),
), ),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -230,7 +234,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (products.isEmpty) { if (products.isEmpty) {
return const Center( return const Center(
child: Text('No Items'), child: Text('No Items'),
@ -263,6 +269,59 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
), ),
child: Column( child: Column(
children: [ 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( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -277,7 +336,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -286,7 +346,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -320,7 +382,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -329,12 +392,15 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -343,7 +409,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -355,7 +423,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -364,7 +433,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -410,7 +481,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -419,7 +491,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -431,7 +505,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -440,7 +515,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -451,7 +528,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -460,13 +538,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -475,7 +556,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
@ -826,7 +909,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
builder: (context, state) { builder: (context, state) {
final orderType = state.maybeWhen( final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn, orElse: () => OrderType.dineIn,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -835,13 +919,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
orderType, orderType,
); );
List<ProductQuantity> items = state.maybeWhen( List<ProductQuantity> items = state.maybeWhen(
orElse: () => [], orElse: () => [],
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -850,7 +937,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products, products,
); );

View File

@ -307,7 +307,8 @@ class _HomePageState extends State<HomePage> {
orElse: () => const Center( orElse: () => const Center(
child: Text('No Items'), child: Text('No Items'),
), ),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -316,7 +317,9 @@ class _HomePageState extends State<HomePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (products.isEmpty) { if (products.isEmpty) {
return const Center( return const Center(
child: Text('No Items'), child: Text('No Items'),
@ -358,7 +361,8 @@ class _HomePageState extends State<HomePage> {
builder: (context, state) { builder: (context, state) {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -367,7 +371,9 @@ class _HomePageState extends State<HomePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (products.isEmpty) { if (products.isEmpty) {
return 0; return 0;
} }
@ -409,7 +415,8 @@ class _HomePageState extends State<HomePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType) {
if (products.isEmpty) { if (products.isEmpty) {
return 0; return 0;
} }
@ -462,7 +469,8 @@ class _HomePageState extends State<HomePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType) =>
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Button.filled( child: Button.filled(
@ -476,6 +484,14 @@ class _HomePageState extends State<HomePage> {
'Mohon pilih meja terlebih dahulu'); 'Mohon pilih meja terlebih dahulu');
return; return;
} }
if (orderType.name == 'delivery' &&
deliveryType == null) {
AppFlushbar.showError(context,
'Mohon pilih pengiriman terlebih dahulu');
return;
}
context.push(ConfirmPaymentPage( context.push(ConfirmPaymentPage(
isTable: widget.table == null isTable: widget.table == null
? false ? false

View File

@ -5,6 +5,7 @@ import 'package:enaklo_pos/core/extensions/string_ext.dart';
import 'package:enaklo_pos/data/models/response/table_model.dart'; import 'package:enaklo_pos/data/models/response/table_model.dart';
import 'package:enaklo_pos/presentation/customer/pages/customer_page.dart'; import 'package:enaklo_pos/presentation/customer/pages/customer_page.dart';
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart'; import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
import 'package:enaklo_pos/presentation/home/dialog/delivery_dialog.dart';
import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart'; import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart';
import 'package:enaklo_pos/presentation/home/models/order_type.dart'; import 'package:enaklo_pos/presentation/home/models/order_type.dart';
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart'; import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
@ -81,7 +82,8 @@ class HomeRightTitle extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox.shrink(), orElse: () => const SizedBox.shrink(),
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -90,7 +92,9 @@ class HomeRightTitle extends StatelessWidget {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return Button.filled( return Button.filled(
width: 180.0, width: 180.0,
height: 40, height: 40,
@ -120,7 +124,8 @@ class HomeRightTitle extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox.shrink(), orElse: () => const SizedBox.shrink(),
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -129,7 +134,9 @@ class HomeRightTitle extends StatelessWidget {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
switch (orderType) { switch (orderType) {
case OrderType.dineIn: case OrderType.dineIn:
return Expanded( return Expanded(
@ -159,7 +166,30 @@ class HomeRightTitle extends StatelessWidget {
case OrderType.takeAway: case OrderType.takeAway:
return const SizedBox.shrink(); return const SizedBox.shrink();
case OrderType.delivery: case OrderType.delivery:
return const SizedBox.shrink(); return Expanded(
child: Button.filled(
width: 180.0,
height: 40,
elevation: 0,
icon: Icon(
Icons.motorcycle_outlined,
color: Colors.white,
size: 24,
),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return DeliveryDialog();
});
},
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
label: deliveryType == null
? 'Pilih Pengiriman'
: deliveryType.name,
),
);
default: default:
return const SizedBox.shrink(); return const SizedBox.shrink();
} }

View File

@ -15,7 +15,19 @@ class OrderTypeSelector extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox.shrink(), orElse: () => const SizedBox.shrink(),
loaded: (items, discountModel, discount, discountAmount, tax, serviceCharge, totalQuantity, totalPrice, draftName, orderType) { loaded: (
items,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType,
deliveryType,
) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -45,9 +57,11 @@ class OrderTypeSelector extends StatelessWidget {
vertical: 8.0, vertical: 8.0,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? AppColors.primary : AppColors.white, color:
isSelected ? AppColors.primary : AppColors.white,
border: Border.all( border: Border.all(
color: isSelected ? AppColors.primary : AppColors.grey, color:
isSelected ? AppColors.primary : AppColors.grey,
width: 1.0, width: 1.0,
), ),
borderRadius: BorderRadius.circular(8.0), borderRadius: BorderRadius.circular(8.0),
@ -55,9 +69,12 @@ class OrderTypeSelector extends StatelessWidget {
child: Text( child: Text(
type.value, type.value,
style: TextStyle( style: TextStyle(
color: isSelected ? AppColors.white : AppColors.black, color:
isSelected ? AppColors.white : AppColors.black,
fontSize: 14, fontSize: 14,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
), ),
), ),
), ),

View File

@ -114,7 +114,8 @@ class ProductCard extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
return state.maybeWhen( return state.maybeWhen(
orElse: () => const SizedBox(), orElse: () => const SizedBox(),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -123,7 +124,9 @@ class ProductCard extends StatelessWidget {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
final totalQuantity = products final totalQuantity = products
.where((item) => item.product.id == data.id) .where((item) => item.product.id == data.id)
.map((item) => item.quantity) .map((item) => item.quantity)

View File

@ -90,7 +90,8 @@ class _SaveOrderDialogState extends State<SaveOrderDialog> {
builder: (context, state) { builder: (context, state) {
final orderType = state.maybeWhen( final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn, orElse: () => OrderType.dineIn,
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -99,7 +100,9 @@ class _SaveOrderDialogState extends State<SaveOrderDialog> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
orderType, orderType,
); );

View File

@ -201,7 +201,8 @@ class _SuccessPaymentDialogState extends State<SuccessPaymentDialog> {
builder: (context, checkoutState) { builder: (context, checkoutState) {
final orderType = checkoutState.maybeWhen( final orderType = checkoutState.maybeWhen(
orElse: () => OrderType.dineIn, orElse: () => OrderType.dineIn,
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -210,7 +211,9 @@ class _SuccessPaymentDialogState extends State<SuccessPaymentDialog> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
orderType, orderType,
); );

View File

@ -250,7 +250,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
orElse: () => const Center( orElse: () => const Center(
child: Text('No Items'), child: Text('No Items'),
), ),
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -259,7 +260,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (products.isEmpty) { if (products.isEmpty) {
return const Center( return const Center(
child: Text('No Items'), child: Text('No Items'),
@ -294,7 +297,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -303,7 +307,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -335,7 +341,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -344,7 +351,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
log("discountAmount: $discountAmount"); log("discountAmount: $discountAmount");
return discountAmount; return discountAmount;
}); });
@ -374,7 +383,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -383,12 +393,15 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -397,7 +410,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -409,7 +424,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -418,7 +434,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return discountAmount; return discountAmount;
}); });
@ -448,7 +466,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
state.maybeWhen( state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -457,12 +476,15 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -471,7 +493,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -483,7 +507,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -492,13 +517,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return discountAmount; return discountAmount;
}); });
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -507,7 +535,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
@ -541,7 +571,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -550,7 +581,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -562,7 +595,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -571,13 +605,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
return discountAmount; return discountAmount;
}); });
final serviceCharge = state.maybeWhen( final serviceCharge = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -586,13 +623,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
serviceCharge, serviceCharge,
); );
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -601,7 +641,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
@ -674,7 +716,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
orElse: () { orElse: () {
return SizedBox.shrink(); return SizedBox.shrink();
}, },
loaded: (items, loaded: (
items,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -683,7 +726,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
customerController.text = draftName; customerController.text = draftName;
return TextFormField( return TextFormField(
readOnly: true, readOnly: true,
@ -1037,7 +1082,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
builder: (context, state) { builder: (context, state) {
final discount = state.maybeWhen( final discount = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1046,7 +1092,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) { orderType,
deliveryType,
) {
if (discountModel == null) { if (discountModel == null) {
return 0; return 0;
} }
@ -1057,7 +1105,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final price = state.maybeWhen( final price = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1066,7 +1115,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products.fold( products.fold(
0, 0,
(previousValue, element) => (previousValue, element) =>
@ -1078,7 +1129,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final tax = state.maybeWhen( final tax = state.maybeWhen(
orElse: () => 0, orElse: () => 0,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1087,7 +1139,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
tax, tax,
); );
@ -1100,7 +1154,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
List<ProductQuantity> items = List<ProductQuantity> items =
state.maybeWhen( state.maybeWhen(
orElse: () => [], orElse: () => [],
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1109,7 +1164,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
products, products,
); );
final totalQty = items.fold( final totalQty = items.fold(
@ -1120,7 +1177,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
final orderType = state.maybeWhen( final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn, orElse: () => OrderType.dineIn,
loaded: (products, loaded: (
products,
discountModel, discountModel,
discount, discount,
discountAmount, discountAmount,
@ -1129,7 +1187,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
totalQuantity, totalQuantity,
totalPrice, totalPrice,
draftName, draftName,
orderType) => orderType,
deliveryType,
) =>
orderType, orderType,
); );