CitizenForum done. Navbar working great. Introduced cache for firestore to hopefully don't reach the bandwith limit again

This commit is contained in:
2023-04-27 22:49:58 +02:00
parent 6590e708c1
commit 6834e34b6a
4 changed files with 245 additions and 53 deletions
+30 -35
View File
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'UserDefinedList.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
const MyHomePage({Key? key, required this.title});
final String title;
@@ -14,89 +14,84 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 0;
bool login = false;
bool isIssueItemEnabled = true;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
void setLogin(bool value) {
setState(() {
login = value;
isIssueItemEnabled = value;
});
}
@override
Widget build(BuildContext context) {
final List<Widget> widgetOptions = <Widget>[
const CitizensForum(),
const NewsList(),
login ? const IssueList(): const Text(
'Mängel (nur für angemeldete Benutzer verfügbar)',
style: optionStyle,
textAlign: TextAlign.center,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: Text(login ? 'Logout' : 'Login'),
onPressed: () {
setLogin(!login);
},
),
const Text(
'Index 2: Profil',
style: optionStyle,
),
],
),
const IssueList(),
Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
ElevatedButton(
child: Text(login ? 'Logout' : 'Login'),
onPressed: () {
setLogin(!login);
},
),
const Text(
'Index 2: Profil',
style: optionStyle,
),
])
];
return Scaffold(
appBar: AppBar(
title: const Text('Oggauer Gemeinde Trommler'),
),
body: Center(
child: widgetOptions.elementAt(_selectedIndex),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddScreen(initialIndex: _selectedIndex,)),
MaterialPageRoute(
builder: (context) => AddScreen(initialIndex: _selectedIndex)),
);
},
tooltip: "Add",
child: Icon(Icons.add),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>
[
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'BürgerForum',
),
BottomNavigationBarItem(
icon: Icon(Icons.newspaper),
label: 'News',
label: 'Neuigkeiten',
),
BottomNavigationBarItem(
icon: Icon(Icons.report),
label: 'Mängel',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
icon: Icon(Icons.account_circle),
label: 'Profil',
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.blue,
unselectedItemColor: Colors.black26,
onTap: _onItemTapped,
),
);
}
}
}