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

OleksandrSobol committed Mar 17, 2021 at 21:32 UTC af9d39f460e995dfeaf7e54507f07f2c0b4e095c
2 files changed +26 -16
lib/src/screens/dashboard/dashboard_page.dart
+21 -16
@@ -125,22 +125,27 @@ class DashboardPage extends BasePage {
125 image: exchangeImage,
126 title: S.of(context).exchange,
127 route: Routes.exchange),
128 - if (walletViewModel.type == WalletType.bitcoin) ActionButton(
129 - image: buyImage,
130 - title: S.of(context).buy,
131 - onClick: () async {
132 - final url = await walletViewModel.getWyreUrl();
133 - if (url.isNotEmpty) {
134 - await Navigator.of(context)
135 - .pushNamed(Routes.webView, arguments: url);
136 -
137 - final orderId = walletViewModel.ordersStore.orderId;
138 -
139 - if (orderId.isNotEmpty) {
140 - await walletViewModel.saveOrder(orderId);
141 - }
142 - }
143 - }),
128 + if (walletViewModel.type == WalletType.bitcoin) Observer(
129 + builder: (_) => ActionButton(
130 + image: buyImage,
131 + title: S.of(context).buy,
132 + onClick: walletViewModel.isRunningWebView
133 + ? null
134 + : () async {
135 + walletViewModel.isRunningWebView = true;
136 + final url = await walletViewModel.getWyreUrl();
137 + if (url.isNotEmpty) {
138 + await Navigator.of(context)
139 + .pushNamed(Routes.webView, arguments: url);
140 +
141 + final orderId = walletViewModel.ordersStore.orderId;
142 +
143 + if (orderId.isNotEmpty) {
144 + await walletViewModel.saveOrder(orderId);
145 + }
146 + }
147 + walletViewModel.isRunningWebView = false;
148 + })),
149 ],
150 )),
151 )
lib/view_model/dashboard/dashboard_view_model.dart
+5
@@ -93,6 +93,8 @@ abstract class DashboardViewModelBase with Store {
93 ]
94 };
95
96 + isRunningWebView = false;
97 +
98 name = appStore.wallet?.name;
99 wallet ??= appStore.wallet;
100 type = wallet.type;
@@ -177,6 +179,9 @@ abstract class DashboardViewModelBase with Store {
179 @observable
180 String subname;
181
182 + @observable
183 + bool isRunningWebView;
184 +
185 @computed
186 String get address => wallet.address;
187