Basic layout, navigation, first empty pages
This commit is contained in:
109
lib/main.dart
109
lib/main.dart
@@ -1,4 +1,24 @@
|
|||||||
import 'package:flutter/material.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() {
|
void main() {
|
||||||
runApp(const MainApp());
|
runApp(const MainApp());
|
||||||
@@ -9,12 +29,93 @@ class MainApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const MaterialApp(
|
return MaterialApp(title: "PaceLab", home: PaceLabLayout(), theme: ThemeData.dark());
|
||||||
home: Scaffold(
|
}
|
||||||
body: Center(
|
}
|
||||||
child: Text('Hello World!'),
|
|
||||||
|
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),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
lib/screens/calendar_screen.dart
Normal file
10
lib/screens/calendar_screen.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CalendarScreen extends StatelessWidget {
|
||||||
|
const CalendarScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Text("Calendar");
|
||||||
|
}
|
||||||
|
}
|
||||||
10
lib/screens/competitions_screen.dart
Normal file
10
lib/screens/competitions_screen.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CompetitionsScreen extends StatelessWidget {
|
||||||
|
const CompetitionsScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text("Competitions");
|
||||||
|
}
|
||||||
|
}
|
||||||
15
lib/screens/dashboard_screen.dart
Normal file
15
lib/screens/dashboard_screen.dart
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class DashboardScreen extends StatefulWidget {
|
||||||
|
const DashboardScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DashboardScreenState extends State<DashboardScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Text("Dashboard");
|
||||||
|
}
|
||||||
|
}
|
||||||
10
lib/screens/events_screen.dart
Normal file
10
lib/screens/events_screen.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class EventsScreen extends StatelessWidget {
|
||||||
|
const EventsScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text("Events");
|
||||||
|
}
|
||||||
|
}
|
||||||
10
lib/screens/season_screen.dart
Normal file
10
lib/screens/season_screen.dart
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SeasonScreen extends StatelessWidget {
|
||||||
|
const SeasonScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text("Season");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user