sidebar stuff

This commit is contained in:
Juan Marulanda De Los Rios 2024-10-20 00:30:24 -04:00
parent 85decfa0f8
commit 0d07aee02a

View File

@ -11,17 +11,42 @@ class HomeScreen extends StatefulWidget {
_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>();
@override
void initState() {
super.initState();
}
bool _isSidebarOpen = true;
// void holder() async {
// List<Widget> drawerItems = await EmailPageState.getDrawerItems(context);
// }
@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: Drawer(
child: Scaffold(
appBar: AppBar(
title: Text('somet'),
),
body: Center(
child: Text('center'),
),
),
),
body: Stack(
children: [
Row(
@ -46,17 +71,132 @@ class _HomeScreenState extends State<HomeScreen> {
// Navigate to Settings
},
),
// 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: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EmailPage()),
);
_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'),
// ),
// );
// },
// );
},
),
// 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(
@ -120,11 +260,11 @@ class _HomeScreenState extends State<HomeScreen> {
],
),
),
// Expanded(
// child: Center(
// child: EmailPage(),
// ),
// )
Expanded(
child: Center(
child: EmailPage(),
),
)
],
),
),
@ -147,5 +287,35 @@ class _HomeScreenState extends State<HomeScreen> {
),
);
}
}
void _showPopupMenu(BuildContext context, Offset position) async {
final RenderBox overlay =
Overlay.of(context).context.findRenderObject() as RenderBox;
await showMenu<String>(
context: context,
position: RelativeRect.fromLTRB(
position.dx,
position.dy,
overlay.size.width - position.dx,
overlay.size.height - position.dy,
),
items: <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'Open',
child: Text('Open'),
),
PopupMenuItem<String>(
value: 'Reply',
child: Text('Reply'),
),
PopupMenuItem<String>(
value: 'Delete',
child: Text('Delete'),
),
],
);
}
}
//show popup menu