color when hoverred, and seen updated

This commit is contained in:
Juan Marulanda De Los Rios 2025-08-11 17:34:59 -04:00
parent 5d4854901e
commit 344029d0dd

View File

@ -9,8 +9,8 @@ class EmailListScreen extends StatefulWidget {
final String folder; final String folder;
final GlobalKey<_EmailListScreenState> key; final GlobalKey<_EmailListScreenState> key;
EmailListScreen({ EmailListScreen(
required this.key, {required this.key,
required this.emails, required this.emails,
required this.getEmailContent, required this.getEmailContent,
required this.folder}) required this.folder})
@ -25,6 +25,7 @@ class _EmailListScreenState extends State<EmailListScreen> {
late List<GetThreadResponse> selectedEmails = late List<GetThreadResponse> selectedEmails =
[]; // holds the emails that are selected i.e. the emails that got the checkbox on []; // holds the emails that are selected i.e. the emails that got the checkbox on
final Set<int> _hoveredRows = {}; //the row that is being hovered over atm final Set<int> _hoveredRows = {}; //the row that is being hovered over atm
bool bulkSelectMenu = false;
@override @override
void initState() { void initState() {
@ -42,9 +43,12 @@ class _EmailListScreenState extends State<EmailListScreen> {
bool selectAllChecks(bool selectionType) { bool selectAllChecks(bool selectionType) {
setState(() { setState(() {
for (int email = 0; email < selectStates.length; email++) { if (selectionType) {
selectStates[email] = selectionType; bulkSelectMenu = true;
} }
for (int email = 0; email < selectStates.length; email++) {
selectStates[email] = selectionType;
}
}); });
printTheSelected(); printTheSelected();
return false; return false;
@ -62,8 +66,13 @@ class _EmailListScreenState extends State<EmailListScreen> {
body: ListView.separated( body: ListView.separated(
itemCount: widget.emails.length, itemCount: widget.emails.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
Color seenColour;
final email = widget.emails[index]; final email = widget.emails[index];
if (email.seen) {
seenColour = ThemeData().highlightColor;
} else {
seenColour = Colors.transparent;
}
return MouseRegion( return MouseRegion(
onEnter: (_) => setState(() => _hoveredRows.add(index)), onEnter: (_) => setState(() => _hoveredRows.add(index)),
onExit: (_) => setState(() => _hoveredRows.remove(index)), onExit: (_) => setState(() => _hoveredRows.remove(index)),
@ -88,6 +97,7 @@ class _EmailListScreenState extends State<EmailListScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [Text(email.subject)], children: [Text(email.subject)],
), ),
// tileColor: () ,
trailing: _hoveredRows.contains(index) trailing: _hoveredRows.contains(index)
? Row( ? Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -107,10 +117,12 @@ class _EmailListScreenState extends State<EmailListScreen> {
], ],
) )
: Text(email.date.toString()), : Text(email.date.toString()),
hoverColor: Colors.transparent,
tileColor: seenColour,
onTap: () async { onTap: () async {
List<String> emailContent = // list of the html List<String> emailContent = // list of the html
await widget.getEmailContent(email.messages, widget.folder); await widget.getEmailContent(email.messages, widget.folder);
// print("thread id? $email.id"); yes
print(email.messages); //email ids of the thread print(email.messages); //email ids of the thread
if (widget.folder == "Drafts") { if (widget.folder == "Drafts") {
print("IN DRAFTS MOVE THE CONTENT TO THE WRITING THING"); print("IN DRAFTS MOVE THE CONTENT TO THE WRITING THING");
@ -131,6 +143,7 @@ class _EmailListScreenState extends State<EmailListScreen> {
), ),
), ),
); );
ApiService().markAsSeen(email.id);
} }
}, },
), ),
@ -160,8 +173,8 @@ class EmailPageState extends State<EmailPage> {
int page = 1; int page = 1;
bool isBackDisabled = false; bool isBackDisabled = false;
final GlobalKey<_EmailListScreenState> emailListKey = GlobalKey<_EmailListScreenState>(); final GlobalKey<_EmailListScreenState> emailListKey =
GlobalKey<_EmailListScreenState>();
@override @override
void initState() { void initState() {
@ -227,7 +240,8 @@ class EmailPageState extends State<EmailPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold(body: EmailListScreen( return Scaffold(
body: EmailListScreen(
key: emailListKey, key: emailListKey,
emails: emails, emails: emails,
// getEmailContent: apiService.fetchEmailContent, // getEmailContent: apiService.fetchEmailContent,