score
This commit is contained in:
@@ -79,8 +79,8 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
.where((element) => removeDiacritics(element.myUser.name!)
|
||||
.toLowerCase()
|
||||
.contains(removeDiacritics(_searchController.text.toLowerCase())))
|
||||
.where((user) =>
|
||||
user.myUser.id != FirebaseAuth.instance.currentUser!.uid)
|
||||
// .where((user) =>
|
||||
// user.myUser.id != FirebaseAuth.instance.currentUser!.uid)
|
||||
.toList();
|
||||
// } else {
|
||||
// filteredUsers = state.users
|
||||
@@ -183,12 +183,19 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text(
|
||||
'${filteredUsers[index].myUser.name ?? ''}, ${filteredUsers[index].professionalInfo.profession}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${filteredUsers[index].myUser.name ?? ''}, ',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
filteredUsers[index].professionalInfo.profession,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
_disponibilidad(filteredUsers[index].professionalInfo),
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:prosappco/blocs/score_bloc/score_bloc.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class ProfessionalScoreListScreen extends StatefulWidget {
|
||||
const ProfessionalScoreListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfessionalScoreListScreen> createState() =>
|
||||
_ProfessionalScoreListScreenState();
|
||||
}
|
||||
|
||||
class _ProfessionalScoreListScreenState
|
||||
extends State<ProfessionalScoreListScreen> {
|
||||
late final ScoreBloc scoreBloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
scoreBloc = Injector.appInstance.get<ScoreBloc>();
|
||||
|
||||
scoreBloc.add(LoadScoresForProfessionalEvent(
|
||||
userId: FirebaseAuth.instance.currentUser!.uid));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => scoreBloc,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reputación'),
|
||||
),
|
||||
body: BlocBuilder<ScoreBloc, ScoreState>(
|
||||
builder: (context, scoreState) {
|
||||
if (scoreState is ScoresForUserLoaded) {
|
||||
return scoreState.scores.isEmpty
|
||||
? const Center(
|
||||
child: Text('No tienes calificaciones'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: scoreState.scores.length,
|
||||
itemBuilder: (_, index) {
|
||||
final scoreInfo = scoreState.scores[index];
|
||||
final score = scoreInfo.score;
|
||||
final user = scoreInfo.user;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
image: user.picture == null
|
||||
? null
|
||||
: DecorationImage(
|
||||
image: NetworkImage(user.picture!),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
child: user.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${user.name}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
'${score.createdAt.toDate().day}/${score.createdAt.toDate().month}/${score.createdAt.toDate().year}',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
'"${score.content.trim()}"',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
// icono de calificación
|
||||
trailing: Text(
|
||||
'⭐ ${score.score}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (_, __) => ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.grey[300],
|
||||
radius: 30,
|
||||
),
|
||||
title: Container(
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
subtitle: Container(
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:prosappco/blocs/score_bloc/score_bloc.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class UserScoreListScreen extends StatefulWidget {
|
||||
const UserScoreListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<UserScoreListScreen> createState() => _UserScoreListScreenState();
|
||||
}
|
||||
|
||||
class _UserScoreListScreenState extends State<UserScoreListScreen> {
|
||||
late final ScoreBloc scoreBloc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
scoreBloc = Injector.appInstance.get<ScoreBloc>();
|
||||
|
||||
scoreBloc.add(
|
||||
LoadScoresForUserEvent(userId: FirebaseAuth.instance.currentUser!.uid));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => scoreBloc,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Reputación'),
|
||||
),
|
||||
body: BlocBuilder<ScoreBloc, ScoreState>(
|
||||
builder: (context, scoreState) {
|
||||
if (scoreState is ScoresForUserLoaded) {
|
||||
return scoreState.scores.isEmpty
|
||||
? const Center(
|
||||
child: Text('No tienes calificaciones'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: scoreState.scores.length,
|
||||
itemBuilder: (_, index) {
|
||||
final scoreInfo = scoreState.scores[index];
|
||||
final score = scoreInfo.score;
|
||||
final user = scoreInfo.user;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(0.2)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
shape: BoxShape.circle,
|
||||
image: user.picture == null
|
||||
? null
|
||||
: DecorationImage(
|
||||
image: NetworkImage(user.picture!),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
child: user.picture == null
|
||||
? Icon(
|
||||
CupertinoIcons.person,
|
||||
color: Colors.grey.shade400,
|
||||
size: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${user.name}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
'${score.createdAt.toDate().day}/${score.createdAt.toDate().month}/${score.createdAt.toDate().year}',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
'"${score.content.trim()}"',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
// icono de calificación
|
||||
trailing: Text(
|
||||
'⭐ ${score.score}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (_, __) => ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.grey[300],
|
||||
radius: 30,
|
||||
),
|
||||
title: Container(
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
subtitle: Container(
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user