delivery dialog

This commit is contained in:
efrilm
2025-10-27 01:07:05 +07:00
parent 8fec9c8cd0
commit 08bbfc393b
7 changed files with 362 additions and 63 deletions
@@ -0,0 +1,98 @@
part of 'dialog.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<CheckoutFormBloc, CheckoutFormState>(
builder: (context, state) {
return Column(
children: List.generate(deliveries.length, (index) {
return _buildItem(
context,
deliveries[index],
selectedType: state.delivery,
);
}),
);
},
),
);
}
Widget _buildItem(
BuildContext context,
Delivery delivery, {
Delivery? selectedType,
}) {
return GestureDetector(
onTap: () {
context.read<CheckoutFormBloc>().add(
CheckoutFormEvent.updateDelivery(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
? AppColor.primary
: AppColor.white,
borderRadius: BorderRadius.circular(8.0),
border: Border.all(
color: selectedType?.id == delivery.id
? AppColor.primary
: AppColor.textSecondary,
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
? AppColor.white
: AppColor.black,
fontWeight: FontWeight.bold,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
SpaceWidth(12.0),
Icon(
Icons.check_circle,
color: selectedType?.id == delivery.id
? AppColor.success
: Colors.transparent,
),
],
),
),
);
}
}
@@ -6,6 +6,8 @@ import '../../../application/checkout/checkout_form/checkout_form_bloc.dart';
import '../../../application/outlet/outlet_loader/outlet_loader_bloc.dart';
import '../../../common/extension/extension.dart';
import '../../../common/theme/theme.dart';
import '../../../common/types/order_type.dart';
import '../../../domain/delivery/delivery.dart';
import '../../../domain/product/product.dart';
import '../button/button.dart';
import '../card/outlet_card.dart';
@@ -15,3 +17,5 @@ import '../spaces/space.dart';
part 'custom_modal_dialog.dart';
part 'outlet_dialog.dart';
part 'variant_dialog.dart';
part 'delivery_dialog.dart';
part 'order_type_dialog.dart';
@@ -1,12 +1,4 @@
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';
part of 'dialog.dart';
class OrderTypeDialog extends StatelessWidget {
const OrderTypeDialog({super.key});
@@ -4,8 +4,9 @@ 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 '../../../../../../common/types/order_type.dart';
import '../../../../../components/button/button.dart';
import '../../../../../components/dialog/order_type_dialog.dart';
import '../../../../../components/dialog/dialog.dart';
class HomeRightTitle extends StatelessWidget {
// final TableModel? table;
@@ -27,71 +28,47 @@ class HomeRightTitle extends StatelessWidget {
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',
),
),
],
children: [_buildButton('Daftar Pesanan', Icons.list, () {})],
),
),
Expanded(
child: Row(
children: [
Expanded(
child: AppElevatedButton.filled(
width: 180.0,
height: 40,
elevation: 0,
onPressed: () {
_buildButton(
state.orderType.value.toTitleCase(),
state.orderType.icon,
() {
showDialog(
context: context,
builder: (context) {
return OrderTypeDialog();
},
);
},
),
switch (state.orderType) {
OrderType.dineIn => _buildButton(
'Pilih Meja',
Icons.table_restaurant_outlined,
() {},
),
OrderType.takeAway => SizedBox.shrink(),
OrderType.delivery => _buildButton(
state.delivery == null
? 'Pilih Pengiriman'
: (state.delivery?.name ?? "-"),
Icons.motorcycle_outlined,
() {
showDialog(
context: context,
builder: (context) {
return OrderTypeDialog();
return DeliveryDialog();
},
);
},
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
icon: Icon(
state.orderType.icon,
color: Colors.white,
size: 24,
),
label: state.orderType.value.toTitleCase(),
),
),
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',
),
),
OrderType.freeTable => SizedBox.shrink(),
},
],
),
),
@@ -101,4 +78,19 @@ class HomeRightTitle extends StatelessWidget {
},
);
}
Expanded _buildButton(String label, IconData icon, Function() onPressed) {
return Expanded(
child: AppElevatedButton.filled(
width: 180.0,
height: 40,
elevation: 0,
onPressed: onPressed,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
icon: Icon(icon, color: Colors.white, size: 24),
label: label,
),
);
}
}