Skip to content

Commit

Permalink
feat: My account, modals, correct logic
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalheartxs committed Sep 26, 2024
1 parent 61390e1 commit 866751a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
4 changes: 2 additions & 2 deletions catalyst_voices/lib/pages/account/account_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,7 +41,7 @@ final class AccountPage extends StatelessWidget {
await VoicesDialog.show<void>(
context: context,
builder: (context) {
return const KeychainDeletedDialog();
return const DeleteKeychainDialog();
},
);
},
Expand Down
48 changes: 46 additions & 2 deletions catalyst_voices/lib/pages/account/delete_keychain_dialog.dart
Original file line number Diff line number Diff line change
@@ -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<DeleteKeychainDialog> createState() => _DeleteKeychainDialogState();
}

class _DeleteKeychainDialogState extends State<DeleteKeychainDialog> {
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(
Expand Down Expand Up @@ -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
Expand All @@ -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<void>(
context: context,
builder: (context) {
return const KeychainDeletedDialog();
},
);
} else {
setState(() {
_errorText = 'Text incorrect';
});
}
},
child: const Text('Delete'),
),
const SizedBox(width: 8),
Expand Down

0 comments on commit 866751a

Please sign in to comment.