diff --git a/lib/pages/monkey/monkey_view.dart b/lib/pages/monkey/monkey_view.dart index 83901fbca..ce4e951d3 100644 --- a/lib/pages/monkey/monkey_view.dart +++ b/lib/pages/monkey/monkey_view.dart @@ -7,40 +7,34 @@ import 'package:flutter_svg/svg.dart'; import 'package:http/http.dart' as http; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:stackwallet/pages/monkey/sub_widgets/fetch_monkey_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/services/coins/banano/banano_wallet.dart'; -import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; +import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; -import '../../widgets/desktop/desktop_app_bar.dart'; -import '../../widgets/desktop/desktop_scaffold.dart'; - class MonkeyView extends ConsumerStatefulWidget { const MonkeyView({ Key? key, required this.walletId, - required this.managerProvider, }) : super(key: key); static const String routeName = "/monkey"; static const double navBarHeight = 65.0; final String walletId; - final ChangeNotifierProvider managerProvider; @override ConsumerState createState() => _MonkeyViewState(); @@ -48,23 +42,21 @@ class MonkeyView extends ConsumerStatefulWidget { class _MonkeyViewState extends ConsumerState { late final String walletId; - late final ChangeNotifierProvider managerProvider; String receivingAddress = ""; - void getMonkeyImage(String address) async { + Future getMonkeyImage(String address) async { if (address.isEmpty) { //address shouldn't be empty return; } - final manager = ref.watch(walletsChangeNotifierProvider - .select((value) => value.getManager(walletId))); - final http.Response response = await http .get(Uri.parse('https://monkey.banano.cc/api/v1/monkey/$address')); if (response.statusCode == 200) { + final manager = + ref.read(walletsChangeNotifierProvider).getManager(walletId); final decodedResponse = response.bodyBytes; await (manager.wallet as BananoWallet) .updateMonkeyImageBytes(decodedResponse); @@ -172,7 +164,6 @@ class _MonkeyViewState extends ConsumerState { @override void initState() { walletId = widget.walletId; - managerProvider = widget.managerProvider; WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { final address = await ref @@ -194,9 +185,9 @@ class _MonkeyViewState extends ConsumerState { @override Widget build(BuildContext context) { - final Coin coin = ref.watch(managerProvider.select((value) => value.coin)); final manager = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(widget.walletId))); + final Coin coin = manager.coin; final bool isDesktop = Util.isDesktop; @@ -400,34 +391,29 @@ class _MonkeyViewState extends ConsumerState { child: PrimaryButton( label: "Fetch MonKey", onPressed: () async { - getMonkeyImage(receivingAddress); + final future = Future.wait([ + getMonkeyImage(receivingAddress), + Future.delayed(const Duration(seconds: 2)), + ]); - showDialog( + await showLoading( + whileFuture: future, context: context, - useSafeArea: false, - barrierDismissible: false, - builder: (context) { - return FetchMonkeyDialog( - onCancel: () async { - Navigator.of(context).pop(); - }, - ); - }, + isDesktop: Util.isDesktop, + message: "Fetching MonKey", + subMessage: "We are fetching your MonKey", ); - await Future.delayed( - const Duration(seconds: 2)); - - if (isDesktop) { - Navigator.of(context).popUntil( - ModalRoute.withName( - DesktopWalletView.routeName), - ); - } else { - Navigator.of(context).popUntil( - ModalRoute.withName(WalletView.routeName), - ); - } + // if (isDesktop) { + // Navigator.of(context).popUntil( + // ModalRoute.withName( + // DesktopWalletView.routeName), + // ); + // } else { + // Navigator.of(context).popUntil( + // ModalRoute.withName(WalletView.routeName), + // ); + // } }, ), ), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index 1ee1b664b..afeec5094 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -42,7 +42,6 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:tuple/tuple.dart'; class DesktopWalletFeatures extends ConsumerStatefulWidget { const DesktopWalletFeatures({ @@ -318,16 +317,10 @@ class _DesktopWalletFeaturesState extends ConsumerState { Future _onMonkeyPressed() async { Navigator.of(context, rootNavigator: true).pop(); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); await (Navigator.of(context).pushNamed( MonkeyView.routeName, - arguments: Tuple2( - widget.walletId, - managerProvider, - ), + arguments: widget.walletId, )); } diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 368d23397..edd3b15fc 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -378,12 +378,11 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case MonkeyView.routeName: - if (args is Tuple2>) { + if (args is String) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => MonkeyView( - walletId: args.item1, - managerProvider: args.item2, + walletId: args, ), settings: RouteSettings( name: settings.name,