update servicio caducado

This commit is contained in:
Felipe
2024-05-25 13:49:08 -05:00
parent fbae057d8a
commit 50f0c04f59
@@ -319,74 +319,58 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
} }
Widget customActionButtons(ServiceEntity service, MyUser user) { Widget customActionButtons(ServiceEntity service, MyUser user) {
if (service.status == ServiceStatus.acepted || DateTime serviceDate = DateTime.parse(service.day);
service.status == ServiceStatus.active) { DateTime now = DateTime.now();
return Wrap( DateTime serviceDateTime = DateTime(
alignment: WrapAlignment.center, serviceDate.year,
spacing: 15, serviceDate.month,
children: [ serviceDate.day,
Visibility( service.range1Hour2.hour,
visible: user.phone == null ? false : true, service.range1Hour2.minute,
child: ElevatedButton( );
onPressed: () => launch("tel:${user.phone}"),
style: ElevatedButton.styleFrom( if (now.isAfter(serviceDateTime)) {
foregroundColor: const Color(0xFF2BA4EC), return const SizedBox();
backgroundColor: Colors.white, } else {
shape: const CircleBorder( if (service.status == ServiceStatus.acepted ||
side: BorderSide( service.status == ServiceStatus.active) {
return Wrap(
alignment: WrapAlignment.center,
spacing: 15,
children: [
Visibility(
visible: user.phone == null ? false : true,
child: ElevatedButton(
onPressed: () => launch("tel:${user.phone}"),
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF2BA4EC),
backgroundColor: Colors.white,
shape: const CircleBorder(
side: BorderSide(
color: Color(0xFF2BA4EC),
width: 2,
),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0),
child: Icon(
Icons.phone_android,
size: 30,
color: Color(0xFF2BA4EC), color: Color(0xFF2BA4EC),
width: 2,
), ),
), ),
), ),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0),
child: Icon(
Icons.phone_android,
size: 30,
color: Color(0xFF2BA4EC),
),
),
), ),
), ElevatedButton(
ElevatedButton( onPressed: () {
onPressed: () { if (service.id != null) {
if (service.id != null) { Navigator.push(
Navigator.push( context,
context, CupertinoPageRoute(
CupertinoPageRoute( builder: (context) => ChatScreen(service: service),
builder: (context) => ChatScreen(service: service), ),
), );
);
}
},
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF2BA4EC),
backgroundColor: Colors.white,
shape: const CircleBorder(
side: BorderSide(
color: Color(0xFF2BA4EC),
width: 2,
),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0),
child: Icon(
Icons.message,
size: 30,
color: Color(0xFF2BA4EC),
),
),
),
Visibility(
visible: user.phone == null ? false : true,
child: ElevatedButton(
onPressed: () async {
final whatsappUrl =
'https://wa.me/${user.phone}?text=${Uri.parse('Hola! me contactaste por Prossapp')}';
if (!await launch(whatsappUrl)) {
throw Exception('Could not launch $whatsappUrl');
} }
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
@@ -402,15 +386,45 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
child: const Padding( child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0), padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0),
child: Icon( child: Icon(
CommunityMaterialIcons.whatsapp, Icons.message,
size: 30, size: 30,
color: Color(0xFF2BA4EC), color: Color(0xFF2BA4EC),
), ),
), ),
), ),
), Visibility(
], visible: user.phone == null ? false : true,
); child: ElevatedButton(
onPressed: () async {
final whatsappUrl =
'https://wa.me/${user.phone}?text=${Uri.parse('Hola! me contactaste por Prossapp')}';
if (!await launch(whatsappUrl)) {
throw Exception('Could not launch $whatsappUrl');
}
},
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF2BA4EC),
backgroundColor: Colors.white,
shape: const CircleBorder(
side: BorderSide(
color: Color(0xFF2BA4EC),
width: 2,
),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 0),
child: Icon(
CommunityMaterialIcons.whatsapp,
size: 30,
color: Color(0xFF2BA4EC),
),
),
),
),
],
);
}
} }
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,159 +511,36 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
} }
Widget customMessageStatus(ServiceEntity service) { Widget customMessageStatus(ServiceEntity service) {
if (service.status == ServiceStatus.cancelled) { 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( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: [ children: [
Card( Card(
color: Colors.red.shade100, color: Colors.red.shade100,
child: const Padding(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Text(
'Cancelado',
style: TextStyle(fontSize: 32, 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),
),
)
],
);
}
if (service.status == ServiceStatus.denied) {
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: Text(
'Rechazado',
style: TextStyle(fontSize: 32, 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),
),
)
],
);
}
if (service.status == ServiceStatus.completed &&
service.userScored == false) {
return Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
Card(
color: Colors.green.shade50,
child: Padding(
padding: const EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Column(
children: [
const Text(
'Completado',
style: TextStyle(fontSize: 32, color: Colors.green),
),
const Text(
'Califica el servicio',
style: TextStyle(fontSize: 20, color: Colors.green),
),
const SizedBox(height: 15),
FilledButton(
onPressed: () {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => ScoreScreen(
service: service,
),
),
);
},
style: FilledButton.styleFrom(
backgroundColor: Colors.green,
padding: const EdgeInsets.symmetric(vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: Container(
alignment: Alignment.center,
width: MediaQuery.of(context).size.width * 0.4,
child: const Text(
'Calificar',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
),
],
),
),
),
Positioned(
top: -40,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.green.shade50, width: 4),
shape: BoxShape.circle,
),
child: const Icon(
Icons.star,
color: Colors.green,
size: 48,
),
),
)
],
);
}
if (service.status == ServiceStatus.completed &&
service.userScored == true) {
return Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
Card(
color: Colors.green.shade50,
child: const Padding( child: const Padding(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32), padding: EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'Completado', 'Caducado',
style: TextStyle(fontSize: 32, color: Colors.green), 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),
), ),
], ],
), ),
@@ -662,18 +552,193 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
border: Border.all(color: Colors.green.shade50, width: 4), border: Border.all(color: Colors.red.shade100, width: 4),
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: const Icon( child:
Icons.star, const Icon(Icons.close_rounded, color: Colors.red, size: 48),
color: Colors.green,
size: 48,
),
), ),
) )
], ],
); );
} else {
if (service.status == ServiceStatus.cancelled) {
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: Text(
'Cancelado',
style: TextStyle(fontSize: 32, 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),
),
)
],
);
}
if (service.status == ServiceStatus.denied) {
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: Text(
'Rechazado',
style: TextStyle(fontSize: 32, 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),
),
)
],
);
}
if (service.status == ServiceStatus.completed &&
service.userScored == false) {
return Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
Card(
color: Colors.green.shade50,
child: Padding(
padding: const EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Column(
children: [
const Text(
'Completado',
style: TextStyle(fontSize: 32, color: Colors.green),
),
const Text(
'Califica el servicio',
style: TextStyle(fontSize: 20, color: Colors.green),
),
const SizedBox(height: 15),
FilledButton(
onPressed: () {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => ScoreScreen(
service: service,
),
),
);
},
style: FilledButton.styleFrom(
backgroundColor: Colors.green,
padding: const EdgeInsets.symmetric(vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: Container(
alignment: Alignment.center,
width: MediaQuery.of(context).size.width * 0.4,
child: const Text(
'Calificar',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
),
],
),
),
),
Positioned(
top: -40,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.green.shade50, width: 4),
shape: BoxShape.circle,
),
child: const Icon(
Icons.star,
color: Colors.green,
size: 48,
),
),
)
],
);
}
if (service.status == ServiceStatus.completed &&
service.userScored == true) {
return Stack(
alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none,
children: [
Card(
color: Colors.green.shade50,
child: const Padding(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32),
child: Column(
children: [
Text(
'Completado',
style: TextStyle(fontSize: 32, color: Colors.green),
),
],
),
),
),
Positioned(
top: -40,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.green.shade50, width: 4),
shape: BoxShape.circle,
),
child: const Icon(
Icons.star,
color: Colors.green,
size: 48,
),
),
)
],
);
}
} }
return const SizedBox(); return const SizedBox();
@@ -754,16 +819,11 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
} }
return GeneralSecondaryButton( return GeneralSecondaryButton(
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) {