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,141 +11,311 @@ class HomeScreen extends StatefulWidget {
_HomeScreenState createState() => _HomeScreenState(); _HomeScreenState createState() => _HomeScreenState();
} }
//TODO: ADD ALL THE DIFF FOLDERS TO THE SIDEBAR
class _HomeScreenState extends State<HomeScreen> { class _HomeScreenState extends State<HomeScreen> {
final _emailPageState = EmailPageState();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
} }
bool _isSidebarOpen = true; bool _isSidebarOpen = true;
// void holder() async {
// List<Widget> drawerItems = await EmailPageState.getDrawerItems(context);
// }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( final List<String> emails = [
body: Stack( 'Welcome to Flutter!',
children: [ 'You have new updates',
Row( 'Your order is shipped',
children: [ 'Important: Security update',
// Sidebar 'Meeting tomorrow',
if (_isSidebarOpen) ];
Container( return Scaffold(
width: 70, key: _scaffoldKey,
color: Color.fromARGB(17, 96, 122, 135), drawer: Drawer(
child: Column( child: Scaffold(
crossAxisAlignment: CrossAxisAlignment.start, appBar: AppBar(
children: [ title: Text('somet'),
ListTile( ),
leading: Icon(Icons.home), body: Center(
onTap: () { child: Text('center'),
// Navigate to Home ),
}, ),
), ),
ListTile( body: Stack(
leading: Icon(Icons.settings), children: [
onTap: () { Row(
// Navigate to Settings children: [
}, // Sidebar
), if (_isSidebarOpen)
ListTile( Container(
leading: Icon(Icons.email), width: 70,
onTap: () { color: Color.fromARGB(17, 96, 122, 135),
Navigator.push( child: Column(
context, crossAxisAlignment: CrossAxisAlignment.start,
MaterialPageRoute( children: [
builder: (context) => EmailPage()), ListTile(
); leading: Icon(Icons.home),
}, onTap: () {
), // Navigate to Home
Spacer(), },
Padding( ),
padding: const EdgeInsets.all(8.0), ListTile(
child: Align( leading: Icon(Icons.settings),
alignment: Alignment.bottomLeft, onTap: () {
child: IconButton( // Navigate to Settings
icon: Icon(Icons.close, color: Colors.white), },
onPressed: () { ),
setState(() { // GestureDetector(
_isSidebarOpen = false;
}); // // 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();
// 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(
alignment: Alignment.bottomLeft,
child: IconButton(
icon: Icon(Icons.close, color: Colors.white),
onPressed: () {
setState(() {
_isSidebarOpen = false;
});
},
), ),
), ),
],
),
),
// Main content
Expanded(
child: Column(
children: [
Container(
padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 4.0),
color: Color.fromARGB(42, 36, 102, 132),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 800,
height: 40,
child: TextField(
decoration: InputDecoration(
hintText: 'Search...',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.search),
),
),
),
],
),
), ),
Container(
padding: EdgeInsets.all(0.0),
color: Color.fromARGB(42, 36, 102, 132),
child: Row(
children: [
Container(
height: 2,
)
],
),
),
Container(
padding: EdgeInsets.all(8.0),
color: Colors.white,
child: Row(
children: [
Container(
child: Text('hiiiiiii'),
),
],
),
),
// Expanded(
// child: Center(
// child: EmailPage(),
// ),
// )
], ],
), ),
), ),
], // Main content
), Expanded(
if (!_isSidebarOpen) child: Column(
Positioned( children: [
bottom: 16, Container(
left: 16, padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 4.0),
child: FloatingActionButton( color: Color.fromARGB(42, 36, 102, 132),
child: Icon(Icons.menu), child: Row(
onPressed: () { mainAxisAlignment: MainAxisAlignment.center,
setState(() { children: [
_isSidebarOpen = true; Container(
}); width: 800,
}, height: 40,
child: TextField(
decoration: InputDecoration(
hintText: 'Search...',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.search),
),
),
),
],
),
),
Container(
padding: EdgeInsets.all(0.0),
color: Color.fromARGB(42, 36, 102, 132),
child: Row(
children: [
Container(
height: 2,
)
],
),
),
Container(
padding: EdgeInsets.all(8.0),
color: Colors.white,
child: Row(
children: [
Container(
child: Text('hiiiiiii'),
),
],
),
),
Expanded(
child: Center(
child: EmailPage(),
),
)
],
), ),
), ),
], ],
), ),
); if (!_isSidebarOpen)
} Positioned(
bottom: 16,
left: 16,
child: FloatingActionButton(
child: Icon(Icons.menu),
onPressed: () {
setState(() {
_isSidebarOpen = true;
});
},
),
),
],
),
);
} }
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