order type
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../common/types/order_type.dart';
|
||||
import '../spaces/space.dart';
|
||||
import 'dialog.dart';
|
||||
|
||||
class OrderTypeDialog extends StatelessWidget {
|
||||
const OrderTypeDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Map<String, dynamic>> types = [
|
||||
{
|
||||
'value': 'dine_in',
|
||||
'label': 'Dine In',
|
||||
'icon': Icons.restaurant_outlined,
|
||||
'type': OrderType.dineIn,
|
||||
},
|
||||
{
|
||||
'value': 'take_away',
|
||||
'label': 'Take Away',
|
||||
'icon': Icons.takeout_dining_outlined,
|
||||
'type': OrderType.takeAway,
|
||||
},
|
||||
{
|
||||
'value': 'delivery',
|
||||
'label': 'Delivery',
|
||||
'icon': Icons.delivery_dining_outlined,
|
||||
'type': OrderType.delivery,
|
||||
},
|
||||
{
|
||||
'value': 'free_table',
|
||||
'label': 'Free Table',
|
||||
'icon': Icons.table_bar_outlined,
|
||||
'type': OrderType.freeTable,
|
||||
},
|
||||
];
|
||||
return CustomModalDialog(
|
||||
title: 'Pilih Tipe',
|
||||
subtitle: 'Silahkan pilih tipe yang sesuai',
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 24.0,
|
||||
),
|
||||
child: BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: List.generate(types.length, (index) {
|
||||
return _buildItem(
|
||||
context,
|
||||
types[index],
|
||||
selectedType: state.orderType,
|
||||
);
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(
|
||||
BuildContext context,
|
||||
Map<String, dynamic> type, {
|
||||
required OrderType selectedType,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<CheckoutFormBloc>().add(
|
||||
CheckoutFormEvent.updateOrderType(type['type']),
|
||||
);
|
||||
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 == type['type']
|
||||
? AppColor.primary
|
||||
: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
border: Border.all(
|
||||
color: selectedType == type['type']
|
||||
? AppColor.primary
|
||||
: AppColor.textSecondary,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
type['icon'],
|
||||
color: selectedType == type['type']
|
||||
? AppColor.white
|
||||
: AppColor.black,
|
||||
),
|
||||
SpaceWidth(12.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
type['label']!,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: selectedType == type['type']
|
||||
? AppColor.white
|
||||
: AppColor.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SpaceWidth(12.0),
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
color: selectedType == type['value']
|
||||
? AppColor.success
|
||||
: Colors.transparent,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/button/button.dart';
|
||||
import '../../../../../components/dialog/order_type_dialog.dart';
|
||||
|
||||
class HomeRightTitle extends StatelessWidget {
|
||||
// final TableModel? table;
|
||||
@@ -10,88 +13,92 @@ class HomeRightTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
height: context.deviceHeight * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary,
|
||||
border: Border(left: BorderSide(color: Colors.white, width: 1.0)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(Icons.list, color: Colors.white, size: 24),
|
||||
label: 'Daftar Pesanan',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
return BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
height: context.deviceHeight * 0.15,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary,
|
||||
border: Border(left: BorderSide(color: Colors.white, width: 1.0)),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return TypeDialog();
|
||||
// },
|
||||
// );
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(
|
||||
Icons.dinner_dining_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(Icons.list, color: Colors.white, size: 24),
|
||||
label: 'Daftar Pesanan',
|
||||
),
|
||||
),
|
||||
label: 'Dine In',
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
icon: Icon(
|
||||
Icons.motorcycle_outlined,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return OrderTypeDialog();
|
||||
},
|
||||
);
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(
|
||||
state.orderType.icon,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
label: state.orderType.value.toTitleCase(),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return DeliveryDialog();
|
||||
// },
|
||||
// );
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
label: 'Pilih Pengiriman',
|
||||
),
|
||||
Expanded(
|
||||
child: AppElevatedButton.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: 'Pilih Pengiriman',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user