Skip to content
Snippets Groups Projects
Commit 19dda40f authored by Madlen Ort's avatar Madlen Ort
Browse files

Weitergemacht

parent 0f7ba831
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; ...@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import '../firebase.dart'; import '../firebase.dart';
//Suchleiste mit den Vorschlägen aller Genres aus Spotify
class CustomSearchDelegate extends SearchDelegate<String>{ class CustomSearchDelegate extends SearchDelegate<String>{
String colorText; String colorText;
CustomSearchDelegate(this.colorText); CustomSearchDelegate(this.colorText);
......
This diff is collapsed.
...@@ -8,6 +8,11 @@ import 'package:page_transition/page_transition.dart'; ...@@ -8,6 +8,11 @@ import 'package:page_transition/page_transition.dart';
import '../homepage.dart'; import '../homepage.dart';
/*
Klasse zum Einloggen
Die Daten werden aus der Datenbank geholt
Entsprechende Fehlermeldungen werden abgefangen
*/
class LoginPage extends StatefulWidget { class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key); const LoginPage({Key? key}) : super(key: key);
...@@ -61,9 +66,9 @@ class _LoginPageState extends State<LoginPage> { ...@@ -61,9 +66,9 @@ class _LoginPageState extends State<LoginPage> {
keyboardType: TextInputType.name, keyboardType: TextInputType.name,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.person, color: Colors.white), prefixIcon: Icon(Icons.person, color: Colors.white),
hintText: 'Username', hintText: 'E-Mail',
hintStyle: TextStyle(color: Colors.white), hintStyle: TextStyle(color: Colors.white),
labelText: 'Username', labelText: 'E-Mail',
labelStyle: TextStyle(color: Colors.white), labelStyle: TextStyle(color: Colors.white),
), ),
),), ),),
...@@ -91,7 +96,7 @@ class _LoginPageState extends State<LoginPage> { ...@@ -91,7 +96,7 @@ class _LoginPageState extends State<LoginPage> {
FirebaseAuth.instance.signInWithEmailAndPassword( FirebaseAuth.instance.signInWithEmailAndPassword(
email: _emailTextController.text, email: _emailTextController.text,
password: _passwordTextController.text).then((value) { password: _passwordTextController.text).then((value) {
Navigator.push(context, MaterialPageRoute(builder: (context)=>const HomePage())); Navigator.push(context, MaterialPageRoute(builder: (context)=>const ClassificationPage()));
}).onError((error, stackTrace){ }).onError((error, stackTrace){
setState(() { setState(() {
_wrongInput = true; _wrongInput = true;
......
...@@ -4,10 +4,14 @@ import 'package:firebase_auth/firebase_auth.dart'; ...@@ -4,10 +4,14 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../classification/classification.dart'; import '../classification/classification.dart';
import 'package:ambient/loginRegister/login.dart'; import 'package:ambient/loginRegister/login.dart';
import 'package:page_transition/page_transition.dart'; import 'package:page_transition/page_transition.dart';
/*
Klasse zum Registrieren
Die User Daten werden in die Firebase Datenbank gespeichert
Fehlermeldungen beim Registrieren werden abgefangen
*/
class RegistrationPage extends StatefulWidget { class RegistrationPage extends StatefulWidget {
const RegistrationPage({Key? key}) : super(key: key); const RegistrationPage({Key? key}) : super(key: key);
...@@ -41,7 +45,6 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -41,7 +45,6 @@ class _RegistrationPage extends State<RegistrationPage> {
Scaffold( Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Center( body: Center(
child :Container( child :Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -53,7 +56,7 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -53,7 +56,7 @@ class _RegistrationPage extends State<RegistrationPage> {
const Expanded( const Expanded(
child: Text( child: Text(
'Ambient!', 'Ambient!',
style: TextStyle(fontSize: 60.0, color: Colors.white), style: TextStyle(fontSize: 50.0, color: Colors.white),
),), ),),
Expanded( Expanded(
...@@ -111,25 +114,27 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -111,25 +114,27 @@ class _RegistrationPage extends State<RegistrationPage> {
), ),
loginRegisterButton(context, false, () { loginRegisterButton(context, false, () {
try{
FirebaseAuth.instance.createUserWithEmailAndPassword( FirebaseAuth.instance.createUserWithEmailAndPassword(
email: _emailTextController.text, email: _emailTextController.text,
password: _passwordTextController.text).then((value){ password: _passwordTextController.text).then((value){
createSetUp(); createSetUp();
print ("Created new account"); print ("Created new account");
Navigator.push(context, MaterialPageRoute(builder: (context)=>ClassificationPage())); Navigator.push(context, MaterialPageRoute(builder: (context)=>ClassificationPage()));
});} }).onError((error, stackTrace){
on FirebaseAuthException catch(e){ String e = error.toString();
if(e.code == 'ERROR_EMAIL_ALREADY_IN_USE'){ print('Error 1 ' + error.toString());
if(error.toString().contains('email-already-in-use')){
print("Email already in use");
setState(() { setState(() {
_infoText = 'Email already in use'; _infoText = 'Email already in use';
}); });
} }
if(e.code == 'weak-password'){ else if(error.toString().contains('weak-password')){
setState(() { setState(() {
_infoText = 'weak Password'; _infoText = 'weak Password';
});} });}
if(e.code == 'invalid-email'){ else if(error.toString().contains('invalid-email')){
setState(() { setState(() {
_infoText = 'invalid email'; _infoText = 'invalid email';
});} });}
...@@ -139,7 +144,7 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -139,7 +144,7 @@ class _RegistrationPage extends State<RegistrationPage> {
}); });
} }
}; });
}), }),
SizedBox(height: 20), SizedBox(height: 20),
loginPage(), loginPage(),
...@@ -177,13 +182,10 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -177,13 +182,10 @@ class _RegistrationPage extends State<RegistrationPage> {
); );
} }
Future addDisplayName() async{ //Beim Anlegen eines Accounts werden auch die Farben angelegt,
FirebaseAuth.instance.currentUser?.updateDisplayName(_usernameTextController.text); //damit der User später die Genres zuordnen kann
}
Future createSetUp() async{ Future createSetUp() async{
//final String id = '${FirebaseAuth.instance.currentUser?.uid.toString()}_genres';
final String id = (FirebaseAuth.instance.currentUser?.uid.toString())!+'_genres'; final String id = (FirebaseAuth.instance.currentUser?.uid.toString())!+'_genres';
final user = FirebaseFirestore.instance.collection('classification').doc(id); final user = FirebaseFirestore.instance.collection('classification').doc(id);
...@@ -200,6 +202,7 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -200,6 +202,7 @@ class _RegistrationPage extends State<RegistrationPage> {
'Brown' : null, 'Brown' : null,
'Black' : null, 'Black' : null,
}; };
print('set up');
await user.set(json); await user.set(json);
} }
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; ...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'login.dart'; import 'login.dart';
//Widgets für den Login/Registrations Screen
Container loginRegisterButton( Container loginRegisterButton(
BuildContext context, bool isLogin, Function onTap) { BuildContext context, bool isLogin, Function onTap) {
return Container( return Container(
...@@ -71,7 +73,6 @@ Container signOutButton( ...@@ -71,7 +73,6 @@ Container signOutButton(
//textWidth //textWidth
height: 10, height: 10,
child: Text( child: Text(
text, text,
style: const TextStyle( style: const TextStyle(
color: Colors.red), color: Colors.red),
......
...@@ -8,9 +8,11 @@ import Foundation ...@@ -8,9 +8,11 @@ import Foundation
import cloud_firestore import cloud_firestore
import firebase_auth import firebase_auth
import firebase_core import firebase_core
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
} }
...@@ -64,6 +64,13 @@ packages: ...@@ -64,6 +64,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.0" version: "1.16.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -78,6 +85,20 @@ packages: ...@@ -78,6 +85,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.4"
firebase_auth: firebase_auth:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -149,6 +170,13 @@ packages: ...@@ -149,6 +170,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
google_fonts:
dependency: "direct main"
description:
name: google_fonts
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.3"
google_nav_bar: google_nav_bar:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -156,6 +184,13 @@ packages: ...@@ -156,6 +184,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.6" version: "5.0.6"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.5"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
...@@ -219,6 +254,55 @@ packages: ...@@ -219,6 +254,55 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.8.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.22"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.7"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
...@@ -226,6 +310,13 @@ packages: ...@@ -226,6 +310,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -287,6 +378,20 @@ packages: ...@@ -287,6 +378,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+3"
sdks: sdks:
dart: ">=2.18.5 <3.0.0" dart: ">=2.18.5 <3.0.0"
flutter: ">=1.20.0" flutter: ">=3.0.0"
...@@ -42,6 +42,7 @@ dependencies: ...@@ -42,6 +42,7 @@ dependencies:
page_transition: ^2.0.9 page_transition: ^2.0.9
flutter_custom_clippers: ^2.1.0 flutter_custom_clippers: ^2.1.0
cloud_firestore: ^4.3.0 cloud_firestore: ^4.3.0
google_fonts: ^2.1.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment