mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Add onramper widget for buy screen (#571)
This commit is contained in:
parent
bd5a2fa49f
commit
b2a5c66c37
6 changed files with 96 additions and 3 deletions
|
@ -4,6 +4,7 @@ import 'package:cake_wallet/entities/wake_lock.dart';
|
|||
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/onramper_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_custom_redeem_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_gift_card_detail_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_more_options_page.dart';
|
||||
|
@ -482,6 +483,10 @@ Future setup(
|
|||
getIt.registerFactory(
|
||||
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
|
||||
|
||||
getIt.registerFactory(() => OnRamperPage(
|
||||
settingsStore: getIt.get<AppStore>().settingsStore,
|
||||
wallet: getIt.get<AppStore>().wallet!));
|
||||
|
||||
getIt.registerFactory(() => ExchangeViewModel(
|
||||
getIt.get<AppStore>().wallet!,
|
||||
_tradesSource,
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/order.dart';
|
|||
import 'package:cake_wallet/src/screens/backup/backup_page.dart';
|
||||
import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/onramper_page.dart';
|
||||
import 'package:cake_wallet/src/screens/buy/pre_order_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_account_cards_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_account_page.dart';
|
||||
|
@ -471,6 +472,9 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
param1: paymentInfo,
|
||||
param2: commitedInfo));
|
||||
|
||||
case Routes.onramperPage:
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<OnRamperPage>());
|
||||
|
||||
default:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => Scaffold(
|
||||
|
|
|
@ -76,4 +76,5 @@ class Routes {
|
|||
static const ioniaPaymentStatusPage = '/ionia_payment_status_page';
|
||||
static const ioniaMoreOptionsPage = '/ionia_more_options_page';
|
||||
static const ioniaCustomRedeemPage = '/ionia_custom_redeem_page';
|
||||
static const onramperPage = '/onramper';
|
||||
}
|
||||
|
|
82
lib/src/screens/buy/onramper_page.dart
Normal file
82
lib/src/screens/buy/onramper_page.dart
Normal file
|
@ -0,0 +1,82 @@
|
|||
import 'dart:io';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||
|
||||
class OnRamperPage extends BasePage {
|
||||
OnRamperPage({
|
||||
required this.settingsStore,
|
||||
required this.wallet});
|
||||
|
||||
final SettingsStore settingsStore;
|
||||
final WalletBase wallet;
|
||||
|
||||
@override
|
||||
String get title => S.current.buy;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final darkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
return OnRamperPageBody(
|
||||
settingsStore: settingsStore,
|
||||
wallet: wallet,
|
||||
darkMode: darkMode,
|
||||
backgroundColor: darkMode
|
||||
? backgroundDarkColor
|
||||
: backgroundLightColor,
|
||||
supportSell: false);
|
||||
}
|
||||
}
|
||||
|
||||
class OnRamperPageBody extends StatefulWidget {
|
||||
OnRamperPageBody({
|
||||
required this.settingsStore,
|
||||
required this.wallet,
|
||||
required this.darkMode,
|
||||
required this.supportSell,
|
||||
required this.backgroundColor});
|
||||
|
||||
static const baseUrl = 'widget.onramper.com';
|
||||
final SettingsStore settingsStore;
|
||||
final WalletBase wallet;
|
||||
final Color backgroundColor;
|
||||
final bool darkMode;
|
||||
final bool supportSell;
|
||||
|
||||
Uri get uri
|
||||
=> Uri.https(
|
||||
baseUrl,
|
||||
'',
|
||||
<String, dynamic>{
|
||||
'apiKey': secrets.onramperApiKey,
|
||||
'defaultCrypto': wallet.currency.title,
|
||||
'defaultFiat': settingsStore.fiatCurrency.title,
|
||||
'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}',
|
||||
'darkMode': darkMode.toString(),
|
||||
'supportSell': supportSell.toString()});
|
||||
|
||||
@override
|
||||
OnRamperPageBodyState createState() => OnRamperPageBodyState();
|
||||
}
|
||||
|
||||
class OnRamperPageBodyState extends State<OnRamperPageBody> {
|
||||
OnRamperPageBodyState();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WebView(
|
||||
initialUrl: widget.uri.toString(),
|
||||
backgroundColor: widget.backgroundColor,
|
||||
javascriptMode: JavascriptMode.unrestricted);
|
||||
}
|
||||
}
|
|
@ -271,10 +271,10 @@ class DashboardPage extends BasePage {
|
|||
|
||||
switch (walletType) {
|
||||
case WalletType.bitcoin:
|
||||
Navigator.of(context).pushNamed(Routes.preOrder);
|
||||
Navigator.of(context).pushNamed(Routes.onramperPage);
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
Navigator.of(context).pushNamed(Routes.preOrder);
|
||||
Navigator.of(context).pushNamed(Routes.onramperPage);
|
||||
break;
|
||||
default:
|
||||
await showPopUp<void>(
|
||||
|
|
|
@ -25,7 +25,8 @@ class SecretKey {
|
|||
SecretKey('moonPaySecretKey', () => ''),
|
||||
SecretKey('sideShiftAffiliateId', () => ''),
|
||||
SecretKey('sideShiftApiKey', () => ''),
|
||||
SecretKey('simpleSwapApiKey', () => '')
|
||||
SecretKey('simpleSwapApiKey', () => ''),
|
||||
SecretKey('onramperApiKey', () => ''),
|
||||
];
|
||||
|
||||
final String name;
|
||||
|
|
Loading…
Reference in a new issue