mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 20:19:25 +00:00
Changed web client for moonpay.
This commit is contained in:
parent
ee6b8767d6
commit
fcb1c891f6
1 changed files with 24 additions and 14 deletions
|
@ -20,6 +20,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||||
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class PreOrderPage extends BasePage {
|
class PreOrderPage extends BasePage {
|
||||||
PreOrderPage({@required this.buyViewModel})
|
PreOrderPage({@required this.buyViewModel})
|
||||||
|
@ -221,20 +222,7 @@ class PreOrderPage extends BasePage {
|
||||||
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||||
bottomSection: Observer(builder: (_) {
|
bottomSection: Observer(builder: (_) {
|
||||||
return LoadingPrimaryButton(
|
return LoadingPrimaryButton(
|
||||||
onPressed: buyViewModel.isRunning
|
onPressed: () => onPresentProvider(context: context),
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
buyViewModel.isRunning = true;
|
|
||||||
final url =
|
|
||||||
await buyViewModel.fetchUrl();
|
|
||||||
if (url.isNotEmpty) {
|
|
||||||
await Navigator.of(context)
|
|
||||||
.pushNamed(Routes.buyWebView,
|
|
||||||
arguments: [url, buyViewModel]);
|
|
||||||
buyViewModel.reset();
|
|
||||||
}
|
|
||||||
buyViewModel.isRunning = false;
|
|
||||||
},
|
|
||||||
text: buyViewModel.selectedProvider == null
|
text: buyViewModel.selectedProvider == null
|
||||||
? S.of(context).buy
|
? S.of(context).buy
|
||||||
: S.of(context).buy_with +
|
: S.of(context).buy_with +
|
||||||
|
@ -275,4 +263,26 @@ class PreOrderPage extends BasePage {
|
||||||
? buyViewModel.isDisabled = false
|
? buyViewModel.isDisabled = false
|
||||||
: buyViewModel.isDisabled = true;
|
: buyViewModel.isDisabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onPresentProvider({BuildContext context}) async {
|
||||||
|
if (buyViewModel.isRunning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buyViewModel.isRunning = true;
|
||||||
|
final url = await buyViewModel.fetchUrl();
|
||||||
|
|
||||||
|
if (url.isNotEmpty) {
|
||||||
|
if (buyViewModel.selectedProvider is MoonPayBuyProvider) {
|
||||||
|
if (await canLaunch(url)) await launch(url);
|
||||||
|
} else {
|
||||||
|
await Navigator.of(context)
|
||||||
|
.pushNamed(Routes.buyWebView,
|
||||||
|
arguments: [url, buyViewModel]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buyViewModel.reset();
|
||||||
|
buyViewModel.isRunning = false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue