diff --git a/Sources/dafl_project_flutter/assets/images/delete_background.png b/Sources/dafl_project_flutter/assets/images/delete_background.png new file mode 100644 index 0000000..0034184 Binary files /dev/null and b/Sources/dafl_project_flutter/assets/images/delete_background.png differ diff --git a/Sources/dafl_project_flutter/assets/images/valid_background.png b/Sources/dafl_project_flutter/assets/images/valid_background.png new file mode 100644 index 0000000..f1fdf26 Binary files /dev/null and b/Sources/dafl_project_flutter/assets/images/valid_background.png differ diff --git a/Sources/dafl_project_flutter/assets/images/valid_icon.riv b/Sources/dafl_project_flutter/assets/images/valid_icon.riv new file mode 100644 index 0000000..b41eb2c Binary files /dev/null and b/Sources/dafl_project_flutter/assets/images/valid_icon.riv differ diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart index 23864bd..02e8115 100644 --- a/Sources/dafl_project_flutter/lib/controller/controller.dart +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -32,4 +32,9 @@ class Controller{ this.currentUser?.usernameDafl = newName; } } + void changePasswordCourant(String newPass){ + if(newPass !=null){ + this.currentUser?.passwDafl = newPass; + } + } } diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 5a473e3..76bda2a 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -385,91 +385,166 @@ class _SplashState extends State { ); } } - -Object errorNotify(int index, context){ +Object Notify(int index, context, {bool isError = true}){ String message; - switch(index){ - case 0: { - message = "Ce nom d'utilisateur existe déjà ! Veuillez réessayer."; - break; - } - case 1: { - message = "Mots de passe différents ! Veuillez réessayer."; - break; - } - case 2: { - message = "Identifiant incorrect ! Veuillez réessayer."; - break; - } - case 3: { - message = "Mot de passe incorrect ! Votre mot de passe doit contenir 8 caractères minimum."; - break; - } - case 4: { - message = "Mot de passe incorrect ! Veuillez réessayer."; - break; + if(isError == true){ + switch(index){ + case 0: { + message = "Ce nom d'utilisateur existe déjà ! Veuillez réessayer."; + break; + } + case 1: { + message = "Mots de passe différents ! Veuillez réessayer."; + break; + } + case 2: { + message = "Identifiant incorrect ! Veuillez réessayer."; + break; + } + case 3: { + message = "Mot de passe incorrect ! Votre mot de passe doit contenir 8 caractères minimum."; + break; + } + case 4: { + message = "Mot de passe incorrect ! Veuillez réessayer."; + break; + } + default: + message = "Une erreur est survenue pendant l'inscription. Veuillez réessayer."; + break; + } - default: - message = "Une erreur est survenue pendant l'inscription. Veuillez réessayer."; - break; + return ScaffoldMessenger.of(context).showSnackBar( SnackBar( + dismissDirection: DismissDirection.down, + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.transparent, + elevation: 0, + content: Stack( + clipBehavior: Clip.none, + children: [ + Container( + padding: EdgeInsets.all(16), + height: 90, + child: Row( + children: [ + Container( + height: 48, + width: 48, + ), + Expanded(child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Oh oh !", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),), + Text(message,style: TextStyle( + ), + overflow: TextOverflow.ellipsis, + maxLines: 2,), + ], + ),), + ], + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/backgroundNotify.png"), + fit: BoxFit.cover), + gradient: LinearGradient(colors: [Color(0xFF81052a),Color(0xFF810548)],begin: Alignment.topLeft, end: Alignment.bottomRight), + borderRadius: BorderRadius.all(Radius.circular(20)), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + blurRadius: 10, + offset: Offset(4, 8), // Shadow position + ), + ], + ), + ), + Positioned( + top: -50, + left: -20, + child: Container( + color: Colors.transparent, + height: 110, + width: 110, + child: riv.RiveAnimation.asset("assets/images/error_icon.riv"),)), + ], + ) + )); } - return ScaffoldMessenger.of(context).showSnackBar( SnackBar( - dismissDirection: DismissDirection.down, - behavior: SnackBarBehavior.floating, - backgroundColor: Colors.transparent, - elevation: 0, - content: Stack( - clipBehavior: Clip.none, - children: [ + else{ + switch(index){ + case 0: { + message = "Vous avez changer votre identifiant avec succès"; + break; + } + case 1: { + message = "Vous avez changer votre mot de passe avec succès"; + break; + } + default: + message = "L'opération a bien été éxécutée"; + break; - Container( - padding: EdgeInsets.all(16), - height: 90, - child: Row( - children: [ - Container( - height: 48, - width: 48, - ), - Expanded(child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Oh oh !", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),), - Text(message,style: TextStyle( - ), - overflow: TextOverflow.ellipsis, - maxLines: 2,), - ], - ),), - ], - ), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/backgroundNotify.png"), - fit: BoxFit.cover), - gradient: LinearGradient(colors: [Color(0xFF81052a),Color(0xFF810548)],begin: Alignment.topLeft, end: Alignment.bottomRight), - borderRadius: BorderRadius.all(Radius.circular(20)), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.3), - blurRadius: 10, - offset: Offset(4, 8), // Shadow position - ), - ], + } + return ScaffoldMessenger.of(context).showSnackBar( SnackBar( + dismissDirection: DismissDirection.down, + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.transparent, + elevation: 0, + content: Stack( + clipBehavior: Clip.none, + children: [ + + Container( + padding: EdgeInsets.all(16), + height: 90, + child: Row( + children: [ + Container( + height: 48, + width: 48, + ), + Expanded(child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Super !", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),), + Text(message,style: TextStyle( + ), + overflow: TextOverflow.ellipsis, + maxLines: 2,), + ], + ),), + ], + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/valid_background.png"), + fit: BoxFit.cover), + gradient: LinearGradient(colors: [Color(0xFF81052a),Color(0xFF810548)],begin: Alignment.topLeft, end: Alignment.bottomRight), + borderRadius: BorderRadius.all(Radius.circular(20)), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + blurRadius: 10, + offset: Offset(4, 8), // Shadow position + ), + ], + ), ), - ), - Positioned( - top: -50, - left: -20, - child: Container( - color: Colors.transparent, - height: 110, - width: 110, - child: riv.RiveAnimation.asset("assets/images/error_icon.riv"),)), - ], - ) - )); + Positioned( + top: -50, + left: -20, + child: Container( + color: Colors.transparent, + height: 110, + width: 110, + child: riv.RiveAnimation.asset("assets/images/valid_icon.riv"),)), + ], + ) + )); + + } + } diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart index 4926b0f..6eb1a42 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart @@ -83,7 +83,10 @@ class _DiscoveryListState extends State { itemBuilder: (context, index){ int itemCount = MyApp().controller.currentUser.Discovery.length ?? 0; int reversedIndex = itemCount - 1 - index; - return Dismissible(key: Key(MyApp().controller.currentUser.Discovery[reversedIndex].name), child: Container( + return Dismissible( + key: Key(MyApp().controller.currentUser.Discovery[reversedIndex].name), + direction: DismissDirection.startToEnd, + child: Container( margin: EdgeInsets.fromLTRB(0, 10, 0, 0), padding: EdgeInsets.fromLTRB(30, 0, 30, 0), child: Column( @@ -124,9 +127,12 @@ class _DiscoveryListState extends State { ) ), onDismissed: (direction) { - MyApp().controller.currentUser.Discovery.removeAt(reversedIndex); + if(direction == DismissDirection.startToEnd) + MyApp().controller.currentUser.Discovery.removeAt(reversedIndex); }, - background: Container(color: Colors.red,),); + background: Container(decoration: BoxDecoration( + image: DecorationImage(image: AssetImage("assets/images/delete_background.png"), fit: BoxFit.cover), + )),); } ), onRefresh: () async { refreshList(); diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart index 2717b96..ab0daa5 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart @@ -74,8 +74,8 @@ class _SettingsWidgetState extends State { Spacer(), GestureDetector( onTap: () { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); MyApp().controller.changeUsernameCourant(userNameTextField.text); + Notify(0,context,isError: false); }, child: Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), child: Text('modifier', @@ -128,6 +128,8 @@ class _SettingsWidgetState extends State { Spacer(), GestureDetector( onTap: () { + MyApp().controller.changePasswordCourant(passwordTextField.text); + Notify(1,context,isError: false); }, child: Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), child: Text('modifier', diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart index d6413fa..e6416c7 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart @@ -230,10 +230,10 @@ class _SignInPageState extends State { void checkInformations(String username,String password){ if(username ==""){ - errorNotify(2, context); + Notify(2, context); } else if(password ==""){ - errorNotify(4, context); + Notify(4, context); } else{ MyApp().controller.changeCurrentUser(MyApp().controller.createUser(userNameTextField.text, passwordTextField.text)); diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart index 4c53ccf..7ee6f17 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart @@ -299,16 +299,16 @@ class _SignUpPageState extends State { void checkInformations(String username,String password, String confirmPassword){ if(username ==""){ - errorNotify(2, context); + Notify(2, context); } else if(password =="" || confirmPassword == ""){ - errorNotify(4, context); + Notify(4, context); } else if(password.length <8){ - errorNotify(2, context); + Notify(2, context); } else if(password != confirmPassword){ - errorNotify(1, context); + Notify(1, context); } else{ MyApp().controller.createUser(userNameTextField.text, passwordConfirmTextField.text);