fix chat
This commit is contained in:
@@ -28,19 +28,19 @@ class ChatModel {
|
|||||||
messages.add(MessageModel(
|
messages.add(MessageModel(
|
||||||
user: data['user'] ?? '',
|
user: data['user'] ?? '',
|
||||||
content: data['content'] ?? '',
|
content: data['content'] ?? '',
|
||||||
timestamp: (data['timestamp'] as Timestamp).toDate(),
|
timestamp: (data['timestamp'] ?? '' as Timestamp).toDate(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatModel(
|
return ChatModel(
|
||||||
messages: messages,
|
messages: messages,
|
||||||
professional_id: snapshot.get('professional_id'),
|
professional_id: snapshot.get('professional_id') ?? '',
|
||||||
user_id: snapshot.get('user_id'),
|
user_id: snapshot.get('user_id') ?? '',
|
||||||
user: fillUserModel
|
user: fillUserModel
|
||||||
? await UserModel.getUser(snapshot.get('user_id'))
|
? await UserModel.getUser(snapshot.get('user_id') ?? '')
|
||||||
: null,
|
: null,
|
||||||
professional: fillUserModel
|
professional: fillUserModel
|
||||||
? await UserModel.getUser(snapshot.get('professional_id'))
|
? await UserModel.getUser(snapshot.get('professional_id') ?? '')
|
||||||
: null,
|
: null,
|
||||||
id: snapshot.id);
|
id: snapshot.id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -58,12 +58,14 @@ Future<List<Event>> getByProId(String day) async {
|
|||||||
.collection('services')
|
.collection('services')
|
||||||
.where('professional_id', isEqualTo: uid)
|
.where('professional_id', isEqualTo: uid)
|
||||||
.where('day', isEqualTo: day.toString())
|
.where('day', isEqualTo: day.toString())
|
||||||
|
.where('status', isEqualTo: 'aprobado')
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
List<Event> eventos = [];
|
List<Event> eventos = [];
|
||||||
for (var element in snapshot.docs) {
|
for (var element in snapshot.docs) {
|
||||||
final event = Event.fromJson(element.data());
|
final event = Event.fromJson(element.data());
|
||||||
event.scoresModel = await ScoresModel.scoreTo(event.userId, false, false);
|
event.scoresModel = await ScoresModel.scoreTo(event.userId, false, false);
|
||||||
|
event.id = element.id;
|
||||||
eventos.add(event);
|
eventos.add(event);
|
||||||
}
|
}
|
||||||
print('eventos $eventos');
|
print('eventos $eventos');
|
||||||
|
|||||||
+36
-16
@@ -236,23 +236,43 @@ class _CitaScreenState extends State<CitaScreen> {
|
|||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await FirebaseFirestore.instance
|
if (widget.evento.status != 'pendiente') {
|
||||||
.collection('chats')
|
await FirebaseFirestore.instance
|
||||||
.doc(widget.evento.id)
|
.collection('chats')
|
||||||
.set({
|
.doc(widget.evento.id)
|
||||||
'professional_id': widget.evento.professionalId,
|
.set({
|
||||||
'user_id': widget.evento.userId
|
'professional_id': widget.evento.professionalId,
|
||||||
}, SetOptions(merge: true)).catchError((error) =>
|
'user_id': widget.evento.userId,
|
||||||
print('Error al crear el documento: $error'));
|
'message': [],
|
||||||
|
}, SetOptions(merge: true)).catchError((error) =>
|
||||||
|
print('Error al crear el documento: $error'));
|
||||||
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return ChatScreen(eventoId: widget.evento.id);
|
return ChatScreen(eventoId: widget.evento.id);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
final snackBar = SnackBar(
|
||||||
|
backgroundColor: Colors.blue,
|
||||||
|
content: const Text(
|
||||||
|
'Primero acepta la solicitud',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
elevation: 8.0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: const Color(0xFF2BA4EC),
|
foregroundColor: const Color(0xFF2BA4EC),
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import 'package:community_material_icon/community_material_icon.dart';
|
import 'package:community_material_icon/community_material_icon.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
import 'package:prosappco/src/components/photo_view.dart';
|
import 'package:prosappco/src/components/photo_view.dart';
|
||||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||||
import 'package:prosappco/src/models/chat_model.dart';
|
import 'package:prosappco/src/models/chat_model.dart';
|
||||||
import 'package:prosappco/src/models/event_model.dart';
|
import 'package:prosappco/src/models/event_model.dart';
|
||||||
import 'package:prosappco/src/models/user_model.dart';
|
|
||||||
import 'package:prosappco/src/screens/chat.dart';
|
import 'package:prosappco/src/screens/chat.dart';
|
||||||
|
|
||||||
class MessagesScreen extends StatefulWidget {
|
class MessagesScreen extends StatefulWidget {
|
||||||
@@ -55,52 +53,47 @@ class _MessagesScreenState extends State<MessagesScreen> {
|
|||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final user = list[index].user;
|
if (list[index].messages.isNotEmpty) {
|
||||||
final lastMsg = list[index].messages.last;
|
final user = list[index].user;
|
||||||
|
final lastMsg = list[index].messages.last;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
(user?.name ?? ''),
|
(user?.name ?? ''),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'" ${lastMsg.content} "',
|
'" ${lastMsg.content} "',
|
||||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
style: const TextStyle(fontStyle: FontStyle.italic),
|
||||||
),
|
),
|
||||||
leading: ReferencePhoto(
|
leading: ReferencePhoto(
|
||||||
ref: user?.photo,
|
ref: user?.photo,
|
||||||
size: 55,
|
size: 55,
|
||||||
sizeCircle: 60,
|
sizeCircle: 60,
|
||||||
),
|
),
|
||||||
trailing: Column(
|
trailing: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.keyboard_arrow_right,
|
Icons.keyboard_arrow_right,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
|
||||||
Text(
|
|
||||||
lastMsg.timestamp.day >= DateTime.now().day
|
|
||||||
? DateFormat('h:mm a').format(lastMsg.timestamp)
|
|
||||||
: DateFormat('dd/MM/yyyy', 'es')
|
|
||||||
.format(lastMsg.timestamp),
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.grey, fontSize: 12),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Event.getEventById(list[index].id).then((value) {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return ChatScreen(eventoId: list[index].id);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
});
|
),
|
||||||
},
|
onTap: () {
|
||||||
);
|
Event.getEventById(list[index].id).then((value) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ChatScreen(eventoId: list[index].id);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -54,52 +54,55 @@ class _MessagesUserScreenState extends State<MessagesUserScreen> {
|
|||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final pro = list[index].professional;
|
if (list[index].messages.isNotEmpty) {
|
||||||
final lastMsg = list[index].messages.last;
|
final pro = list[index].professional;
|
||||||
|
final lastMsg = list[index].messages.last;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
(pro?.name ?? ''),
|
(pro?.name ?? ''),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'" ${lastMsg.content} "',
|
'" ${lastMsg.content} "',
|
||||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
style: const TextStyle(fontStyle: FontStyle.italic),
|
||||||
),
|
),
|
||||||
leading: ReferencePhoto(
|
leading: ReferencePhoto(
|
||||||
ref: pro?.photo,
|
ref: pro?.photo,
|
||||||
size: 55,
|
size: 55,
|
||||||
sizeCircle: 60,
|
sizeCircle: 60,
|
||||||
),
|
),
|
||||||
trailing: Column(
|
trailing: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.keyboard_arrow_right,
|
Icons.keyboard_arrow_right,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
|
||||||
Text(
|
|
||||||
lastMsg.timestamp.day >= DateTime.now().day
|
|
||||||
? DateFormat('h:mm a').format(lastMsg.timestamp)
|
|
||||||
: DateFormat('dd/MM/yyyy', 'es')
|
|
||||||
.format(lastMsg.timestamp),
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.grey, fontSize: 12),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
Event.getEventById(list[index].id).then((value) {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return ChatScreen(eventoId: list[index].id);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
Text(
|
||||||
});
|
lastMsg.timestamp.day >= DateTime.now().day
|
||||||
},
|
? DateFormat('h:mm a').format(lastMsg.timestamp)
|
||||||
);
|
: DateFormat('dd/MM/yyyy', 'es')
|
||||||
|
.format(lastMsg.timestamp),
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.grey, fontSize: 12),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Event.getEventById(list[index].id).then((value) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ChatScreen(eventoId: list[index].id);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:prosappco/src/components/drawer_professional.dart';
|
import 'package:prosappco/src/components/drawer_professional.dart';
|
||||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||||
import 'package:prosappco/src/models/event_model.dart';
|
import 'package:prosappco/src/models/event_model.dart';
|
||||||
import 'package:prosappco/src/screens/cita.dart';
|
|
||||||
|
|
||||||
class MyServicesProScreen extends StatefulWidget {
|
class MyServicesProScreen extends StatefulWidget {
|
||||||
MyServicesProScreen({super.key});
|
MyServicesProScreen({super.key});
|
||||||
@@ -75,14 +74,16 @@ class _MyServicesProScreenState extends State<MyServicesProScreen> {
|
|||||||
? Colors.blue[100]
|
? Colors.blue[100]
|
||||||
: Colors.red[100],
|
: Colors.red[100],
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
print(event.id);
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
// Navigator.push(
|
||||||
builder: (BuildContext context) {
|
// context,
|
||||||
return CitaScreen(evento: event);
|
// CupertinoPageRoute(
|
||||||
},
|
// builder: (BuildContext context) {
|
||||||
),
|
// return CitaScreen(evento: event);
|
||||||
);
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
leading: event.status == 'aprobado'
|
leading: event.status == 'aprobado'
|
||||||
? const Icon(
|
? const Icon(
|
||||||
|
|||||||
@@ -409,6 +409,8 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
_profesionalController.text =
|
_profesionalController.text =
|
||||||
profesional.name.toString();
|
profesional.name.toString();
|
||||||
|
|
||||||
|
professionalId = profesional.id;
|
||||||
|
|
||||||
professionalUbicacion =
|
professionalUbicacion =
|
||||||
profesional.ubicacion;
|
profesional.ubicacion;
|
||||||
|
|
||||||
@@ -440,8 +442,6 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
professionalId = profesional.id;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -579,7 +579,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
|||||||
: professionalLongitude,
|
: professionalLongitude,
|
||||||
'pendiente')
|
'pendiente')
|
||||||
.then((value) {
|
.then((value) {
|
||||||
Navigator.push(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@@ -7,6 +10,9 @@ import 'package:prosappco/src/components/pop_appbar.dart';
|
|||||||
import 'package:prosappco/src/models/event_model.dart';
|
import 'package:prosappco/src/models/event_model.dart';
|
||||||
import 'package:prosappco/src/models/scores_model.dart';
|
import 'package:prosappco/src/models/scores_model.dart';
|
||||||
import 'package:prosappco/src/models/user_model.dart';
|
import 'package:prosappco/src/models/user_model.dart';
|
||||||
|
import 'package:prosappco/src/screens/profile.dart';
|
||||||
|
import 'package:prosappco/src/screens/profile_pro.dart';
|
||||||
|
import 'package:prosappco/src/screens/service.dart';
|
||||||
|
|
||||||
class ServiceAfterScreen extends StatefulWidget {
|
class ServiceAfterScreen extends StatefulWidget {
|
||||||
var eventoId;
|
var eventoId;
|
||||||
@@ -47,8 +53,18 @@ class _ServiceAfterScreenState extends State<ServiceAfterScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar:
|
appBar: PopAppbar(
|
||||||
PopAppbar(onPressed: () => Navigator.pop(context), label: 'Servicio'),
|
onPressed: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return const ServiceScreen();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
label: 'Servicio'),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
|
|||||||
Reference in New Issue
Block a user