From af9d39f460e995dfeaf7e54507f07f2c0b4e095c Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Wed, 17 Mar 2021 21:32:13 +0200 Subject: [PATCH] CAKE-279 | added isRunningWebView to the dashboard_view_model.dart; applied isRunningWebView to call of WebViewPage in the dashboard_page.dart --- lib/src/screens/dashboard/dashboard_page.dart | 33 +++++++++++-------- .../dashboard/dashboard_view_model.dart | 5 +++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 7f52bacf3..75111fa97 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -125,22 +125,27 @@ class DashboardPage extends BasePage { image: exchangeImage, title: S.of(context).exchange, route: Routes.exchange), - if (walletViewModel.type == WalletType.bitcoin) ActionButton( - image: buyImage, - title: S.of(context).buy, - onClick: () async { - final url = await walletViewModel.getWyreUrl(); - if (url.isNotEmpty) { - await Navigator.of(context) - .pushNamed(Routes.webView, arguments: url); + if (walletViewModel.type == WalletType.bitcoin) Observer( + builder: (_) => ActionButton( + image: buyImage, + title: S.of(context).buy, + onClick: walletViewModel.isRunningWebView + ? null + : () async { + walletViewModel.isRunningWebView = true; + final url = await walletViewModel.getWyreUrl(); + if (url.isNotEmpty) { + await Navigator.of(context) + .pushNamed(Routes.webView, arguments: url); - final orderId = walletViewModel.ordersStore.orderId; + final orderId = walletViewModel.ordersStore.orderId; - if (orderId.isNotEmpty) { - await walletViewModel.saveOrder(orderId); - } - } - }), + if (orderId.isNotEmpty) { + await walletViewModel.saveOrder(orderId); + } + } + walletViewModel.isRunningWebView = false; + })), ], )), ) diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 4af71e8e7..786984bdd 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -93,6 +93,8 @@ abstract class DashboardViewModelBase with Store { ] }; + isRunningWebView = false; + name = appStore.wallet?.name; wallet ??= appStore.wallet; type = wallet.type; @@ -177,6 +179,9 @@ abstract class DashboardViewModelBase with Store { @observable String subname; + @observable + bool isRunningWebView; + @computed String get address => wallet.address;