|
@@ -1,59 +1,37 @@
|
|
|
-// import 'package:crab_ui/email.dart';
|
|
|
import 'package:crab_ui/folder_drawer.dart';
|
|
|
-
|
|
|
+import 'package:flutter/widgets.dart';
|
|
|
import 'api_service.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'email.dart';
|
|
|
-import 'dart:html' as html;
|
|
|
-import 'dart:ui_web' as ui;
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
|
@override
|
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
|
}
|
|
|
|
|
|
-//TODO: ADD ALL THE DIFF FOLDERS TO THE SIDEBAR
|
|
|
+
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
|
- // final _emailPageState = EmailPageState();
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
+ final GlobalKey<EmailPageState> _emailPageKey = GlobalKey<EmailPageState>();
|
|
|
ApiService apiService = ApiService();
|
|
|
+ bool _isSidebarOpen = true;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
|
- bool _isSidebarOpen = true;
|
|
|
- // void holder() async {
|
|
|
- // List<Widget> drawerItems = await EmailPageState.getDrawerItems(context);
|
|
|
- // }
|
|
|
-
|
|
|
- // Method to handle what happens when a folder is tapped
|
|
|
- void _onFolderSelected(String folder) async {
|
|
|
- // Fetch emails from the selected folder using the ApiService
|
|
|
- // List fetchedEmails = await apiService.fetchEmailsFromFolder(folder);
|
|
|
- // setState(() {
|
|
|
- // emails = fetchedEmails; // Update the email list
|
|
|
- // });
|
|
|
- print(folder);
|
|
|
- }
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- final List<String> emails = [
|
|
|
- 'Welcome to Flutter!',
|
|
|
- 'You have new updates',
|
|
|
- 'Your order is shipped',
|
|
|
- 'Important: Security update',
|
|
|
- 'Meeting tomorrow',
|
|
|
- ];
|
|
|
return Scaffold(
|
|
|
key: _scaffoldKey,
|
|
|
drawer: FolderDrawer(
|
|
|
- apiService: apiService,
|
|
|
- onFolderTap: _onFolderSelected,
|
|
|
+ apiService: apiService,
|
|
|
+ onFolderTap: (folder) {
|
|
|
+ _emailPageKey.currentState?.updateSelectedFolder(folder);
|
|
|
+ },
|
|
|
),
|
|
|
-
|
|
|
body: Stack(
|
|
|
children: [
|
|
|
Row(
|
|
@@ -78,119 +56,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
// Navigate to Settings
|
|
|
},
|
|
|
),
|
|
|
- // EmailPage(),
|
|
|
- // GestureDetector(
|
|
|
-
|
|
|
- // // onTapDown: (TapDownDetails details) {
|
|
|
- // // _showPopupMenu(context, details.globalPosition);
|
|
|
- // // },
|
|
|
- // // child: Expanded(
|
|
|
- // child: Scaffold(
|
|
|
- // appBar: AppBar(
|
|
|
- // // leading: Icon(Icons.email),
|
|
|
- // // flexibleSpace: Padding(
|
|
|
- // // padding: const EdgeInsets.only(
|
|
|
- // // top: 40), // Adjust padding as needed
|
|
|
-
|
|
|
- // // child: Wrap(
|
|
|
- // // spacing: 10.0,
|
|
|
- // // alignment: WrapAlignment.center,
|
|
|
- // // // children: [
|
|
|
- // // // ListTile(leading: Icon(Icons.mail),),
|
|
|
- // // // ListTile(leading: Icon(Icons.mail),),
|
|
|
- // // // ListTile(leading: Icon(Icons.mail),),
|
|
|
- // // // ],
|
|
|
- // // ),
|
|
|
- // // ),
|
|
|
- // // ],
|
|
|
- // ),
|
|
|
- // body: ListView.separated(
|
|
|
- // itemBuilder: (context, index) {
|
|
|
- // return ListTile(
|
|
|
- // leading: Icon(Icons.mail),
|
|
|
- // title: Text(emails[index]),
|
|
|
- // );
|
|
|
- // },
|
|
|
- // separatorBuilder: (context, index) => Divider(),
|
|
|
- // itemCount: 5,
|
|
|
- // ),
|
|
|
- // )
|
|
|
ListTile(
|
|
|
leading: Icon(Icons.email),
|
|
|
onTap: () {
|
|
|
_scaffoldKey.currentState?.openDrawer();
|
|
|
},
|
|
|
),
|
|
|
-
|
|
|
- // leading: SizedBox(
|
|
|
- // width: 20,
|
|
|
- // child: GestureDetector(
|
|
|
- // onTapDown: (TapDownDetails details) {
|
|
|
- // _showPopupMenu(context, details.globalPosition);
|
|
|
- // },
|
|
|
- // child: SizedBox(
|
|
|
- // width: 40,
|
|
|
- // child: Icon(Icons.email)
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
-
|
|
|
- // trailing: SizedBox(
|
|
|
- // width: 20,
|
|
|
- // child: PopupMenuButton<String>(
|
|
|
- // onSelected: (value) {
|
|
|
- // print(value);
|
|
|
- // print('ajdsnv');
|
|
|
- // },
|
|
|
- // itemBuilder: (BuildContext context) {
|
|
|
- // return <PopupMenuEntry<String>>[
|
|
|
- // PopupMenuItem<String>(
|
|
|
- // value: 'Open',
|
|
|
- // child: Text('Open'),
|
|
|
- // )
|
|
|
- // ];
|
|
|
- // },
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
-
|
|
|
- // onTap: () {
|
|
|
- // Navigator.push(
|
|
|
- // context,
|
|
|
- // MaterialPageRoute(
|
|
|
- // builder: (context) => EmailPage()),
|
|
|
- // );
|
|
|
- // },
|
|
|
-
|
|
|
- // ),
|
|
|
-
|
|
|
- // Drawer(
|
|
|
- // child: FutureBuilder<List<Widget>>()
|
|
|
- // future: _emailPageState.getDrawerItems(context), // call the async function to get the future
|
|
|
- // builder: (BuildContext context,
|
|
|
- // AsyncSnapshot<List<Widget>> snapshot) {
|
|
|
- // if (snapshot.connectionState ==
|
|
|
- // ConnectionState.waiting) {
|
|
|
- // // While data is loading, show a progress indicator
|
|
|
- // return Center(child: CircularProgressIndicator());
|
|
|
- // } else if (snapshot.hasError) {
|
|
|
- // // If something went wrong, show an error message
|
|
|
- // return Center(
|
|
|
- // child: Text('Error: ${snapshot.error}'));
|
|
|
- // } else {
|
|
|
- // // When data is fetched successfully, display the items
|
|
|
- // return ListView(
|
|
|
- // padding: EdgeInsets.zero,
|
|
|
- // children: snapshot
|
|
|
- // .data!, // Unwrap the data once confirmed it's there
|
|
|
- // );
|
|
|
- // }
|
|
|
- // },
|
|
|
- // )
|
|
|
- // ),
|
|
|
Spacer(),
|
|
|
-
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
child: Align(
|
|
@@ -251,12 +123,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
Container(
|
|
|
child: Text('hiiiiiii'),
|
|
|
),
|
|
|
-
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: EmailPage(selectedFolder: "INBOX",),
|
|
|
+ child: EmailPage(key: _emailPageKey),
|
|
|
)
|
|
|
],
|
|
|
),
|