juan 1 kuukausi sitten
vanhempi
commit
83592472d4
1 muutettua tiedostoa jossa 21 lisäystä ja 28 poistoa
  1. 21 28
      lib/home_page.dart

+ 21 - 28
lib/home_page.dart

@@ -1,8 +1,9 @@
 // import 'package:crab_ui/email.dart';
+import 'package:crab_ui/folder_drawer.dart';
+
 import 'api_service.dart';
 import 'package:flutter/material.dart';
 import 'email.dart';
-import 'api_service.dart';
 import 'dart:html' as html;
 import 'dart:ui_web' as ui;
 
@@ -13,8 +14,9 @@ class HomeScreen extends StatefulWidget {
 
 //TODO: ADD ALL THE DIFF FOLDERS TO THE SIDEBAR
 class _HomeScreenState extends State<HomeScreen> {
-  final _emailPageState = EmailPageState();
+  // final _emailPageState = EmailPageState();
   final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
+  ApiService apiService = ApiService();
 
   @override
   void initState() {
@@ -26,6 +28,16 @@ class _HomeScreenState extends State<HomeScreen> {
   //   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 = [
@@ -37,16 +49,11 @@ class _HomeScreenState extends State<HomeScreen> {
     ];
     return Scaffold(
       key: _scaffoldKey,
-      drawer: Drawer(
-        child: Scaffold(
-          appBar: AppBar(
-            title: Text('somet'),
-          ),
-          body: Center(
-            child: Text('center'),
-          ),
-        ),
+      drawer: FolderDrawer(
+        apiService: apiService, 
+        onFolderTap: _onFolderSelected,
       ),
+
       body: Stack(
         children: [
           Row(
@@ -71,6 +78,7 @@ class _HomeScreenState extends State<HomeScreen> {
                           // Navigate to Settings
                         },
                       ),
+                      // EmailPage(),
                       // GestureDetector(
 
                       //     // onTapDown: (TapDownDetails details) {
@@ -111,20 +119,6 @@ class _HomeScreenState extends State<HomeScreen> {
                         leading: Icon(Icons.email),
                         onTap: () {
                           _scaffoldKey.currentState?.openDrawer();
-                          // showModalBottomSheet(
-                          //   context: context,
-                          //   builder: (context) {
-                          //     return Scaffold(
-                          //       appBar: AppBar(
-                          //         title: Text('AppBar-Like Modal'),
-                          //         backgroundColor: Colors.purple,
-                          //       ),
-                          //       body: Center(
-                          //         child: Text('This is the content inside the AppBar-like modal'),
-                          //       ),
-                          //     );
-                          //   },
-                          // );
                         },
                       ),
                       
@@ -257,13 +251,12 @@ class _HomeScreenState extends State<HomeScreen> {
                           Container(
                             child: Text('hiiiiiii'),
                           ),
+                          
                         ],
                       ),
                     ),
                     Expanded(
-                      child: Center(
-                        child: EmailPage(),
-                      ),
+                      child: EmailPage(selectedFolder: "INBOX",),
                     )
                   ],
                 ),