lista de servicios
This commit is contained in:
+2
-6
@@ -30,12 +30,8 @@ class MainApp extends StatelessWidget {
|
|||||||
create: (context) => Injector.appInstance.get<ProfessionalBloc>(),
|
create: (context) => Injector.appInstance.get<ProfessionalBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<ProfessionalProfileBloc>(
|
BlocProvider<ProfessionalProfileBloc>(
|
||||||
create: (context) =>
|
create: (context) => Injector.appInstance.get<ProfessionalProfileBloc>(),
|
||||||
Injector.appInstance.get<ProfessionalProfileBloc>(),
|
)
|
||||||
),
|
|
||||||
BlocProvider<ServiceBloc>(
|
|
||||||
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
child: BlocBuilder<MyUserBloc, MyUserState>(
|
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
|||||||
@@ -4,21 +4,31 @@ import 'package:cloud_firestore/cloud_firestore.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:professional_repository/professional_repository.dart';
|
||||||
|
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
|
import 'package:user_repository/user_repository.dart';
|
||||||
|
|
||||||
part 'service_event.dart';
|
part 'service_event.dart';
|
||||||
part 'service_state.dart';
|
part 'service_state.dart';
|
||||||
|
|
||||||
class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||||
final FirebaseServiceRepository _serviceRepository;
|
final FirebaseServiceRepository _serviceRepository;
|
||||||
|
final UserRepository _userRepository;
|
||||||
|
final FirebaseProfessionalRepository _professionalRepository;
|
||||||
|
|
||||||
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
ServiceBloc({
|
||||||
: _serviceRepository = serviceRepository,
|
required FirebaseServiceRepository serviceRepository,
|
||||||
|
required UserRepository userRepository,
|
||||||
|
required FirebaseProfessionalRepository professionRepository,
|
||||||
|
}) : _serviceRepository = serviceRepository,
|
||||||
|
_userRepository = userRepository,
|
||||||
|
_professionalRepository = professionRepository,
|
||||||
super(CreateServiceInitial()) {
|
super(CreateServiceInitial()) {
|
||||||
on<CreateService>(_onCreateService);
|
on<CreateService>(_onCreateService);
|
||||||
on<LoadService>(_onLoadService);
|
on<LoadService>(_onLoadService);
|
||||||
on<UpdateServiceStatus>(_onUpdateServiceStatus);
|
on<UpdateServiceStatus>(_onUpdateServiceStatus);
|
||||||
|
on<LoadServicesForUser>(_onLoadServicesForUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
||||||
@@ -66,6 +76,40 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onLoadServicesForUser(
|
||||||
|
LoadServicesForUser event, Emitter<ServiceState> emit) async {
|
||||||
|
try {
|
||||||
|
final servicesStream =
|
||||||
|
_serviceRepository.getServicesForUser(event.userId);
|
||||||
|
|
||||||
|
await for (var services in servicesStream) {
|
||||||
|
final professionalIds = services.map((e) => e.professionalId);
|
||||||
|
final List<MyUser> users =
|
||||||
|
await _userRepository.getUsersFromIds(professionalIds);
|
||||||
|
|
||||||
|
final usersDir = {for (var e in users) e.id: e};
|
||||||
|
|
||||||
|
final List<ProfessionalEntity> professionsList =
|
||||||
|
await _professionalRepository
|
||||||
|
.getProfessionsFromIds(professionalIds);
|
||||||
|
|
||||||
|
final professionsDir = {for (var e in professionsList) e.id: e};
|
||||||
|
|
||||||
|
final servicesInfo = services.map((e) {
|
||||||
|
return ServiceInfoUI(
|
||||||
|
service: e,
|
||||||
|
user: usersDir[e.professionalId]!,
|
||||||
|
professional: professionsDir[e.professionalId]!);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
emit(ServicesForUserLoaded(servicesInfo));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log(e.toString());
|
||||||
|
emit(CreateServiceFailure());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _onUpdateServiceStatus(
|
void _onUpdateServiceStatus(
|
||||||
UpdateServiceStatus event, Emitter<ServiceState> emit) async {
|
UpdateServiceStatus event, Emitter<ServiceState> emit) async {
|
||||||
try {
|
try {
|
||||||
@@ -79,3 +123,12 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ServiceInfoUI {
|
||||||
|
final ServiceEntity service;
|
||||||
|
final MyUser user;
|
||||||
|
final ProfessionalEntity professional;
|
||||||
|
|
||||||
|
ServiceInfoUI(
|
||||||
|
{required this.service, required this.user, required this.professional});
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ class UpdateServiceStatus extends ServiceEvent {
|
|||||||
List<Object> get props => [serviceId, newStatus];
|
List<Object> get props => [serviceId, newStatus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LoadServicesForUser extends ServiceEvent {
|
||||||
|
final String userId;
|
||||||
|
|
||||||
|
const LoadServicesForUser(this.userId);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [userId];
|
||||||
|
}
|
||||||
|
|
||||||
class CreateService extends ServiceEvent {
|
class CreateService extends ServiceEvent {
|
||||||
final String professionalId;
|
final String professionalId;
|
||||||
final bool? professionalScored;
|
final bool? professionalScored;
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ class ServiceLoaded extends ServiceState {
|
|||||||
List<Object> get props => [service];
|
List<Object> get props => [service];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ServicesForUserLoaded extends ServiceState {
|
||||||
|
final List<ServiceInfoUI> services;
|
||||||
|
|
||||||
|
const ServicesForUserLoaded(this.services);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [services];
|
||||||
|
}
|
||||||
|
|
||||||
class CreateServiceInitial extends ServiceState {}
|
class CreateServiceInitial extends ServiceState {}
|
||||||
|
|
||||||
class CreateServiceFailure extends ServiceState {}
|
class CreateServiceFailure extends ServiceState {}
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ class AppDI {
|
|||||||
injector.get<FirebaseProfessionalRepository>()),
|
injector.get<FirebaseProfessionalRepository>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
injector.registerSingleton<ServiceBloc>(() => ServiceBloc(
|
injector.registerDependency<ServiceBloc>(
|
||||||
serviceRepository: injector.get<FirebaseServiceRepository>()));
|
() => ServiceBloc(
|
||||||
|
serviceRepository: injector.get<FirebaseServiceRepository>(),
|
||||||
|
userRepository: injector.get<UserRepository>(),
|
||||||
|
professionRepository: injector.get<FirebaseProfessionalRepository>(),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:injector/injector.dart';
|
||||||
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
|
||||||
class UserServiceListScreen extends StatefulWidget {
|
class UserServiceListScreen extends StatefulWidget {
|
||||||
const UserServiceListScreen({super.key});
|
const UserServiceListScreen({super.key});
|
||||||
@@ -8,20 +12,61 @@ class UserServiceListScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
class _UserServiceListScreenState extends State<UserServiceListScreen> {
|
||||||
|
late final ServiceBloc serviceBloc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
serviceBloc = Injector.appInstance.get<ServiceBloc>();
|
||||||
|
|
||||||
|
serviceBloc
|
||||||
|
.add(LoadServicesForUser(FirebaseAuth.instance.currentUser!.uid));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return BlocProvider<ServiceBloc>(
|
||||||
appBar: AppBar(
|
create: (context) => serviceBloc,
|
||||||
title: const Text('Mis Servicios'),
|
child: Scaffold(
|
||||||
),
|
appBar: AppBar(
|
||||||
body: ListView.builder(
|
title: const Text('Mis Servicios'),
|
||||||
itemCount: 10,
|
),
|
||||||
itemBuilder: (_, __) {
|
body: BlocBuilder<ServiceBloc, ServiceState>(
|
||||||
return ListTile(
|
builder: (context, serviceState) {
|
||||||
onTap: () {},
|
if (serviceState is ServicesForUserLoaded) {
|
||||||
title: Text('Servicio ${__ + 1}'),
|
return serviceState.services.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: Text('No tienes servicios'),
|
||||||
|
)
|
||||||
|
: ListView.builder(
|
||||||
|
itemCount: serviceState.services.length,
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final serviceInfo = serviceState.services[index];
|
||||||
|
final user = serviceInfo.user;
|
||||||
|
final professional = serviceInfo.professional;
|
||||||
|
final service = serviceInfo.service;
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
onTap: () {},
|
||||||
|
title: Column(
|
||||||
|
children: [
|
||||||
|
Text(user.name ?? ''),
|
||||||
|
Text(professional.identification),
|
||||||
|
Text(service.address),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,218 +41,224 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return BlocProvider<ServiceBloc>(
|
||||||
appBar: AppBar(
|
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
||||||
title: const Text('Servicio'),
|
child: Scaffold(
|
||||||
),
|
appBar: AppBar(
|
||||||
body: BlocBuilder<ServiceBloc, ServiceState>(
|
title: const Text('Servicio'),
|
||||||
builder: (context, state) {
|
),
|
||||||
if (state is ServiceLoaded) {
|
body: BlocBuilder<ServiceBloc, ServiceState>(
|
||||||
final service = state.service;
|
builder: (context, state) {
|
||||||
return FutureBuilder(
|
if (state is ServiceLoaded) {
|
||||||
future: _getUserAndProfessionalInfo(service),
|
final service = state.service;
|
||||||
builder: (BuildContext context,
|
return FutureBuilder(
|
||||||
AsyncSnapshot<List<dynamic>> snapshot) {
|
future: _getUserAndProfessionalInfo(service),
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
builder: (BuildContext context, AsyncSnapshot<List<dynamic>> snapshot) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
} else {
|
return const Center(child: CircularProgressIndicator());
|
||||||
if (snapshot.hasError) {
|
|
||||||
return Center(
|
|
||||||
child: Text('Error inesperado: ${snapshot.error}'),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
final userInfo = snapshot.data![0] as MyUser;
|
if (snapshot.hasError) {
|
||||||
final professionalInfo =
|
return Center(
|
||||||
snapshot.data![1] as ProfessionalEntity;
|
child: Text('Error inesperado: ${snapshot.error}'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final userInfo = snapshot.data![0] as MyUser;
|
||||||
|
final professionalInfo =
|
||||||
|
snapshot.data![1] as ProfessionalEntity;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
width: 60,
|
width: 60,
|
||||||
height: 60,
|
height: 60,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey.shade300,
|
color: Colors.grey.shade300,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
image: userInfo.picture == null
|
image: userInfo.picture == null
|
||||||
? null
|
? null
|
||||||
: DecorationImage(
|
: DecorationImage(
|
||||||
image: NetworkImage(userInfo.picture!),
|
image: NetworkImage(userInfo.picture!),
|
||||||
fit: BoxFit.contain,
|
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,
|
||||||
ListTile(
|
color: Colors.grey.shade400,
|
||||||
leading: const Icon(Icons.near_me),
|
size: 40,
|
||||||
title: Text(
|
)
|
||||||
service.address,
|
: null,
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 15, color: Colors.grey[600]),
|
title: Row(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
subtitle: service.aditionalAddress.isEmpty
|
children: [
|
||||||
? null
|
Text(
|
||||||
: Text(
|
'${userInfo.name}',
|
||||||
service.aditionalAddress,
|
style: const TextStyle(
|
||||||
style: TextStyle(
|
fontWeight: FontWeight.bold),
|
||||||
fontSize: 15, color: Colors.grey[600]),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 5),
|
||||||
service.description.isEmpty
|
Text(
|
||||||
? const SizedBox()
|
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
||||||
: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
|
||||||
child: Text(
|
|
||||||
'"${service.description.trim()}"',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
fontStyle: FontStyle.italic,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
Expanded(
|
),
|
||||||
child: customMessageStatus(service),
|
subtitle: const Text('Rating: 5.0'),
|
||||||
),
|
),
|
||||||
customButton(service, context),
|
Container(
|
||||||
const SizedBox(height: 20),
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: customMessageStatus(service),
|
||||||
|
),
|
||||||
|
customButton(service, context),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
BlocProvider.of<ServiceBloc>(context)
|
||||||
BlocProvider.of<ServiceBloc>(context)
|
.add(LoadService(widget.serviceId));
|
||||||
.add(LoadService(widget.serviceId));
|
return const Center(
|
||||||
return const Center(
|
child: CircularProgressIndicator(),
|
||||||
child: CircularProgressIndicator(),
|
);
|
||||||
);
|
}
|
||||||
}
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -366,14 +372,12 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
return '\$${formatter.format(number)}';
|
return '\$${formatter.format(number)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<dynamic>> _getUserAndProfessionalInfo(
|
Future<List<dynamic>> _getUserAndProfessionalInfo(ServiceEntity service) async {
|
||||||
ServiceEntity service) async {
|
|
||||||
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
||||||
final userInfo = await userRepo.getMyUser(service.professionalId);
|
final userInfo = await userRepo.getMyUser(service.professionalId);
|
||||||
|
|
||||||
final professionalRepo = FirebaseProfessionalRepository();
|
final professionalRepo = FirebaseProfessionalRepository();
|
||||||
final professionalInfo =
|
final professionalInfo = await professionalRepo.getProInfo(service.professionalId);
|
||||||
await professionalRepo.getProInfo(service.professionalId);
|
|
||||||
|
|
||||||
return [userInfo, professionalInfo];
|
return [userInfo, professionalInfo];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class UserServicesScreen extends StatelessWidget {
|
|
||||||
const UserServicesScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Mis servicios'),
|
|
||||||
),
|
|
||||||
body: const Center(
|
|
||||||
child: Text('Servicios'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+17
@@ -189,4 +189,21 @@ class FirebaseProfessionalRepository {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<ProfessionalEntity>> getProfessionsFromIds(
|
||||||
|
Iterable<String> ids) async {
|
||||||
|
try {
|
||||||
|
// Realizar una consulta única para obtener la información de todos los usuarios
|
||||||
|
final querySnapshot = await professionalCollection
|
||||||
|
.where(FieldPath.documentId, whereIn: ids)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
return querySnapshot.docs
|
||||||
|
.map((e) => ProfessionalEntity.fromDocument(e.data()))
|
||||||
|
.toList();
|
||||||
|
} catch (e) {
|
||||||
|
log('getProfessionsFromIds ${e.toString()}');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ class FirebaseServiceRepository {
|
|||||||
return docRef.id;
|
return docRef.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> updateServiceStatus(
|
||||||
|
String serviceId, ServiceStatus newStatus) async {
|
||||||
|
await serviceCollection
|
||||||
|
.doc(serviceId)
|
||||||
|
.update({'status': enumToIntService(newStatus)});
|
||||||
|
}
|
||||||
|
|
||||||
Stream<ServiceEntity> getService(String serviceId) {
|
Stream<ServiceEntity> getService(String serviceId) {
|
||||||
return serviceCollection.doc(serviceId).snapshots().map((snapshot) {
|
return serviceCollection.doc(serviceId).snapshots().map((snapshot) {
|
||||||
if (snapshot.exists) {
|
if (snapshot.exists) {
|
||||||
@@ -21,10 +28,12 @@ class FirebaseServiceRepository {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateServiceStatus(
|
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
|
||||||
String serviceId, ServiceStatus newStatus) async {
|
return serviceCollection
|
||||||
await serviceCollection
|
.where('user_id', isEqualTo: userId)
|
||||||
.doc(serviceId)
|
.snapshots()
|
||||||
.update({'status': enumToIntService(newStatus)});
|
.map((querySnapshot) => querySnapshot.docs
|
||||||
|
.map((doc) => ServiceEntity.fromDocument(doc.data()))
|
||||||
|
.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -403,4 +403,20 @@ class FirebaseUserRepository implements UserRepository {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids) async {
|
||||||
|
try {
|
||||||
|
// Realizar una consulta única para obtener la información de todos los usuarios
|
||||||
|
final querySnapshot =
|
||||||
|
await usersCollection.where(FieldPath.documentId, whereIn: ids).get();
|
||||||
|
|
||||||
|
return querySnapshot.docs
|
||||||
|
.map((e) => MyUser.fromEntity(MyUserEntity.fromDocument(e.data())))
|
||||||
|
.toList();
|
||||||
|
} catch (e) {
|
||||||
|
log('getUsersFromIds ${e.toString()}');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ abstract class UserRepository {
|
|||||||
Future<void> createUser(MyUser myUser);
|
Future<void> createUser(MyUser myUser);
|
||||||
|
|
||||||
Future<List<MyUser>> getUsersProfessionalActive();
|
Future<List<MyUser>> getUsersProfessionalActive();
|
||||||
|
|
||||||
|
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UpdatePassworErros { credentialsWrong, userNotFound, unknown }
|
enum UpdatePassworErros { credentialsWrong, userNotFound, unknown }
|
||||||
|
|||||||
Reference in New Issue
Block a user