diff --git a/lib/pages/pinpad_views/lock_screen_view.dart b/lib/pages/pinpad_views/lock_screen_view.dart index 2b9b12b79..7e9f9b77f 100644 --- a/lib/pages/pinpad_views/lock_screen_view.dart +++ b/lib/pages/pinpad_views/lock_screen_view.dart @@ -14,7 +14,9 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/biometrics.dart'; import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -80,19 +82,47 @@ class _LockscreenViewState extends ConsumerState { if (widget.popOnSuccess) { Navigator.of(context).pop(widget.routeOnSuccessArguments); } else { - unawaited(Navigator.of(context).pushReplacementNamed( - widget.routeOnSuccess, - arguments: widget.routeOnSuccessArguments, - )); - if (widget.routeOnSuccess == HomeView.routeName && - widget.routeOnSuccessArguments is String) { + final loadIntoWallet = widget.routeOnSuccess == HomeView.routeName && + widget.routeOnSuccessArguments is String; + + if (loadIntoWallet) { final walletId = widget.routeOnSuccessArguments as String; - unawaited(Navigator.of(context).pushNamed(WalletView.routeName, - arguments: Tuple2( + + final manager = + ref.read(walletsChangeNotifierProvider).getManager(walletId); + if (manager.coin == Coin.monero || manager.coin == Coin.wownero) { + await showLoading( + opaqueBG: true, + whileFuture: manager.initializeExisting(), + context: context, + message: "Loading ${manager.coin.prettyName} wallet...", + ); + } + } + + if (mounted) { + unawaited( + Navigator.of(context).pushReplacementNamed( + widget.routeOnSuccess, + arguments: widget.routeOnSuccessArguments, + ), + ); + + if (loadIntoWallet) { + final walletId = widget.routeOnSuccessArguments as String; + + unawaited( + Navigator.of(context).pushNamed( + WalletView.routeName, + arguments: Tuple2( walletId, ref .read(walletsChangeNotifierProvider) - .getManagerProvider(walletId)))); + .getManagerProvider(walletId), + ), + ), + ); + } } } } diff --git a/lib/pages/receive_view/addresses/address_tag.dart b/lib/pages/receive_view/addresses/address_tag.dart index df03dc405..56d591301 100644 --- a/lib/pages/receive_view/addresses/address_tag.dart +++ b/lib/pages/receive_view/addresses/address_tag.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/rounded_container.dart'; class AddressTag extends StatelessWidget { @@ -16,10 +17,12 @@ class AddressTag extends StatelessWidget { vertical: 5, horizontal: 7, ), - color: Colors.black, + color: Theme.of(context).extension()!.buttonBackPrimary, child: Text( tag.capitalize(), - style: STextStyles.w500_14(context), + style: STextStyles.w500_14(context).copyWith( + color: Theme.of(context).extension()!.buttonTextPrimary, + ), ), ); } diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart index 7e308c61f..1dd34f330 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart @@ -62,6 +62,44 @@ class _AddEditNodeViewState extends ConsumerState { late bool saveEnabled; late bool testConnectionEnabled; + Future _xmrHelper(String url, int? port) async { + final uri = Uri.parse(url); + + final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; + + final uriString = "${uri.scheme}://${uri.host}:${port ?? 0}$path"; + + ref.read(nodeFormDataProvider).useSSL = true; + + final response = await testMoneroNodeConnection( + Uri.parse(uriString), + false, + ); + + if (response.cert != null) { + if (mounted) { + final shouldAllowBadCert = await showBadX509CertificateDialog( + response.cert!, + response.url!, + response.port!, + context, + ); + + if (shouldAllowBadCert) { + final response = + await testMoneroNodeConnection(Uri.parse(uriString), true); + ref.read(nodeFormDataProvider).host = url; + return response.success; + } + } + } else { + ref.read(nodeFormDataProvider).host = url; + return response.success; + } + + return false; + } + Future _testConnection({bool showFlushBar = true}) async { final formData = ref.read(nodeFormDataProvider); @@ -86,41 +124,19 @@ class _AddEditNodeViewState extends ConsumerState { case Coin.monero: case Coin.wownero: try { - final uri = Uri.parse(formData.host!); - if (uri.scheme.startsWith("http")) { - final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; + final url = formData.host!; + final uri = Uri.tryParse(url); + if (uri != null) { + if (!uri.hasScheme) { + // try https first + testPassed = await _xmrHelper("https://$url", formData.port); - String uriString = - "${uri.scheme}://${uri.host}:${formData.port ?? 0}$path"; - - if (uri.host == "https") { - ref.read(nodeFormDataProvider).useSSL = true; - } else { - ref.read(nodeFormDataProvider).useSSL = false; - } - - final response = await testMoneroNodeConnection( - Uri.parse(uriString), - false, - ); - - if (response.cert != null) { - if (mounted) { - final shouldAllowBadCert = await showBadX509CertificateDialog( - response.cert!, - response.url!, - response.port!, - context, - ); - - if (shouldAllowBadCert) { - final response = await testMoneroNodeConnection( - Uri.parse(uriString), true); - testPassed = response.success; - } + if (testPassed == false) { + // try http + testPassed = await _xmrHelper("http://$url", formData.port); } } else { - testPassed = response.success; + testPassed = await _xmrHelper(url, formData.port); } } } catch (e, s) { @@ -158,7 +174,7 @@ class _AddEditNodeViewState extends ConsumerState { break; } - if (showFlushBar) { + if (showFlushBar && mounted) { if (testPassed) { unawaited(showFloatingFlushBar( type: FlushBarType.success, @@ -182,7 +198,7 @@ class _AddEditNodeViewState extends ConsumerState { bool? shouldSave; - if (!canConnect) { + if (!canConnect && mounted) { await showDialog( context: context, useSafeArea: true, @@ -975,7 +991,6 @@ class _NodeFormState extends ConsumerState { controller: _usernameController, readOnly: shouldBeReadOnly, enabled: enableField(_usernameController), - keyboardType: TextInputType.number, focusNode: _usernameFocusNode, style: STextStyles.field(context), decoration: standardInputDecoration( @@ -1024,7 +1039,7 @@ class _NodeFormState extends ConsumerState { controller: _passwordController, readOnly: shouldBeReadOnly, enabled: enableField(_passwordController), - keyboardType: TextInputType.number, + obscureText: true, focusNode: _passwordFocusNode, style: STextStyles.field(context), decoration: standardInputDecoration( diff --git a/lib/utilities/show_loading.dart b/lib/utilities/show_loading.dart index 9e48f7800..4a684d54c 100644 --- a/lib/utilities/show_loading.dart +++ b/lib/utilities/show_loading.dart @@ -10,6 +10,7 @@ Future showLoading({ required String message, String? subMessage, bool isDesktop = false, + bool opaqueBG = false, }) async { unawaited( showDialog( @@ -21,7 +22,7 @@ Future showLoading({ color: Theme.of(context) .extension()! .overlay - .withOpacity(0.6), + .withOpacity(opaqueBG ? 1.0 : 0.6), child: CustomLoadingOverlay( message: message, subMessage: subMessage,