Compare commits

..

No commits in common. 'master' and 'FIX/FEED_PAGINATION' have entirely different histories.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

@ -39,9 +39,9 @@ C'est un réseau social donc l'utilisateur pourra publier et commenter des posts
La racine de notre gitlab est composé de deux dossier essentielles au projet:
[**Sources**](Sources) : **Code de l'application**
[**src**](src) : **Code de l'application**
[**Documentation**](Documentation) : **Regroupe l'entièreté de la documentation**
[**doc**](doc) : **Regroupe l'entièreté de la documentation**
</br>
@ -49,33 +49,10 @@ La racine de notre gitlab est composé de deux dossier essentielles au projet:
## Fonctionnement
<div align = center>
<img src="Documentation/Images/Overview.png" />
</div>
### Feeds
Une fois authentifié vous aurez la possibilité de voir les posts capsules de vos amis, de voir les musiques qu'ils mettent en avant accompagner éventuellement d'une image, d'une description, de leurs localisations... (Vous n'avez pas d'amis, pas de soucis, cliquer seulement sur l'icon en haut a gauche de la page pour suivre nimporte quel personne que vous voulez), Mais aussi juste d'un simple mouvement du doigt swiper pour vous retrouvez sur la page Discovery où vous verrais les posts récents en tendance dans le monde 🌎
Amuser vous à cliquer sur les posts pour ecouter la music mais aussi connaître les détails et savoir qui a commenter 💬 et liker ❤️. Si la musique vous plaît enregistrer la et vous la retrouverez lorsque vous aurez envie de poster.
### Post
Pour participer à cette aventure musicale avec des gens du monde entier, cliquez simplement sur l'icône JustMusic. Gardez à l'esprit que vous ne pourrez poster qu'une fois par jour, donc réfléchissez bien à la musique que vous souhaitez mettre en avant. N'hésitez pas à ajouter une photo et une description pour rendre votre publication plus chaleureuse 😃.
### Profil
Consultez l'aperçu de votre profil pour savoir combien de personnes vous suivent et que vous suivez. Vous pouvez également voir le nombre de capsules que vous avez publiées, personnaliser les paramètres de votre compte selon vos préférences, et explorez votre historique de capsules pour vous remémorer vos précédentes publications 🎧.
#### Bonne aventure musicale 🎵🌟
## Deploiement
- [x] &nbsp; ![IOS](https://img.shields.io/badge/IOS-000?style=for-the-badge&logo=apple&logoColor=black&color=white)
- [x] &nbsp; ![Android](https://img.shields.io/badge/Android-000?style=for-the-badge&logo=android&logoColor=white&color=green)
- [x] &nbsp; ![Safari](https://img.shields.io/badge/Safari-000000.svg?style=for-the-badge&logo=Safari&logoColor=white)
## Techniciens
@ -87,7 +64,7 @@ Consultez l'aperçu de votre profil pour savoir combien de personnes vous suiven
<img src ="https://codefirst.iut.uca.fr/git/avatars/1ff65c9c5ab0e8c8883fb48adbcf972f?size=870" height="50px">
</a>
<a href = "https://codefirst.iut.uca.fr/git/david.d_almeida">
<img src ="https://codefirst.iut.uca.fr/git/avatars/a16fa2dc52ceae18d8923c91121caa66?size=870" height="50px">
<img src ="https://codefirst.iut.uca.fr/git/avatars/0f8eaaad1e26d3de644ca522eccaea7c?size=870" height="50px">
</a>
<a href = "https://codefirst.iut.uca.fr/git/rayhan.hassou">
<img src ="https://codefirst.iut.uca.fr/git/avatars/84062b2bb326d9e9154a9859b375e599?size=870" height="50px">

@ -1,34 +0,0 @@
import 'package:tuple/tuple.dart';
import 'Music.dart';
class Capsule {
final String _id;
late Music _music;
Tuple2<String?,String?> _location;
DateTime _date;
// Constructor
Capsule(this._id, this._location, this._date);
//Getters and setters
String get id => _id;
Music get music => _music;
set music(Music value) {
_music = value;
}
Tuple2<String?, String?> get location => _location;
set location(Tuple2<String?, String?> value) {
_location = value;
}
DateTime get date => _date;
set date(DateTime value) {
_date = value;
}
}

@ -52,9 +52,9 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
setState(() => canResendEmail = true);
} on FirebaseAuthException catch (e) {
if (e.code == "invalid-email") {
error = "Format de mail incorrect";
} else if (e.code == "user-not-found") {
error = "Mail incorrect";
} else if (e.code == "user-not-found") {
error = "Format de mail incorrect";
} else if (e.code == "too-many-requests") {
error =
"Trop de tentatives. Veuillez réessayer plus tard";

@ -1,310 +1,310 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_signin_button/button_list.dart';
import 'package:flutter_signin_button/button_view.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/main.dart';
import 'package:justmusic/values/constants.dart';
import '../components/login_button.dart';
import '../exceptions/user_exception.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
bool passenable = true;
final _formKey = GlobalKey<FormState>();
final _userMailTextField = TextEditingController();
final _passwordTextField = TextEditingController();
handleLogin() async {
if (_formKey.currentState!.validate()) {
try {
await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text);
Navigator.pushNamed(context, '/feed');
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
e.toString(),
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
),
backgroundColor: Colors.red,
),
);
}
}
}
signInWithGoogle() async {
try {
await MyApp.userViewModel.signInWithGoogle();
} on UserException catch (e) {
if (e.code == 'user-created') {
Navigator.pushNamed(context, '/explanation');
} else if (e.code == 'user-already-exist') {
Navigator.pushNamed(context, '/feed');
}
}
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: bgColor,
body: Align(
child: SizedBox(
height: double.infinity,
width: 600,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 40, right: 40),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
flex: 4,
child: Padding(
padding: EdgeInsets.only(bottom: 60),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"Te revoilà !",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h),
),
SizedBox(
height: 10,
),
SizedBox(
width: 230.w,
child: Text(
"Bon retour parmis nous. Tu nous as manqué !",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
textAlign: TextAlign.center,
),
),
],
),
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
controller: _userMailTextField,
keyboardAppearance: Brightness.dark,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Entrez un email valide';
}
return null;
},
cursorColor: primaryColor,
keyboardType: TextInputType.emailAddress,
style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffix: const Padding(padding: EdgeInsets.only(left: 20.0)),
fillColor: bgTextField,
filled: true,
errorStyle: TextStyle(fontSize: 9, height: 0.3),
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Email',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)),
),
SizedBox(
height: 18,
),
TextFormField(
controller: _passwordTextField,
keyboardAppearance: Brightness.dark,
obscureText: passenable,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Entrez un mot de passe valide';
}
return null;
},
cursorColor: primaryColor,
style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
fillColor: bgTextField,
filled: true,
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Mot de passe',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffixIcon: Container(
padding: EdgeInsets.only(right: 10),
margin: EdgeInsets.all(5),
height: 3,
child: InkWell(
onTap: () {
setState(() {
if (passenable) {
passenable = false;
} else {
passenable = true;
}
});
},
// Image tapped
splashColor: Colors.white10,
// Splash color over image
child: Image(
image: passenable
? AssetImage("assets/images/show_icon.png")
: AssetImage("assets/images/hide_icon.png"),
height: 2,
),
)),
errorStyle: TextStyle(fontSize: 9, height: 0.3),
),
),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.pushNamed(context, '/forgetPassword');
},
child: Padding(
padding: EdgeInsets.only(top: 10),
child: Text(
"Mot de passe oublié ?",
style: GoogleFonts.plusJakartaSans(color: Colors.white),
),
)),
SizedBox(
height: defaultPadding,
),
SizedBox(
width: 600,
child: LoginButton(
callback: handleLogin,
text: "Se connecter",
)),
Align(
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.pushNamed(context, '/register');
},
child: Padding(
padding: EdgeInsets.only(top: 20),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Pas encore inscrit ?',
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 15),
children: <TextSpan>[
TextSpan(
text: " Sinscrire",
style: GoogleFonts.plusJakartaSans(
fontSize: 15,
fontWeight: FontWeight.w400,
color: primaryColor)),
],
),
),
),
),
),
],
),
),
Expanded(
flex: 3,
child: Padding(
padding: EdgeInsets.only(top: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 600),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
color: Color(0xFF3D3D3D),
height: 1,
),
),
Padding(
padding: const EdgeInsets.only(
left: defaultPadding, right: defaultPadding),
child: Text(
'Ou',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
child: Container(
height: 1,
color: Color(0xFF3D3D3D),
)),
],
),
),
SizedBox(height: defaultPadding),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 540),
child: SizedBox(
width: 300.sp,
height: 50,
child: SignInButton(
Buttons.Google,
text: "Login with Google",
onPressed: signInWithGoogle,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
),
),
),
],
),
))
],
))))
],
)),
)));
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_signin_button/button_list.dart';
import 'package:flutter_signin_button/button_view.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/main.dart';
import 'package:justmusic/values/constants.dart';
import '../components/login_button.dart';
import '../exceptions/user_exception.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
bool passenable = true;
final _formKey = GlobalKey<FormState>();
final _userMailTextField = TextEditingController();
final _passwordTextField = TextEditingController();
handleLogin() async {
if (_formKey.currentState!.validate()) {
try {
await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text);
Navigator.pushNamed(context, '/feed');
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
e.toString(),
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
),
backgroundColor: Colors.red,
),
);
}
}
}
signInWithGoogle() async {
try {
await MyApp.userViewModel.signInWithGoogle();
} on UserException catch (e) {
if (e.code == 'user-created') {
Navigator.pushNamed(context, '/explanation');
} else if (e.code == 'user-already-exist') {
Navigator.pushNamed(context, '/feed');
}
}
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: bgColor,
body: Align(
child: SizedBox(
height: double.infinity,
width: 600,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 40, right: 40),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
flex: 4,
child: Padding(
padding: EdgeInsets.only(bottom: 60),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"Te revoilà!",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h),
),
SizedBox(
height: 10,
),
SizedBox(
width: 230.w,
child: Text(
"Bon retour parmis nous tu nous as manqué!",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
textAlign: TextAlign.center,
),
),
],
),
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
controller: _userMailTextField,
keyboardAppearance: Brightness.dark,
validator: (value) {
if (value == null || value.isEmpty) {
return 'entrez un email valide';
}
return null;
},
cursorColor: primaryColor,
keyboardType: TextInputType.emailAddress,
style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffix: const Padding(padding: EdgeInsets.only(left: 20.0)),
fillColor: bgTextField,
filled: true,
errorStyle: TextStyle(fontSize: 9, height: 0.3),
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Email',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)),
),
SizedBox(
height: 18,
),
TextFormField(
controller: _passwordTextField,
keyboardAppearance: Brightness.dark,
obscureText: passenable,
validator: (value) {
if (value == null || value.isEmpty) {
return 'entrez un mot de passe valide';
}
return null;
},
cursorColor: primaryColor,
style: GoogleFonts.plusJakartaSans(color: primaryColor),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
fillColor: bgTextField,
filled: true,
focusColor: Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Mot de passe',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField),
prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
suffixIcon: Container(
padding: EdgeInsets.only(right: 10),
margin: EdgeInsets.all(5),
height: 3,
child: InkWell(
onTap: () {
setState(() {
if (passenable) {
passenable = false;
} else {
passenable = true;
}
});
},
// Image tapped
splashColor: Colors.white10,
// Splash color over image
child: Image(
image: passenable
? AssetImage("assets/images/show_icon.png")
: AssetImage("assets/images/hide_icon.png"),
height: 2,
),
)),
errorStyle: TextStyle(fontSize: 9, height: 0.3),
),
),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.pushNamed(context, '/forgetPassword');
},
child: Padding(
padding: EdgeInsets.only(top: 10),
child: Text(
"Mot de passe oublié?",
style: GoogleFonts.plusJakartaSans(color: Colors.white),
),
)),
SizedBox(
height: defaultPadding,
),
SizedBox(
width: 600,
child: LoginButton(
callback: handleLogin,
text: "Se connecter",
)),
Align(
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.pushNamed(context, '/register');
},
child: Padding(
padding: EdgeInsets.only(top: 20),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Pas encore inscrit?',
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 15),
children: <TextSpan>[
TextSpan(
text: " Sinscire",
style: GoogleFonts.plusJakartaSans(
fontSize: 15,
fontWeight: FontWeight.w400,
color: primaryColor)),
],
),
),
),
),
),
],
),
),
Expanded(
flex: 3,
child: Padding(
padding: EdgeInsets.only(top: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 600),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
color: Color(0xFF3D3D3D),
height: 1,
),
),
Padding(
padding: const EdgeInsets.only(
left: defaultPadding, right: defaultPadding),
child: Text(
'Ou',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.bold),
),
),
Expanded(
child: Container(
height: 1,
color: Color(0xFF3D3D3D),
)),
],
),
),
SizedBox(height: defaultPadding),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 540),
child: SizedBox(
width: 300.sp,
height: 50,
child: SignInButton(
Buttons.Google,
text: "Login with Google",
onPressed: signInWithGoogle,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
),
),
),
],
),
))
],
))))
],
)),
)));
}
}

@ -1,98 +1,98 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/values/constants.dart';
import '../components/join_button.dart';
class WellcomeScreen extends StatelessWidget {
const WellcomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.all(defaultPadding),
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/wellcome_background.png"),
fit: BoxFit.cover,
),
),
child: Align(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 10,
child: Padding(
padding: EdgeInsets.only(bottom: 100),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Bienvenue sur,",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 34),
),
Image(
image: AssetImage("assets/images/logo.png"),
width: 230,
),
SizedBox(
height: 25,
),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 520),
child: Text(
"Explore les nouvelles découvertes musicales de tes amis, et partage leur ton mood.",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w200,
fontSize: 15),
),
),
],
),
),
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
JoinButton(),
SizedBox(
height: defaultPadding,
),
GestureDetector(
onTap: () {
Navigator.pushNamed(context, '/login');
},
child: Padding(
padding: const EdgeInsets.all(3.0),
child: Text(
"Tu as déja un compte ? Connexion",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 15),
),
),
),
],
),
),
],
),
) /* add child content here */,
),
);
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/values/constants.dart';
import '../components/join_button.dart';
class WellcomeScreen extends StatelessWidget {
const WellcomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.all(defaultPadding),
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/wellcome_background.png"),
fit: BoxFit.cover,
),
),
child: Align(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 10,
child: Padding(
padding: EdgeInsets.only(bottom: 100),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Bienvenue sur,",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 34),
),
Image(
image: AssetImage("assets/images/logo.png"),
width: 230,
),
SizedBox(
height: 25,
),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 520),
child: Text(
"Explore les nouvelles découvertes musicales de tes amis, et partage leur ton mood.",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w200,
fontSize: 15),
),
),
],
),
),
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
JoinButton(),
SizedBox(
height: defaultPadding,
),
GestureDetector(
onTap: () {
Navigator.pushNamed(context, '/login');
},
child: Padding(
padding: const EdgeInsets.all(3.0),
child: Text(
"Tu as déja un compte? Connexion",
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 15),
),
),
),
],
),
),
],
),
) /* add child content here */,
),
);
}
}

@ -1,33 +0,0 @@
import 'package:cloud_firestore/cloud_firestore.dart';
class CapsuleService {
Future<List<bool>> recapSevenDays(String id) async {
List<bool> recapList = [];
DateTime sevenDaysAgo = DateTime.now().subtract(Duration(days: 6));
QuerySnapshot<Map<String, dynamic>> response = await FirebaseFirestore
.instance
.collection("capsules")
.where("user_id", isEqualTo: id)
.get();
List<Map<String, dynamic>?> capsuleList = response.docs
.map((DocumentSnapshot<Map<String, dynamic>> doc) => doc.data())
.toList();
for (int i = 0; i < 7; i++) {
DateTime date = sevenDaysAgo.add(Duration(days: i));
bool capsuleExists = capsuleList.any((post) =>
post?["date"] != null &&
post?["date"].toDate().year == date.year &&
post?["date"].toDate().month == date.month &&
post?["date"].toDate().day == date.day);
recapList.add(capsuleExists);
}
return recapList;
}
}

@ -37,7 +37,7 @@ class MusicService {
List<Tuple2<int, String>> capsules = [];
var querySnapshot = await FirebaseFirestore.instance
.collection('capsules')
.collection('posts')
.where('user_id', isEqualTo: idUser)
.where('date', isGreaterThanOrEqualTo: DateTime(year, month))
.where('date', isLessThan: DateTime(year, month + 1))

@ -23,15 +23,6 @@ class PostService {
var userRef = MyApp.db.collection("users").doc(id);
var capsule = {
"user_id": id,
"date": DateTime.now(),
"place": [location?.item1, location?.item2],
"song_id": idMusic,
};
await MyApp.db.collection("capsules").doc(postAdd.id).set(capsule);
await MyApp.db.runTransaction((transaction) async {
var userSnapshot = await transaction.get(userRef);
if (userSnapshot.exists) {
@ -150,6 +141,35 @@ class PostService {
return !isTodayAvailable;
}
Future<List<bool>> recapSevenDays(String id) async {
List<bool> recapList = [];
DateTime sevenDaysAgo = DateTime.now().subtract(Duration(days: 6));
QuerySnapshot<Map<String, dynamic>> response = await FirebaseFirestore
.instance
.collection("posts")
.where("user_id", isEqualTo: id)
.get();
List<Map<String, dynamic>?> postList = response.docs
.map((DocumentSnapshot<Map<String, dynamic>> doc) => doc.data())
.toList();
for (int i = 0; i < 7; i++) {
DateTime date = sevenDaysAgo.add(Duration(days: i));
bool postExists = postList.any((post) =>
post?["date"] != null &&
post?["date"].toDate().year == date.year &&
post?["date"].toDate().month == date.month &&
post?["date"].toDate().day == date.day);
recapList.add(postExists);
}
return recapList;
}
Future<List<String>> getLikesByPostId(String id) async {
var response =
await FirebaseFirestore.instance.collection("posts").doc(id).get();

@ -241,13 +241,8 @@ class MusicViewModel {
var musics = await getMusicsWithIds(capsulesData.map((capsule) => capsule.item2).toList());
for (var capsule in capsulesData) {
var music = musics.firstWhere(
(music) => music.id == capsule.item2,
orElse: () => Music("-1", "", "", "", 0, 0, false, []),
);
if (music.id != "-1")
capsules.add(Tuple2(capsule.item1, music));
var music = musics.firstWhere((music) => music.id == capsule.item2);
capsules.add(Tuple2(capsule.item1, music));
}
return capsules;
} catch (e) {

@ -1,7 +1,6 @@
import 'dart:io';
import 'package:justmusic/model/Post.dart';
import 'package:justmusic/services/CapsuleService.dart';
import 'package:justmusic/services/PostService.dart';
import 'package:tuple/tuple.dart';
@ -15,7 +14,6 @@ class PostViewModel {
var lastPostFriend;
var lastPostDiscovery;
final PostService _postService = PostService();
final CapsuleService _capsuleService = CapsuleService();
// Constructor
PostViewModel();
@ -116,7 +114,7 @@ class PostViewModel {
Future<List<bool>> recapSevenDays(String id) async {
try {
return await _capsuleService.recapSevenDays(id);
return await _postService.recapSevenDays(id);
} catch (e) {
print(e);
rethrow;
@ -147,6 +145,7 @@ class PostViewModel {
print(bool);
return bool;
} catch (e) {
print("haaaaaaaaa");
rethrow;
}
}

Loading…
Cancel
Save