Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -916,4 +916,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: d5ebeed53a738c4992d155ad65b0166c472906e5

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
1 change: 1 addition & 0 deletions lib/Screens/Chat/chat_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:app_prototyo/Screens/Chat/chat_service.dart';
import 'package:app_prototyo/Screens/Findscreen/SeeUser/seeuser.dart';
import 'package:app_prototyo/Screens/LogIn/auth_page.dart';
import 'package:app_prototyo/Screens/LogIn/services/auth_service.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
Expand Down
74 changes: 21 additions & 53 deletions lib/Screens/LogIn/auth_page.dart
Original file line number Diff line number Diff line change
@@ -1,61 +1,29 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:app_prototyo/Screens/LogIn/login_or_register_page.dart';
import 'package:app_prototyo/Screens/homebar.dart';
import 'package:app_prototyo/Screens/CreateUser/welcomescreen.dart';

class AuthPage extends StatelessWidget {
const AuthPage({Key? key});
import 'package:google_sign_in/google_sign_in.dart';

@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// Warte 3 Sekunden, bevor der Ladeindikator angezeigt wird
Future.delayed(Duration(seconds: 3));
return Center(
child: CircularProgressIndicator(),
);
}
class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;

if (snapshot.hasData && snapshot.data != null) {
// Wenn eingeloggt
User? user = snapshot.data;
// Google Sign in
signInWithGoogle() async {
// begin interactive sign in process
final GoogleSignInAccount? gUser = await GoogleSignIn().signIn();

return FutureBuilder<DocumentSnapshot>(
future: FirebaseFirestore.instance
.collection('user')
.doc(user?.uid)
.get(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
}
// obtain auth details from request
final GoogleSignInAuthentication gAuth = await gUser!.authentication;

if (snapshot.hasData &&
snapshot.data != null &&
snapshot.data!.exists) {
// Benutzer ist bereits registriert
return TabsScreen(); // Navigiere zum TabsScreen nach der Anmeldung
} else {
// Benutzer ist neu registriert
return WelcomeScreen(); // Navigiere zum WelcomeScreen nach der Registrierung
}
},
);
} else {
return LoginOrRegisterPage(); // Wenn nicht eingeloggt, zur LoginPage-Seite navigieren oder zur Register Page
}
},
),
// create a new credential for user (credential = Berechtigung)
final credential = GoogleAuthProvider.credential(
accessToken: gAuth.accessToken,
idToken: gAuth.idToken,
);

// sign in
return await FirebaseAuth.instance.signInWithCredential(credential);
}

User? getCurrentUser() {
return _auth.currentUser;
}
}

149 changes: 96 additions & 53 deletions lib/Screens/LogIn/forgot_pw_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';

Expand All @@ -17,15 +19,15 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
super.dispose();
}

Future passwordReset() async {
Future<void> passwordReset() async {
try {
await FirebaseAuth.instance
.sendPasswordResetEmail(email: _emailController.text.trim());
showDialog(
context: context,
builder: (context) {
return const AlertDialog(
content: Text('Password reset link sent! Check your email'),
content: Text('Password reset link sent! Check your email.'),
);
},
);
Expand All @@ -41,8 +43,61 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
}
}

Widget buildTextField({
required TextEditingController controller,
required String hintText,
required bool obscureText,
}) {
return TextField(
controller: controller,
obscureText: obscureText,
style: const TextStyle(color: Colors.white),
decoration: InputDecoration(
hintText: hintText,
hintStyle: const TextStyle(color: Colors.white70),
filled: true,
fillColor: const Color.fromRGBO(1, 25, 45, 0.7),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Colors.transparent),
borderRadius: BorderRadius.circular(10),
),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(10),
),
),
);
}

Widget buildButton({
required String text,
required VoidCallback onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: const Color.fromRGBO(41, 51, 76, 1.0),
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
);
}

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;

return Scaffold(
appBar: AppBar(
iconTheme: const IconThemeData(
Expand All @@ -52,63 +107,51 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {
elevation: 0,
),
backgroundColor: const Color.fromRGBO(75, 173, 193, 1.0),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// icon lock
Container(
margin: const EdgeInsets.only(
top: 20,
bottom: 5,
left: 20,
right: 20,
body: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 135),
Icon(
Icons.email_outlined,
size: screenWidth * 0.3,
color: Colors.white,
),
width: 200, // --> skaliert das LOGO
child: Image.asset('assets/bilder/open_lock.png',
color: const Color.fromARGB(255, 41, 51, 76)),
),
const SizedBox(height: 70),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text(
'Enter your Email and we will send you a password reset link',
const SizedBox(height: 20),
const Text(
'Forgot Password',
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
const Text(
'Enter your email address below to receive a password reset link.',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20),
style: TextStyle(
color: Colors.white70,
fontSize: 16,
),
),
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: TextField(
const SizedBox(height: 20),
buildTextField(
controller: _emailController,
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(color: Color.fromRGBO(75, 173, 193, 1.0)),
),
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(color: Color.fromARGB(255, 41, 51, 76)),
),
fillColor: const Color.fromARGB(214, 216, 231, 234),
filled: true,
hintText: 'Email',
hintStyle: TextStyle(color: Colors.grey[600]),
),
hintText: 'Email',
obscureText: false,
),
),
const SizedBox(height: 20),
MaterialButton(
height: 40,
onPressed: passwordReset,
color: const Color.fromARGB(255, 41, 51, 76),
child: const Text(
'Reset Password',
style: TextStyle(color: Colors.white),
const SizedBox(height: 20),
buildButton(
text: 'Reset Password',
onTap: passwordReset,
),
),
],
],
),
),
),
);
Expand Down
Loading