feat: delivery type
This commit is contained in:
@@ -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,16 +82,19 @@ class HomeRightTitle 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 Button.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
@@ -120,16 +124,19 @@ class HomeRightTitle 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,
|
||||
) {
|
||||
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: [
|
||||
@@ -36,8 +48,8 @@ class OrderTypeSelector extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<CheckoutBloc>().add(
|
||||
CheckoutEvent.updateOrderType(type),
|
||||
);
|
||||
CheckoutEvent.updateOrderType(type),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -71,4 +88,4 @@ class OrderTypeSelector extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,16 +114,19 @@ class ProductCard extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox(),
|
||||
loaded: (products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
loaded: (
|
||||
products,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType,
|
||||
deliveryType,
|
||||
) {
|
||||
final totalQuantity = products
|
||||
.where((item) => item.product.id == data.id)
|
||||
.map((item) => item.quantity)
|
||||
|
||||
@@ -90,16 +90,19 @@ class _SaveOrderDialogState extends State<SaveOrderDialog> {
|
||||
builder: (context, state) {
|
||||
final orderType = state.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
|
||||
@@ -201,16 +201,19 @@ class _SuccessPaymentDialogState extends State<SuccessPaymentDialog> {
|
||||
builder: (context, checkoutState) {
|
||||
final orderType = checkoutState.maybeWhen(
|
||||
orElse: () => OrderType.dineIn,
|
||||
loaded: (items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) =>
|
||||
loaded: (
|
||||
items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType,
|
||||
deliveryType,
|
||||
) =>
|
||||
orderType,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user