Files
afterwork/lib/presentation/widgets/account_deletion_card.dart
2024-11-08 20:30:23 +00:00

68 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import '../../../../core/constants/colors.dart';
/// [AccountDeletionCard] est un widget permettant à l'utilisateur de supprimer son compte.
/// Il affiche une confirmation avant d'effectuer l'action de suppression.
class AccountDeletionCard extends StatelessWidget {
final BuildContext context;
const AccountDeletionCard({Key? key, required this.context}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
color: AppColors.cardColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
elevation: 2,
child: ListTile(
leading: const Icon(Icons.delete, color: Colors.redAccent),
title: const Text(
'Supprimer le compte',
style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold),
),
onTap: () => _showDeleteConfirmationDialog(),
),
);
}
/// Affiche un dialogue de confirmation pour la suppression du compte.
void _showDeleteConfirmationDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: AppColors.backgroundColor,
title: const Text(
'Confirmer la suppression',
style: TextStyle(color: Colors.white),
),
content: const Text(
'Êtes-vous sûr de vouloir supprimer votre compte ? Cette action est irréversible.',
style: TextStyle(color: Colors.white70),
),
actions: [
TextButton(
onPressed: () {
debugPrint("[LOG] Suppression du compte annulée.");
Navigator.of(context).pop();
},
child: Text('Annuler', style: TextStyle(color: AppColors.accentColor)),
),
TextButton(
onPressed: () {
debugPrint("[LOG] Suppression du compte confirmée.");
Navigator.of(context).pop();
// Logique de suppression du compte ici.
},
child: const Text(
'Supprimer',
style: TextStyle(color: Colors.redAccent),
),
),
],
);
},
);
}
}