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

Methode zum abrufen der genres

parent b042d6cf
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ import 'package:google_fonts/google_fonts.dart'; ...@@ -11,7 +11,7 @@ import 'package:google_fonts/google_fonts.dart';
Klasse & Screen zur Klassifizierung der Farben zu den Genres. Klasse & Screen zur Klassifizierung der Farben zu den Genres.
Es gibt eine graue Default Seite wenn keine Farbe ausgewählt ist. Es gibt eine graue Default Seite wenn keine Farbe ausgewählt ist.
Wenn eine Farbe ausgewählt wird, kann man das Genre dazu auswählen. Wenn eine Farbe ausgewählt wird, kann man das Genre dazu auswählen.
Die Klassifiezierung wird dann in der Datenbank aktualisiert Die Klassifizierung wird dann in der Datenbank aktualisiert
*/ */
class ClassificationPage extends StatefulWidget { class ClassificationPage extends StatefulWidget {
...@@ -86,7 +86,10 @@ class _ClassificationPageState extends State<ClassificationPage> { ...@@ -86,7 +86,10 @@ class _ClassificationPageState extends State<ClassificationPage> {
child: ListView( child: ListView(
children: <Widget>[ children: <Widget>[
GestureDetector( GestureDetector(
onTap: (){ onTap: () async {
String genre = await changeFirebase().getGenreByHex('FF0000');
print('Get genre by hex ' + genre);
if(!_redSelected){closeAll(); setState(() => _redSelected = true); } if(!_redSelected){closeAll(); setState(() => _redSelected = true); }
else{closeAll();} else{closeAll();}
_ambientBackgroundColor = Colors.red; _ambientBackgroundColor = Colors.red;
...@@ -460,4 +463,5 @@ class _ClassificationPageState extends State<ClassificationPage> { ...@@ -460,4 +463,5 @@ class _ClassificationPageState extends State<ClassificationPage> {
}); });
_ambientBackgroundColor = Colors.grey.withOpacity(0.5); _ambientBackgroundColor = Colors.grey.withOpacity(0.5);
} }
} }
...@@ -36,12 +36,12 @@ class changeFirebase{ ...@@ -36,12 +36,12 @@ class changeFirebase{
return true; return true;
} }
String getGenreByHex(String code){ Future<String> getGenreByHex(String code) async {
switch (code){ switch (code){
case 'FF0000': case 'FF0000':
return getGenreByColor('Red'); return await getGenreByColor('Red');
case 'FFA500': case 'FFA500':
return getGenreByColor('Orange'); return await getGenreByColor('Orange');
case 'FFFF00': case 'FFFF00':
return getGenreByColor('Yellow'); return getGenreByColor('Yellow');
case '00FF00': case '00FF00':
...@@ -59,17 +59,17 @@ class changeFirebase{ ...@@ -59,17 +59,17 @@ class changeFirebase{
case '000000': case '000000':
return getGenreByColor('Black'); return getGenreByColor('Black');
} }
return ''; return 'nothing';
} }
String getGenreByColor(String color){
Future<String> getGenreByColor(String color) async {
String genre = ''; String genre = '';
FutureBuilder<DocumentSnapshot>( await FirebaseFirestore.instance.collection('classification').doc(id).get().then((snapshot) async {
future: FirebaseFirestore.instance.collection('classification').doc(id).get(), genre = await snapshot.data()![color];
builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot){ return genre;
genre = snapshot.data![color];
return const SizedBox();
}); });
return genre; return genre;
} }
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import 'package:firebase_auth/firebase_auth.dart'; ...@@ -5,6 +5,7 @@ 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 'package:page_transition/page_transition.dart'; import 'package:page_transition/page_transition.dart';
import 'package:google_fonts/google_fonts.dart';
import '../homepage.dart'; import '../homepage.dart';
...@@ -51,10 +52,11 @@ class _LoginPageState extends State<LoginPage> { ...@@ -51,10 +52,11 @@ class _LoginPageState extends State<LoginPage> {
child : Column( child : Column(
children:[ children:[
SizedBox(height: 80,), SizedBox(height: 80,),
const Expanded( Expanded(
child: Text( child: Text(
'Ambient!', 'Ambient!',
style: TextStyle(fontSize: 50.0, color: Colors.white), style: GoogleFonts.cabin(
fontSize: 50.0, color: Colors.white,),
),), ),),
Expanded( Expanded(
child: Column( child: Column(
......
...@@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; ...@@ -6,6 +6,7 @@ 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';
import 'package:google_fonts/google_fonts.dart';
/* /*
Klasse zum Registrieren Klasse zum Registrieren
...@@ -47,16 +48,17 @@ class _RegistrationPage extends State<RegistrationPage> { ...@@ -47,16 +48,17 @@ class _RegistrationPage extends State<RegistrationPage> {
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Center( body: Center(
child :Container( child :Container(
decoration: const BoxDecoration( decoration: BoxDecoration(
), ),
child: SizedBox(width: 250, height: 600, child: SizedBox(width: 250, height: 600,
child : Column( child : Column(
children:[ children:[
SizedBox(height: 40,), SizedBox(height: 40,),
const Expanded( Expanded(
child: Text( child: Text(
'Ambient!', 'Ambient!',
style: TextStyle(fontSize: 50.0, color: Colors.white), style: GoogleFonts.cabin(
fontSize: 50.0, color: Colors.white,)
),), ),),
Expanded( Expanded(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment