Functional Navbar + New icons

switch between pages with pageprovider
This commit is contained in:
Jonas Braus
2024-11-21 11:39:27 +01:00
parent acd52702da
commit 0240fce953
4 changed files with 49 additions and 9 deletions
+17 -9
View File
@@ -49,35 +49,43 @@ class MyHome extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(), appBar: AppBar(),
body: Container(), body: Consumer<PageProvider>(
bottomNavigationBar: GNav( builder: (context, pageProvider, child) {
return pageProvider.pages[pageProvider.selectedPage];
},
),
bottomNavigationBar: Padding(
padding: EdgeInsets.all(5),
child: GNav(
onTabChange: (index) { onTabChange: (index) {
Provider.of<PageProvider>(context, listen: false).changePage(index);
}, },
gap: 8, gap: 8,
backgroundColor: Theme.of(context).colorScheme.secondary, style: GnavStyle.google,
backgroundColor: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.onSurface, color: Theme.of(context).colorScheme.onSurface,
activeColor: Theme.of(context).colorScheme.onPrimary, activeColor: Theme.of(context).colorScheme.onPrimary,
tabBackgroundColor: Theme.of(context).colorScheme.primary, tabBackgroundColor: Theme.of(context).colorScheme.primary,
tabs: const [ tabs: const [
GButton( GButton(
icon: Icons.food_bank, icon: Icons.fastfood_outlined,
text: "Essen", text: "Essen",
),GButton( ),GButton(
icon: Icons.room, icon: Icons.landscape,
text: "Ambiente", text: "Ambiente",
),GButton( ),GButton(
icon: Icons.person, icon: Icons.mood,
text: "Service", text: "Service",
),GButton( ),GButton(
icon: Icons.question_mark, icon: Icons.feedback,
text: "Verschläge", text: "Verschläge",
), GButton( ), GButton(
icon: Icons.add_rounded, icon: Icons.comment,
text: "Verbesserungen", text: "Verbesserungen",
), ),
], ],
), ),
)
); );
} }
} }
+10
View File
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class PageAmbiente extends StatelessWidget {
const PageAmbiente({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
+10
View File
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class PageEssen extends StatelessWidget {
const PageEssen({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
+12
View File
@@ -1,5 +1,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mensaapp/pages/pageAmbiente.dart';
import 'package:mensaapp/pages/pageEssen.dart';
class PageProvider extends ChangeNotifier { class PageProvider extends ChangeNotifier {
int selectedPage = 0;
List<Widget> pages = [
const PageEssen(),
const PageAmbiente()
];
void changePage(int index) {
selectedPage = index;
notifyListeners();
}
} }