DoctorPassword widget AND Doctor view ended

pull/112/head
Aurian JAULT 2 years ago
parent 9c33b23c03
commit 8ff5522428

@ -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<List<Password>> strenght(Account user) {
var orange= <Password>[];
var red = <Password>[];
List<Password> 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<Password> timeUsed(Account user) {
List<Password> list = user.vault.passwordList;
var res = [];
List<Password> res = [];
var toDay = DateTime.now();
list.forEach((element) {
var date = element.getModifDate!;

@ -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<HealthPage> {
@override
Widget build(BuildContext context) {
// Passwords's Strenght
List list = Doctor.strenght(context.read<Account>());
List<List<Password>> list = Doctor.strenght(context.read<Account>());
Password selected;
// Media Query
var size = MediaQuery.of(context).size;
var w = size.width;
@ -54,6 +56,152 @@ class _HealthPageState extends State<HealthPage> {
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<Password>(
icon: const Icon(Icons.arrow_drop_down),
items: list[0]
.map<DropdownMenuItem<Password>>(
(val) => DropdownMenuItem<Password>(
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<Password>(
icon: const Icon(Icons.arrow_drop_down),
items: list[1]
.map<DropdownMenuItem<Password>>((val) =>
DropdownMenuItem<Password>(
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<Password>(
icon: const Icon(Icons.arrow_drop_down),
items: Doctor.reused(context.read<Account>())
.map<DropdownMenuItem<Password>>((val) =>
DropdownMenuItem<Password>(
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<Password>(
icon: const Icon(Icons.arrow_drop_down),
items: Doctor.timeUsed(context.read<Account>())
.map<DropdownMenuItem<Password>>((val) =>
DropdownMenuItem<Password>(
value: val,
child: Padding(
padding: const EdgeInsets.all(5),
child: DoctorPassword(
password: val, color: Colors.orange))))
.toList(),
onChanged: ((value) {})),
),
],
)),
);

@ -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<RedPassword> createState() => _RedPasswordState();
}
Password password;
var color;
class _RedPasswordState extends State<RedPassword> {
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,
),
)
],
),
);
}
}
}
Loading…
Cancel
Save