feat: delivery type
This commit is contained in:
parent
a46a2cfa7c
commit
6fdaac2c0f
BIN
assets/images/gojek.png
Normal file
BIN
assets/images/gojek.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
BIN
assets/images/grab.png
Normal file
BIN
assets/images/grab.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
@ -186,6 +186,12 @@ class $AssetsImagesGen {
|
||||
/// File path: 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
|
||||
AssetGenImage get logo => const AssetGenImage('assets/images/logo.png');
|
||||
|
||||
@ -265,6 +271,8 @@ class $AssetsImagesGen {
|
||||
drink5,
|
||||
drink6,
|
||||
drink7,
|
||||
gojek,
|
||||
grab,
|
||||
logo,
|
||||
managePrinter,
|
||||
manageProduct,
|
||||
|
||||
15
lib/data/datasources/delivery_local_datasource.dart
Normal file
15
lib/data/datasources/delivery_local_datasource.dart
Normal 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,
|
||||
),
|
||||
];
|
||||
11
lib/data/models/response/delivery_response_model.dart
Normal file
11
lib/data/models/response/delivery_response_model.dart
Normal file
@ -0,0 +1,11 @@
|
||||
class DeliveryModel {
|
||||
String id;
|
||||
String name;
|
||||
String imageUrl;
|
||||
|
||||
DeliveryModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.imageUrl,
|
||||
});
|
||||
}
|
||||
@ -2,6 +2,7 @@ import 'dart:developer';
|
||||
|
||||
import 'package:bloc/bloc.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/presentation/table/models/draft_order_item.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.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_RemoveItem>((event, emit) {
|
||||
@ -91,7 +93,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_DeleteItem>((event, emit) {
|
||||
@ -116,7 +119,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_Started>((event, emit) async {
|
||||
@ -126,12 +130,24 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
final tax = await settingsLocalDatasource.getTax();
|
||||
final serviceCharge = await settingsLocalDatasource.getServiceCharge();
|
||||
|
||||
emit(_Loaded([], null, 0, 0, tax.value, serviceCharge, 0, 0, '',
|
||||
OrderType.dineIn));
|
||||
emit(_Loaded(
|
||||
[],
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
tax.value,
|
||||
serviceCharge,
|
||||
0,
|
||||
0,
|
||||
'',
|
||||
OrderType.dineIn,
|
||||
null,
|
||||
));
|
||||
} catch (e) {
|
||||
// If loading fails, use default values
|
||||
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.draftName,
|
||||
currentState.orderType,
|
||||
));
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_RemoveDiscount>((event, emit) {
|
||||
@ -163,7 +179,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_AddTax>((event, emit) {
|
||||
@ -178,7 +195,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_AddServiceCharge>((event, emit) {
|
||||
@ -194,6 +212,7 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType,
|
||||
currentState.deliveryType,
|
||||
));
|
||||
});
|
||||
|
||||
@ -209,7 +228,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_RemoveServiceCharge>((event, emit) {
|
||||
@ -224,7 +244,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_UpdateOrderType>((event, emit) {
|
||||
@ -239,7 +260,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
event.orderType));
|
||||
event.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_UpdateItemNotes>((event, emit) {
|
||||
@ -260,7 +282,8 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
currentState.totalQuantity,
|
||||
currentState.totalPrice,
|
||||
currentState.draftName,
|
||||
currentState.orderType));
|
||||
currentState.orderType,
|
||||
currentState.deliveryType));
|
||||
});
|
||||
|
||||
on<_SaveDraftOrder>((event, emit) async {
|
||||
@ -310,7 +333,26 @@ class CheckoutBloc extends Bloc<CheckoutEvent, CheckoutState> {
|
||||
draftOrder.totalQuantity,
|
||||
draftOrder.totalPrice,
|
||||
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,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,4 +42,8 @@ class CheckoutEvent with _$CheckoutEvent {
|
||||
//load draft order
|
||||
const factory CheckoutEvent.loadDraftOrder(DraftOrderModel data) =
|
||||
_LoadDraftOrder;
|
||||
|
||||
// Update delivery type
|
||||
const factory CheckoutEvent.updateDeliveryType(DeliveryModel delivery) =
|
||||
_UpdateDeliveryType;
|
||||
}
|
||||
|
||||
@ -14,7 +14,9 @@ class CheckoutState with _$CheckoutState {
|
||||
int totalQuantity,
|
||||
int totalPrice,
|
||||
String draftName,
|
||||
OrderType orderType) = _Loaded;
|
||||
OrderType orderType,
|
||||
DeliveryModel? deliveryType,
|
||||
) = _Loaded;
|
||||
const factory CheckoutState.error(String message) = _Error;
|
||||
|
||||
//save draft order
|
||||
|
||||
114
lib/presentation/home/dialog/delivery_dialog.dart
Normal file
114
lib/presentation/home/dialog/delivery_dialog.dart
Normal 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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,19 @@ class ServiceDialog extends StatelessWidget {
|
||||
return state.maybeWhen(
|
||||
initial: () => const SizedBox(),
|
||||
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),
|
||||
orElse: () => const SizedBox(),
|
||||
);
|
||||
|
||||
@ -44,7 +44,20 @@ class TaxDialog extends StatelessWidget {
|
||||
return state.maybeWhen(
|
||||
initial: () => const SizedBox(),
|
||||
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'),
|
||||
subtitle: Text('tarif pajak ($tax%)'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
@ -52,7 +52,8 @@ class _TypeDialogState extends State<TypeDialog> {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox.shrink(),
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -61,7 +62,9 @@ class _TypeDialogState extends State<TypeDialog> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return Column(
|
||||
children: List.generate(types.length, (index) {
|
||||
return _buildItem(
|
||||
|
||||
@ -198,7 +198,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
orElse: () => const Center(
|
||||
child: Text('No Items'),
|
||||
),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -207,7 +208,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (products.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No Items'),
|
||||
@ -240,7 +243,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -249,7 +253,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -280,7 +286,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -289,7 +296,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -300,7 +309,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final subTotal = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -309,7 +319,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -343,7 +355,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -352,12 +365,15 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -366,7 +382,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -378,7 +396,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -387,7 +406,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -425,7 +446,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -434,13 +456,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -449,7 +474,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -491,7 +518,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -500,7 +528,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -512,7 +542,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -521,7 +552,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -532,7 +565,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -541,13 +575,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -556,7 +593,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
@ -1220,7 +1259,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1229,7 +1269,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -1240,7 +1282,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1249,7 +1292,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -1261,7 +1306,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1270,13 +1316,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderTyp,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1285,13 +1334,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1300,7 +1352,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
@ -1315,7 +1369,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
List<ProductQuantity> items =
|
||||
state.maybeWhen(
|
||||
orElse: () => [],
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1324,7 +1379,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products,
|
||||
);
|
||||
final totalQty = items.fold(
|
||||
|
||||
@ -132,7 +132,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox(),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -141,7 +142,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
@ -221,7 +224,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
orElse: () => const Center(
|
||||
child: Text('No Items'),
|
||||
),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -230,7 +234,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
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,7 +336,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -286,7 +346,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -320,7 +382,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -329,12 +392,15 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -343,7 +409,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -355,7 +423,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -364,7 +433,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -410,7 +481,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -419,7 +491,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -431,7 +505,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -440,7 +515,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -451,7 +528,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -460,13 +538,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -475,7 +556,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
@ -826,7 +909,8 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
builder: (context, state) {
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -835,13 +919,16 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
List<ProductQuantity> items = state.maybeWhen(
|
||||
orElse: () => [],
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -850,7 +937,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products,
|
||||
);
|
||||
|
||||
|
||||
@ -307,7 +307,8 @@ class _HomePageState extends State<HomePage> {
|
||||
orElse: () => const Center(
|
||||
child: Text('No Items'),
|
||||
),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -316,7 +317,9 @@ class _HomePageState extends State<HomePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (products.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No Items'),
|
||||
@ -358,7 +361,8 @@ class _HomePageState extends State<HomePage> {
|
||||
builder: (context, state) {
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -367,7 +371,9 @@ class _HomePageState extends State<HomePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (products.isEmpty) {
|
||||
return 0;
|
||||
}
|
||||
@ -409,7 +415,8 @@ class _HomePageState extends State<HomePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType) {
|
||||
if (products.isEmpty) {
|
||||
return 0;
|
||||
}
|
||||
@ -462,7 +469,8 @@ class _HomePageState extends State<HomePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType) =>
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Button.filled(
|
||||
@ -476,6 +484,14 @@ class _HomePageState extends State<HomePage> {
|
||||
'Mohon pilih meja terlebih dahulu');
|
||||
return;
|
||||
}
|
||||
|
||||
if (orderType.name == 'delivery' &&
|
||||
deliveryType == null) {
|
||||
AppFlushbar.showError(context,
|
||||
'Mohon pilih pengiriman terlebih dahulu');
|
||||
return;
|
||||
}
|
||||
|
||||
context.push(ConfirmPaymentPage(
|
||||
isTable: widget.table == null
|
||||
? false
|
||||
|
||||
@ -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/presentation/customer/pages/customer_page.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/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||
@ -81,7 +82,8 @@ class HomeRightTitle extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox.shrink(),
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -90,7 +92,9 @@ class HomeRightTitle extends StatelessWidget {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return Button.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
@ -120,7 +124,8 @@ class HomeRightTitle extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox.shrink(),
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -129,7 +134,9 @@ class HomeRightTitle extends StatelessWidget {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
switch (orderType) {
|
||||
case OrderType.dineIn:
|
||||
return Expanded(
|
||||
@ -159,7 +166,30 @@ class HomeRightTitle extends StatelessWidget {
|
||||
case OrderType.takeAway:
|
||||
return const SizedBox.shrink();
|
||||
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:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@ -15,7 +15,19 @@ class OrderTypeSelector extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
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(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -45,9 +57,11 @@ class OrderTypeSelector extends StatelessWidget {
|
||||
vertical: 8.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AppColors.primary : AppColors.white,
|
||||
color:
|
||||
isSelected ? AppColors.primary : AppColors.white,
|
||||
border: Border.all(
|
||||
color: isSelected ? AppColors.primary : AppColors.grey,
|
||||
color:
|
||||
isSelected ? AppColors.primary : AppColors.grey,
|
||||
width: 1.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
@ -55,9 +69,12 @@ class OrderTypeSelector extends StatelessWidget {
|
||||
child: Text(
|
||||
type.value,
|
||||
style: TextStyle(
|
||||
color: isSelected ? AppColors.white : AppColors.black,
|
||||
color:
|
||||
isSelected ? AppColors.white : AppColors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -114,7 +114,8 @@ class ProductCard extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox(),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -123,7 +124,9 @@ class ProductCard extends StatelessWidget {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
final totalQuantity = products
|
||||
.where((item) => item.product.id == data.id)
|
||||
.map((item) => item.quantity)
|
||||
|
||||
@ -90,7 +90,8 @@ class _SaveOrderDialogState extends State<SaveOrderDialog> {
|
||||
builder: (context, state) {
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -99,7 +100,9 @@ class _SaveOrderDialogState extends State<SaveOrderDialog> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
|
||||
@ -201,7 +201,8 @@ class _SuccessPaymentDialogState extends State<SuccessPaymentDialog> {
|
||||
builder: (context, checkoutState) {
|
||||
final orderType = checkoutState.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -210,7 +211,9 @@ class _SuccessPaymentDialogState extends State<SuccessPaymentDialog> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
|
||||
@ -250,7 +250,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
orElse: () => const Center(
|
||||
child: Text('No Items'),
|
||||
),
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -259,7 +260,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (products.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No Items'),
|
||||
@ -294,7 +297,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -303,7 +307,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -335,7 +341,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -344,7 +351,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
log("discountAmount: $discountAmount");
|
||||
return discountAmount;
|
||||
});
|
||||
@ -374,7 +383,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -383,12 +393,15 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -397,7 +410,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -409,7 +424,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -418,7 +434,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return discountAmount;
|
||||
});
|
||||
|
||||
@ -448,7 +466,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -457,12 +476,15 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -471,7 +493,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -483,7 +507,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -492,13 +517,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return discountAmount;
|
||||
});
|
||||
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -507,7 +535,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
@ -541,7 +571,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -550,7 +581,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -562,7 +595,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -571,13 +605,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
return discountAmount;
|
||||
});
|
||||
|
||||
final serviceCharge = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -586,13 +623,16 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
serviceCharge,
|
||||
);
|
||||
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -601,7 +641,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
|
||||
@ -674,7 +716,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
orElse: () {
|
||||
return SizedBox.shrink();
|
||||
},
|
||||
loaded: (items,
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -683,7 +726,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
customerController.text = draftName;
|
||||
return TextFormField(
|
||||
readOnly: true,
|
||||
@ -1037,7 +1082,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
builder: (context, state) {
|
||||
final discount = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1046,7 +1092,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
if (discountModel == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -1057,7 +1105,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final price = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1066,7 +1115,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
@ -1078,7 +1129,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final tax = state.maybeWhen(
|
||||
orElse: () => 0,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1087,7 +1139,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
tax,
|
||||
);
|
||||
|
||||
@ -1100,7 +1154,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
List<ProductQuantity> items =
|
||||
state.maybeWhen(
|
||||
orElse: () => [],
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1109,7 +1164,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
products,
|
||||
);
|
||||
final totalQty = items.fold(
|
||||
@ -1120,7 +1177,8 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (products,
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
@ -1129,7 +1187,9 @@ class _PaymentTablePageState extends State<PaymentTablePage> {
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user