added sender and time to the email tile inside of the thread

This commit is contained in:
Juan Marulanda De Los Rios 2025-05-19 19:01:48 -04:00
parent 95697efdab
commit 7ec032c0f2

View File

@ -8,8 +8,12 @@ import 'structs.dart';
class CollapsableEmails extends StatefulWidget { class CollapsableEmails extends StatefulWidget {
final List<String> thread; // email id's in the form xyz@gmail.com final List<String> thread; // email id's in the form xyz@gmail.com
final List<String> threadHTML; final List<String> threadHTML;
final String threadIDs;
CollapsableEmails({required this.thread, required this.threadHTML}); CollapsableEmails(
{required this.thread,
required this.threadHTML,
required this.threadIDs});
@override @override
State<CollapsableEmails> createState() => _CollapsableEmailsState(); State<CollapsableEmails> createState() => _CollapsableEmailsState();
@ -21,12 +25,15 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
Set<int> _expandedEmails = {}; //open emails Set<int> _expandedEmails = {}; //open emails
List viewtypeIDs = []; //IDs of the viewtypes, order matters List viewtypeIDs = []; //IDs of the viewtypes, order matters
List heightOfViewTypes = []; //the height of each viewtype List heightOfViewTypes = []; //the height of each viewtype
List<SerializableMessage> emailsInThread = [];
bool _isLoaded = false;
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
_registerViewFactory(widget.threadHTML); _registerViewFactory(widget.threadHTML);
_serializableData(widget.threadIDs);
} }
void _registerViewFactory(List<String> currentContent) async { void _registerViewFactory(List<String> currentContent) async {
@ -70,27 +77,21 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
viewtypeIDs.add(viewTypeId); viewtypeIDs.add(viewTypeId);
heightOfViewTypes.add(heightOfEmail); heightOfViewTypes.add(heightOfEmail);
} }
}
// viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}'; void _serializableData(String threadID) async {
// final emailHTML = web.document.createElement('div') as web.HTMLDivElement emailsInThread = await ApiService().threadsInSerializable(threadID);
// ..id = viewTypeId print("done thread serializable");
// ..innerHTML = currentContent[0].toJS; // temporarily index because it has to do all of them if (!mounted) return;
// emailHTML.style setState(() {
// ..width = '100%' _isLoaded = true;
// ..height = '100%' });
// ..overflow = 'auto'
// ..scrollBehavior = 'smooth';
// ui.platformViewRegistry.registerViewFactory(
// viewTypeId,
// (int viewId) => emailHTML,
// );
// });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column(children: [ return _isLoaded
?Column(children: [
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: widget.thread.length, itemCount: widget.thread.length,
@ -100,7 +101,8 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
return Column( return Column(
children: [ children: [
ListTile( ListTile(
title: Text("email $index"), title: Text(emailsInThread[index].from),
trailing: Text(emailsInThread[index].date),
onTap: () { onTap: () {
setState(() { setState(() {
if (isExpanded) { if (isExpanded) {
@ -125,6 +127,6 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
}, },
), ),
) )
]); ]): const Center(child:CircularProgressIndicator());
} }
} }