update servicio caducado

This commit is contained in:
Felipe
2024-05-25 13:49:08 -05:00
parent fbae057d8a
commit 50f0c04f59
@@ -319,6 +319,19 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
} }
Widget customActionButtons(ServiceEntity service, MyUser user) { Widget customActionButtons(ServiceEntity service, MyUser user) {
DateTime serviceDate = DateTime.parse(service.day);
DateTime now = DateTime.now();
DateTime serviceDateTime = DateTime(
serviceDate.year,
serviceDate.month,
serviceDate.day,
service.range1Hour2.hour,
service.range1Hour2.minute,
);
if (now.isAfter(serviceDateTime)) {
return const SizedBox();
} else {
if (service.status == ServiceStatus.acepted || if (service.status == ServiceStatus.acepted ||
service.status == ServiceStatus.active) { service.status == ServiceStatus.active) {
return Wrap( return Wrap(
@@ -412,6 +425,7 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
], ],
); );
} }
}
return const SizedBox(); return const SizedBox();
} }
@@ -433,7 +447,6 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
onPressed: () async { onPressed: () async {
final Uri url = Uri.parse( final Uri url = Uri.parse(
'https://www.google.com/maps/search/?api=1&query=${service.latitude},${service.longitude}'); 'https://www.google.com/maps/search/?api=1&query=${service.latitude},${service.longitude}');
if (!await launchUrl(url)) { if (!await launchUrl(url)) {
throw Exception('Could not launch $url'); throw Exception('Could not launch $url');
} }
@@ -498,6 +511,57 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
} }
Widget customMessageStatus(ServiceEntity service) { Widget customMessageStatus(ServiceEntity service) {
DateTime serviceDate = DateTime.parse(service.day);
DateTime now = DateTime.now();
DateTime serviceDateTime = DateTime(
serviceDate.year,
serviceDate.month,
serviceDate.day,
service.range1Hour2.hour,
service.range1Hour2.minute,
);
if (now.isAfter(serviceDateTime)) {
return Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
Card(
color: Colors.red.shade100,
child: const Padding(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Caducado',
style: TextStyle(fontSize: 32, color: Colors.red),
),
Text(
'Tu servicio ha excedido \n el tiempo de espera',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: Colors.red),
),
],
),
),
),
Positioned(
top: -40,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.red.shade100, width: 4),
shape: BoxShape.circle,
),
child:
const Icon(Icons.close_rounded, color: Colors.red, size: 48),
),
)
],
);
} else {
if (service.status == ServiceStatus.cancelled) { if (service.status == ServiceStatus.cancelled) {
return Stack( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@@ -522,8 +586,8 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
border: Border.all(color: Colors.red.shade100, width: 4), border: Border.all(color: Colors.red.shade100, width: 4),
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: child: const Icon(Icons.close_rounded,
const Icon(Icons.close_rounded, color: Colors.red, size: 48), color: Colors.red, size: 48),
), ),
) )
], ],
@@ -553,8 +617,8 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
border: Border.all(color: Colors.red.shade100, width: 4), border: Border.all(color: Colors.red.shade100, width: 4),
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: child: const Icon(Icons.close_rounded,
const Icon(Icons.close_rounded, color: Colors.red, size: 48), color: Colors.red, size: 48),
), ),
) )
], ],
@@ -675,6 +739,7 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
], ],
); );
} }
}
return const SizedBox(); return const SizedBox();
} }
@@ -757,13 +822,8 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
label: 'Volver', label: 'Volver',
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}); },
// customStatusButton( );
// label: 'Volver',
// onPressed: () {
// Navigator.pop(context);
// },
// );
} }
String formatCurrency(int number) { String formatCurrency(int number) {