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});