fecha en mensajes y lista profesional

This commit is contained in:
Felipe
2024-05-25 10:09:54 -05:00
parent f1b2497c92
commit 0e93bc23b8
2 changed files with 81 additions and 51 deletions
+24 -5
View File
@@ -367,9 +367,9 @@ class _ChatScreenState extends State<ChatScreen> {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
DateFormat('h:mm a').format(e.createdAt),
_getFechaHoraFormateada(e.createdAt),
style:
const TextStyle(color: Colors.grey, fontSize: 12),
const TextStyle(color: Colors.grey, fontSize: 11),
),
),
],
@@ -403,10 +403,10 @@ class _ChatScreenState extends State<ChatScreen> {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
DateFormat('h:mm a').format(e.createdAt),
_getFechaHoraFormateada(e.createdAt),
style: const TextStyle(
color: Colors.grey,
fontSize: 12,
fontSize: 11,
),
),
),
@@ -417,7 +417,26 @@ class _ChatScreenState extends State<ChatScreen> {
.toList();
}
Future<List<dynamic>> _getUserAndProfessionalInfo(ServiceEntity service) async {
String _getFechaHoraFormateada(DateTime fecha) {
final now = DateTime.now();
final yesterday = now.subtract(const Duration(days: 1));
final formatter = DateFormat('h:mm a');
if (fecha.day == now.day &&
fecha.month == now.month &&
fecha.year == now.year) {
return 'Hoy - ${formatter.format(fecha)}';
} else if (fecha.day == yesterday.day &&
fecha.month == yesterday.month &&
fecha.year == yesterday.year) {
return 'Ayer - ${formatter.format(fecha)}';
} else {
return '${DateFormat('dd/MM/yyyy').format(fecha)} - ${formatter.format(fecha)}';
}
}
Future<List<dynamic>> _getUserAndProfessionalInfo(
ServiceEntity service) async {
final userRepo = FirebaseUserRepository(FirebaseAuth.instance);
final MyUser? userInfo;