fix pov user y profesional
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:score_repository/score_repository.dart';
|
import 'package:score_repository/score_repository.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
part 'score_event.dart';
|
part 'score_event.dart';
|
||||||
part 'score_state.dart';
|
part 'score_state.dart';
|
||||||
@@ -17,14 +17,14 @@ class ScoreBloc extends Bloc<ScoreEvent, ScoreState> {
|
|||||||
try {
|
try {
|
||||||
emit(ScoreSuccess(_firebaseScoreRepository.getReputation()));
|
emit(ScoreSuccess(_firebaseScoreRepository.getReputation()));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("siteriespierdes1" + e.toString());
|
log(e.toString());
|
||||||
}
|
}
|
||||||
_firebaseScoreRepository.streamReputation().listen((event) {
|
_firebaseScoreRepository.streamReputation().listen((event) {
|
||||||
try {
|
try {
|
||||||
emit(ScoreSuccess(event));
|
emit(ScoreSuccess(event));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// log
|
// log
|
||||||
log("siteriespierdes2" + e.toString());
|
log(e.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class ScoreBloc extends Bloc<ScoreEvent, ScoreState> {
|
|||||||
try {
|
try {
|
||||||
await _firebaseScoreRepository.addComment(event.comment);
|
await _firebaseScoreRepository.addComment(event.comment);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("siteriespierdes3" + e.toString());
|
log(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,36 +228,37 @@ class GeneralDrawer extends StatelessWidget {
|
|||||||
: reputation.average;
|
: reputation.average;
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
trailing: const Icon(Icons.keyboard_arrow_right,
|
trailing: const Icon(Icons.keyboard_arrow_right,
|
||||||
color: Colors.black),
|
color: Colors.black),
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'Reputación',
|
'Reputación',
|
||||||
style: TextStyle(color: Colors.black),
|
style: TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
children: [
|
children: [
|
||||||
RatingBar.builder(
|
RatingBar.builder(
|
||||||
initialRating: calculoRating(average),
|
initialRating: calculoRating(average),
|
||||||
minRating: 1,
|
minRating: 1,
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
allowHalfRating: true,
|
allowHalfRating: true,
|
||||||
itemCount: 5,
|
itemCount: 5,
|
||||||
itemSize: 25,
|
itemSize: 25,
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
itemBuilder: (context, _) => const Icon(
|
itemBuilder: (context, _) => const Icon(
|
||||||
Icons.star,
|
Icons.star,
|
||||||
color: Color(0xFF2BA4EC),
|
color: Color(0xFF2BA4EC),
|
||||||
),
|
|
||||||
onRatingUpdate: (rating) {},
|
|
||||||
ignoreGestures: true,
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
onRatingUpdate: (rating) {},
|
||||||
Text(
|
ignoreGestures: true,
|
||||||
'${average.toStringAsFixed(1)} (${total.toString()})',
|
),
|
||||||
),
|
const SizedBox(width: 5),
|
||||||
],
|
Text(
|
||||||
));
|
'${average.toStringAsFixed(1)} (${total.toString()})',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:injector/injector.dart';
|
import 'package:injector/injector.dart';
|
||||||
import 'package:score_repository/score_repository.dart';
|
import 'package:score_repository/score_repository.dart';
|
||||||
|
|
||||||
class GeneralReputation extends StatelessWidget {
|
class GeneralReputation extends StatefulWidget {
|
||||||
final String userId;
|
final String userId;
|
||||||
final Widget Function(BuildContext, ReputationEntity) builder;
|
final Widget Function(BuildContext, ReputationEntity) builder;
|
||||||
|
|
||||||
@@ -13,10 +13,24 @@ class GeneralReputation extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<GeneralReputation> createState() => _GeneralReputationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GeneralReputationState extends State<GeneralReputation> {
|
||||||
|
late Future<ReputationEntity> reputation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
final repository = Injector.appInstance.get<FirebaseScoreRepository>();
|
final repository = Injector.appInstance.get<FirebaseScoreRepository>();
|
||||||
|
reputation = repository.getReputationByUserId(widget.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: repository.getReputationByUserId(userId),
|
future: reputation,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
@@ -24,7 +38,7 @@ class GeneralReputation extends StatelessWidget {
|
|||||||
return Text('Error: ${snapshot.error}');
|
return Text('Error: ${snapshot.error}');
|
||||||
} else {
|
} else {
|
||||||
final reputation = snapshot.data!;
|
final reputation = snapshot.data!;
|
||||||
return builder(context, reputation);
|
return widget.builder(context, reputation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ 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';
|
||||||
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:injector/injector.dart';
|
import 'package:injector/injector.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:prosappco/blocs/chat_bloc/chat_bloc.dart';
|
import 'package:prosappco/blocs/chat_bloc/chat_bloc.dart';
|
||||||
|
import 'package:prosappco/components/general_reputation.dart';
|
||||||
import 'package:prosappco/screens/user/user_view_profile_screen.dart';
|
import 'package:prosappco/screens/user/user_view_profile_screen.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';
|
||||||
@@ -59,7 +61,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
children: [
|
children: [
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _getUserAndProfessionalInfo(widget.service),
|
future: _getUserAndProfessionalInfo(widget.service),
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<dynamic>> snapshot) {
|
builder: (BuildContext context,
|
||||||
|
AsyncSnapshot<List<dynamic>> snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else {
|
} else {
|
||||||
@@ -105,15 +108,73 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
subtitle: const Text(
|
subtitle: widget.service.userId ==
|
||||||
'Rating: 5.0',
|
FirebaseAuth.instance.currentUser!.uid
|
||||||
// _disponibilidad(
|
? GeneralReputation(
|
||||||
// filteredUsers[index].professionalInfo),
|
userId: widget.service.professionalId,
|
||||||
style: TextStyle(
|
builder: (context, reputation) {
|
||||||
fontSize: 13,
|
final average = reputation.averagePro;
|
||||||
color: Colors.blue,
|
final total = reputation.totalPro;
|
||||||
),
|
|
||||||
),
|
return Row(
|
||||||
|
children: [
|
||||||
|
RatingBar.builder(
|
||||||
|
initialRating:
|
||||||
|
calculoRating(average),
|
||||||
|
minRating: 1,
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
allowHalfRating: true,
|
||||||
|
itemCount: 5,
|
||||||
|
itemSize: 25,
|
||||||
|
maxRating: 5,
|
||||||
|
itemBuilder: (context, _) =>
|
||||||
|
const Icon(
|
||||||
|
Icons.star,
|
||||||
|
color: Color(0xFF2BA4EC),
|
||||||
|
),
|
||||||
|
onRatingUpdate: (rating) {},
|
||||||
|
ignoreGestures: true,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
'${average.toStringAsFixed(1)} (${total.toString()})',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
})
|
||||||
|
: GeneralReputation(
|
||||||
|
userId: widget.service.userId,
|
||||||
|
builder: (context, reputation) {
|
||||||
|
final average = reputation.average;
|
||||||
|
final total = reputation.total;
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
RatingBar.builder(
|
||||||
|
initialRating:
|
||||||
|
calculoRating(average),
|
||||||
|
minRating: 1,
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
allowHalfRating: true,
|
||||||
|
itemCount: 5,
|
||||||
|
itemSize: 25,
|
||||||
|
maxRating: 5,
|
||||||
|
itemBuilder: (context, _) =>
|
||||||
|
const Icon(
|
||||||
|
Icons.star,
|
||||||
|
color: Color(0xFF2BA4EC),
|
||||||
|
),
|
||||||
|
onRatingUpdate: (rating) {},
|
||||||
|
ignoreGestures: true,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
'${average.toStringAsFixed(1)} (${total.toString()})',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -318,11 +379,28 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
final MyUser? userInfo;
|
final MyUser? userInfo;
|
||||||
|
|
||||||
if (FirebaseAuth.instance.currentUser!.uid == service.userId) {
|
if (FirebaseAuth.instance.currentUser!.uid == service.userId) {
|
||||||
userInfo = await userRepo.getMyUser(service.userId);
|
|
||||||
} else {
|
|
||||||
userInfo = await userRepo.getMyUser(service.professionalId);
|
userInfo = await userRepo.getMyUser(service.professionalId);
|
||||||
|
} else {
|
||||||
|
userInfo = await userRepo.getMyUser(service.userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [userInfo];
|
return [userInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double calculoRating(double average) {
|
||||||
|
String numeroString = average.toString();
|
||||||
|
List<String> partes = numeroString.split('.');
|
||||||
|
int parteEntera = int.parse(partes[0]);
|
||||||
|
int parteFraccionaria = partes.length > 1 ? int.parse(partes[1]) : 0;
|
||||||
|
|
||||||
|
if (parteFraccionaria >= 3) {
|
||||||
|
parteFraccionaria = 5;
|
||||||
|
} else {
|
||||||
|
parteFraccionaria = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unir la parte entera y fraccionaria y convertirlo nuevamente a double
|
||||||
|
double resultado = double.parse('$parteEntera.$parteFraccionaria');
|
||||||
|
return resultado;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
|||||||
import 'package:injector/injector.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:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
import 'package:prosappco/components/general_reputation.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';
|
||||||
@@ -24,11 +25,20 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
double _rating = 1.0;
|
double _rating = 1.0;
|
||||||
TextEditingController commentController = TextEditingController();
|
TextEditingController commentController = TextEditingController();
|
||||||
late Future<List<dynamic>> _userInfoFuture;
|
late Future<List<dynamic>> _userInfoFuture;
|
||||||
|
late bool isProfessional;
|
||||||
|
late String userId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_userInfoFuture = _getUserAndProfessionalInfo(widget.service);
|
_userInfoFuture = _getUserAndProfessionalInfo(widget.service);
|
||||||
|
isProfessional =
|
||||||
|
FirebaseAuth.instance.currentUser!.uid == widget.service.userId
|
||||||
|
? true
|
||||||
|
: false;
|
||||||
|
|
||||||
|
userId =
|
||||||
|
isProfessional ? widget.service.professionalId : widget.service.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -56,48 +66,155 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
} else {
|
} else {
|
||||||
final userInfo = snapshot.data![0] as MyUser;
|
final userInfo = snapshot.data![0] as MyUser;
|
||||||
|
|
||||||
return Padding(
|
return SizedBox(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
width: double.infinity,
|
||||||
child: ListTile(
|
child: Stack(
|
||||||
leading: Container(
|
alignment: Alignment.center,
|
||||||
width: 60,
|
children: [
|
||||||
height: 60,
|
Column(
|
||||||
decoration: BoxDecoration(
|
mainAxisSize: MainAxisSize.min,
|
||||||
color: Colors.grey.shade300,
|
children: [
|
||||||
shape: BoxShape.circle,
|
Container(
|
||||||
image: userInfo.picture == null
|
width: 95,
|
||||||
? null
|
height: 95,
|
||||||
: DecorationImage(
|
decoration: BoxDecoration(
|
||||||
image: NetworkImage(
|
color: Colors.grey.shade300,
|
||||||
userInfo.picture ?? ''),
|
shape: BoxShape.circle,
|
||||||
fit: BoxFit.contain,
|
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: 50,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'${userInfo.name}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
GeneralReputation(
|
||||||
|
userId: userId,
|
||||||
|
builder: (BuildContext context,
|
||||||
|
ReputationEntity reputation) {
|
||||||
|
final double average;
|
||||||
|
|
||||||
|
if (isProfessional) {
|
||||||
|
average = reputation.averagePro;
|
||||||
|
} else {
|
||||||
|
average = reputation.average;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Positioned(
|
||||||
|
top: 3,
|
||||||
|
right: MediaQuery.of(context).size.width *
|
||||||
|
0.3,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10,
|
||||||
|
vertical: 3,
|
||||||
),
|
),
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
child: userInfo.picture == null
|
color: Colors.white,
|
||||||
? Icon(
|
borderRadius:
|
||||||
CupertinoIcons.person,
|
BorderRadius.circular(20),
|
||||||
color: Colors.grey.shade400,
|
boxShadow: [
|
||||||
size: 40,
|
BoxShadow(
|
||||||
)
|
color:
|
||||||
: null,
|
Colors.black.withOpacity(0.1),
|
||||||
),
|
spreadRadius: 1,
|
||||||
title: Text(
|
blurRadius: 2,
|
||||||
userInfo.name ?? '',
|
offset: const Offset(
|
||||||
overflow: TextOverflow.ellipsis,
|
0,
|
||||||
style: const TextStyle(
|
1,
|
||||||
fontSize: 15,
|
),
|
||||||
fontWeight: FontWeight.w600,
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
subtitle: const Text(
|
child: Row(
|
||||||
'Rating: 5.0',
|
mainAxisSize: MainAxisSize.min,
|
||||||
style: TextStyle(
|
children: [
|
||||||
fontSize: 13,
|
const Icon(
|
||||||
color: Colors.blue,
|
Icons.star,
|
||||||
),
|
color: Colors.yellow,
|
||||||
),
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
average.toStringAsFixed(2),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
// child: 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: Text(
|
||||||
|
// userInfo.name ?? '',
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 15,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// subtitle: const Text(
|
||||||
|
// 'Rating: 5.0',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 13,
|
||||||
|
// color: Colors.blue,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -129,6 +246,16 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
},
|
},
|
||||||
ignoreGestures: false,
|
ignoreGestures: false,
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
child: Text(
|
||||||
|
customMessage(_rating),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: Color(0xFF2BA4EC),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 40, vertical: 40),
|
horizontal: 40, vertical: 40),
|
||||||
@@ -226,6 +353,26 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String customMessage(double rating) {
|
||||||
|
if (rating > 4.0) {
|
||||||
|
return '¡Excelente! 👏🌟';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rating < 2.0) {
|
||||||
|
return '¡Malo! 😔❌';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rating <= 4.0 && rating >= 3.0) {
|
||||||
|
return '¡Bueno! 👍😊';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rating < 3.0 && rating >= 2.0) {
|
||||||
|
return '¡Regular! 😐🔄';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<dynamic>> _getUserAndProfessionalInfo(
|
Future<List<dynamic>> _getUserAndProfessionalInfo(
|
||||||
ServiceEntity service) async {
|
ServiceEntity service) async {
|
||||||
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
|
||||||
@@ -233,9 +380,9 @@ class _ScoreScreenState extends State<ScoreScreen> {
|
|||||||
final MyUser? userInfo;
|
final MyUser? userInfo;
|
||||||
|
|
||||||
if (FirebaseAuth.instance.currentUser!.uid == service.userId) {
|
if (FirebaseAuth.instance.currentUser!.uid == service.userId) {
|
||||||
userInfo = await userRepo.getMyUser(service.userId);
|
|
||||||
} else {
|
|
||||||
userInfo = await userRepo.getMyUser(service.professionalId);
|
userInfo = await userRepo.getMyUser(service.professionalId);
|
||||||
|
} else {
|
||||||
|
userInfo = await userRepo.getMyUser(service.userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [userInfo];
|
return [userInfo];
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import 'package:injector/injector.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:professional_repository/professional_repository.dart';
|
import 'package:professional_repository/professional_repository.dart';
|
||||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
import 'package:prosappco/components/general_reputation.dart';
|
||||||
import 'package:prosappco/components/general_secondary_button.dart';
|
import 'package:prosappco/components/general_secondary_button.dart';
|
||||||
import 'package:prosappco/screens/chat/chat_screen.dart';
|
import 'package:prosappco/screens/chat/chat_screen.dart';
|
||||||
import 'package:prosappco/screens/score/score_screen.dart';
|
import 'package:prosappco/screens/score/score_screen.dart';
|
||||||
|
import 'package:score_repository/score_repository.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:url_launcher/url_launcher.dart';
|
||||||
@@ -75,49 +77,126 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
SizedBox(
|
||||||
leading: Container(
|
width: double.infinity,
|
||||||
width: 60,
|
child: Stack(
|
||||||
height: 60,
|
alignment: Alignment.center,
|
||||||
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: [
|
children: [
|
||||||
Text(
|
Column(
|
||||||
'${userInfo.name}',
|
mainAxisSize: MainAxisSize.min,
|
||||||
style: const TextStyle(
|
children: [
|
||||||
fontWeight: FontWeight.bold),
|
Container(
|
||||||
|
width: 95,
|
||||||
|
height: 95,
|
||||||
|
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: 50,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'${userInfo.name}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
GeneralReputation(
|
||||||
Text(
|
userId: service.userId,
|
||||||
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
builder: (BuildContext context,
|
||||||
style: TextStyle(
|
ReputationEntity reputation) {
|
||||||
color: Colors.grey[600],
|
final average = reputation.average;
|
||||||
),
|
|
||||||
|
return Positioned(
|
||||||
|
top: 3,
|
||||||
|
right: MediaQuery.of(context)
|
||||||
|
.size
|
||||||
|
.width *
|
||||||
|
0.3,
|
||||||
|
child: Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10,
|
||||||
|
vertical: 3,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(20),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black
|
||||||
|
.withOpacity(0.1),
|
||||||
|
spreadRadius: 1,
|
||||||
|
blurRadius: 2,
|
||||||
|
offset: const Offset(
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize:
|
||||||
|
MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.star,
|
||||||
|
color: Colors.yellow,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
average
|
||||||
|
.toStringAsFixed(2),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: const Text('Rating: 5.0'),
|
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(
|
margin: const EdgeInsets.only(
|
||||||
@@ -376,19 +455,19 @@ class _ProfessionalServiceScreenState extends State<ProfessionalServiceScreen> {
|
|||||||
),
|
),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 20,
|
vertical: 15,
|
||||||
horizontal: 0,
|
horizontal: 0,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.near_me,
|
Icons.near_me,
|
||||||
size: 30,
|
size: 25,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 230,
|
width: MediaQuery.of(context).size.width * 0.6,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ import 'package:injector/injector.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:professional_repository/professional_repository.dart';
|
import 'package:professional_repository/professional_repository.dart';
|
||||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
import 'package:prosappco/components/drawer_reputation.dart';
|
||||||
|
import 'package:prosappco/components/general_reputation.dart';
|
||||||
import 'package:prosappco/screens/chat/chat_screen.dart';
|
import 'package:prosappco/screens/chat/chat_screen.dart';
|
||||||
import 'package:prosappco/components/general_secondary_button.dart';
|
import 'package:prosappco/components/general_secondary_button.dart';
|
||||||
import 'package:prosappco/screens/score/score_screen.dart';
|
import 'package:prosappco/screens/score/score_screen.dart';
|
||||||
|
import 'package:score_repository/score_repository.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:url_launcher/url_launcher.dart';
|
||||||
@@ -76,50 +79,174 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
SizedBox(
|
||||||
leading: Container(
|
width: double.infinity,
|
||||||
width: 60,
|
child: Stack(
|
||||||
height: 60,
|
alignment: Alignment.center,
|
||||||
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: [
|
children: [
|
||||||
Text(
|
Column(
|
||||||
'${userInfo.name}',
|
mainAxisSize: MainAxisSize.min,
|
||||||
style: const TextStyle(
|
children: [
|
||||||
fontWeight: FontWeight.bold),
|
Container(
|
||||||
|
width: 95,
|
||||||
|
height: 95,
|
||||||
|
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: 50,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'${userInfo.name}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
GeneralReputation(
|
||||||
Text(
|
userId: service.professionalId,
|
||||||
'${DateFormat('dd MMMM', 'es').format(DateTime.parse(service.day))} - ${ScheduleEntity.getFormatTime(service.range1Hour1)}',
|
builder: (BuildContext context,
|
||||||
style: TextStyle(
|
ReputationEntity reputation) {
|
||||||
color: Colors.grey[600],
|
final average =
|
||||||
),
|
reputation.averagePro;
|
||||||
|
|
||||||
|
return Positioned(
|
||||||
|
top: 3,
|
||||||
|
right: MediaQuery.of(context)
|
||||||
|
.size
|
||||||
|
.width *
|
||||||
|
0.3,
|
||||||
|
child: Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10,
|
||||||
|
vertical: 3,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(20),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black
|
||||||
|
.withOpacity(0.1),
|
||||||
|
spreadRadius: 1,
|
||||||
|
blurRadius: 2,
|
||||||
|
offset: const Offset(
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize:
|
||||||
|
MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.star,
|
||||||
|
color: Colors.yellow,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
average
|
||||||
|
.toStringAsFixed(2),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: const Text('Rating: 5.0'),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// 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(
|
Container(
|
||||||
margin: const EdgeInsets.only(
|
margin: const EdgeInsets.only(
|
||||||
left: 40,
|
left: 40,
|
||||||
@@ -345,19 +472,19 @@ class _UserServiceScreenState extends State<UserServiceScreen> {
|
|||||||
),
|
),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 20,
|
vertical: 15,
|
||||||
horizontal: 0,
|
horizontal: 0,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.near_me,
|
Icons.near_me,
|
||||||
size: 30,
|
size: 25,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 230,
|
width: MediaQuery.of(context).size.width * 0.6,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class FirebaseScoreRepository {
|
|||||||
final snap = await reputationsCollection.doc(userId).get();
|
final snap = await reputationsCollection.doc(userId).get();
|
||||||
return ReputationEntity.fromDocument(snap.data()!);
|
return ReputationEntity.fromDocument(snap.data()!);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("siteriespierdes4" + e.toString());
|
log(e.toString());
|
||||||
return const ReputationEntity(
|
return const ReputationEntity(
|
||||||
total: 0,
|
total: 0,
|
||||||
average: 0,
|
average: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user