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

Weitergemacht

parent b878a1e5
No related branches found
No related tags found
No related merge requests found
import 'package:flutter/material.dart';
class CustomSearchDelegate extends SearchDelegate {
import '../firebase.dart';
class CustomSearchDelegate extends SearchDelegate<String>{
String colorText;
CustomSearchDelegate(this.colorText);
late String searchGenre;
// Demo list to show querying
static List<String> searchTerms = [
"acoustic",
......@@ -131,6 +137,7 @@ class CustomSearchDelegate extends SearchDelegate {
"world-music"
];
// first overwrite to
// clear the search text
@override
......@@ -150,7 +157,7 @@ class CustomSearchDelegate extends SearchDelegate {
Widget? buildLeading(BuildContext context) {
return IconButton(
onPressed: () {
close(context, null);
close(context, '');
},
icon: Icon(Icons.arrow_back),
);
......@@ -192,8 +199,12 @@ class CustomSearchDelegate extends SearchDelegate {
var result = matchQuery[index];
return ListTile(
title: Text(result),
onTap: () {
close(context, result);
changeFirebase().updateColorGenre(colorText, result);}
);
},
);
}
}
\ No newline at end of file
import 'package:ambient/firebase.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_custom_clippers/flutter_custom_clippers.dart';
import 'CustomSearchDelegate.dart';
import 'homepage.dart';
import '../homepage.dart';
class ClassificationPage extends StatefulWidget {
const ClassificationPage({Key? key}) : super(key: key);
......@@ -16,6 +17,9 @@ class ClassificationPage extends StatefulWidget {
class _ClassificationPageState extends State<ClassificationPage> {
final String id = (FirebaseAuth.instance.currentUser?.uid.toString())!+'_genres';
Color _ambientBackgroundColor = Colors.grey.withOpacity(0.5);
Color _ambientHeader = Colors.white;
......@@ -25,29 +29,14 @@ class _ClassificationPageState extends State<ClassificationPage> {
bool _orangeSelected = false;
bool _yellowSelected = false;
bool _greenSelected = false;
bool _whiteSelected = false;
bool _blueSelected = false;
bool _pinkSelected = false;
bool _purpleSelected = false;
bool _brownSelected = false;
bool _blackSelected = false;
void _redContainerWasTapped() {
setState(() => _redSelected = !_redSelected);
//if redSelected = true dann rot, sonst wieder grau
_ambientBackgroundColor = Colors.red;
if (!_redSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}
}
void _orangeContainerWasTapped() {
setState(() => _orangeSelected = !_orangeSelected);
_ambientBackgroundColor = Colors.orange;
if (!_orangeSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}
}
void _yellowContainerWasTapped() {
setState(() => _yellowSelected = !_yellowSelected);
_ambientBackgroundColor = Colors.yellow;
if (!_yellowSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}
}
void _greenContainerWasTapped() {
setState(() => _greenSelected = !_greenSelected);
_ambientBackgroundColor = Colors.green;
if (!_greenSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}
}
bool _errorText = false;
@override
Widget build(BuildContext context) {
......@@ -74,60 +63,169 @@ class _ClassificationPageState extends State<ClassificationPage> {
Expanded(
child: ListView(
children: <Widget>[
SizedBox(height: 20,),
const SizedBox(height: 20,),
GestureDetector(
onTap: _redContainerWasTapped,
onTap: (){
if(!_redSelected){closeAll(); setState(() => _redSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.red;
if (!_redSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
//if Datenbank bei rot = 0, dann not selected, ansonsten change
child: _redSelected ?
selectedColor(
"Red", Colors.red, "Rot Rec 1", "Rot Rec 2",
"Rot Rec 3") : noSelection("Red")
selectedColor("Red", Colors.red, Colors.white.withOpacity(0.7),
"rock","latin", "blues",
'Starke Emotionen, Liebe, Energie') : noSelection("Red")
)
,),
SizedBox(height: 20,),
const SizedBox(height: 20,),
GestureDetector(
onTap: _orangeContainerWasTapped,
onTap: (){
if(!_orangeSelected){closeAll(); setState(() => _orangeSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.orange;
if (!_orangeSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _orangeSelected ?
selectedColor(
"Orange", Colors.orange, "Orange 1",
"Orange 2", "Orange 3") : noSelection(
"Orange")
selectedColor("Orange", Colors.orange, Colors.white.withOpacity(0.7),
"soul", "jazz", "Orange 3", 'Wärme, Energie, Herbst') : noSelection("Orange")
)
,),
SizedBox(height: 20,),
const SizedBox(height: 20,),
GestureDetector(
onTap: _yellowContainerWasTapped,
onTap: () {
if(!_yellowSelected){closeAll(); setState(() => _yellowSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.yellow;
if (!_yellowSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _yellowSelected ?
selectedColor(
"Yellow", Colors.yellow, "Yellow1",
"Yellow1", "Yellow1") : noSelection(
"Yellow")
selectedColor("Yellow", Colors.yellow, Colors.white,
"pop", "funk", "country", 'Freude, Optimismus, Wärme') : noSelection("Yellow")
)
,),
SizedBox(height: 20,),
const SizedBox(height: 20,),
GestureDetector(
onTap: _greenContainerWasTapped,
onTap: () {
if(!_greenSelected){closeAll(); setState(() => _greenSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.green;
if (!_greenSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _greenSelected ?
selectedColor("Green", Colors.green, Colors.white.withOpacity(0.7),
"ambient", "classical", "new-age", 'Ruhe, Wachstum, Natur') : noSelection("Green")
)
,),
const SizedBox(height: 20,),
GestureDetector(
onTap: (){
if(!_whiteSelected){closeAll(); setState(() => _whiteSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.white60;
if (!_whiteSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _whiteSelected ?
selectedColor("White", Colors.white60, Colors.grey,
"classical", "ambient", "piano", 'Reinheit, Frieden, Gelassenheit') : noSelection("White")
)
,),
const SizedBox(height: 20,),
GestureDetector(
onTap: () {
if(!_blueSelected){closeAll(); setState(() => _blueSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.blue;
if (!_blueSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _blueSelected ?
selectedColor( "Blue", Colors.blue, Colors.white.withOpacity(0.7),
"blues", "rainy-day", "indie-pop", 'Ruhe, Gelassenheit, Traurigkeit') : noSelection("Blue")
)
,),
const SizedBox(height: 20,),
GestureDetector(
onTap: () {
if(!_pinkSelected){closeAll(); setState(() => _pinkSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.pinkAccent;
if (!_pinkSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _pinkSelected ?
selectedColor(
"Green", Colors.green, "Green1",
"Green2", "Green3") : noSelection(
"Green")
"Pink", Colors.pink, Colors.white.withOpacity(0.7),
"pop", "k-pop", "r-n-b", 'Romantik, Anmut, Nostalgie') : noSelection("Pink")
)
,),
const SizedBox(height: 20,),
GestureDetector(
onTap: () {
if(!_purpleSelected){closeAll(); setState(() => _purpleSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.purple;
if (!_purpleSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _purpleSelected ?
selectedColor("Purple", Colors.purple, Colors.white.withOpacity(0.7),
"rock", "classical", "hip-hop", 'Luxus, Spiritualität, Ambition') : noSelection("Purple")
)
,),
SizedBox(height: 20,),
ElevatedButton(
const SizedBox(height: 20,),
GestureDetector(
onTap: () {
if(!_brownSelected){closeAll(); setState(() => _brownSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.brown;
if (!_brownSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _brownSelected ?
selectedColor("Brown", Colors.brown, Colors.white.withOpacity(0.7),
"country", "Brown2", "Brown3", 'info') : noSelection("Brown")
)
,),
const SizedBox(height: 20,),
GestureDetector(
onTap: () {
if(!_blackSelected){closeAll(); setState(() => _blackSelected = true); }
else{closeAll();}
_ambientBackgroundColor = Colors.black54;
if (!_blackSelected){_ambientBackgroundColor = Colors.grey.withOpacity(0.5);}},
child: Container(
child: _blackSelected ?
selectedColor("Black", Colors.black54, Colors.white.withOpacity(0.7), "Black1", "Black2", "Black3", 'info') : noSelection("Black")
)
,),
const SizedBox(height: 20,),
SizedBox(
width: 100,
child : StreamBuilder(
stream: FirebaseFirestore.instance.collection('classification').doc(id).snapshots(),
builder: (BuildContext context,
AsyncSnapshot snapshot) {
return ElevatedButton(
style:ButtonStyle(backgroundColor: MaterialStatePropertyAll<Color>(Colors.white.withOpacity(0.9))),
child: const Text(
"Skip",
style: TextStyle(color: Colors.indigo, fontWeight: FontWeight.bold),
),
"Save",
style: TextStyle(color: Colors.indigo, fontWeight: FontWeight.bold),),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context)=>const HomePage()));
}),
print(changeFirebase().checkIfEverythingSelected(snapshot).toString());
if (changeFirebase().checkIfEverythingSelected(snapshot)) {
Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage()));
}
else{
setState(() {
_errorText = true;
});
}
});
})),
Container(
child: _errorText ?
const Text('Not everything is selected!',
textAlign: TextAlign.center,
style: TextStyle( fontSize: 20, color: Colors.red),)
: null
),
SizedBox(height: 40,)
]),
),
]
......@@ -135,22 +233,28 @@ class _ClassificationPageState extends State<ClassificationPage> {
));
}
//wenn die Farbe nicht ausgewählt ist, wird kein Genre-Auswahl dargestellt und die Farben sind auf grau
Text errorText(){
return const Text(
'Not Everything is selected',
style: TextStyle(fontSize: 20, color: Colors.red)
);
}
//wenn die Farbe nicht ausgewählt ist, wird kein Genre-Auswahl dargestellt und die Farben sind grau
Column noSelection(String colorText) {
return Column(
children: [
Row(
children: [
SizedBox(width: 30, height: 50),
const SizedBox(width: 30, height: 50),
Text(colorText,
style: TextStyle(fontSize: 30, color: Colors.grey)),
style: const TextStyle(fontSize: 30, color: Colors.grey)),
]
),
Align(
alignment: Alignment.center,
child: Row(
children: [
SizedBox(width: 30),
const SizedBox(width: 30),
Container(
width: 340,
decoration: BoxDecoration(
......@@ -160,9 +264,19 @@ class _ClassificationPageState extends State<ClassificationPage> {
width: 1),
borderRadius: BorderRadius.circular(10),
),
child:
Text(checkForGenre(colorText).toString(), textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, color: Colors.grey),)
child: StreamBuilder(
stream: FirebaseFirestore.instance.collection('classification').doc(id).snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot){
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
return
Text(changeFirebase().checkForNull(snapshot.data.data()[colorText]), textAlign: TextAlign.center,
style: const TextStyle(fontSize: 20, color: Colors.grey),);
}
)
)
]
)
......@@ -170,21 +284,25 @@ class _ClassificationPageState extends State<ClassificationPage> {
]);
}
Column selectedColor(String colorText, Color color, String rec1, String rec2,
String rec3) {
Column selectedColor(String colorText, Color color, Color textColor, String rec1, String rec2, String rec3, String infoText) {
return Column(
children: [
Row(
children: [
SizedBox(width: 30, height: 50),
const SizedBox(width: 30, height: 50),
Text(colorText, style: TextStyle(fontSize: 30, color: color)),
]
IconButton(onPressed:(){
_showMyDialog(colorText, infoText);
},
alignment: Alignment.centerRight,
icon: Icon( Icons.info_outline, color: color),
),
selectedGenre(colorText, color, rec1, rec2, rec3),
],),
selectedGenre(colorText, color, textColor, rec1, rec2, rec3),
]);
}
Align selectedGenre(String colorText, Color color, String rec1, String rec2,
Align selectedGenre(String colorText, Color color, Color textColor, String rec1, String rec2,
String rec3) {
return Align(
alignment: Alignment.center,
......@@ -192,7 +310,7 @@ class _ClassificationPageState extends State<ClassificationPage> {
children: [
Row(
children: [
SizedBox(width: 30),
const SizedBox(width: 30),
Container(
width: 340,
decoration: BoxDecoration(
......@@ -203,12 +321,22 @@ class _ClassificationPageState extends State<ClassificationPage> {
borderRadius: BorderRadius.circular(10),
),
child:
Text(checkForGenre(colorText).toString(), textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, color: Colors.grey),)
StreamBuilder(
stream: FirebaseFirestore.instance.collection('classification').doc(id).snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
return
Text(changeFirebase().checkForNull(snapshot.data.data()[colorText]), textAlign: TextAlign.center,
style: TextStyle(color: color, fontSize: 20),);
}
),
]
) ]
),
SizedBox(height: 30),
const SizedBox(height: 30),
Container(
width: 340,
// alignment: Alignment.center,
......@@ -220,60 +348,58 @@ class _ClassificationPageState extends State<ClassificationPage> {
color: Colors.grey.withOpacity(0.5),
blurRadius: 10.0,
spreadRadius: 2.0,
offset: Offset(0.0, 0.0),
offset: const Offset(0.0, 0.0),
)
],
),
child: Column(
children: [
SizedBox(height: 20,),
const SizedBox(height: 20,),
Container(
width: 290,
child: TextField(
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search, color: Colors.white.withOpacity(0.7)),
Icons.search, color: textColor),
hintText: 'search for genres',
hintStyle: TextStyle(
fontSize: 20, color: Colors.white.withOpacity(0.7))),
style: TextStyle(fontSize: 20, color: Colors.white),
fontSize: 20, color: textColor)),
style: TextStyle(fontSize: 20, color: textColor),
onTap: () {
// method to show the search bar
showSearch(
context: context,
// delegate to customize the search bar
delegate: CustomSearchDelegate(),
delegate: CustomSearchDelegate(colorText),
);
},
changeFirebase().updateColorGenre(colorText, genreValue);},
),
),
SizedBox(height: 50),
const SizedBox(height: 50),
Text("Recommendation", style: TextStyle(
fontSize: 20, color: Colors.white.withOpacity(0.7))),
fontSize: 20, color: textColor)),
Column(
children: [
SizedBox(height: 20,),
const SizedBox(height: 20,),
Row(
children: [
SizedBox(width: 40,),
recommendationLabel(colorText, rec1),
const SizedBox(width: 40,),
recommendationLabel(colorText, rec1, textColor),
]
),
SizedBox(height: 20,),
const SizedBox(height: 20,),
Row(
children: [
SizedBox(width: 40,),
recommendationLabel(colorText, rec1),
const SizedBox(width: 40,),
recommendationLabel(colorText, rec2, textColor),
]
),
SizedBox(height: 20,),
const SizedBox(height: 20,),
Row(
children: [
SizedBox(width: 40,),
recommendationLabel(colorText, rec1),
const SizedBox(width: 40,),
recommendationLabel(colorText, rec3, textColor),
]
),
SizedBox(height: 50,)
const SizedBox(height: 50,)
]
)
]
......@@ -283,9 +409,9 @@ class _ClassificationPageState extends State<ClassificationPage> {
]));
}
GestureDetector recommendationLabel(String colorText, String rec) {
GestureDetector recommendationLabel(String colorText, String rec, Color textColor) {
return GestureDetector(
onTap: () => updateColorGenre(colorText, rec),
onTap: () => changeFirebase().updateColorGenre(colorText, rec),
child:Container(
child: Row(
children: [
......@@ -300,37 +426,52 @@ class _ClassificationPageState extends State<ClassificationPage> {
alignment: Alignment.center,
child: Text
(rec, textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, color: Colors.white),)
style: TextStyle(fontSize: 20, color: textColor)
),
)
]
)]
)
),
);
}
Future<void> updateColorGenre(String colorText, String genre) async {
String id = await'${FirebaseAuth.instance.currentUser?.uid.toString()}_genres';
FirebaseFirestore.instance.collection('classification')
.doc(id)
.update({colorText: genre});
closeAll();
}
Future<String> checkForGenre(String colorText) async {
String id = '${FirebaseAuth.instance.currentUser?.uid.toString()}_genres';
var document = FirebaseFirestore.instance.collection('classification').doc(id);
var snapshot = await document.get();
//snapshot.data();
//if(snapshot.data()?.containsKey(colorText)){
return await snapshot.get(colorText);
}
Future<void> _showMyDialog(String colorText, String infoText) {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text (colorText),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(infoText),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Okay'),
onPressed: () {
Navigator.of(context).pop();
},),
],);
},);}
closeAll(){
_ambientBackgroundColor = Colors.grey.withOpacity(0.5);
setState(() {
_redSelected = false;
_orangeSelected = false;
_yellowSelected = false;
_greenSelected = false;
_whiteSelected = false;
_blueSelected = false;
_pinkSelected = false;
_purpleSelected = false;
_brownSelected = false;
_blackSelected = false;
});
_ambientBackgroundColor = Colors.grey.withOpacity(0.5);
}
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
class changeFirebase{
final String id = (FirebaseAuth.instance.currentUser?.uid.toString())!+'_genres';
Future<void> updateColorGenre(String colorText, String genre) async {
await FirebaseFirestore.instance.collection('classification')
.doc(id)
.update({colorText: genre});
}
String checkForNull(var document){
if(document == null){
return 'Not Selected';
}
else{
return document.toString();
}
}
bool checkIfEverythingSelected(AsyncSnapshot snapshot){
if (snapshot.data['Red'] == null){ return false;}
if (snapshot.data['Orange'] == null){ return false;}
if (snapshot.data['Yellow'] == null){ return false;}
if (snapshot.data['Green'] == null){ return false;}
if (snapshot.data['White'] == null){ return false;}
if (snapshot.data['Blue'] == null){ return false;}
if (snapshot.data['Pink'] == null){ return false;}
if (snapshot.data['Purple'] == null){ return false;}
if (snapshot.data['Brown'] == null){ return false;}
if (snapshot.data['Black'] == null){ return false;}
return true;
}
String getGenreByHex(String code){
switch (code){
case 'FF0000':
return getGenreByColor('Red');
case 'FF8800':
return getGenreByColor('Orange');
case 'FFFF00':
return getGenreByColor('Yellow');
case 'FF8800':
return getGenreByColor('Green');
case 'FFFFFF':
return getGenreByColor('White');
case '0000FF':
return getGenreByColor('Blue');
case 'FFC0CB':
return getGenreByColor('Pink');
case 'A020F0':
return getGenreByColor('Purple');
case '964B00':
return getGenreByColor('Brown');
case '000000':
return getGenreByColor('Black');
}
return '';
}
String getGenreByColor(String color){
String genre = '';
FutureBuilder<DocumentSnapshot>(
future: FirebaseFirestore.instance.collection('classification').doc(id).get(),
builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot){
genre = snapshot.data![color];
return const SizedBox();
});
return genre;
}
}
\ No newline at end of file
File moved
File moved
import 'package:ambient/registration.dart';
import 'package:ambient/widgets.dart';
import 'package:ambient/classification/classification.dart';
import 'package:ambient/loginRegister/registration.dart';
import 'package:ambient/loginRegister/widgets.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:page_transition/page_transition.dart';
import 'homepage.dart';
import '../homepage.dart';
class LoginPage extends StatefulWidget {
......@@ -18,6 +19,7 @@ class LoginPage extends StatefulWidget {
class _LoginPageState extends State<LoginPage> {
TextEditingController _passwordTextController = TextEditingController();
TextEditingController _emailTextController = TextEditingController();
bool _wrongInput = false;
@override
......@@ -26,8 +28,12 @@ class _LoginPageState extends State<LoginPage> {
return Stack(
children: <Widget>[
Image.asset("ambientL.jpeg",height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width, fit: BoxFit.cover),
Image.asset("ambientL.jpeg",
alignment: Alignment.centerLeft,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,),
// width: MediaQuery.of(context).size.width, fit: BoxFit.cover),
Scaffold(
backgroundColor: Colors.transparent,
......@@ -36,50 +42,63 @@ class _LoginPageState extends State<LoginPage> {
child :Container(
decoration: const BoxDecoration(
),
child: SizedBox(width: 250, height: 600,
child: SizedBox(width: 250, height: 650,
child : Column(
children:[
SizedBox(height: 80,),
const Expanded(
child: Text(
'Login',
style: TextStyle(fontSize: 30.0, color: Colors.white),
'Ambient!',
style: TextStyle(fontSize: 50.0, color: Colors.white),
),),
Expanded(
child: Column(
children:[
Expanded(
child: TextField(
style: TextStyle(color: Colors.white),
controller: _emailTextController,
keyboardType: TextInputType.name,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person, color: Colors.blueGrey),
prefixIcon: Icon(Icons.person, color: Colors.white),
hintText: 'Username',
hintStyle: TextStyle(color: Colors.white),
labelText: 'Username',
labelStyle: TextStyle(color: Colors.white),
),
),),
Expanded(
child: TextField(
style: TextStyle(color: Colors.white),
controller: _passwordTextController,
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.lock_outline, color: Colors.blueGrey),
hintStyle: TextStyle(color: Colors.white),
prefixIcon: Icon(Icons.lock_outline, color: Colors.white),
hintText: 'Password',
labelText: 'Password',
labelStyle: TextStyle(color: Colors.white),
),
),),
]
)
),
_wrongInput ? const Text( 'E-Mail or password wrong',
style: TextStyle(color: Colors.red),)
: const SizedBox(),
loginRegisterButton(context, true, (){
FirebaseAuth.instance.signInWithEmailAndPassword(
email: _emailTextController.text,
password: _passwordTextController.text).then((value) {
Navigator.push(context, MaterialPageRoute(builder: (context)=>const HomePage()));
}).onError((error, stackTrace){
errorFunction("Password or email not correct");
setState(() {
_wrongInput = true;
});
});
}),
registrationPage(),
]
)
......@@ -93,7 +112,8 @@ class _LoginPageState extends State<LoginPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Have no account yet?" ,
style: TextStyle(color: Colors.black)),
style: TextStyle(color: Colors.white)),
SizedBox(width: 20,),
ElevatedButton(
style:ButtonStyle(backgroundColor: MaterialStatePropertyAll<Color>(Colors.white.withOpacity(0.9))),
child: const Text(
......
import 'package:ambient/homepage.dart';
import 'package:ambient/widgets.dart';
import 'package:ambient/loginRegister/widgets.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'classification.dart';
import '../classification/classification.dart';
import 'package:ambient/login.dart';
import 'package:ambient/loginRegister/login.dart';
import 'package:page_transition/page_transition.dart';
......@@ -21,14 +20,24 @@ class _RegistrationPage extends State<RegistrationPage> {
TextEditingController _passwordTextController = TextEditingController();
TextEditingController _emailTextController = TextEditingController();
TextEditingController _usernameTextController = TextEditingController();
String _infoText = '';
@override
Widget build(BuildContext context) {
Firebase.initializeApp();
return Stack(
children: <Widget>[
const SizedBox(
width: double.infinity,
height: double.infinity,
child: DecoratedBox( decoration: BoxDecoration(
color: Color(0xff353444),
),
),
),
Image.asset("ambientR.jpeg",height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width, fit: BoxFit.cover),
width: MediaQuery.of(context).size.width),
Scaffold(
backgroundColor: Colors.transparent,
......@@ -40,11 +49,13 @@ class _RegistrationPage extends State<RegistrationPage> {
child: SizedBox(width: 250, height: 600,
child : Column(
children:[
SizedBox(height: 40,),
const Expanded(
child: Text(
'Registration',
style: TextStyle(fontSize: 30.0, color: Colors.white),
'Ambient!',
style: TextStyle(fontSize: 60.0, color: Colors.white),
),),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
......@@ -53,45 +64,82 @@ class _RegistrationPage extends State<RegistrationPage> {
Expanded(
child: TextField(
controller: _usernameTextController,
style: TextStyle(color: Colors.white),
keyboardType: TextInputType.name,
decoration: InputDecoration(
prefixIcon: Icon(Icons.person, color: Colors.white),
hintText: 'Username',
hintStyle: TextStyle(color: Colors.white),
labelText: 'Username',
labelStyle: TextStyle(color: Colors.white.withOpacity(0.7))
),
),),
Expanded(
child: TextField(
controller: _emailTextController,
style: TextStyle(color: Colors.white),
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
prefixIcon: Icon(Icons.mail_outline, color: Colors.white),
hintText: 'Email',
hintStyle: TextStyle(color: Colors.white),
labelText: 'Email',
labelStyle: TextStyle(color: Colors.white.withOpacity(0.7))
),
),),
Expanded(
child: TextField(
controller: _passwordTextController,
style: TextStyle(color: Colors.white),
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock_outline, color: Colors.white),
hintStyle: TextStyle(color: Colors.white),
hintText: 'Password',
labelText: 'Password',
),
),),
labelStyle: TextStyle(color: Colors.white.withOpacity(0.7))
),),),
]
)
),
Text(
_infoText,
style: const TextStyle (color: Colors.red)
),
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()));
}).onError((error, stackTrace) {
print("Error ${error.toString()}");
});}
on FirebaseAuthException catch(e){
if(e.code == 'ERROR_EMAIL_ALREADY_IN_USE'){
setState(() {
_infoText = 'Email already in use';
});
//addDisplayName();
createSetUp();
}
if(e.code == 'weak-password'){
setState(() {
_infoText = 'weak Password';
});}
if(e.code == 'invalid-email'){
setState(() {
_infoText = 'invalid email';
});}
else{
setState(() {
_infoText = 'invalid Input';
});
}
};
}),
SizedBox(height: 20),
loginPage(),
......@@ -105,7 +153,8 @@ class _RegistrationPage extends State<RegistrationPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Already have an account?" ,
style: TextStyle(color: Colors.black)),
style: TextStyle(color: Colors.white)),
SizedBox(width: 20,),
ElevatedButton(
style:ButtonStyle(backgroundColor: MaterialStatePropertyAll<Color>(Colors.white.withOpacity(0.9))),
child: const Text(
......@@ -122,7 +171,6 @@ class _RegistrationPage extends State<RegistrationPage> {
child: LoginPage(),
childCurrent: RegistrationPage(),
));
},
)
],
......@@ -135,14 +183,22 @@ class _RegistrationPage extends State<RegistrationPage> {
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 json = {
'user' : _usernameTextController.text,
'Red' : 'Not Selected',
'Orange' : 'Not Selected',
'Yellow' : 'Not Selected',
'Red' : null,
'Orange' : null,
'Yellow' : null,
'Green' : null,
'White' : null,
'Blue' : null,
'Pink' : null,
'Purple' : null,
'Brown' : null,
'Black' : null,
};
await user.set(json);
}
......
File moved
import 'package:ambient/classification.dart';
import 'package:ambient/registration.dart';
import 'package:ambient/Classification/classification.dart';
import 'package:ambient/LoginRegister/registration.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'homepage.dart';
import 'login.dart';
import 'LoginRegister/login.dart';
void main() async {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment