import 'package:flutter/material.dart'; enum SidebarPage { myFiles, shared, settings } class Sidebar extends StatelessWidget { final SidebarPage selectedPage; final ValueChanged onPageSelected; final VoidCallback onLogout; const Sidebar({ required this.selectedPage, required this.onPageSelected, required this.onLogout, super.key, }); @override Widget build(BuildContext context) { final selectedColor = Theme.of(context).colorScheme.primary.withOpacity(0.15); final outlineColor = Colors.purple[100]; Widget buildTile( {required IconData icon, required String label, required SidebarPage page}) { final selected = selectedPage == page; return Container( margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), decoration: selected ? BoxDecoration( color: selectedColor, border: Border.all(color: outlineColor!, width: 2), borderRadius: BorderRadius.circular(12), ) : null, child: ListTile( leading: Icon(icon, color: selected ? Theme.of(context).colorScheme.primary : null), title: Text(label, style: TextStyle( color: selected ? Theme.of(context).colorScheme.primary : null)), onTap: () => onPageSelected(page), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), ), ); } return NavigationDrawer( backgroundColor: Theme.of(context).colorScheme.surface, children: [ const SizedBox(height: 24), buildTile( icon: Icons.folder, label: 'My Files', page: SidebarPage.myFiles), buildTile( icon: Icons.share, label: 'Shared Files', page: SidebarPage.shared), buildTile( icon: Icons.settings, label: 'Settings', page: SidebarPage.settings), const Spacer(), ListTile( leading: const Icon(Icons.logout), title: const Text('Logout'), onTap: onLogout, ), const SizedBox(height: 20), ], ); } }