From 74f09d84cda1a6b9e0ef1fab5323742283995ae0 Mon Sep 17 00:00:00 2001 From: broodjeaap Date: Thu, 11 Jun 2020 22:02:19 +0200 Subject: [PATCH] Drawer for the app with 2 pages/views (?) --- lib/AppDrawer.dart | 32 ++++++++++++++++++++++++++++++++ lib/MonthValuesPage.dart | 3 +++ lib/YearsPage.dart | 18 ++++++++++++++++++ lib/main.dart | 7 ++++++- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 lib/AppDrawer.dart create mode 100644 lib/YearsPage.dart diff --git a/lib/AppDrawer.dart b/lib/AppDrawer.dart new file mode 100644 index 0000000..a0a648a --- /dev/null +++ b/lib/AppDrawer.dart @@ -0,0 +1,32 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class AppDrawer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + DrawerHeader( + child: Text("Oh That's A ..."), + ), + ListTile( + title: Text("Month values"), + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, "/monthValues"); + } + ), + ListTile( + title: Text("Years"), + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, "/years"); + } + ), + ], + ) + ); + } +} \ No newline at end of file diff --git a/lib/MonthValuesPage.dart b/lib/MonthValuesPage.dart index c1df76d..a2c32d4 100644 --- a/lib/MonthValuesPage.dart +++ b/lib/MonthValuesPage.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'AppDrawer.dart'; + class MonthValuesPage extends StatelessWidget { final Map monthValues = { "January": 0, @@ -42,6 +44,7 @@ class MonthValuesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( + drawer: AppDrawer(), appBar: AppBar( title: Text("Month Values") ), diff --git a/lib/YearsPage.dart b/lib/YearsPage.dart new file mode 100644 index 0000000..e01f5ac --- /dev/null +++ b/lib/YearsPage.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +import 'AppDrawer.dart'; + +class YearsPage extends StatelessWidget { + @override + Widget build(BuildContext context){ + return Scaffold( + drawer: AppDrawer(), + appBar: AppBar( + title: Text("Overview"), + ), + body: Center( + child: Text("Years page") + ) + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 9b9650b..2818e3e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:ohthatsa/YearsPage.dart'; import 'MonthValuesPage.dart'; @@ -12,7 +13,11 @@ class OhThatsA extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: "OhThatsA", - home: MonthValuesPage() + initialRoute: '/monthValues', + routes: { + '/monthValues': (context) => MonthValuesPage(), + '/years': (context) => YearsPage(), + } ); } }