scored true
This commit is contained in:
@@ -33,6 +33,7 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
on<LoadServicesHistoryForUser>(_onLoadServicesHistoryForUser);
|
on<LoadServicesHistoryForUser>(_onLoadServicesHistoryForUser);
|
||||||
on<LoadServicesHistoryForProfessional>(
|
on<LoadServicesHistoryForProfessional>(
|
||||||
_onLoadServicesHistoryForProfessional);
|
_onLoadServicesHistoryForProfessional);
|
||||||
|
on<UpdateProfessionalScored>(_onUpdateProfessionalScored);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
||||||
@@ -235,6 +236,18 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
emit(CreateServiceFailure());
|
emit(CreateServiceFailure());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onUpdateProfessionalScored(
|
||||||
|
UpdateProfessionalScored event, Emitter<ServiceState> emit) async {
|
||||||
|
try {
|
||||||
|
emit(CreateServiceLoading());
|
||||||
|
await _serviceRepository.setProfessionalScored(event.serviceId);
|
||||||
|
emit(ProfessionalScoredUpdated());
|
||||||
|
} catch (e) {
|
||||||
|
log(e.toString());
|
||||||
|
emit(CreateServiceFailure());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ServiceInfoUI {
|
class ServiceInfoUI {
|
||||||
|
|||||||
@@ -62,6 +62,24 @@ class LoadServicesHistoryForUser extends ServiceEvent {
|
|||||||
List<Object> get props => [userId];
|
List<Object> get props => [userId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LoadServicesByDay extends ServiceEvent {
|
||||||
|
final String day;
|
||||||
|
|
||||||
|
const LoadServicesByDay(this.day);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [day];
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateProfessionalScored extends ServiceEvent {
|
||||||
|
final String serviceId;
|
||||||
|
|
||||||
|
const UpdateProfessionalScored(this.serviceId);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [serviceId];
|
||||||
|
}
|
||||||
|
|
||||||
class CreateService extends ServiceEvent {
|
class CreateService extends ServiceEvent {
|
||||||
final String professionalId;
|
final String professionalId;
|
||||||
final bool? professionalScored;
|
final bool? professionalScored;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ class ServiceLoaded extends ServiceState {
|
|||||||
List<Object> get props => [service];
|
List<Object> get props => [service];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ServicesForUserLoaded extends ServiceState {
|
class ServicesForUserLoaded extends ServiceState {
|
||||||
final List<ServiceInfoUI> services;
|
final List<ServiceInfoUI> services;
|
||||||
|
|
||||||
@@ -49,3 +48,5 @@ class ServiceStatusUpdated extends ServiceState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [newStatus];
|
List<Object> get props => [newStatus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProfessionalScoredUpdated extends ServiceState {}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import 'package:flutter/cupertino.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:flutter_rating_bar/flutter_rating_bar.dart';
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||||
|
import 'package:injector/injector.dart';
|
||||||
import 'package:prosappco/blocs/score_bloc/score_bloc.dart';
|
import 'package:prosappco/blocs/score_bloc/score_bloc.dart';
|
||||||
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
import 'package:score_repository/score_repository.dart';
|
import 'package:score_repository/score_repository.dart';
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
import 'package:user_repository/user_repository.dart';
|
import 'package:user_repository/user_repository.dart';
|
||||||
@@ -102,7 +104,7 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Text(
|
const Text(
|
||||||
'Calificación',
|
'Califica el servicio',
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@@ -155,12 +157,16 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
thickness: 0.5,
|
thickness: 0.5,
|
||||||
),
|
),
|
||||||
Padding(
|
BlocProvider<ServiceBloc>(
|
||||||
|
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 10,
|
vertical: 10,
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
),
|
),
|
||||||
child: FilledButton(
|
child: BlocBuilder<ServiceBloc, ServiceState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final CommentEntity comment = widget.service.userId ==
|
final CommentEntity comment = widget.service.userId ==
|
||||||
FirebaseAuth.instance.currentUser!.uid
|
FirebaseAuth.instance.currentUser!.uid
|
||||||
@@ -170,7 +176,7 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
isFromUser: true,
|
isFromUser: true,
|
||||||
score: _rating,
|
score: _rating,
|
||||||
destinationId: widget.service.professionalId,
|
destinationId: widget.service.professionalId,
|
||||||
content: commentController.text,
|
content: commentController.text.trim(),
|
||||||
createdAt: Timestamp.now(),
|
createdAt: Timestamp.now(),
|
||||||
)
|
)
|
||||||
: CommentEntity(
|
: CommentEntity(
|
||||||
@@ -179,12 +185,18 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
isFromUser: false,
|
isFromUser: false,
|
||||||
score: _rating,
|
score: _rating,
|
||||||
destinationId: widget.service.userId,
|
destinationId: widget.service.userId,
|
||||||
content: commentController.text,
|
content: commentController.text.trim(),
|
||||||
createdAt: Timestamp.now(),
|
createdAt: Timestamp.now(),
|
||||||
);
|
);
|
||||||
|
|
||||||
BlocProvider.of<ScoreBloc>(context)
|
BlocProvider.of<ScoreBloc>(context)
|
||||||
.add(SendScoreEvent(comment: comment));
|
.add(SendScoreEvent(comment: comment));
|
||||||
|
|
||||||
|
context
|
||||||
|
.read<ServiceBloc>()
|
||||||
|
.add(UpdateProfessionalScored(widget.service.id!));
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
@@ -204,6 +216,9 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -517,41 +517,8 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service.status == ServiceStatus.completed) {
|
if (service.status == ServiceStatus.completed &&
|
||||||
if (service.userScored) {
|
service.userScored == false) {
|
||||||
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(
|
|
||||||
'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.check_rounded,
|
|
||||||
color: Colors.green,
|
|
||||||
size: 48,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: AlignmentDirectional.topCenter,
|
alignment: AlignmentDirectional.topCenter,
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
@@ -566,11 +533,11 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
'Completado',
|
'Completado',
|
||||||
style: TextStyle(fontSize: 32, color: Colors.green),
|
style: TextStyle(fontSize: 32, color: Colors.green),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
const Text(
|
const Text(
|
||||||
'Califica el servicio',
|
'Califica el servicio',
|
||||||
style: TextStyle(fontSize: 28, color: Colors.green),
|
style: TextStyle(fontSize: 20, color: Colors.green),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -582,7 +549,24 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Calificar'),
|
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,
|
||||||
|
width: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
child: const Text(
|
||||||
|
'Calificar',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -607,6 +591,45 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|||||||
@@ -647,7 +647,8 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
// ],
|
// ],
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
if (service.status == ServiceStatus.completed) {
|
if (service.status == ServiceStatus.completed &&
|
||||||
|
service.professionalScored == false) {
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: AlignmentDirectional.topCenter,
|
alignment: AlignmentDirectional.topCenter,
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
@@ -662,11 +663,11 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
'Completado',
|
'Completado',
|
||||||
style: TextStyle(fontSize: 32, color: Colors.green),
|
style: TextStyle(fontSize: 32, color: Colors.green),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
const Text(
|
const Text(
|
||||||
'Califica el servicio',
|
'Califica el servicio',
|
||||||
style: TextStyle(fontSize: 28, color: Colors.green),
|
style: TextStyle(fontSize: 20, color: Colors.green),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
@@ -678,7 +679,64 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Calificar'),
|
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,
|
||||||
|
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.professionalScored == 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),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -68,6 +68,29 @@ class FirebaseServiceRepository {
|
|||||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// actualizar professionalScored a true
|
||||||
|
|
||||||
|
Future<void> setProfessionalScored(String serviceId) {
|
||||||
|
return serviceCollection
|
||||||
|
.doc(serviceId)
|
||||||
|
.update({'professional_scored': true});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setUserScored(String serviceId) {
|
||||||
|
return serviceCollection.doc(serviceId).update({'user_scored': true});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: NEW
|
||||||
|
Stream<List<ServiceEntity>> getServicesByDay(String day) {
|
||||||
|
return serviceCollection
|
||||||
|
.where('day', isEqualTo: day)
|
||||||
|
.where('status', whereIn: [0, 1, 2, 3])
|
||||||
|
.snapshots()
|
||||||
|
.map((querySnapshot) => querySnapshot.docs
|
||||||
|
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||||
|
.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user