This commit is contained in:
Juan Felipe Duarte
2023-05-05 10:28:10 -05:00
parent fe8a3fa834
commit eb94895397
8 changed files with 162 additions and 127 deletions
+36 -16
View File
@@ -236,23 +236,43 @@ class _CitaScreenState extends State<CitaScreen> {
const SizedBox(width: 20),
ElevatedButton(
onPressed: () async {
await FirebaseFirestore.instance
.collection('chats')
.doc(widget.evento.id)
.set({
'professional_id': widget.evento.professionalId,
'user_id': widget.evento.userId
}, SetOptions(merge: true)).catchError((error) =>
print('Error al crear el documento: $error'));
if (widget.evento.status != 'pendiente') {
await FirebaseFirestore.instance
.collection('chats')
.doc(widget.evento.id)
.set({
'professional_id': widget.evento.professionalId,
'user_id': widget.evento.userId,
'message': [],
}, SetOptions(merge: true)).catchError((error) =>
print('Error al crear el documento: $error'));
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ChatScreen(eventoId: widget.evento.id);
},
),
);
Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
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(
foregroundColor: const Color(0xFF2BA4EC),