diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index b25b1c8..7cf202f 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -1,113 +1,113 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:flutter/Material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:justmusic/values/constants.dart'; - -class EditablePostComponent extends StatefulWidget { - const EditablePostComponent({Key? key}) : super(key: key); - - @override - State createState() => _EditablePostComponentState(); -} - -class _EditablePostComponentState extends State { - @override - Widget build(BuildContext context) { - return ClipRRect( - borderRadius: BorderRadius.circular(25), - child: Container( - constraints: BoxConstraints(maxWidth: 400), - width: double.infinity, - color: warningBttnColor, - child: Column( - children: [ - AspectRatio( - aspectRatio: 1 / 1, - child: Container( - decoration: BoxDecoration( - // add border - border: Border.all(width: 3.0, color: grayColor), - // set border radius - borderRadius: BorderRadius.circular(20), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - // implement image - child: const Image( - image: AssetImage("assets/images/exemple_cover.png"), - fit: BoxFit.cover, - width: double.infinity, - ), - ), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(15, 25, 15, 25), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AutoSizeText( - "France, Lyon", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, - ), - Image( - image: AssetImage("assets/images/camera_icon.png"), - width: 30, - ), - AutoSizeText( - "10 Juil. 2023", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, - ), - ], - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(15, 0, 10, 25), - child: SizedBox( - width: double.infinity, - child: TextFormField( - keyboardAppearance: Brightness.dark, - minLines: 1, - cursorColor: primaryColor, - style: GoogleFonts.plusJakartaSans( - color: Colors.white, - fontSize: 13, - fontWeight: FontWeight.w300), - maxLines: 4, - maxLength: 120, - decoration: InputDecoration( - counterStyle: GoogleFonts.plusJakartaSans( - color: grayText, fontSize: 9), - focusedBorder: const OutlineInputBorder( - borderSide: - BorderSide(width: 0, color: Colors.transparent), - borderRadius: - BorderRadius.all(Radius.circular(10))), - contentPadding: - const EdgeInsets.only(top: 0, bottom: 0, left: 0), - fillColor: Colors.transparent, - filled: true, - focusColor: Colors.transparent, - enabledBorder: const OutlineInputBorder( - borderSide: - BorderSide(width: 0, color: Colors.transparent), - borderRadius: - BorderRadius.all(Radius.circular(10))), - hintText: 'Description...', - hintStyle: GoogleFonts.plusJakartaSans( - color: grayText, - fontSize: 13, - fontWeight: FontWeight.w300), - ), - ), - )), - ], - ), - )); - } -} +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/Material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:justmusic/values/constants.dart'; + +class EditablePostComponent extends StatefulWidget { + const EditablePostComponent({Key? key}) : super(key: key); + + @override + State createState() => _EditablePostComponentState(); +} + +class _EditablePostComponentState extends State { + @override + Widget build(BuildContext context) { + return ClipRRect( + borderRadius: BorderRadius.circular(25), + child: Container( + constraints: BoxConstraints(maxWidth: 400), + width: double.infinity, + color: warningBttnColor, + child: Column( + children: [ + AspectRatio( + aspectRatio: 1 / 1, + child: Container( + decoration: BoxDecoration( + // add border + border: Border.all(width: 3.0, color: grayColor), + // set border radius + borderRadius: BorderRadius.circular(20), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + // implement image + child: const Image( + image: AssetImage("assets/images/exemple_cover.png"), + fit: BoxFit.cover, + width: double.infinity, + ), + ), + ), + ), + Padding( + padding: EdgeInsets.fromLTRB(15, 25, 15, 25), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AutoSizeText( + "France, Lyon", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 13.sp), + maxFontSize: 20, + ), + Image( + image: AssetImage("assets/images/camera_icon.png"), + width: 30, + ), + AutoSizeText( + "10 Juil. 2023", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 13.sp), + maxFontSize: 20, + ), + ], + ), + ), + Padding( + padding: EdgeInsets.fromLTRB(15, 0, 10, 25), + child: SizedBox( + width: double.infinity, + child: TextFormField( + keyboardAppearance: Brightness.dark, + minLines: 1, + cursorColor: primaryColor, + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontSize: 13, + fontWeight: FontWeight.w300), + maxLines: 4, + maxLength: 120, + decoration: InputDecoration( + counterStyle: GoogleFonts.plusJakartaSans( + color: grayText, fontSize: 9), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent), + borderRadius: + BorderRadius.all(Radius.circular(10))), + contentPadding: + const EdgeInsets.only(top: 0, bottom: 0, left: 0), + fillColor: Colors.transparent, + filled: true, + focusColor: Colors.transparent, + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent), + borderRadius: + BorderRadius.all(Radius.circular(10))), + hintText: 'Description...', + hintStyle: GoogleFonts.plusJakartaSans( + color: grayText, + fontSize: 13, + fontWeight: FontWeight.w300), + ), + ), + )), + ], + ), + )); + } +} diff --git a/Sources/justMUSIC/lib/model/mapper/UserMapper.dart b/Sources/justMUSIC/lib/model/mapper/UserMapper.dart index 58a3f15..8ef5bbc 100644 --- a/Sources/justMUSIC/lib/model/mapper/UserMapper.dart +++ b/Sources/justMUSIC/lib/model/mapper/UserMapper.dart @@ -7,7 +7,7 @@ class UserMapper { final data = snapshot.data(); return User( data?["uid"] ?? "", - data?["pseudo"] ?? "", + data?["unique_id"] ?? "", data?["country"] ?? "", data?["mail"] ?? "", data?["profilePicture"] ?? "", diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index e6a625b..574eac8 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -1,126 +1,126 @@ -import 'dart:ui'; -import 'package:flutter/Material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:justmusic/components/back_button.dart'; -import 'package:justmusic/screens/search_song_screen.dart'; -import '../components/editable_post_component.dart'; -import '../components/post_button_component.dart'; -import '../values/constants.dart'; - -class PostScreen extends StatefulWidget { - const PostScreen({Key? key}) : super(key: key); - - @override - State createState() => _PostScreenState(); -} - -class _PostScreenState extends State - with SingleTickerProviderStateMixin { - final scrollController = ScrollController(); - late AnimationController _controller; - late Animation _animation; - - @override - void initState() { - _controller = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 400), - ); - - _animation = Tween(begin: 0.0, end: 400.0).animate( - CurvedAnimation( - parent: _controller, - curve: Curves.easeOut, - ), - ); - super.initState(); - } - - void openDetailPost() { - showModalBottomSheet( - transitionAnimationController: _controller, - barrierColor: Colors.black.withOpacity(0.7), - backgroundColor: Colors.transparent, - elevation: 1, - constraints: const BoxConstraints( - maxWidth: 600, - ), - isScrollControlled: true, - context: context, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), topRight: Radius.circular(20))), - builder: ((context) { - return const ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), topRight: Radius.circular(20)), - child: SearchSongScreen()); - }), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - resizeToAvoidBottomInset: true, - backgroundColor: bgColor, - extendBodyBehindAppBar: true, - appBar: PreferredSize( - preferredSize: Size(double.infinity, 80), - child: SafeArea( - child: Padding( - padding: const EdgeInsets.only( - left: defaultPadding, - right: defaultPadding, - top: defaultPadding), - child: Row( - children: [BackButtonComponent()], - ), - ), - ), - ), - body: Container( - padding: - const EdgeInsets.only(left: defaultPadding, right: defaultPadding), - width: double.infinity, - height: double.infinity, - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/background_justMusic.png"), - fit: BoxFit.cover, - ), - ), - child: Stack( - alignment: Alignment.topCenter, - children: [ - ScrollConfiguration( - behavior: ScrollBehavior().copyWith(scrollbars: false), - child: SingleChildScrollView( - controller: scrollController, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - height: 100.h, - ), - GestureDetector( - onTap: openDetailPost, - child: EditablePostComponent(), - ), - SizedBox( - height: 40.h, - ), - PostButtonComponent(), - SizedBox( - height: 40.h, - ), - ], - ), - ), - ), - ], - ), - ), - ); - } -} +import 'dart:ui'; +import 'package:flutter/Material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:justmusic/components/back_button.dart'; +import 'package:justmusic/screens/search_song_screen.dart'; +import '../components/editable_post_component.dart'; +import '../components/post_button_component.dart'; +import '../values/constants.dart'; + +class PostScreen extends StatefulWidget { + const PostScreen({Key? key}) : super(key: key); + + @override + State createState() => _PostScreenState(); +} + +class _PostScreenState extends State + with SingleTickerProviderStateMixin { + final scrollController = ScrollController(); + late AnimationController _controller; + late Animation _animation; + + @override + void initState() { + _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 400), + ); + + _animation = Tween(begin: 0.0, end: 400.0).animate( + CurvedAnimation( + parent: _controller, + curve: Curves.easeOut, + ), + ); + super.initState(); + } + + void openDetailPost() { + showModalBottomSheet( + transitionAnimationController: _controller, + barrierColor: Colors.black.withOpacity(0.7), + backgroundColor: Colors.transparent, + elevation: 1, + constraints: const BoxConstraints( + maxWidth: 600, + ), + isScrollControlled: true, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), topRight: Radius.circular(20))), + builder: ((context) { + return const ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), topRight: Radius.circular(20)), + child: SearchSongScreen()); + }), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: true, + backgroundColor: bgColor, + extendBodyBehindAppBar: true, + appBar: PreferredSize( + preferredSize: Size(double.infinity, 80), + child: SafeArea( + child: Padding( + padding: const EdgeInsets.only( + left: defaultPadding, + right: defaultPadding, + top: defaultPadding), + child: Row( + children: [BackButtonComponent()], + ), + ), + ), + ), + body: Container( + padding: + const EdgeInsets.only(left: defaultPadding, right: defaultPadding), + width: double.infinity, + height: double.infinity, + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/background_justMusic.png"), + fit: BoxFit.cover, + ), + ), + child: Stack( + alignment: Alignment.topCenter, + children: [ + ScrollConfiguration( + behavior: ScrollBehavior().copyWith(scrollbars: false), + child: SingleChildScrollView( + controller: scrollController, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + height: 100.h, + ), + GestureDetector( + onTap: openDetailPost, + child: EditablePostComponent(), + ), + SizedBox( + height: 40.h, + ), + PostButtonComponent(), + SizedBox( + height: 40.h, + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/Sources/justMUSIC/lib/screens/profile_screen.dart b/Sources/justMUSIC/lib/screens/profile_screen.dart index 896cd91..a362d35 100644 --- a/Sources/justMUSIC/lib/screens/profile_screen.dart +++ b/Sources/justMUSIC/lib/screens/profile_screen.dart @@ -1,146 +1,146 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:justmusic/values/icons.dart'; -import '../components/profile_component.dart'; -import '../components/setting_part_component.dart'; -import '../main.dart'; -import '../values/constants.dart'; - -class ProfileScreen extends StatefulWidget { - const ProfileScreen({Key? key}) : super(key: key); - - @override - State createState() => _ProfileScreenState(); -} - -class _ProfileScreenState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: PreferredSize( - preferredSize: Size(double.infinity, 58), - child: Container( - height: double.infinity, - color: bgAppBar, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: defaultPadding), - child: Stack( - alignment: Alignment.centerLeft, - children: [ - GestureDetector( - onTap: () { - Navigator.pop(context); - }, - child: Container( - height: 15, - width: 15, - child: Image( - image: AssetImage("assets/images/return_icon.png"), - height: 8, - ), - )), - Align( - child: Text( - "Profile", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, - fontSize: 14, - fontWeight: FontWeight.bold), - ), - ) - ], - ), - ), - ), - ), - body: Container( - width: double.infinity, - height: double.infinity, - color: bgColor, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: settingPadding), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 68.h, bottom: 40), - child: - ProfileComponent(user: MyApp.userViewModel.userCurrent), - ), - Padding( - padding: - const EdgeInsets.only(bottom: 12, left: defaultPadding), - child: Text( - "Compte", - style: GoogleFonts.plusJakartaSans( - color: grayText, - fontWeight: FontWeight.w800, - fontSize: 16), - ), - ), - ClipRRect( - borderRadius: BorderRadius.circular(8), - child: Column( - children: const [ - SettingPartComponent( - icon: JustMusicIcon.profile, - label: 'Compte', - ), - SettingPartComponent( - icon: JustMusicIcon.history, - label: 'Historiques des capsules', - ), - SettingPartComponent( - icon: JustMusicIcon.spotify, - label: 'Lier un compte Spotify', - ), - SettingPartComponent( - icon: JustMusicIcon.trash, - label: 'Supprimer mon compte', - ), - SettingPartComponent( - icon: JustMusicIcon.cross, - label: 'Déconnexion', - important: true, - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only( - bottom: 12, left: defaultPadding, top: 40), - child: Text( - "Préférences", - style: GoogleFonts.plusJakartaSans( - color: grayText, - fontWeight: FontWeight.w800, - fontSize: 16), - ), - ), - ClipRRect( - borderRadius: BorderRadius.circular(8), - child: Column( - children: const [ - SettingPartComponent( - icon: JustMusicIcon.theme, - label: 'Thême de l\'application', - ), - SettingPartComponent( - icon: JustMusicIcon.notification, - label: 'Notifications', - ), - ], - ), - ) - ], - ), - ), - ), - ), - ); - } -} +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:justmusic/values/icons.dart'; +import '../components/profile_component.dart'; +import '../components/setting_part_component.dart'; +import '../main.dart'; +import '../values/constants.dart'; + +class ProfileScreen extends StatefulWidget { + const ProfileScreen({Key? key}) : super(key: key); + + @override + State createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + preferredSize: Size(double.infinity, 58), + child: Container( + height: double.infinity, + color: bgAppBar, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: defaultPadding), + child: Stack( + alignment: Alignment.centerLeft, + children: [ + GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: Container( + height: 15, + width: 15, + child: Image( + image: AssetImage("assets/images/return_icon.png"), + height: 8, + ), + )), + Align( + child: Text( + "Profile", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.bold), + ), + ) + ], + ), + ), + ), + ), + body: Container( + width: double.infinity, + height: double.infinity, + color: bgColor, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: settingPadding), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 68.h, bottom: 40), + child: + ProfileComponent(user: MyApp.userViewModel.userCurrent), + ), + Padding( + padding: + const EdgeInsets.only(bottom: 12, left: defaultPadding), + child: Text( + "Compte", + style: GoogleFonts.plusJakartaSans( + color: grayText, + fontWeight: FontWeight.w800, + fontSize: 16), + ), + ), + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: Column( + children: const [ + SettingPartComponent( + icon: JustMusicIcon.profile, + label: 'Compte', + ), + SettingPartComponent( + icon: JustMusicIcon.history, + label: 'Historiques des capsules', + ), + SettingPartComponent( + icon: JustMusicIcon.spotify, + label: 'Lier un compte Spotify', + ), + SettingPartComponent( + icon: JustMusicIcon.trash, + label: 'Supprimer mon compte', + ), + SettingPartComponent( + icon: JustMusicIcon.cross, + label: 'Déconnexion', + important: true, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only( + bottom: 12, left: defaultPadding, top: 40), + child: Text( + "Préférences", + style: GoogleFonts.plusJakartaSans( + color: grayText, + fontWeight: FontWeight.w800, + fontSize: 16), + ), + ), + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: Column( + children: const [ + SettingPartComponent( + icon: JustMusicIcon.theme, + label: 'Thême de l\'application', + ), + SettingPartComponent( + icon: JustMusicIcon.notification, + label: 'Notifications', + ), + ], + ), + ) + ], + ), + ), + ), + ), + ); + } +} diff --git a/Sources/justMUSIC/lib/service/AuthService.dart b/Sources/justMUSIC/lib/service/AuthService.dart index 65828fc..d7e39fa 100644 --- a/Sources/justMUSIC/lib/service/AuthService.dart +++ b/Sources/justMUSIC/lib/service/AuthService.dart @@ -1,3 +1,4 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import '../main.dart'; @@ -9,10 +10,13 @@ class AuthService { password: password, ); + String uniqueId = await generateUniqueId(pseudo); + final user = { "mail": email, "pseudo": pseudo, "phone_number": "", + "unique_id": uniqueId, "picture": "https://media.licdn.com/dms/image/D4E03AQHvc_b89ogFtQ/profile-displayphoto-shrink_400_400/0/1665060931103?e=1695859200&v=beta&t=wVLbxqeokYiPJ13nJ3SMq97iZvcm3ra0ufWFZCSzhjg", "friends": [] @@ -36,6 +40,22 @@ class AuthService { } } + Future generateUniqueId(String pseudo) async { + String uniqueId = '$pseudo#0001'; + int suffix = 1; + final CollectionReference usersCollection = + FirebaseFirestore.instance.collection("users"); + final QuerySnapshot querySnapshot = + await usersCollection.where('pseudo', isEqualTo: pseudo).get(); + + for (final doc in querySnapshot.docs) { + suffix++; + uniqueId = '$pseudo#${suffix.toString().padLeft(4, '0')}'; + } + + return uniqueId; + } + login(String email, String password) async { try { await FirebaseAuth.instance diff --git a/Sources/justMUSIC/lib/values/constants.dart b/Sources/justMUSIC/lib/values/constants.dart index f29ef36..60f494f 100644 --- a/Sources/justMUSIC/lib/values/constants.dart +++ b/Sources/justMUSIC/lib/values/constants.dart @@ -1,26 +1,26 @@ -import 'package:flutter/material.dart'; - -// All needed color in the project - -const primaryColor = Color(0xFF643BF4); -const secondaryColor = Color(0xFF1C1B23); -const bgColor = Color(0xFF0C0C0C); -const grayColor = Color(0xFF242424); -const profileBttnColor = Color(0xFF232323); -const warningBttnColor = Color(0xFF141414); -const disabledBttnColor = Color(0xFF1F1B2E); -const bgTextField = Color(0xFF1C1B23); -const strokeTextField = Color(0xFF373546); -const unactiveFeed = Color(0xFF848484); -const gradiantPost = Color(0xFF0D0D0D); -const bgModal = Color(0xFF1E1E1E); -const textFieldMessage = Color(0xFF232323); -const bgComment = Color(0xFF222222); -const bgAppBar = Color(0xFF181818); -const grayText = Color(0xFF898989); -const settingColor = Color(0xFF232323); -const searchBarColor = Color(0xFF161616); -// All constants important too us - -const defaultPadding = 30.0; -const settingPadding = 12.0; +import 'package:flutter/material.dart'; + +// All needed color in the project + +const primaryColor = Color(0xFF643BF4); +const secondaryColor = Color(0xFF1C1B23); +const bgColor = Color(0xFF0C0C0C); +const grayColor = Color(0xFF242424); +const profileBttnColor = Color(0xFF232323); +const warningBttnColor = Color(0xFF141414); +const disabledBttnColor = Color(0xFF1F1B2E); +const bgTextField = Color(0xFF1C1B23); +const strokeTextField = Color(0xFF373546); +const unactiveFeed = Color(0xFF848484); +const gradiantPost = Color(0xFF0D0D0D); +const bgModal = Color(0xFF1E1E1E); +const textFieldMessage = Color(0xFF232323); +const bgComment = Color(0xFF222222); +const bgAppBar = Color(0xFF181818); +const grayText = Color(0xFF898989); +const settingColor = Color(0xFF232323); +const searchBarColor = Color(0xFF161616); +// All constants important too us + +const defaultPadding = 30.0; +const settingPadding = 12.0; diff --git a/Sources/justMUSIC/lib/view_model/UserViewModel.dart b/Sources/justMUSIC/lib/view_model/UserViewModel.dart index d793449..5d41ebc 100644 --- a/Sources/justMUSIC/lib/view_model/UserViewModel.dart +++ b/Sources/justMUSIC/lib/view_model/UserViewModel.dart @@ -37,9 +37,18 @@ class UserViewModel { } } + bool _isAlphaNumeric(String input) { + final RegExp alphaNumericRegExp = RegExp(r'^[a-zA-Z0-9]+$'); + return alphaNumericRegExp.hasMatch(input); + } + register(String pseudo, String password, String email) async { + if (!_isAlphaNumeric(pseudo)) { + throw ("Le pseudo doit contenir seulement des lettres et des chiffres"); + } + try { - await _authService.register(pseudo, email, password); + await _authService.register(pseudo.toLowerCase(), email, password); final user = await MyApp.db .collection("users") .doc(firebase_auth.FirebaseAuth.instance.currentUser?.uid) diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index 5a37499..f42c1e9 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" audioplayers: dependency: "direct main" description: @@ -93,10 +93,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" circular_reveal_animation: dependency: "direct main" description: @@ -141,10 +141,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" crypto: dependency: transitive description: @@ -348,10 +348,10 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" lints: dependency: transitive description: @@ -364,10 +364,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -380,10 +380,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" modal_bottom_sheet: dependency: "direct main" description: @@ -396,10 +396,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: transitive description: @@ -529,10 +529,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" text_scroll: dependency: "direct main" description: @@ -598,5 +598,5 @@ packages: source: hosted version: "1.1.0" sdks: - dart: ">=2.18.2 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=3.3.0"