diff --git a/assets/images/password.png b/assets/images/password.png new file mode 100644 index 0000000..ca59c44 Binary files /dev/null and b/assets/images/password.png differ diff --git a/lib/forget_passwort/forget_pass_screen.dart b/lib/forget_passwort/forget_pass_screen.dart index 21a2ea2..3286483 100644 --- a/lib/forget_passwort/forget_pass_screen.dart +++ b/lib/forget_passwort/forget_pass_screen.dart @@ -1,48 +1,114 @@ +import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; -class ForgetPasswort extends StatefulWidget { - @override - State createState() => _ForgetPasswortState(); -} +import '../login_page/login_screen.dart'; +import '../services/global_variables.dart'; -class _ForgetPasswortState extends State { +class ForgetPasswort extends StatelessWidget { final TextEditingController _emailController = TextEditingController(); + final FirebaseAuth _auth = FirebaseAuth.instance; + + ForgetPasswort({Key? key}) : super(key: key); + + void _forgetPassSubmitForm(BuildContext context) async { + try { + await _auth.sendPasswordResetEmail( + email: _emailController.text, + ); + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => Login()), + ); + } catch (error) { + Fluttertoast.showToast(msg: error.toString()); + } + } @override Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + return Scaffold( - appBar: AppBar( - title: const Text('Passwort vergessen'), - ), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - const Text( - 'Geben Sie Ihre E-Mail-Adresse ein, um das Passwort zurückzusetzen:', - style: TextStyle(fontSize: 16), - ), - const SizedBox(height: 16), - TextFormField( - controller: _emailController, - keyboardType: TextInputType.emailAddress, - decoration: InputDecoration( - labelText: 'E-Mail-Adresse', - border: OutlineInputBorder(), + body: SingleChildScrollView( + child: Container( + height: size.height - 18, // Adjust for bottom overflow + child: Stack( + children: [ + Image.network( + signupUrlImage, + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, ), - ), - const SizedBox(height: 16), - ElevatedButton( - onPressed: () { - final email = _emailController.text; - // Fügen Sie hier den Code für das Zurücksetzen des Passworts hinzu - }, - child: const Text('Passwort zurücksetzen'), - ), - ], + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 80), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.only(left: 80, right: 80), + child: Transform.scale( + scale: 0.8, // 20% smaller + child: Image.asset('assets/images/password.png'), + ), + ), + const SizedBox(height: 15), + const Text( + 'Geben Sie Ihre E-Mail-Adresse ein, um das Passwort zurückzusetzen:', + style: TextStyle(fontSize: 16), + ), + const SizedBox(height: 16), + TextFormField( + controller: _emailController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + labelText: 'E-Mail', + filled: true, + fillColor: Colors.blueGrey.withOpacity(0.2), + errorBorder: const UnderlineInputBorder( + borderSide: BorderSide(color: Colors.red), + ), + ), + validator: (value) { + if (value!.isEmpty) { + return 'Bitte geben Sie Ihre E-Mail-Adresse ein'; + } + return null; + }, + ), + const SizedBox(height: 15), + ElevatedButton( + onPressed: () { + _forgetPassSubmitForm(context); + }, + style: ElevatedButton.styleFrom( + primary: Colors.cyan, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(13), + ), + ), + child: Padding( + padding: EdgeInsets.symmetric(vertical: 14), + child: Text( + 'Reset Passwort', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), ), ), ); } -} +} \ No newline at end of file diff --git a/lib/login_page/login_screen.dart b/lib/login_page/login_screen.dart index ef08e31..67561f0 100644 --- a/lib/login_page/login_screen.dart +++ b/lib/login_page/login_screen.dart @@ -1,10 +1,11 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:cpd_ss23/ForgetPasswort/forget_pass_screen.dart'; +import 'package:cpd_ss23/forget_passwort/forget_pass_screen.dart'; import 'package:cpd_ss23/services/global_methods.dart'; import 'package:cpd_ss23/services/global_variables.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; +import '../forget_passwort/forget_pass_screen.dart'; import '../signup_page/signup_screen.dart'; class Login extends StatefulWidget { diff --git a/lib/signup_page/signup_screen.dart b/lib/signup_page/signup_screen.dart index 8a677b8..8c268c3 100644 --- a/lib/signup_page/signup_screen.dart +++ b/lib/signup_page/signup_screen.dart @@ -109,7 +109,7 @@ class _SignUpState extends State { 'createdAt': Timestamp.now(), }); - Navigator.canPop(context) ? Navigator.of(context) : null; + Navigator.canPop(context) ? Navigator.pop(context) : null; } catch (e) { // Handle any errors that occur during sign-up setState(){ @@ -117,7 +117,6 @@ class _SignUpState extends State { } GlobalMethod.showErrorDialog(error: e.toString(), ctx: context); } - setState(() { _isLoading = false; });