servicio
This commit is contained in:
@@ -6,17 +6,13 @@ import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
import 'package:prosappco/components/general_primary_button.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
|
||||
class ServiceScreen extends StatefulWidget {
|
||||
// final String serviceId;
|
||||
const ServiceScreen({
|
||||
super.key,
|
||||
// required this.serviceId
|
||||
});
|
||||
final String serviceId;
|
||||
const ServiceScreen({Key? key, required this.serviceId}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ServiceScreen> createState() => _ServiceScreenState();
|
||||
@@ -71,182 +67,217 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
image: userInfo.picture == null
|
||||
? null
|
||||
: DecorationImage(
|
||||
image: NetworkImage(userInfo.picture!),
|
||||
fit: BoxFit.contain,
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
image: userInfo.picture == null
|
||||
? null
|
||||
: DecorationImage(
|
||||
image: NetworkImage(
|
||||
userInfo.picture!),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: userInfo.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${userInfo.name}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: const Text('Rating: 5.0'),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(
|
||||
left: 40, right: 40, top: 20, bottom: 20),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFD6F4FF),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(1, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 27,
|
||||
color: Colors.black54,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
service.location ==
|
||||
ServiceLocationPreferences.delivery
|
||||
? const Text(
|
||||
'Servicio a su domicilio.',
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 14),
|
||||
)
|
||||
: const Text(
|
||||
'Servicio en sitio / consultorio',
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: settings?.tarifas ?? false,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
formatCurrency(
|
||||
int.tryParse(service.rate) ?? 0),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 25),
|
||||
),
|
||||
const Text('Tarifa de consulta'),
|
||||
const SizedBox(height: 15),
|
||||
const Text(
|
||||
'Metodos de pago',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
professionalInfo.paymentMethods.datafono ||
|
||||
professionalInfo.paymentMethods.nequi ||
|
||||
professionalInfo
|
||||
.paymentMethods.transferencia
|
||||
? Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods.datafono,
|
||||
child: const Chip(
|
||||
label: Text('Datafono')),
|
||||
),
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods.nequi,
|
||||
child: const Chip(
|
||||
label: Text('Nequi')),
|
||||
),
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods.transferencia,
|
||||
child: const Chip(
|
||||
label: Text(
|
||||
'Transferencia Bancaria')),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const Text(
|
||||
'No hay metodos de pago registrados',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black45,
|
||||
child: userInfo.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${userInfo.name}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.near_me),
|
||||
title: Text(
|
||||
service.address,
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.grey[600]),
|
||||
),
|
||||
subtitle: service.aditionalAddress.isEmpty
|
||||
? null
|
||||
: Text(
|
||||
service.aditionalAddress,
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: Colors.grey[600]),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: const Text('Rating: 5.0'),
|
||||
),
|
||||
),
|
||||
service.description.isEmpty
|
||||
? const SizedBox()
|
||||
: Container(
|
||||
alignment: Alignment.center,
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.8,
|
||||
child: Text(
|
||||
'"${service.description.trim()}"',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
fontStyle: FontStyle.italic,
|
||||
Container(
|
||||
margin: const EdgeInsets.only(
|
||||
left: 40,
|
||||
right: 40,
|
||||
top: 20,
|
||||
bottom: 20),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFD6F4FF),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(1, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 27,
|
||||
color: Colors.black54,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
service.location ==
|
||||
ServiceLocationPreferences
|
||||
.delivery
|
||||
? const Text(
|
||||
'Servicio a s domicilio.',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14),
|
||||
)
|
||||
: const Text(
|
||||
'Servicio en sitio / consultorio',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: customMessageStatus(service),
|
||||
Visibility(
|
||||
visible: settings?.tarifas ?? false,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
formatCurrency(
|
||||
int.tryParse(service.rate) ?? 0),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 25),
|
||||
),
|
||||
const Text('Tarifa de consulta'),
|
||||
const SizedBox(height: 15),
|
||||
const Text(
|
||||
'Metodos de pago',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
professionalInfo
|
||||
.paymentMethods.datafono ||
|
||||
professionalInfo
|
||||
.paymentMethods.nequi ||
|
||||
professionalInfo.paymentMethods
|
||||
.transferencia
|
||||
? Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods
|
||||
.datafono,
|
||||
child: const Chip(
|
||||
label:
|
||||
Text('Datafono')),
|
||||
),
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods.nequi,
|
||||
child: const Chip(
|
||||
label: Text('Nequi')),
|
||||
),
|
||||
Visibility(
|
||||
visible: professionalInfo
|
||||
.paymentMethods
|
||||
.transferencia,
|
||||
child: const Chip(
|
||||
label: Text(
|
||||
'Transferencia Bancaria')),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const Text(
|
||||
'No hay metodos de pago registrados',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black45,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.near_me),
|
||||
title: Text(
|
||||
service.address,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]),
|
||||
),
|
||||
subtitle: service.aditionalAddress.isEmpty
|
||||
? null
|
||||
: Text(
|
||||
service.aditionalAddress,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
service.description.isEmpty
|
||||
? const SizedBox()
|
||||
: Container(
|
||||
alignment: Alignment.center,
|
||||
width: MediaQuery.of(context)
|
||||
.size
|
||||
.width *
|
||||
0.8,
|
||||
child: Text(
|
||||
'"${service.description.trim()}"',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
customMessageStatus(service),
|
||||
|
||||
// customButton(service, context),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
height: 1,
|
||||
thickness: 0.5,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 15,
|
||||
),
|
||||
child: customButton(service, context),
|
||||
),
|
||||
customButton(service, context),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -254,8 +285,8 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// BlocProvider.of<ServiceBloc>(context)
|
||||
// .add(LoadService(widget.serviceId));
|
||||
BlocProvider.of<ServiceBloc>(context)
|
||||
.add(LoadService(widget.serviceId));
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
@@ -341,31 +372,69 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
GeneralPrimaryButton customButton(
|
||||
ServiceEntity service, BuildContext context) {
|
||||
ElevatedButton customButton(ServiceEntity service, BuildContext context) {
|
||||
if (service.status == ServiceStatus.pending) {
|
||||
return GeneralPrimaryButton(
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
final currentState = context.read<ServiceBloc>().state;
|
||||
if (currentState is ServiceLoaded) {
|
||||
// context.read<ServiceBloc>().add(
|
||||
// UpdateServiceStatus(
|
||||
// widget.serviceId,
|
||||
// ServiceStatus.cancelled,
|
||||
// ),
|
||||
// );
|
||||
context.read<ServiceBloc>().add(
|
||||
UpdateServiceStatus(
|
||||
widget.serviceId,
|
||||
ServiceStatus.cancelled,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
color: Colors.red,
|
||||
label: 'Cancelar Servicio',
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.error,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'Cancelar servicio',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return GeneralPrimaryButton(
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
final currentState = context.read<ServiceBloc>().state;
|
||||
if (currentState is ServiceLoaded) {
|
||||
context.read<ServiceBloc>().add(
|
||||
UpdateServiceStatus(
|
||||
widget.serviceId,
|
||||
ServiceStatus.cancelled,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
label: 'Volver',
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'Volver',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -378,12 +447,21 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
Future<List<dynamic>> _getUserAndProfessionalInfo(
|
||||
ServiceEntity service) async {
|
||||
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
||||
final userInfo = await userRepo.getMyUser(service.professionalId);
|
||||
|
||||
final professionalRepo = FirebaseProfessionalRepository();
|
||||
final professionalInfo =
|
||||
await professionalRepo.getProInfo(service.professionalId);
|
||||
if (FirebaseAuth.instance.currentUser!.uid == service.professionalId) {
|
||||
final userInfo = await userRepo.getMyUser(service.userId);
|
||||
final professionalInfo =
|
||||
await professionalRepo.getProInfo(service.professionalId);
|
||||
|
||||
return [userInfo, professionalInfo];
|
||||
return [userInfo, professionalInfo];
|
||||
} else {
|
||||
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
||||
final userInfo = await userRepo.getMyUser(service.professionalId);
|
||||
|
||||
final professionalInfo =
|
||||
await professionalRepo.getProInfo(service.professionalId);
|
||||
|
||||
return [userInfo, professionalInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user