mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 18:44:31 +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_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/utilities/text_styles.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:tuple/tuple.dart';
|
||||
|
||||
import 'delete_wallet_keys_popup.dart';
|
||||
|
||||
class DesktopAttentionDeleteWallet extends ConsumerStatefulWidget {
|
||||
const DesktopAttentionDeleteWallet({
|
||||
Key? key,
|
||||
|
|
|
@ -5,6 +5,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.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/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/constants.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/stack_text_field.dart';
|
||||
|
||||
import '../../../../../providers/desktop/storage_crypto_handler_provider.dart';
|
||||
import '../../../../../providers/global/wallets_provider.dart';
|
||||
|
||||
class DesktopDeleteWalletDialog extends ConsumerStatefulWidget {
|
||||
const DesktopDeleteWalletDialog({
|
||||
Key? key,
|
||||
|
@ -42,6 +41,62 @@ class _DesktopDeleteWalletDialog
|
|||
bool hidePassword = true;
|
||||
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
|
||||
void initState() {
|
||||
passwordController = TextEditingController();
|
||||
|
@ -106,6 +161,12 @@ class _DesktopDeleteWalletDialog
|
|||
obscureText: hidePassword,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
autofocus: true,
|
||||
onSubmitted: (_) {
|
||||
if (_continueEnabled) {
|
||||
enterPassphrase();
|
||||
}
|
||||
},
|
||||
decoration: standardInputDecoration(
|
||||
"Enter password",
|
||||
passwordFocusNode,
|
||||
|
@ -179,64 +240,7 @@ class _DesktopDeleteWalletDialog
|
|||
onPressed: _continueEnabled
|
||||
? () async {
|
||||
// add loading indicator
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
enterPassphrase();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue