122 lines
3.2 KiB
Dart
122 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:pacelab/screens/calendar_screen.dart';
|
|
import 'package:pacelab/screens/competitions_screen.dart';
|
|
import 'package:pacelab/screens/dashboard_screen.dart';
|
|
import 'package:pacelab/screens/events_screen.dart';
|
|
import 'package:pacelab/screens/season_screen.dart';
|
|
|
|
class Destination {
|
|
const Destination(this.label, this.icon);
|
|
|
|
final String label;
|
|
final IconData icon;
|
|
}
|
|
|
|
const List<Destination> destinations = [
|
|
Destination('Dashboard', Icons.dashboard),
|
|
Destination('Season', Icons.event),
|
|
Destination('Calendar', Icons.calendar_month),
|
|
Destination('Competitions', Icons.flag),
|
|
Destination('Events', Icons.edit_calendar_rounded),
|
|
];
|
|
|
|
void main() {
|
|
runApp(const MainApp());
|
|
}
|
|
|
|
class MainApp extends StatelessWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(title: "PaceLab", home: PaceLabLayout(), theme: ThemeData.dark());
|
|
}
|
|
}
|
|
|
|
class PaceLabLayout extends StatefulWidget {
|
|
const PaceLabLayout({super.key});
|
|
|
|
@override
|
|
State<PaceLabLayout> createState() => _PaceLabLayoutState();
|
|
}
|
|
|
|
class _PaceLabLayoutState extends State<PaceLabLayout> {
|
|
int selectedIndex = 0;
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text("PaceLab"), backgroundColor: Colors.red.shade900),
|
|
body: Row(
|
|
children: [
|
|
navDrawer(),
|
|
Navigator(
|
|
key: ValueKey(selectedIndex),
|
|
onGenerateRoute: (settings) {
|
|
Widget page = const DashboardScreen();
|
|
|
|
switch (selectedIndex) {
|
|
case 0:
|
|
{
|
|
page = const DashboardScreen();
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
page = SeasonScreen();
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
page = CalendarScreen();
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
page = CompetitionsScreen();
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
page = EventsScreen();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return MaterialPageRoute(builder: (_) => page);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
NavigationDrawer navDrawer() {
|
|
return NavigationDrawer(
|
|
selectedIndex: selectedIndex,
|
|
onDestinationSelected: (value) => _onItemTapped(value),
|
|
indicatorColor: Colors.grey.shade700,
|
|
children: [
|
|
UserAccountsDrawerHeader(
|
|
decoration: BoxDecoration(color: Colors.redAccent),
|
|
accountName: Text("User name"), // todo
|
|
accountEmail: Text("VDOT: 48"), // todo
|
|
currentAccountPicture: FlutterLogo(), // todo
|
|
),
|
|
...destinations.map((Destination destination) {
|
|
return NavigationDrawerDestination(
|
|
icon: Icon(destination.icon),
|
|
label: Text(destination.label),
|
|
);
|
|
}),
|
|
],
|
|
);
|
|
}
|
|
}
|