login variable zum ein und auschalten der mängel liste (Später möglicherweise auch nutzbar für "Darf nur mängel posten wen angemeldet"

This commit is contained in:
2022-12-21 16:15:55 +01:00
parent 8ccd755737
commit 7ab6be455f
5 changed files with 77 additions and 10 deletions
+46 -2
View File
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'UserDefinedList.dart';
@@ -13,9 +15,14 @@ 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);
static /*const*/ final List<Widget> _widgetOptions = <Widget>[
/*static /*const*/ final List<Widget> _widgetOptions = <Widget>[
/*Text(
'Index 0: News',
style: optionStyle,
@@ -26,7 +33,7 @@ class _MyHomePageState extends State<MyHomePage> {
'Index 2: Profil',
style: optionStyle,
)
];
];*/
void _onItemTapped(int index) {
setState(() {
@@ -34,8 +41,45 @@ class _MyHomePageState extends State<MyHomePage> {
});
}
void setLogin(bool value) {
setState(() {
login = value;
isIssueItemEnabled = value;
});
}
@override
Widget build(BuildContext context) {
final List<Widget> _widgetOptions = <Widget>[
NewsList(),
login ? IssueList() : Container(
child: 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 Text(
'Index 2: Profil',
style: optionStyle,
)*/
return Scaffold(
appBar: AppBar(
title: const Text('Oggauer Gemeinde Trommler'),