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