diff --git a/catalyst_voices/lib/pages/account/account_page.dart b/catalyst_voices/lib/pages/account/account_page.dart index 608f19cbd4..edf1bf07ae 100644 --- a/catalyst_voices/lib/pages/account/account_page.dart +++ b/catalyst_voices/lib/pages/account/account_page.dart @@ -1,5 +1,5 @@ import 'package:catalyst_voices/common/ext/account_role_ext.dart'; -import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart'; +import 'package:catalyst_voices/pages/account/delete_keychain_dialog.dart'; import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart'; import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; @@ -41,7 +41,7 @@ final class AccountPage extends StatelessWidget { await VoicesDialog.show( context: context, builder: (context) { - return const KeychainDeletedDialog(); + return const DeleteKeychainDialog(); }, ); }, diff --git a/catalyst_voices/lib/pages/account/delete_keychain_dialog.dart b/catalyst_voices/lib/pages/account/delete_keychain_dialog.dart index f060fb820e..0d94152532 100644 --- a/catalyst_voices/lib/pages/account/delete_keychain_dialog.dart +++ b/catalyst_voices/lib/pages/account/delete_keychain_dialog.dart @@ -1,14 +1,40 @@ +import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart'; import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; import 'package:catalyst_voices/widgets/modals/voices_desktop_dialog.dart'; +import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; import 'package:catalyst_voices/widgets/text_field/voices_text_field.dart'; import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; import 'package:flutter/material.dart'; -class DeleteKeychainDialog extends StatelessWidget { +class DeleteKeychainDialog extends StatefulWidget { const DeleteKeychainDialog({super.key}); + @override + State createState() => _DeleteKeychainDialogState(); +} + +class _DeleteKeychainDialogState extends State { + final _textEditingController = TextEditingController(); + String? _errorText; + + @override + void initState() { + super.initState(); + _textEditingController.addListener(() { + setState(() { + _errorText = null; + }); + }); + } + + @override + void dispose() { + _textEditingController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return VoicesDesktopDialog( @@ -74,7 +100,9 @@ Your Catalyst account will be removed,
this action cannot be undone!''', SizedBox( width: 300, child: VoicesTextField( + controller: _textEditingController, decoration: VoicesTextFieldDecoration( + errorText: _errorText, filled: true, fillColor: Theme.of(context) .colors @@ -89,7 +117,23 @@ Your Catalyst account will be removed,
this action cannot be undone!''', children: [ VoicesFilledButton( backgroundColor: Theme.of(context).colors.iconsError, - onTap: () {}, + onTap: () async { + if (_textEditingController.text == + 'Remove Keychain') { + // TODO(Jakub): remove keychain + Navigator.of(context).pop(); + await VoicesDialog.show( + context: context, + builder: (context) { + return const KeychainDeletedDialog(); + }, + ); + } else { + setState(() { + _errorText = 'Text incorrect'; + }); + } + }, child: const Text('Delete'), ), const SizedBox(width: 8),