monorepo/dialer/lib/features/settings/key/delete_key_pair.dart
Bartosz e8aba933d0
All checks were successful
/ mirror (push) Successful in 4s
Cryptographic Keys and History changes (#8)
Co-authored-by: stcb <21@stcb.cc>
Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#8
Co-authored-by: Bartosz <bartosz.michalak@epitech.eu>
Co-committed-by: Bartosz <bartosz.michalak@epitech.eu>
2024-12-20 09:13:05 +00:00

66 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'key_storage.dart';
class DeleteKeyPairPage extends StatelessWidget {
const DeleteKeyPairPage({super.key});
Future<void> _deleteKeyPair(BuildContext context) async {
final keyStorage = KeyStorage();
await keyStorage.deleteKeys();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('The key pair has been deleted.'),
),
);
Navigator.pop(context);
}
void _showConfirmationDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Confirm Deletion'),
content: const Text(
'Are you sure you want to delete the key pair? This action is irreversible.'),
actions: [
TextButton(
child: const Text('Cancel'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: const Text('Delete'),
onPressed: () {
Navigator.of(context).pop();
_deleteKeyPair(context);
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Delete a Key Pair'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
_showConfirmationDialog(context);
},
child: const Text('Delete Key Pair'),
),
),
);
}
}