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
+48 -45
View File
@@ -54,52 +54,55 @@ class _MessagesUserScreenState extends State<MessagesUserScreen> {
child: ListView.builder(
itemCount: list.length,
itemBuilder: (BuildContext context, int index) {
final pro = list[index].professional;
final lastMsg = list[index].messages.last;
return ListTile(
title: Text(
(pro?.name ?? ''),
),
subtitle: Text(
'" ${lastMsg.content} "',
style: const TextStyle(fontStyle: FontStyle.italic),
),
leading: ReferencePhoto(
ref: pro?.photo,
size: 55,
sizeCircle: 60,
),
trailing: Column(
children: [
SizedBox(height: 8),
const Icon(
Icons.keyboard_arrow_right,
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);
},
if (list[index].messages.isNotEmpty) {
final pro = list[index].professional;
final lastMsg = list[index].messages.last;
return ListTile(
title: Text(
(pro?.name ?? ''),
),
subtitle: Text(
'" ${lastMsg.content} "',
style: const TextStyle(fontStyle: FontStyle.italic),
),
leading: ReferencePhoto(
ref: pro?.photo,
size: 55,
sizeCircle: 60,
),
trailing: Column(
children: [
SizedBox(height: 8),
const Icon(
Icons.keyboard_arrow_right,
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);
},
),
);
});
},
);
} else {
return const SizedBox();
}
},
),
),