All checks were successful
Deploy Flutter to Firebase (Mac) / deploy-android (push) Successful in 2m40s
58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PasswordRequirements extends StatelessWidget {
|
|
final String password;
|
|
|
|
const PasswordRequirements({super.key, required this.password});
|
|
|
|
bool get _hasMinLength => password.length >= 8;
|
|
bool get _hasUppercase => password.contains(RegExp(r'[A-Z]'));
|
|
bool get _hasLowercase => password.contains(RegExp(r'[a-z]'));
|
|
bool get _hasDigit => password.contains(RegExp(r'[0-9]'));
|
|
bool get _hasSpecialChar =>
|
|
password.contains(RegExp(r'[!@#\$%^&*(),.?":{}|<>]'));
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(height: 10),
|
|
const Text(
|
|
'Votre mot de passe doit contenir :',
|
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 8),
|
|
_buildRequirement(_hasMinLength, 'Au moins 8 caractères'),
|
|
_buildRequirement(_hasUppercase, 'Une majuscule'),
|
|
_buildRequirement(_hasLowercase, 'Une minuscule'),
|
|
_buildRequirement(_hasDigit, 'Un chiffre'),
|
|
_buildRequirement(_hasSpecialChar, 'Un caractère spécial'),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildRequirement(bool isMet, String text) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
isMet ? Icons.check_circle : Icons.circle_outlined,
|
|
color: isMet ? Colors.green : Colors.grey,
|
|
size: 16,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
color: isMet ? Colors.green : Colors.grey,
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|