lading chat

This commit is contained in:
Felipe
2024-04-23 14:51:15 -05:00
parent 34135b25e1
commit 76be1f1f1a
6 changed files with 366 additions and 195 deletions
+234 -116
View File
@@ -8,7 +8,6 @@ import 'package:injector/injector.dart';
import 'package:intl/intl.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:service_repository/service_repository.dart';
import 'package:user_repository/user_repository.dart';
@@ -26,6 +25,8 @@ class _ChatScreenState extends State<ChatScreen> {
final TextEditingController _messageController = TextEditingController();
final FocusNode _messageFocusNode = FocusNode();
List<dynamic>? _userInfo;
@override
void initState() {
super.initState();
@@ -37,6 +38,12 @@ class _ChatScreenState extends State<ChatScreen> {
userId: widget.service.userId,
professionalId: widget.service.professionalId,
));
_getUserAndProfessionalInfo(widget.service).then((userInfo) {
setState(() {
_userInfo = userInfo;
});
});
}
@override
@@ -60,125 +67,236 @@ class _ChatScreenState extends State<ChatScreen> {
return Column(
children: [
FutureBuilder(
future: _getUserAndProfessionalInfo(widget.service),
future: _userInfo != null ? Future.value(_userInfo) : null,
builder: (BuildContext context,
AsyncSnapshot<List<dynamic>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else {
if (snapshot.hasError) {
return Center(
child: Text('Error inesperado: ${snapshot.error}'),
);
} else {
final userInfo = snapshot.data![0] as MyUser;
return Container(
padding: const EdgeInsets.symmetric(vertical: 8),
color: const Color(0xFFD6F4FF),
alignment: Alignment.topCenter,
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,
AsyncSnapshot<List<dynamic>?> snapshot) {
if (_userInfo != null) {
final userInfo = _userInfo![0] as MyUser;
return Container(
padding: const EdgeInsets.symmetric(vertical: 8),
color: const Color(0xFFD6F4FF),
alignment: Alignment.topCenter,
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,
),
),
title: Text(
userInfo.name ?? '',
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
subtitle: widget.service.userId ==
FirebaseAuth.instance.currentUser!.uid
? GeneralReputation(
userId: widget.service.professionalId,
builder: (context, reputation) {
final average = reputation.averagePro;
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()})',
),
],
);
},
),
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: widget.service.userId ==
FirebaseAuth.instance.currentUser!.uid
? GeneralReputation(
userId: widget.service.professionalId,
builder: (context, reputation) {
final average = reputation.averagePro;
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()})',
),
],
);
},
),
),
);
} else {
// Indicador de carga opcional si se desea mostrar mientras se carga la información por primera vez.
return const Center(child: CircularProgressIndicator());
}
// if (snapshot.connectionState == ConnectionState.waiting) {
// return const Center(child: CircularProgressIndicator());
// } else {
// if (snapshot.hasError) {
// return Center(
// child: Text('Error inesperado: ${snapshot.error}'),
// );
// } else {
// final userInfo = snapshot.data![0] as MyUser;
// return Container(
// padding: const EdgeInsets.symmetric(vertical: 8),
// color: const Color(0xFFD6F4FF),
// alignment: Alignment.topCenter,
// 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: widget.service.userId ==
// FirebaseAuth.instance.currentUser!.uid
// ? GeneralReputation(
// userId: widget.service.professionalId,
// builder: (context, reputation) {
// final average = reputation.averagePro;
// 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()})',
// ),
// ],
// );
// },
// ),
// ),
// );
// }
// }
},
),
Expanded(
@@ -73,14 +73,14 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
if (state is ProfessionalListSuccess) {
final List<UserProfessional> filteredUsers;
// TODO : encaso de filtro dañado
// TODO: encaso de filtro dañado
// if (_searchController.text.isNotEmpty) {
filteredUsers = state.users
.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
@@ -148,35 +148,38 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 15),
child: Column(
children: [
Row(
children: [
const Expanded(
child: Text(
'Servicio a domicilio',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w500,
color: Colors.black,
Visibility(
visible: settings?.domicilios ?? false,
child: Row(
children: [
const Expanded(
child: Text(
'Servicio a domicilio',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w500,
color: Colors.black,
),
),
),
),
Switch(
value: deliveryValue,
onChanged: (value) {
setState(() {
deliveryValue = value;
if (settings?.domicilios == true) {
Switch(
value: deliveryValue,
onChanged: (value) {
setState(() {
deliveryValue = value;
if (!deliveryValue) {
officeValue = true;
if (settings?.domicilios == true) {
deliveryValue = value;
if (!deliveryValue) {
officeValue = true;
}
} else {
deliveryValue = false;
}
} else {
deliveryValue = false;
}
});
},
),
],
});
},
),
],
),
),
Row(
children: [
@@ -9,6 +9,7 @@ import cloud_firestore
import file_selector_macos
import firebase_auth
import firebase_core
import firebase_messaging
import firebase_storage
import flutter_local_notifications
import geolocator_apple
@@ -22,6 +23,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
+79 -31
View File
@@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: _flutterfire_internals
sha256: "4eec93681221723a686ad580c2e7d960e1017cf1a4e0a263c2573c2c6b0bf5cd"
sha256: "99b5dec989287c1aca71bf27339e0022b4dc3679225f442fb75790ef44535bf8"
url: "https://pub.dev"
source: hosted
version: "1.3.25"
version: "1.3.30"
analyzer:
dependency: transitive
description:
@@ -291,26 +291,26 @@ packages:
dependency: transitive
description:
name: firebase_auth_platform_interface
sha256: f294ceef40409a36c819a14280ca864fe487b44033e5276443377c66cb448310
sha256: "0edf2466247d18cd2111c4784e43bce49d39cc4d052c122e8060630a136b5a09"
url: "https://pub.dev"
source: hosted
version: "7.1.8"
version: "7.2.3"
firebase_auth_web:
dependency: transitive
description:
name: firebase_auth_web
sha256: "1f231da900fe7ff9f2974f8adcbdb3363c410c24725978afa5dc33e1e7e62e06"
sha256: "86da840704099da55b306ff3587a8aa72b1f541acfba266072263a896fd4b807"
url: "https://pub.dev"
source: hosted
version: "5.9.8"
version: "5.11.2"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
sha256: "53316975310c8af75a96e365f9fccb67d1c544ef0acdbf0d88bbe30eedd1c4f9"
sha256: "6b1152a5af3b1cfe7e45309e96fc1aa14873f410f7aadb3878aa7812acfa7531"
url: "https://pub.dev"
source: hosted
version: "2.27.0"
version: "2.30.0"
firebase_core_platform_interface:
dependency: transitive
description:
@@ -323,10 +323,34 @@ packages:
dependency: transitive
description:
name: firebase_core_web
sha256: c8e1d59385eee98de63c92f961d2a7062c5d9a65e7f45bdc7f1b0b205aab2492
sha256: c8b02226e548f35aace298e2bb2e6c24e34e8a203d614e742bb1146e5a4ad3c8
url: "https://pub.dev"
source: hosted
version: "2.11.5"
version: "2.15.0"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
sha256: d01e454837b1ce221791682051fd584e4827bdff5fdad3595708a917db01ad0a
url: "https://pub.dev"
source: hosted
version: "14.8.2"
firebase_messaging_platform_interface:
dependency: transitive
description:
name: firebase_messaging_platform_interface
sha256: e459eb4eb0aef67833843f474e8697e091086d71aa186253b93eb141eec3ee2f
url: "https://pub.dev"
source: hosted
version: "4.5.32"
firebase_messaging_web:
dependency: "direct main"
description:
name: firebase_messaging_web
sha256: f0600d25c1c710338d568d200164fa791ce8d390d141d04408908615834a0db6
url: "https://pub.dev"
source: hosted
version: "3.8.2"
firebase_storage:
dependency: transitive
description:
@@ -458,7 +482,7 @@ packages:
source: hosted
version: "4.0.1"
flutter_test:
dependency: "direct dev"
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
@@ -555,14 +579,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.3"
get:
dependency: "direct main"
description:
name: get
sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a"
url: "https://pub.dev"
source: hosted
version: "4.6.5"
glob:
dependency: transitive
description:
@@ -795,6 +811,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.4"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
@@ -831,26 +871,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.0"
mime:
dependency: transitive
description:
@@ -911,10 +951,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider_linux:
dependency: transitive
description:
@@ -1306,6 +1346,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
watcher:
dependency: transitive
description:
@@ -1315,13 +1363,13 @@ packages:
source: hosted
version: "1.1.0"
web:
dependency: transitive
dependency: "direct main"
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.5.1"
webview_flutter:
dependency: "direct main"
description:
@@ -1387,5 +1435,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0 <4.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.10.0"
+20 -20
View File
@@ -11,6 +11,10 @@ environment:
dependencies:
animate_do: ^3.0.2
animated_splash_screen: ^1.3.0
chat_repository:
path: packages/chat_repository
city_repository:
path: packages/city_repository
cloud_firestore: ^4.15.4
community_material_icon: ^5.9.55
cupertino_icons: ^1.0.2
@@ -19,6 +23,8 @@ dependencies:
file_picker: ^5.3.2
firebase_auth: ^4.17.4
firebase_core: ^2.25.4
firebase_messaging: ^14.8.2
firebase_messaging_web: ^3.8.2
flutter:
sdk: flutter
flutter_animate: null
@@ -28,25 +34,34 @@ dependencies:
flutter_local_notifications: ^14.1.1
flutter_localizations:
sdk: flutter
flutter_otp_text_field: ^1.1.1
flutter_polyline_points: ^2.0.0
flutter_rating_bar: ^4.0.1
flutter_otp_text_field: ^1.1.1
otp_timer_button: ^1.1.0
font_awesome_flutter: ^10.4.0
geocoding: ^2.1.0
geolocator: ^9.0.2
get: null
google_maps_flutter: ^2.5.0
google_sign_in: ^6.1.4
http: ^1.1.0
image_picker: ^1.0.7
injector: ^3.0.0
intl_phone_field: ^3.2.0
intl: ^0.18.1
intl_phone_field: ^3.2.0
location: ^5.0.3
otp_timer_button: ^1.1.0
package_info_plus: ^4.2.0
profession_repository:
path: packages/profession_repository
professional_repository:
path: packages/professional_repository
provider: ^6.0.5
responsive_builder: ^0.7.0
score_repository:
path: packages/score_repository
service_repository:
path: packages/service_repository
setting_repository:
path: packages/setting_repository
shared_preferences: ^2.0.10
shimmer: ^3.0.0
table_calendar: null
@@ -54,26 +69,11 @@ dependencies:
url_launcher: ^6.1.10
user_repository:
path: packages/user_repository
city_repository:
path: packages/city_repository
score_repository:
path: packages/score_repository
chat_repository:
path: packages/chat_repository
setting_repository:
path: packages/setting_repository
professional_repository:
path: packages/professional_repository
profession_repository:
path: packages/profession_repository
service_repository:
path: packages/service_repository
web: ^0.5.1
webview_flutter: ^4.4.1
dev_dependencies:
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
flutter:
uses-material-design: true