diff --git a/lib/LoginPage.dart b/lib/LoginPage.dart new file mode 100644 index 0000000..fdca8a1 --- /dev/null +++ b/lib/LoginPage.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; + +class LoginPage extends StatefulWidget { + LoginPage({Key? key}) : super(key: key); + + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + final _emailController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + super.dispose(); + } + + 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); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + children: [ + TextFormField( + controller: _emailController, + decoration: const 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 SizedBox(height: 16), + 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 { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Ungültige E-Mail-Adresse'), + duration: Duration(seconds: 2), + ), + ); + } + }, + child: const Text('Anmelden'), + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Noch kein Konto?'), + TextButton( + onPressed: () { + // Navigiere zur Registrierungsseite + }, + child: const Text('Registrieren'), + ), + ], + ), + ], + ), + ), + ], + ), + ); + } +} + diff --git a/lib/home.dart b/lib/home.dart index 9a9c1c3..c8b4c47 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -1,54 +1,30 @@ -import 'package:oggauergemeindetrommler/AddPage.dart'; import 'package:flutter/material.dart'; +import 'package:oggauergemeindetrommler/LoginPage.dart'; +import 'AddPage.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; - @override State createState() => _MyHomePageState(); } - class _MyHomePageState extends State { int _selectedIndex = 0; - bool login = false; - - static const TextStyle optionStyle = - TextStyle(fontSize: 30, fontWeight: FontWeight.bold); - void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } - void setLogin(bool value) { - setState(() { - login = value; - }); - } - - @override Widget build(BuildContext context) { final List widgetOptions = [ - const GenericList(collectionName: 'CitizensForum', selectedIndex: 0), - const GenericList(collectionName: 'News', selectedIndex: 1), - const GenericList(collectionName: 'Issues', selectedIndex: 2), - Column(mainAxisAlignment: MainAxisAlignment.center, children: [ - ElevatedButton( - child: Text(login ? 'Logout' : 'Login'), - onPressed: () { - setLogin(!login); - }, - ), - const Text( - 'Index 2: Profil', - style: optionStyle, - ), - ]) + const GenericList(collectionName: 'CitizensForum'), + const GenericList(collectionName: 'News'), + const GenericList(collectionName: 'Issues'), + LoginPage() ]; return Scaffold(