Log In Page Layout erstellt
This commit is contained in:
+82
-22
@@ -1,19 +1,29 @@
|
|||||||
import 'package:oggauergemeindetrommler/AddPage.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'AddPage.dart';
|
||||||
import 'UserDefinedList.dart';
|
import 'UserDefinedList.dart';
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key, required this.title});
|
const MyHomePage({Key? key, required this.title});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
//final TextEditingController _emailController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValidEmail(String email) {
|
||||||
|
// Hier kannst du deine Validierungslogik implementieren
|
||||||
|
// Rückgabe true, wenn die E-Mail gültig ist, andernfalls false
|
||||||
|
// Beispiel:
|
||||||
|
return RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email);
|
||||||
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
bool login = false;
|
final TextEditingController _emailController = TextEditingController();
|
||||||
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
|
||||||
static const TextStyle optionStyle =
|
static const TextStyle optionStyle =
|
||||||
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
||||||
@@ -24,32 +34,81 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLogin(bool value) {
|
|
||||||
setState(() {
|
|
||||||
login = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<Widget> widgetOptions = <Widget>[
|
final List<Widget> widgetOptions = <Widget>[
|
||||||
const GenericList(collectionName: 'CitizensForum'),
|
const GenericList(collectionName: 'CitizensForum'),
|
||||||
const GenericList(collectionName: 'News'),
|
const GenericList(collectionName: 'News'),
|
||||||
const GenericList(collectionName: 'Issues'),
|
const GenericList(collectionName: 'Issues'),
|
||||||
Column(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
Column(
|
||||||
ElevatedButton(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Text(login ? 'Logout' : 'Login'),
|
children: <Widget>[
|
||||||
onPressed: () {
|
const SizedBox(height: 16),
|
||||||
setLogin(!login);
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _emailController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'E-Mail',
|
||||||
|
),
|
||||||
|
|
||||||
|
validator: (value) {
|
||||||
|
if (value!.isEmpty) {
|
||||||
|
return 'Bitte geben Sie eine E-Mail-Adresse ein.';
|
||||||
|
} else if (!isValidEmail(value)) {
|
||||||
|
return 'Bitte geben Sie eine gültige E-Mail-Adresse ein.';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Text(
|
|
||||||
'Index 2: Profil',
|
const SizedBox(height: 16),
|
||||||
style: optionStyle,
|
TextFormField(
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Passwort',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
String email = _emailController.text;
|
||||||
|
if (isValidEmail(email)) {
|
||||||
|
// E-Mail ist gültig, führe die entsprechende Aktion aus
|
||||||
|
} else {/*
|
||||||
|
_scaffoldKey.currentState!.showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Ungültige E-Mail-Adresse'),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text('Anmelden'),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text('Noch kein Konto?'),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
// Navigiere zur Registrierungsseite
|
||||||
|
},
|
||||||
|
child: Text('Registrieren'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
])
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Oggauer Gemeinde Trommler'),
|
title: const Text('Oggauer Gemeinde Trommler'),
|
||||||
@@ -57,17 +116,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
body: Center(
|
body: Center(
|
||||||
child: widgetOptions.elementAt(_selectedIndex),
|
child: widgetOptions.elementAt(_selectedIndex),
|
||||||
),
|
),
|
||||||
floatingActionButton: _selectedIndex == 3 // Wenn der ausgewählte Index 3 ist, also auf dem Profil-Widget
|
floatingActionButton: _selectedIndex == 3
|
||||||
? null // Zeigt keinen Button an
|
? null
|
||||||
: FloatingActionButton(
|
: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AddScreen(initialIndex: _selectedIndex)),
|
builder: (context) => AddScreen(initialIndex: _selectedIndex),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
tooltip: "Add",
|
tooltip: 'Add',
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user