- Add config.dart for API configuration - Implement sidebar navigation with logout functionality - Add file sharing dialog with public/private options - Create shares page to view and manage shared files - Implement file upload/download/delete operations - Add authentication persistence using shared preferences - Configure CORS for API to enable cross-origin requests
74 lines
2.2 KiB
Dart
74 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
enum SidebarPage { myFiles, shared, settings }
|
|
|
|
class Sidebar extends StatelessWidget {
|
|
final SidebarPage selectedPage;
|
|
final ValueChanged<SidebarPage> 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),
|
|
],
|
|
);
|
|
}
|
|
}
|