diff --git a/lib/Classes/doctor.dart b/lib/Classes/doctor.dart index 62a885f..bed61fb 100644 --- a/lib/Classes/doctor.dart +++ b/lib/Classes/doctor.dart @@ -22,16 +22,16 @@ class Doctor { // retourne une liste de deux tableaux // Res[0] --> Listes de Passwords "Moyen" (Affichage Orange) // Res[1] --> Listes de Passwords "Trop faible" (Affichage Rouge) - static List strenght(Account user) { + static List> strenght(Account user) { var orange= []; var red = []; List list = user.vault.passwordList; list.forEach((element) { double strength = estimatePasswordStrength(element.getPassword); - if (strength < 0.5) { + if (strength < 0.3) { red.add(element); } else { - if (strength < 0.7) { + if (strength < 0.8) { orange.add(element); } } @@ -40,9 +40,9 @@ class Doctor { return res; } - static List timeUsed(Account user) { + static List timeUsed(Account user) { List list = user.vault.passwordList; - var res = []; + List res = []; var toDay = DateTime.now(); list.forEach((element) { var date = element.getModifDate!; diff --git a/lib/ui/health_page.dart b/lib/ui/health_page.dart index b690f20..223b7b3 100644 --- a/lib/ui/health_page.dart +++ b/lib/ui/health_page.dart @@ -6,6 +6,7 @@ import 'package:test/Classes/strength_password.dart'; import 'package:test/Classes/vault.dart'; import 'package:test/ui/widget/page_title_widget.dart'; import 'package:test/ui/widget/password_widget.dart'; +import 'package:test/ui/widget/red_password.dart'; import '../Classes/account.dart'; @@ -20,7 +21,8 @@ class _HealthPageState extends State { @override Widget build(BuildContext context) { // Passwords's Strenght - List list = Doctor.strenght(context.read()); + List> list = Doctor.strenght(context.read()); + Password selected; // Media Query var size = MediaQuery.of(context).size; var w = size.width; @@ -54,6 +56,152 @@ class _HealthPageState extends State { const SizedBox( width: 20, ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(25), + child: Text( + "Critical password(s) strenght", + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: w * 0.035), + ), + ) + ], + ), + const SizedBox( + width: 15, + ), + Container( + color: Colors.red, + height: 50, + width: w * 0.80, + child: DropdownButton( + icon: const Icon(Icons.arrow_drop_down), + items: list[0] + .map>( + (val) => DropdownMenuItem( + value: val, + child: Padding( + padding: const EdgeInsets.all(5), + child: DoctorPassword( + password: val, + color: Colors.red, + ), + ))) + .toList(), + onChanged: ((value) {})), + ), + const SizedBox( + width: 100, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(25), + child: Text( + "Medium password(s) strenght", + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: w * 0.035), + ), + ) + ], + ), + Container( + color: Colors.orange, + height: 50, + width: w * 0.80, + child: DropdownButton( + icon: const Icon(Icons.arrow_drop_down), + items: list[1] + .map>((val) => + DropdownMenuItem( + value: val, + child: Padding( + padding: const EdgeInsets.all(5), + child: DoctorPassword( + password: val, color: Colors.orange)))) + .toList(), + onChanged: ((value) {})), + ), + const SizedBox( + width: 100, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(25), + child: Text( + "Reused password(s)", + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: w * 0.035), + ), + ) + ], + ), + + Container( + color: Colors.blueGrey, + height: 50, + width: w * 0.80, + child: DropdownButton( + icon: const Icon(Icons.arrow_drop_down), + items: Doctor.reused(context.read()) + .map>((val) => + DropdownMenuItem( + value: val, + child: Padding( + padding: const EdgeInsets.all(5), + child: DoctorPassword( + password: val, color: Colors.orange)))) + .toList(), + onChanged: ((value) {})), + ), + + + + const SizedBox( + width: 100, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(25), + child: Text( + "Too old password(s)", + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: w * 0.035), + ), + ) + ], + ), + + Container( + color: Colors.lightGreen, + height: 50, + width: w * 0.80, + child: DropdownButton( + icon: const Icon(Icons.arrow_drop_down), + items: Doctor.timeUsed(context.read()) + .map>((val) => + DropdownMenuItem( + value: val, + child: Padding( + padding: const EdgeInsets.all(5), + child: DoctorPassword( + password: val, color: Colors.orange)))) + .toList(), + onChanged: ((value) {})), + ), + + ], )), ); diff --git a/lib/ui/widget/red_password.dart b/lib/ui/widget/red_password.dart index 52c69df..1707f9e 100644 --- a/lib/ui/widget/red_password.dart +++ b/lib/ui/widget/red_password.dart @@ -1,18 +1,60 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:test/Classes/password.dart'; +import 'package:flutter/services.dart'; -class RedPassword extends StatefulWidget { - Password password; - RedPassword({super.key, required this.password}); +class DoctorPassword extends StatelessWidget { - @override - State createState() => _RedPasswordState(); -} + Password password; + + var color; -class _RedPasswordState extends State { + DoctorPassword({super.key, required this.password,required this.color}); + @override Widget build(BuildContext context) { - return Scaffold(); + var size = MediaQuery.of(context).size; + var w = size.width; + var h = size.height; + // Widget + return Container( + height: h * 1, + width: w * 0.80, + decoration: BoxDecoration( + color: color, + ), + child: Row( + children: [ + Image.asset( + 'assets/${password.getWebsiteImage}.png', + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + password.getName, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + Text( + password.getEmail!, + style: const TextStyle( + ) + ) + ], + ), + const Spacer(), + InkWell( + onTap: () async { + await Clipboard.setData( + ClipboardData(text: password.getPassword)); + }, + child: const Icon( + Icons.copy, + ), + ) + ], + ), + ); } -} +} \ No newline at end of file