Implemented Views + View for avg

This commit is contained in:
Jonas Braus
2024-11-28 21:15:11 +01:00
parent 7f85b84a15
commit ec7a03e43f
6 changed files with 188 additions and 4 deletions
+38 -1
View File
@@ -24,6 +24,11 @@ class PageDashboard extends StatelessWidget {
@override
Widget build(BuildContext context) {
var viewDatabaseFunctions = {
0: requestSupabaseToday,
1: requestSupabaseToday,
};
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.primary,
@@ -52,7 +57,7 @@ class PageDashboard extends StatelessWidget {
],
),
body: FutureBuilder(
future: requestSupabaseToday(),
future: viewDatabaseFunctions[Provider.of<ViewProvider>(context, listen: false).selectedView]!(),
builder: (context, snapshot) {
return Consumer<ViewProvider> (
builder: (context, viewProvider, child) {
@@ -61,6 +66,38 @@ class PageDashboard extends StatelessWidget {
);
},
),
drawer: Drawer(
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 60),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text("Ansichten", textAlign: TextAlign.center, style: TextStyle(fontSize: 20,),),
const SizedBox(height: 20),
FilledButton.icon(
style: const ButtonStyle(padding: WidgetStatePropertyAll(EdgeInsets.symmetric(vertical: 20))),
icon: const Icon(Icons.today),
label: const Text("Alle - Heute"),
onPressed: () {
Provider.of<ViewProvider>(context, listen: false).setSelectedView(0);
Navigator.pop(context);
},
),
SizedBox(height: 10),
FilledButton.icon(
style: const ButtonStyle(padding: WidgetStatePropertyAll(EdgeInsets.symmetric(vertical: 20))),
icon: const Icon(Icons.today),
label: const Text("Durchschnitt - Heute"),
onPressed: () {
Provider.of<ViewProvider>(context, listen: false).setSelectedView(1);
Navigator.pop(context);
},
),
],
),
),
),
);
}
}