fix pantalla servicio

This commit is contained in:
Felipe
2024-04-12 12:12:32 -05:00
parent ef06730840
commit 34c60af688
2 changed files with 514 additions and 185 deletions
@@ -1,3 +1,4 @@
import 'package:community_material_icon/community_material_icon.dart';
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -9,6 +10,7 @@ import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
import 'package:prosappco/components/general_secondary_button.dart'; import 'package:prosappco/components/general_secondary_button.dart';
import 'package:service_repository/service_repository.dart'; import 'package:service_repository/service_repository.dart';
import 'package:setting_repository/setting_repository.dart'; import 'package:setting_repository/setting_repository.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:user_repository/user_repository.dart'; import 'package:user_repository/user_repository.dart';
class ProfessionalServiceScreen extends StatefulWidget { class ProfessionalServiceScreen extends StatefulWidget {
@@ -166,25 +168,27 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
], ],
), ),
), ),
ListTile( customMapButton(service),
leading: const Icon(Icons.near_me),
title: Text( // ListTile(
service.address, // leading: const Icon(Icons.near_me),
style: TextStyle( // title: Text(
fontSize: 15, // service.address,
color: Colors.grey[600], // style: TextStyle(
), // fontSize: 15,
), // color: Colors.grey[600],
subtitle: service.aditionalAddress.isEmpty // ),
? null // ),
: Text( // subtitle: service.aditionalAddress.isEmpty
service.aditionalAddress, // ? null
style: TextStyle( // : Text(
fontSize: 15, // service.aditionalAddress,
color: Colors.grey[600], // style: TextStyle(
), // fontSize: 15,
), // color: Colors.grey[600],
), // ),
// ),
// ),
service.description.isEmpty service.description.isEmpty
? const SizedBox() ? const SizedBox()
: Container( : Container(
@@ -201,7 +205,9 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
), ),
), ),
), ),
const SizedBox(height: 65), const SizedBox(height: 20),
customActionButtons(service, userInfo),
const SizedBox(height: 60),
customMessageStatus(service), customMessageStatus(service),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
@@ -236,37 +242,207 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
); );
} }
Widget customMessageStatus(ServiceEntity service) { Widget customActionButtons(ServiceEntity service, MyUser user) {
if (service.status == ServiceStatus.acepted) { if (service.status == ServiceStatus.acepted ||
return Stack( service.status == ServiceStatus.active) {
alignment: AlignmentDirectional.topCenter, return Wrap(
clipBehavior: Clip.none, alignment: WrapAlignment.center,
spacing: 15,
children: [ children: [
Card( Visibility(
color: Colors.green.shade50, visible: user.phone == null ? false : true,
child: const Padding( child: ElevatedButton(
padding: EdgeInsets.fromLTRB(32, 56, 32, 32), onPressed: () => launch("tel:${user.phone}"),
child: Text( style: ElevatedButton.styleFrom(
'Aceptado', foregroundColor: const Color(0xFF2BA4EC),
style: TextStyle(fontSize: 32, color: Colors.green), 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),
),
), ),
), ),
), ),
Positioned( ElevatedButton(
top: -40, onPressed: () {},
child: Container( style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(16), foregroundColor: const Color(0xFF2BA4EC),
decoration: BoxDecoration( backgroundColor: Colors.white,
color: Colors.white, shape: const CircleBorder(
border: Border.all(color: Colors.green.shade50, width: 4), side: BorderSide(
shape: BoxShape.circle, color: Color(0xFF2BA4EC),
width: 2,
),
), ),
child: const Icon(Icons.check, color: Colors.green, size: 48),
), ),
) 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(
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();
}
Widget customMapButton(ServiceEntity service) {
if ((service.status == ServiceStatus.acepted ||
service.status == ServiceStatus.pending ||
service.status == ServiceStatus.active) &&
service.location == ServiceLocationPreferences.delivery) {
return Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 25,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
final Uri url = Uri.parse(
'https://www.google.com/maps/search/?api=1&query=${service.latitude},${service.longitude}');
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
},
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF2BA4EC),
backgroundColor: const Color(0xFF2BA4EC),
shape: const CircleBorder(
side: BorderSide(
color: Color(0xFF2BA4EC),
width: 2,
),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 20,
horizontal: 0,
),
child: Icon(
Icons.near_me,
size: 30,
color: Colors.white,
),
),
),
const SizedBox(width: 15),
SizedBox(
width: 230,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
service.address,
maxLines: 3,
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 15,
//center
),
),
service.aditionalAddress.isEmpty
? Container()
: Text(
service.aditionalAddress,
textAlign: TextAlign.start,
maxLines: 3,
style: const TextStyle(
fontSize: 15,
color: Colors.black54,
),
),
],
),
),
],
),
);
}
return const SizedBox();
}
Widget customMessageStatus(ServiceEntity service) {
// if (service.status == ServiceStatus.acepted) {
// 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: Text(
// 'Aceptado',
// 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.check, color: Colors.green, size: 48),
// ),
// )
// ],
// );
// }
if (service.status == ServiceStatus.cancelled) { if (service.status == ServiceStatus.cancelled) {
return Stack( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@@ -330,40 +506,40 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
); );
} }
if (service.status == ServiceStatus.active) { // if (service.status == ServiceStatus.active) {
return Stack( // return Stack(
alignment: AlignmentDirectional.topCenter, // alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none, // clipBehavior: Clip.none,
children: [ // children: [
Card( // Card(
color: Colors.green.shade50, // 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: Text( // child: Text(
'En proceso...', // 'En proceso...',
style: TextStyle(fontSize: 32, color: Colors.green), // style: TextStyle(fontSize: 32, color: Colors.green),
), // ),
), // ),
), // ),
Positioned( // Positioned(
top: -40, // top: -40,
child: Container( // child: Container(
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.green.shade50, width: 4),
shape: BoxShape.circle, // shape: BoxShape.circle,
), // ),
child: const Icon( // child: const Icon(
Icons.access_time_rounded, // Icons.access_time_rounded,
color: Colors.green, // color: Colors.green,
size: 48, // size: 48,
), // ),
), // ),
) // )
], // ],
); // );
} // }
if (service.status == ServiceStatus.completed) { if (service.status == ServiceStatus.completed) {
return Stack( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@@ -389,7 +565,7 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
child: const Icon( child: const Icon(
Icons.star, Icons.check_rounded,
color: Colors.green, color: Colors.green,
size: 48, size: 48,
), ),
+261 -108
View File
@@ -1,3 +1,4 @@
import 'package:community_material_icon/community_material_icon.dart';
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -9,6 +10,7 @@ import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
import 'package:prosappco/components/general_secondary_button.dart'; import 'package:prosappco/components/general_secondary_button.dart';
import 'package:service_repository/service_repository.dart'; import 'package:service_repository/service_repository.dart';
import 'package:setting_repository/setting_repository.dart'; import 'package:setting_repository/setting_repository.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:user_repository/user_repository.dart'; import 'package:user_repository/user_repository.dart';
class UserServiceScreen extends StatefulWidget { class UserServiceScreen extends StatefulWidget {
@@ -233,25 +235,29 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
], ],
), ),
), ),
ListTile(
leading: const Icon(Icons.near_me), customMapButton(service),
title: Text(
service.address,
style: TextStyle( // ListTile(
fontSize: 15, // leading: const Icon(Icons.near_me),
color: Colors.grey[600], // title: Text(
), // service.address,
), // style: TextStyle(
subtitle: service.aditionalAddress.isEmpty // fontSize: 15,
? null // color: Colors.grey[600],
: Text( // ),
service.aditionalAddress, // ),
style: TextStyle( // subtitle: service.aditionalAddress.isEmpty
fontSize: 15, // ? null
color: Colors.grey[600], // : Text(
), // service.aditionalAddress,
), // style: TextStyle(
), // fontSize: 15,
// color: Colors.grey[600],
// ),
// ),
// ),
service.description.isEmpty service.description.isEmpty
? const SizedBox() ? const SizedBox()
: Container( : Container(
@@ -268,7 +274,9 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
), ),
), ),
), ),
const SizedBox(height: 55), const SizedBox(height: 20),
customActionButtons(service, userInfo),
const SizedBox(height: 60),
customMessageStatus(service), customMessageStatus(service),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
@@ -303,6 +311,175 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
); );
} }
Widget customMapButton(ServiceEntity service) {
if ((service.status == ServiceStatus.acepted ||
service.status == ServiceStatus.active) &&
service.location == ServiceLocationPreferences.office) {
return Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 25,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
final Uri url = Uri.parse(
'https://www.google.com/maps/search/?api=1&query=${service.latitude},${service.longitude}');
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
},
style: ElevatedButton.styleFrom(
foregroundColor: const Color(0xFF2BA4EC),
backgroundColor: const Color(0xFF2BA4EC),
shape: const CircleBorder(
side: BorderSide(
color: Color(0xFF2BA4EC),
width: 2,
),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 20,
horizontal: 0,
),
child: Icon(
Icons.near_me,
size: 30,
color: Colors.white,
),
),
),
const SizedBox(width: 15),
SizedBox(
width: 230,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
service.address,
maxLines: 3,
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 15,
//center
),
),
service.aditionalAddress.isEmpty
? Container()
: Text(
service.aditionalAddress,
textAlign: TextAlign.start,
maxLines: 3,
style: const TextStyle(
fontSize: 15,
color: Colors.black54,
),
),
],
),
),
],
),
);
}
return const SizedBox();
}
Widget customActionButtons(ServiceEntity service, MyUser user) {
if (service.status == ServiceStatus.acepted ||
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),
),
),
),
),
ElevatedButton(
onPressed: () {},
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(
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();
}
Widget customMessageStatus(ServiceEntity service) { Widget customMessageStatus(ServiceEntity service) {
if (service.status == ServiceStatus.pending) { if (service.status == ServiceStatus.pending) {
return Stack( return Stack(
@@ -335,36 +512,36 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
], ],
); );
} }
if (service.status == ServiceStatus.acepted) { // if (service.status == ServiceStatus.acepted) {
return Stack( // return Stack(
alignment: AlignmentDirectional.topCenter, // alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none, // clipBehavior: Clip.none,
children: [ // children: [
Card( // Card(
color: Colors.green.shade50, // 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: Text( // child: Text(
'Aceptado', // 'Aceptado',
style: TextStyle(fontSize: 32, color: Colors.green), // style: TextStyle(fontSize: 32, color: Colors.green),
), // ),
), // ),
), // ),
Positioned( // Positioned(
top: -40, // top: -40,
child: Container( // child: Container(
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.green.shade50, width: 4),
shape: BoxShape.circle, // shape: BoxShape.circle,
), // ),
child: const Icon(Icons.check, color: Colors.green, size: 48), // child: const Icon(Icons.check, color: Colors.green, size: 48),
), // ),
) // )
], // ],
); // );
} // }
if (service.status == ServiceStatus.cancelled) { if (service.status == ServiceStatus.cancelled) {
return Stack( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@@ -428,40 +605,40 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
); );
} }
if (service.status == ServiceStatus.active) { // if (service.status == ServiceStatus.active) {
return Stack( // return Stack(
alignment: AlignmentDirectional.topCenter, // alignment: AlignmentDirectional.topCenter,
clipBehavior: Clip.none, // clipBehavior: Clip.none,
children: [ // children: [
Card( // Card(
color: Colors.green.shade50, // 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: Text( // child: Text(
'En proceso...', // 'En proceso...',
style: TextStyle(fontSize: 32, color: Colors.green), // style: TextStyle(fontSize: 32, color: Colors.green),
), // ),
), // ),
), // ),
Positioned( // Positioned(
top: -40, // top: -40,
child: Container( // child: Container(
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.green.shade50, width: 4),
shape: BoxShape.circle, // shape: BoxShape.circle,
), // ),
child: const Icon( // child: const Icon(
Icons.access_time_rounded, // Icons.access_time_rounded,
color: Colors.green, // color: Colors.green,
size: 48, // size: 48,
), // ),
), // ),
) // )
], // ],
); // );
} // }
if (service.status == ServiceStatus.completed) { if (service.status == ServiceStatus.completed) {
return Stack( return Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
@@ -514,30 +691,6 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
}, },
); );
} }
// if (service.status == ServiceStatus.acepted) {
// return GeneralSecondaryButton(
// label: 'Iniciar servicio',
// onPressed: () {
// final currentState = context.read<ServiceBloc>().state;
// if (currentState is ServiceLoaded) {
// context.read<ServiceBloc>().add(
// UpdateServiceStatus(widget.serviceId, ServiceStatus.active));
// }
// },
// );
// }
// if (service.status == ServiceStatus.active) {
// return GeneralSecondaryButton(
// label: 'Terminar servicio',
// onPressed: () {
// final currentState = context.read<ServiceBloc>().state;
// if (currentState is ServiceLoaded) {
// context.read<ServiceBloc>().add(UpdateServiceStatus(
// widget.serviceId, ServiceStatus.completed));
// }
// });
// }
return GeneralSecondaryButton( return GeneralSecondaryButton(
label: 'Volver', label: 'Volver',