CAKE-279 | added isRunningWebView to the dashboard_view_model.dart; applied isRunningWebView to call of WebViewPage in the dashboard_page.dart

This commit is contained in:
OleksandrSobol 2021-03-17 21:32:13 +02:00
parent d752692c3f
commit af9d39f460
2 changed files with 24 additions and 14 deletions

View file

@ -125,22 +125,27 @@ class DashboardPage extends BasePage {
image: exchangeImage, image: exchangeImage,
title: S.of(context).exchange, title: S.of(context).exchange,
route: Routes.exchange), route: Routes.exchange),
if (walletViewModel.type == WalletType.bitcoin) ActionButton( if (walletViewModel.type == WalletType.bitcoin) Observer(
image: buyImage, builder: (_) => ActionButton(
title: S.of(context).buy, image: buyImage,
onClick: () async { title: S.of(context).buy,
final url = await walletViewModel.getWyreUrl(); onClick: walletViewModel.isRunningWebView
if (url.isNotEmpty) { ? null
await Navigator.of(context) : () async {
.pushNamed(Routes.webView, arguments: url); 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) { if (orderId.isNotEmpty) {
await walletViewModel.saveOrder(orderId); await walletViewModel.saveOrder(orderId);
} }
} }
}), walletViewModel.isRunningWebView = false;
})),
], ],
)), )),
) )

View file

@ -93,6 +93,8 @@ abstract class DashboardViewModelBase with Store {
] ]
}; };
isRunningWebView = false;
name = appStore.wallet?.name; name = appStore.wallet?.name;
wallet ??= appStore.wallet; wallet ??= appStore.wallet;
type = wallet.type; type = wallet.type;
@ -177,6 +179,9 @@ abstract class DashboardViewModelBase with Store {
@observable @observable
String subname; String subname;
@observable
bool isRunningWebView;
@computed @computed
String get address => wallet.address; String get address => wallet.address;