Select Git revision
neutral.txt
-
Stuart Gathman authoredStuart Gathman authored
firebase.dart 2.21 KiB
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;
}
Future<String> getGenreByHex(String code) async {
switch (code){
case 'FF0000':
return await getGenreByColor('Red');
case 'FFA500':
return await getGenreByColor('Orange');
case 'FFFF00':
return getGenreByColor('Yellow');
case '00FF00':
return getGenreByColor('Green');
case 'FFFFFF':
return getGenreByColor('White');
case '0000FF':
return getGenreByColor('Blue');
case 'FF46FD':
return getGenreByColor('Pink');
case '7F45D8':
return getGenreByColor('Purple');
case '67402D':
return getGenreByColor('Brown');
case '000000':
return getGenreByColor('Black');
}
return 'nothing';
}
Future<String> getGenreByColor(String color) async {
String genre = '';
await FirebaseFirestore.instance.collection('classification').doc(id).get().then((snapshot) async {
genre = await snapshot.data()![color];
return genre;