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