mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 14:48:55 +00:00
submit on enter passphrase
This commit is contained in:
parent
c5c0443d00
commit
9a47ce349e
2 changed files with 66 additions and 63 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
@ -10,8 +11,6 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
import 'delete_wallet_keys_popup.dart';
|
|
||||||
|
|
||||||
class DesktopAttentionDeleteWallet extends ConsumerStatefulWidget {
|
class DesktopAttentionDeleteWallet extends ConsumerStatefulWidget {
|
||||||
const DesktopAttentionDeleteWallet({
|
const DesktopAttentionDeleteWallet({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
|
@ -5,6 +5,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart';
|
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart';
|
||||||
|
import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
@ -16,9 +18,6 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||||
|
|
||||||
import '../../../../../providers/desktop/storage_crypto_handler_provider.dart';
|
|
||||||
import '../../../../../providers/global/wallets_provider.dart';
|
|
||||||
|
|
||||||
class DesktopDeleteWalletDialog extends ConsumerStatefulWidget {
|
class DesktopDeleteWalletDialog extends ConsumerStatefulWidget {
|
||||||
const DesktopDeleteWalletDialog({
|
const DesktopDeleteWalletDialog({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -42,6 +41,62 @@ class _DesktopDeleteWalletDialog
|
||||||
bool hidePassword = true;
|
bool hidePassword = true;
|
||||||
bool _continueEnabled = false;
|
bool _continueEnabled = false;
|
||||||
|
|
||||||
|
Future<void> enterPassphrase() async {
|
||||||
|
unawaited(
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
LoadingIndicator(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await Future<void>.delayed(const Duration(seconds: 1));
|
||||||
|
|
||||||
|
final verified = await ref
|
||||||
|
.read(storageCryptoHandlerProvider)
|
||||||
|
.verifyPassphrase(passwordController.text);
|
||||||
|
|
||||||
|
if (verified) {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
|
final words = await ref
|
||||||
|
.read(walletsChangeNotifierProvider)
|
||||||
|
.getManager(widget.walletId)
|
||||||
|
.mnemonic;
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
DesktopAttentionDeleteWallet.routeName,
|
||||||
|
arguments: widget.walletId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 300));
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
showFloatingFlushBar(
|
||||||
|
type: FlushBarType.warning,
|
||||||
|
message: "Invalid passphrase!",
|
||||||
|
context: context,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
passwordController = TextEditingController();
|
passwordController = TextEditingController();
|
||||||
|
@ -106,6 +161,12 @@ class _DesktopDeleteWalletDialog
|
||||||
obscureText: hidePassword,
|
obscureText: hidePassword,
|
||||||
enableSuggestions: false,
|
enableSuggestions: false,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
|
autofocus: true,
|
||||||
|
onSubmitted: (_) {
|
||||||
|
if (_continueEnabled) {
|
||||||
|
enterPassphrase();
|
||||||
|
}
|
||||||
|
},
|
||||||
decoration: standardInputDecoration(
|
decoration: standardInputDecoration(
|
||||||
"Enter password",
|
"Enter password",
|
||||||
passwordFocusNode,
|
passwordFocusNode,
|
||||||
|
@ -179,64 +240,7 @@ class _DesktopDeleteWalletDialog
|
||||||
onPressed: _continueEnabled
|
onPressed: _continueEnabled
|
||||||
? () async {
|
? () async {
|
||||||
// add loading indicator
|
// add loading indicator
|
||||||
unawaited(
|
enterPassphrase();
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.center,
|
|
||||||
children: const [
|
|
||||||
LoadingIndicator(
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(seconds: 1));
|
|
||||||
|
|
||||||
final verified = await ref
|
|
||||||
.read(storageCryptoHandlerProvider)
|
|
||||||
.verifyPassphrase(passwordController.text);
|
|
||||||
|
|
||||||
if (verified) {
|
|
||||||
Navigator.of(context, rootNavigator: true)
|
|
||||||
.pop();
|
|
||||||
|
|
||||||
final words = await ref
|
|
||||||
.read(walletsChangeNotifierProvider)
|
|
||||||
.getManager(widget.walletId)
|
|
||||||
.mnemonic;
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
unawaited(
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
DesktopAttentionDeleteWallet.routeName,
|
|
||||||
arguments: widget.walletId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Navigator.of(context, rootNavigator: true)
|
|
||||||
.pop();
|
|
||||||
|
|
||||||
await Future<void>.delayed(
|
|
||||||
const Duration(milliseconds: 300));
|
|
||||||
|
|
||||||
unawaited(
|
|
||||||
showFloatingFlushBar(
|
|
||||||
type: FlushBarType.warning,
|
|
||||||
message: "Invalid passphrase!",
|
|
||||||
context: context,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue