feat: delivery type

This commit is contained in:
efrilm
2025-08-06 18:47:20 +07:00
parent a46a2cfa7c
commit 6fdaac2c0f
22 changed files with 1560 additions and 679 deletions
@@ -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(),
);
+14 -1
View File
@@ -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,
+13 -10
View File
@@ -52,16 +52,19 @@ class _TypeDialogState extends State<TypeDialog> {
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(
children: List.generate(types.length, (index) {
return _buildItem(