From c025fbe07a191d2fcecc1b4054fe630ede896c25 Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 23 Jul 2025 10:29:13 -0400 Subject: [PATCH] add the compose widget to sidebar --- lib/home_page.dart | 136 +++++++++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/lib/home_page.dart b/lib/home_page.dart index cbd2e76..1b277ce 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -5,6 +5,7 @@ import 'structs.dart'; import 'api_service.dart'; import 'package:flutter/material.dart'; import 'email.dart'; +import 'Compose.dart'; class HomeScreen extends StatefulWidget { @override @@ -44,49 +45,50 @@ class _HomeScreenState extends State with TickerProviderStateMixin { }); } - void _showOptionsSearchDialog () async { + void _showOptionsSearchDialog() async { List folders = await apiService.fetchFolders(); if (mounted) { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text('Choose an Option'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: folders.map((option) { - return ListTile( - title: Text(option), - leading: Radio( - value: option, - groupValue: _selectedOption, // Bind with _selectedOption - onChanged: (String? value) { - setState(() { - _selectedOption = value; - }); - Navigator.of(context).pop(); // Close the dialog on selection - }, - ), - ); - }).toList(), - ), - actions: [ - ElevatedButton( - child: Text('Submit'), - onPressed: () { - Navigator.of(context).pop(); // Close the dialog - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text('You selected: $_selectedOption'), - )); - }, + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Choose an Option'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: folders.map((option) { + return ListTile( + title: Text(option), + leading: Radio( + value: option, + groupValue: _selectedOption, // Bind with _selectedOption + onChanged: (String? value) { + setState(() { + _selectedOption = value; + }); + Navigator.of(context) + .pop(); // Close the dialog on selection + }, + ), + ); + }).toList(), ), - ], - ); - }, - );} + actions: [ + ElevatedButton( + child: Text('Submit'), + onPressed: () { + Navigator.of(context).pop(); // Close the dialog + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('You selected: $_selectedOption'), + )); + }, + ), + ], + ); + }, + ); + } } - // Remove a tab void _removeTab(int index) { @@ -119,7 +121,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { body: ListView.separated( itemCount: result.length, itemBuilder: (context, index) { - final SerializableMessage email = result[index]; + final SerializableMessage email = result[index]; return ListTile( title: Text(email.from, style: TextStyle(fontWeight: FontWeight.bold)), @@ -132,27 +134,24 @@ class _HomeScreenState extends State with TickerProviderStateMixin { // print('tapped'); // List emailContent = // await apiService.fetchEmailContent([email.id], email.list); - //call the foldable - + //call the foldable + List emailContent = // list of the html - await apiService.fetchEmailContent([email.id], email.list); + await apiService + .fetchEmailContent([email.id], email.list); // List emailIds = email.messages; - - + Navigator.push( context, MaterialPageRoute( - builder: (context) =>SonicEmailView( - email: email, - emailHTML: emailContent[0]) - ), + builder: (context) => SonicEmailView( + email: email, emailHTML: emailContent[0])), ); }, ); }, separatorBuilder: (context, index) => Divider(), ), - ); } }, @@ -170,7 +169,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { return Scaffold( backgroundColor: Theme.of(context).colorScheme.onPrimary, body: Padding( - padding: const EdgeInsets.fromLTRB(0, 20, 0 , 20), + padding: const EdgeInsets.fromLTRB(0, 20, 0, 20), child: Scaffold( key: _scaffoldKey, drawer: FolderDrawer( @@ -195,6 +194,12 @@ class _HomeScreenState extends State with TickerProviderStateMixin { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + ListTile( + leading: Icon(Icons.edit_note_sharp), + onTap: () { + OverlayService() + .showPersistentWidget(context); + }), ListTile( leading: Icon(Icons.home), onTap: () { @@ -219,7 +224,8 @@ class _HomeScreenState extends State with TickerProviderStateMixin { child: Align( alignment: Alignment.bottomLeft, child: IconButton( - icon: Icon(Icons.close, color: Colors.white), + icon: + Icon(Icons.close, color: Colors.white), onPressed: () { setState(() { _isSidebarOpen = false; @@ -256,7 +262,8 @@ class _HomeScreenState extends State with TickerProviderStateMixin { ), onSubmitted: (value) { if (value.isNotEmpty) { - _performSearch(value, _selectedOption); + _performSearch( + value, _selectedOption); } //this is the input box i mentioned // if (value == '') { @@ -314,8 +321,10 @@ class _HomeScreenState extends State with TickerProviderStateMixin { Text(entry.value), if (entry.value != 'Emails') GestureDetector( - onTap: () => _removeTab(entry.key), - child: Icon(Icons.close, size: 16), + onTap: () => + _removeTab(entry.key), + child: Icon(Icons.close, + size: 16), ), ], ), @@ -333,23 +342,28 @@ class _HomeScreenState extends State with TickerProviderStateMixin { children: [ ElevatedButton( onPressed: () { - _emailPageKey.currentState!.isBackDisabled ? null: _emailPageKey.currentState - ?.updatePagenation('back'); + _emailPageKey.currentState!.isBackDisabled + ? null + : _emailPageKey.currentState + ?.updatePagenation('back'); }, child: Icon(Icons.navigate_before), ), Builder( builder: (context) { - final emailState = _emailPageKey.currentState; + final emailState = + _emailPageKey.currentState; if (emailState == null) { // Schedule a rebuild once the state is available Future.microtask(() => setState(() {})); return Text('Loading...'); } - + return ValueListenableBuilder( - valueListenable: emailState.currentPageNotifier, - builder: (context, value, _) => Text('$value'), + valueListenable: + emailState.currentPageNotifier, + builder: (context, value, _) => + Text('$value'), ); }, ), @@ -376,7 +390,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { }).toList(), ), ), - + // if (_tabs.isEmpty) // Expanded( // child: EmailPage(key: _emailPageKey),