From e60de643a6d784b85ff7bc7714b544b83941c165 Mon Sep 17 00:00:00 2001 From: "Ortner.Elias" Date: Thu, 17 Nov 2022 16:31:35 +0100 Subject: [PATCH] Switch between Pages (Navbar) 17.11.2022 16:31 - Ortner Elias --- lib/main.dart | 133 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 128 insertions(+), 5 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f4537ab..a36b571 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,12 +11,8 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( + return const MaterialApp( title: 'Flutter Demo', - theme: ThemeData( - primarySwatch: Colors.green, - scaffoldBackgroundColor: const Color(0xFFFFFFFF) - ), home: const MyHomePage(title: 'Bürger Forum Oggau'), ); } @@ -31,6 +27,24 @@ class MyHomePage extends StatefulWidget { State createState() => _MyHomePageState(); } +class ProfilePage extends StatefulWidget { + const ProfilePage({super.key, required this.title}); + + final String title; + + @override + State createState() => _ProfilePageState(); +} + +class MangelPage extends StatefulWidget { + const MangelPage({super.key, required this.title}); + + final String title; + + @override + State createState() => _MangelPageState(); +} + class _MyHomePageState extends State { int _counter = 0; @@ -40,6 +54,22 @@ class _MyHomePageState extends State { }); } + void _pushMangel(){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const MangelPage(title: 'Mängel'), + ), + ); + } + + void _pushProfile(){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const ProfilePage(title: 'Profil'), + ), + ); + } + @override Widget build(BuildContext context) { @@ -74,6 +104,53 @@ class _MyHomePageState extends State { child: IconTheme( data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary), child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + tooltip: 'News', + icon: const Icon(Icons.newspaper), + onPressed: () {}, + ), + //if (centerLocations.contains(fabLocation)) const Spacer(), + IconButton( + tooltip: 'Mängel', + icon: const Icon(Icons.warning), + onPressed: () => {_pushMangel()}, + ), + IconButton( + tooltip: 'Profil', + icon: const Icon(Icons.person), + onPressed: () => {_pushProfile()}, + ), + ], + ), + ), + ) + ); + } +} + +class _ProfilePageState extends State { + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + + title: Text(widget.title), + ), + body: Center( + + child: Column( + ), + ), + bottomNavigationBar: BottomAppBar( + color: const Color(0xFF1601FD), + child: IconTheme( + data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ IconButton( tooltip: 'News', @@ -89,7 +166,53 @@ class _MyHomePageState extends State { IconButton( tooltip: 'Profil', icon: const Icon(Icons.person), + onPressed: () => {}, + ), + ], + ), + ), + ) + ); + } +} + +class _MangelPageState extends State { + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + + title: Text(widget.title), + ), + body: Center( + + child: Column( + ), + ), + bottomNavigationBar: BottomAppBar( + color: const Color(0xFF1601FD), + child: IconTheme( + data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + tooltip: 'News', + icon: const Icon(Icons.newspaper), onPressed: () {}, + ), + //if (centerLocations.contains(fabLocation)) const Spacer(), + IconButton( + tooltip: 'Mängel', + icon: const Icon(Icons.warning), + onPressed: () {}, + ), + IconButton( + tooltip: 'Profil', + icon: const Icon(Icons.person), + onPressed: () => {}, ), ], ),