2025-07-31 19:25:45 +07:00
|
|
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
2025-07-30 22:38:44 +07:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
|
|
|
|
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../core/constants/colors.dart';
|
|
|
|
|
|
|
|
|
|
class ServiceDialog extends StatelessWidget {
|
|
|
|
|
const ServiceDialog({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AlertDialog(
|
2025-07-31 19:25:45 +07:00
|
|
|
backgroundColor: AppColors.white,
|
|
|
|
|
title: Row(
|
2025-07-30 22:38:44 +07:00
|
|
|
children: [
|
2025-07-31 19:25:45 +07:00
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'Pilih Layanan',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: AppColors.black,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 4.0),
|
|
|
|
|
Text(
|
|
|
|
|
'Pilih layanan yang ingin diterapkan pada pesanan',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2025-07-30 22:38:44 +07:00
|
|
|
),
|
|
|
|
|
),
|
2025-07-31 19:25:45 +07:00
|
|
|
SpaceWidth(12),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.close, color: AppColors.black),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
context.pop();
|
|
|
|
|
},
|
2025-07-30 22:38:44 +07:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
content: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
BlocBuilder<CheckoutBloc, CheckoutState>(
|
|
|
|
|
builder: (context, state) {
|
|
|
|
|
return state.maybeWhen(
|
|
|
|
|
initial: () => const SizedBox(),
|
|
|
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
2025-08-06 18:47:20 +07:00
|
|
|
loaded: (
|
|
|
|
|
data,
|
|
|
|
|
a,
|
|
|
|
|
b,
|
|
|
|
|
c,
|
|
|
|
|
d,
|
|
|
|
|
service,
|
|
|
|
|
e,
|
|
|
|
|
f,
|
|
|
|
|
g,
|
|
|
|
|
orderType,
|
|
|
|
|
deliveryType,
|
|
|
|
|
) =>
|
2025-07-31 19:25:45 +07:00
|
|
|
_buildServiceItem(context, service),
|
2025-07-30 22:38:44 +07:00
|
|
|
orElse: () => const SizedBox(),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-07-31 19:25:45 +07:00
|
|
|
|
|
|
|
|
Widget _buildServiceItem(BuildContext context, int service) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
context.read<CheckoutBloc>().add(
|
|
|
|
|
CheckoutEvent.addServiceCharge(service > 0 ? 0 : service),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
|
|
|
|
|
margin: const EdgeInsets.only(bottom: 8.0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColors.primary,
|
|
|
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: AppColors.primary,
|
|
|
|
|
width: 1.0,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
"Biaya layanan ($service%)",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
color: AppColors.white,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SpaceWidth(12.0),
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.check_circle,
|
|
|
|
|
color: AppColors.green,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-07-30 22:38:44 +07:00
|
|
|
}
|