mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-78-Ethereum
This commit is contained in:
commit
eff0369709
28 changed files with 753 additions and 627 deletions
1
.github/workflows/pr_test_build.yml
vendored
1
.github/workflows/pr_test_build.yml
vendored
|
@ -107,7 +107,6 @@ jobs:
|
|||
echo "const moonPayApiKey = '${{ secrets.MOON_PAY_API_KEY }}';" >> lib/.secrets.g.dart
|
||||
echo "const moonPaySecretKey = '${{ secrets.MOON_PAY_SECRET_KEY }}';" >> lib/.secrets.g.dart
|
||||
echo "const sideShiftAffiliateId = '${{ secrets.SIDE_SHIFT_AFFILIATE_ID }}';" >> lib/.secrets.g.dart
|
||||
echo "const sideShiftApiKey = '${{ secrets.SIDE_SHIFT_API_KEY }}';" >> lib/.secrets.g.dart
|
||||
echo "const simpleSwapApiKey = '${{ secrets.SIMPLE_SWAP_API_KEY }}';" >> lib/.secrets.g.dart
|
||||
echo "const simpleSwapApiKeyDesktop = '${{ secrets.SIMPLE_SWAP_API_KEY_DESKTOP }}';" >> lib/.secrets.g.dart
|
||||
echo "const onramperApiKey = '${{ secrets.ONRAMPER_API_KEY }}';" >> lib/.secrets.g.dart
|
||||
|
|
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
|
@ -40,6 +40,7 @@ import 'package:cake_wallet/utils/payment_request.dart';
|
|||
import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/anon_invoice_page_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/anonpay_details_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/market_place_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_auth_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_buy_card_view_model.dart';
|
||||
|
@ -876,6 +877,8 @@ Future setup({
|
|||
|
||||
getIt.registerFactory(() => IoniaGiftCardsListViewModel(ioniaService: getIt.get<IoniaService>()));
|
||||
|
||||
getIt.registerFactory(()=> MarketPlaceViewModel(getIt.get<IoniaService>()));
|
||||
|
||||
getIt.registerFactory(() => IoniaAuthViewModel(ioniaService: getIt.get<IoniaService>()));
|
||||
|
||||
getIt.registerFactoryParam<IoniaMerchPurchaseViewModel, double, IoniaMerchant>(
|
||||
|
@ -905,7 +908,7 @@ Future setup({
|
|||
return IoniaVerifyIoniaOtp(getIt.get<IoniaAuthViewModel>(), email, isSignIn);
|
||||
});
|
||||
|
||||
getIt.registerFactory(() => IoniaWelcomePage(getIt.get<IoniaGiftCardsListViewModel>()));
|
||||
getIt.registerFactory(() => IoniaWelcomePage());
|
||||
|
||||
getIt.registerFactoryParam<IoniaBuyGiftCardPage, List, void>((List args, _) {
|
||||
final merchant = args.first as IoniaMerchant;
|
||||
|
|
|
@ -55,11 +55,11 @@ class LanguageService {
|
|||
'cs': 'czk',
|
||||
'ur': 'pak',
|
||||
'id': 'idn',
|
||||
'yo': 'yor',
|
||||
'yo': 'nga',
|
||||
'ha': 'hau'
|
||||
};
|
||||
|
||||
static final list = <String, String> {};
|
||||
static final list = <String, String>{};
|
||||
|
||||
static void loadLocaleList() {
|
||||
supportedLocales.forEach((key, value) {
|
||||
|
|
|
@ -19,10 +19,10 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
|
||||
static const affiliateId = secrets.sideShiftAffiliateId;
|
||||
static const apiBaseUrl = 'https://sideshift.ai/api';
|
||||
static const rangePath = '/v1/pairs';
|
||||
static const orderPath = '/v1/orders';
|
||||
static const quotePath = '/v1/quotes';
|
||||
static const permissionPath = '/v1/permissions';
|
||||
static const rangePath = '/v2/pair';
|
||||
static const orderPath = '/v2/shifts';
|
||||
static const quotePath = '/v2/quotes';
|
||||
static const permissionPath = '/v2/permissions';
|
||||
|
||||
static const List<CryptoCurrency> _notSupported = [
|
||||
CryptoCurrency.xhv,
|
||||
|
@ -36,23 +36,22 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
CryptoCurrency.scrt,
|
||||
CryptoCurrency.stx,
|
||||
CryptoCurrency.bttc,
|
||||
CryptoCurrency.usdt,
|
||||
CryptoCurrency.eos,
|
||||
];
|
||||
|
||||
static List<ExchangePair> _supportedPairs() {
|
||||
final supportedCurrencies = CryptoCurrency.all
|
||||
.where((element) => !_notSupported.contains(element))
|
||||
.toList();
|
||||
final supportedCurrencies =
|
||||
CryptoCurrency.all.where((element) => !_notSupported.contains(element)).toList();
|
||||
|
||||
return supportedCurrencies
|
||||
.map((i) => supportedCurrencies
|
||||
.map((k) => ExchangePair(from: i, to: k, reverse: true)))
|
||||
.map((i) => supportedCurrencies.map((k) => ExchangePair(from: i, to: k, reverse: true)))
|
||||
.expand((i) => i)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
ExchangeProviderDescription get description =>
|
||||
ExchangeProviderDescription.sideShift;
|
||||
ExchangeProviderDescription get description => ExchangeProviderDescription.sideShift;
|
||||
|
||||
@override
|
||||
Future<double> fetchRate(
|
||||
|
@ -65,17 +64,18 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
if (amount == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
final fromCurrency = _normalizeCryptoCurrency(from);
|
||||
final toCurrency = _normalizeCryptoCurrency(to);
|
||||
final url =
|
||||
apiBaseUrl + rangePath + '/' + fromCurrency + '/' + toCurrency;
|
||||
|
||||
final fromCurrency = from.title.toLowerCase();
|
||||
final toCurrency = to.title.toLowerCase();
|
||||
final depositNetwork = _networkFor(from);
|
||||
final settleNetwork = _networkFor(to);
|
||||
|
||||
final url = "$apiBaseUrl$rangePath/$fromCurrency-$depositNetwork/$toCurrency-$settleNetwork";
|
||||
|
||||
final uri = Uri.parse(url);
|
||||
final response = await get(uri);
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final rate = double.parse(responseJSON['rate'] as String);
|
||||
final max = double.parse(responseJSON['max'] as String);
|
||||
|
||||
if (amount > max) return 0.00;
|
||||
|
||||
return rate;
|
||||
} catch (_) {
|
||||
|
@ -101,25 +101,38 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final canCreateOrder = responseJSON['createOrder'] as bool;
|
||||
final canCreateQuote = responseJSON['createQuote'] as bool;
|
||||
return canCreateOrder && canCreateQuote;
|
||||
final cancreateShift = responseJSON['createShift'] as bool;
|
||||
return cancreateShift;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Trade> createTrade(
|
||||
{required TradeRequest request, required bool isFixedRateMode}) async {
|
||||
Future<Trade> createTrade({required TradeRequest request, required bool isFixedRateMode}) async {
|
||||
final _request = request as SideShiftRequest;
|
||||
final quoteId = await _createQuote(_request);
|
||||
final url = apiBaseUrl + orderPath;
|
||||
final headers = {'Content-Type': 'application/json'};
|
||||
String url = '';
|
||||
final depositCoin = request.depositMethod.title.toLowerCase();
|
||||
final settleCoin = request.settleMethod.title.toLowerCase();
|
||||
final body = {
|
||||
'type': 'fixed',
|
||||
'quoteId': quoteId,
|
||||
'affiliateId': affiliateId,
|
||||
'settleAddress': _request.settleAddress,
|
||||
'refundAddress': _request.refundAddress
|
||||
'refundAddress': _request.refundAddress,
|
||||
};
|
||||
|
||||
if (isFixedRateMode) {
|
||||
final quoteId = await _createQuote(_request);
|
||||
body['quoteId'] = quoteId;
|
||||
|
||||
url = apiBaseUrl + orderPath + '/fixed';
|
||||
} else {
|
||||
url = apiBaseUrl + orderPath + '/variable';
|
||||
final depositNetwork = _networkFor(request.depositMethod);
|
||||
final settleNetwork = _networkFor(request.settleMethod);
|
||||
body["depositCoin"] = depositCoin;
|
||||
body["settleCoin"] = settleCoin;
|
||||
body["settleNetwork"] = settleNetwork;
|
||||
body["depositNetwork"] = depositNetwork;
|
||||
}
|
||||
final headers = {'Content-Type': 'application/json'};
|
||||
|
||||
final uri = Uri.parse(url);
|
||||
final response = await post(uri, headers: headers, body: json.encode(body));
|
||||
|
||||
|
@ -136,8 +149,9 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final id = responseJSON['id'] as String;
|
||||
final inputAddress = responseJSON['depositAddress']['address'] as String;
|
||||
final settleAddress = responseJSON['settleAddress']['address'] as String;
|
||||
final inputAddress = responseJSON['depositAddress'] as String;
|
||||
final settleAddress = responseJSON['settleAddress'] as String;
|
||||
final depositAmount = responseJSON['depositAmount'] as String?;
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
|
@ -147,7 +161,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
inputAddress: inputAddress,
|
||||
refundAddress: settleAddress,
|
||||
state: TradeState.created,
|
||||
amount: _request.depositAmount,
|
||||
amount: depositAmount ?? _request.depositAmount,
|
||||
payoutAddress: settleAddress,
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
|
@ -156,13 +170,17 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
Future<String> _createQuote(SideShiftRequest request) async {
|
||||
final url = apiBaseUrl + quotePath;
|
||||
final headers = {'Content-Type': 'application/json'};
|
||||
final depositMethod = _normalizeCryptoCurrency(request.depositMethod);
|
||||
final settleMethod = _normalizeCryptoCurrency(request.settleMethod);
|
||||
final depositMethod = request.depositMethod.title.toLowerCase();
|
||||
final settleMethod = request.settleMethod.title.toLowerCase();
|
||||
final depositNetwork = _networkFor(request.depositMethod);
|
||||
final settleNetwork = _networkFor(request.settleMethod);
|
||||
final body = {
|
||||
'depositMethod': depositMethod,
|
||||
'settleMethod': settleMethod,
|
||||
'depositCoin': depositMethod,
|
||||
'settleCoin': settleMethod,
|
||||
'affiliateId': affiliateId,
|
||||
'depositAmount': request.depositAmount,
|
||||
'settleAmount': request.depositAmount,
|
||||
'settleNetwork': settleNetwork,
|
||||
'depositNetwork': depositNetwork,
|
||||
};
|
||||
final uri = Uri.parse(url);
|
||||
final response = await post(uri, headers: headers, body: json.encode(body));
|
||||
|
@ -189,9 +207,15 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
{required CryptoCurrency from,
|
||||
required CryptoCurrency to,
|
||||
required bool isFixedRateMode}) async {
|
||||
final fromCurrency = _normalizeCryptoCurrency(from);
|
||||
final toCurrency = _normalizeCryptoCurrency(to);
|
||||
final url = apiBaseUrl + rangePath + '/' + fromCurrency + '/' + toCurrency;
|
||||
final fromCurrency = isFixedRateMode ? to : from;
|
||||
final toCurrency = isFixedRateMode ? from : to;
|
||||
|
||||
final fromNetwork = _networkFor(fromCurrency);
|
||||
final toNetwork = _networkFor(toCurrency);
|
||||
|
||||
final url =
|
||||
"$apiBaseUrl$rangePath/${fromCurrency.title.toLowerCase()}-$fromNetwork/${toCurrency.title.toLowerCase()}-$toNetwork";
|
||||
|
||||
final uri = Uri.parse(url);
|
||||
final response = await get(uri);
|
||||
|
||||
|
@ -210,6 +234,14 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
final min = double.tryParse(responseJSON['min'] as String? ?? '');
|
||||
final max = double.tryParse(responseJSON['max'] as String? ?? '');
|
||||
|
||||
if (isFixedRateMode) {
|
||||
final currentRate = double.parse(responseJSON['rate'] as String);
|
||||
return Limits(
|
||||
min: min != null ? (min * currentRate) : null,
|
||||
max: max != null ? (max * currentRate) : null,
|
||||
);
|
||||
}
|
||||
|
||||
return Limits(min: min, max: max);
|
||||
}
|
||||
|
||||
|
@ -227,8 +259,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final error = responseJSON['error']['message'] as String;
|
||||
|
||||
throw TradeNotFoundException(id,
|
||||
provider: description, description: error);
|
||||
throw TradeNotFoundException(id, provider: description, description: error);
|
||||
}
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
|
@ -236,36 +267,32 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final fromCurrency = responseJSON['depositMethodId'] as String;
|
||||
final fromCurrency = responseJSON['depositCoin'] as String;
|
||||
final from = CryptoCurrency.fromString(fromCurrency);
|
||||
final toCurrency = responseJSON['settleMethodId'] as String;
|
||||
final toCurrency = responseJSON['settleCoin'] as String;
|
||||
final to = CryptoCurrency.fromString(toCurrency);
|
||||
final inputAddress = responseJSON['depositAddress']['address'] as String;
|
||||
final expectedSendAmount = responseJSON['depositAmount'].toString();
|
||||
final deposits = responseJSON['deposits'] as List?;
|
||||
final settleAddress = responseJSON['settleAddress']['address'] as String;
|
||||
final inputAddress = responseJSON['depositAddress'] as String;
|
||||
final expectedSendAmount = responseJSON['depositAmount'] as String?;
|
||||
final status = responseJSON['status'] as String?;
|
||||
final settleAddress = responseJSON['settleAddress'] as String;
|
||||
TradeState? state;
|
||||
String? status;
|
||||
|
||||
if (deposits?.isNotEmpty ?? false) {
|
||||
status = deposits![0]['status'] as String?;
|
||||
}
|
||||
state = TradeState.deserialize(raw: status ?? 'created');
|
||||
final isVariable = (responseJSON['type'] as String) == 'variable';
|
||||
|
||||
final expiredAtRaw = responseJSON['expiresAtISO'] as String;
|
||||
final expiredAt = DateTime.tryParse(expiredAtRaw)?.toLocal();
|
||||
final expiredAtRaw = responseJSON['expiresAt'] as String;
|
||||
final expiredAt = isVariable ? null : DateTime.tryParse(expiredAtRaw)?.toLocal();
|
||||
|
||||
return Trade(
|
||||
id: id,
|
||||
from: from,
|
||||
to: to,
|
||||
provider: description,
|
||||
inputAddress: inputAddress,
|
||||
amount: expectedSendAmount,
|
||||
state: state,
|
||||
expiredAt: expiredAt,
|
||||
payoutAddress: settleAddress
|
||||
);
|
||||
id: id,
|
||||
from: from,
|
||||
to: to,
|
||||
provider: description,
|
||||
inputAddress: inputAddress,
|
||||
amount: expectedSendAmount ?? '',
|
||||
state: state,
|
||||
expiredAt: expiredAt,
|
||||
payoutAddress: settleAddress);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -280,28 +307,25 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
|||
@override
|
||||
String get title => 'SideShift';
|
||||
|
||||
static String _normalizeCryptoCurrency(CryptoCurrency currency) {
|
||||
switch (currency) {
|
||||
case CryptoCurrency.zaddr:
|
||||
return 'zaddr';
|
||||
case CryptoCurrency.zec:
|
||||
return 'zec';
|
||||
case CryptoCurrency.bnb:
|
||||
return currency.tag!.toLowerCase();
|
||||
case CryptoCurrency.usdterc20:
|
||||
return 'usdtErc20';
|
||||
case CryptoCurrency.usdttrc20:
|
||||
return 'usdtTrc20';
|
||||
case CryptoCurrency.usdcpoly:
|
||||
return 'usdcpolygon';
|
||||
case CryptoCurrency.usdcsol:
|
||||
return 'usdcsol';
|
||||
case CryptoCurrency.maticpoly:
|
||||
String _networkFor(CryptoCurrency currency) =>
|
||||
currency.tag != null ? _normalizeTag(currency.tag!) : 'mainnet';
|
||||
|
||||
String _normalizeTag(String tag) {
|
||||
switch (tag) {
|
||||
case 'ETH':
|
||||
return 'ethereum';
|
||||
case 'TRX':
|
||||
return 'tron';
|
||||
case 'LN':
|
||||
return 'lightning';
|
||||
case 'POLY':
|
||||
return 'polygon';
|
||||
case CryptoCurrency.btcln:
|
||||
return 'ln';
|
||||
case 'ZEC':
|
||||
return 'zcash';
|
||||
case 'AVAXC':
|
||||
return 'avax';
|
||||
default:
|
||||
return currency.title.toLowerCase();
|
||||
return tag.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/sync_status.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:connectivity/connectivity.dart';
|
||||
|
||||
Timer? _checkConnectionTimer;
|
||||
|
||||
void startCheckConnectionReaction(
|
||||
|
|
|
@ -175,7 +175,6 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
fullscreenDialog: true);
|
||||
} else if (isSingleCoin) {
|
||||
return MaterialPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => getIt.get<WalletRestorePage>(
|
||||
param1: availableWalletTypes.first
|
||||
));
|
||||
|
@ -196,7 +195,6 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
|
||||
case Routes.restoreWallet:
|
||||
return MaterialPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => getIt.get<WalletRestorePage>(
|
||||
param1: settings.arguments as WalletType));
|
||||
|
||||
|
@ -206,6 +204,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
|
||||
case Routes.dashboard:
|
||||
return CupertinoPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => getIt.get<DashboardPage>());
|
||||
|
||||
case Routes.send:
|
||||
|
@ -468,7 +467,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
return CupertinoPageRoute<void>( builder: (_) => getIt.get<IoniaCreateAccountPage>());
|
||||
|
||||
case Routes.ioniaManageCardsPage:
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaManageCardsPage>());
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) => getIt.get<IoniaManageCardsPage>());
|
||||
|
||||
case Routes.ioniaBuyGiftCardPage:
|
||||
final args = settings.arguments as List;
|
||||
|
@ -536,7 +536,6 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
case Routes.anonPayInvoicePage:
|
||||
final args = settings.arguments as List;
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => getIt.get<AnonPayInvoicePage>(param1: args));
|
||||
|
||||
case Routes.anonPayReceivePage:
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:cake_wallet/entities/main_actions.dart';
|
|||
import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/market_place_page.dart';
|
||||
import 'package:cake_wallet/utils/version_comparator.dart';
|
||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/market_place_view_model.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/yat_emoji_id.dart';
|
||||
|
@ -27,8 +27,6 @@ import 'package:mobx/mobx.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:cake_wallet/src/screens/release_notes/release_notes_screen.dart';
|
||||
|
||||
class DashboardPage extends StatelessWidget {
|
||||
|
@ -251,7 +249,12 @@ class _DashboardPageView extends BasePage {
|
|||
if (dashboardViewModel.shouldShowMarketPlaceInDashboard) {
|
||||
pages.add(Semantics(
|
||||
label: 'Marketplace Page',
|
||||
child: MarketPlacePage(dashboardViewModel: dashboardViewModel)));
|
||||
child: MarketPlacePage(
|
||||
dashboardViewModel: dashboardViewModel,
|
||||
marketPlaceViewModel: getIt.get<MarketPlaceViewModel>(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
pages.add(Semantics(label: 'Balance Page', child: balancePage));
|
||||
pages.add(Semantics(
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/entities/main_actions.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_action_button.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/market_place_page.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/market_place_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
|
@ -70,7 +72,10 @@ class DesktopDashboardActions extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
Expanded(
|
||||
child: MarketPlacePage(dashboardViewModel: dashboardViewModel),
|
||||
child: MarketPlacePage(
|
||||
dashboardViewModel: dashboardViewModel,
|
||||
marketPlaceViewModel: getIt.get<MarketPlaceViewModel>(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -273,7 +273,7 @@ class AddressPage extends BasePage {
|
|||
reaction((_) => receiveOptionViewModel.selectedReceiveOption, (ReceivePageOption option) {
|
||||
switch (option) {
|
||||
case ReceivePageOption.anonPayInvoice:
|
||||
Navigator.pushReplacementNamed(
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.anonPayInvoicePage,
|
||||
arguments: [addressListViewModel.address.address, option],
|
||||
|
@ -285,7 +285,7 @@ class AddressPage extends BasePage {
|
|||
final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink);
|
||||
|
||||
if (clearnetUrl != null && onionUrl != null) {
|
||||
Navigator.pushReplacementNamed(
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.anonPayReceivePage,
|
||||
arguments: AnonpayDonationLinkInfo(
|
||||
|
@ -295,7 +295,7 @@ class AddressPage extends BasePage {
|
|||
),
|
||||
);
|
||||
} else {
|
||||
Navigator.pushReplacementNamed(
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.anonPayInvoicePage,
|
||||
arguments: [addressListViewModel.address.address, option],
|
||||
|
|
|
@ -3,16 +3,20 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
|||
import 'package:cake_wallet/src/widgets/market_place_item.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/market_place_view_model.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class MarketPlacePage extends StatelessWidget {
|
||||
|
||||
MarketPlacePage({required this.dashboardViewModel});
|
||||
MarketPlacePage({
|
||||
required this.dashboardViewModel,
|
||||
required this.marketPlaceViewModel,
|
||||
});
|
||||
|
||||
final DashboardViewModel dashboardViewModel;
|
||||
final MarketPlaceViewModel marketPlaceViewModel;
|
||||
final _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
|
@ -48,7 +52,7 @@ class MarketPlacePage extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
MarketPlaceItem(
|
||||
onTap: () =>_navigatorToGiftCardsPage(context),
|
||||
onTap: () => _navigatorToGiftCardsPage(context),
|
||||
title: S.of(context).cake_pay_title,
|
||||
subTitle: S.of(context).cake_pay_subtitle,
|
||||
),
|
||||
|
@ -70,12 +74,13 @@ class MarketPlacePage extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _navigatorToGiftCardsPage(BuildContext context) {
|
||||
final walletType = dashboardViewModel.type;
|
||||
|
||||
switch (walletType) {
|
||||
case WalletType.haven:
|
||||
showPopUp<void>(
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
|
@ -85,9 +90,14 @@ class MarketPlacePage extends StatelessWidget {
|
|||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
break;
|
||||
default:
|
||||
Navigator.of(context).pushNamed(Routes.ioniaWelcomePage);
|
||||
default:
|
||||
marketPlaceViewModel.isIoniaUserAuthenticated().then((value) {
|
||||
if (value) {
|
||||
Navigator.pushNamed(context, Routes.ioniaManageCardsPage);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pushNamed(Routes.ioniaWelcomePage);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,107 +25,126 @@ class TransactionsPage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: ResponsiveLayoutUtil.instance.isMobile(context)
|
||||
? null
|
||||
: Theme.of(context).colorScheme.background,
|
||||
padding: EdgeInsets.only(top: 24, bottom: 24),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
HeaderRow(dashboardViewModel: dashboardViewModel),
|
||||
Expanded(child: Observer(builder: (_) {
|
||||
final items = dashboardViewModel.items;
|
||||
return GestureDetector(
|
||||
onLongPress: () => dashboardViewModel.balanceViewModel.isReversing =
|
||||
!dashboardViewModel.balanceViewModel.isReversing,
|
||||
onLongPressUp: () => dashboardViewModel.balanceViewModel.isReversing =
|
||||
!dashboardViewModel.balanceViewModel.isReversing,
|
||||
child: Container(
|
||||
color: ResponsiveLayoutUtil.instance.isMobile(context)
|
||||
? null
|
||||
: Theme.of(context).colorScheme.background,
|
||||
padding: EdgeInsets.only(top: 24, bottom: 24),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
HeaderRow(dashboardViewModel: dashboardViewModel),
|
||||
Expanded(child: Observer(builder: (_) {
|
||||
final items = dashboardViewModel.items;
|
||||
|
||||
return items.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
return items.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
|
||||
if (item is DateSectionItem) {
|
||||
return DateSectionRaw(date: item.date);
|
||||
}
|
||||
if (item is DateSectionItem) {
|
||||
return DateSectionRaw(date: item.date);
|
||||
}
|
||||
|
||||
if (item is TransactionListItem) {
|
||||
final transaction = item.transaction;
|
||||
if (item is TransactionListItem) {
|
||||
final transaction = item.transaction;
|
||||
|
||||
return Observer(
|
||||
builder: (_) => TransactionRow(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.transactionDetails, arguments: transaction),
|
||||
direction: transaction.direction,
|
||||
formattedDate: DateFormat('HH:mm').format(transaction.date),
|
||||
formattedAmount: item.formattedCryptoAmount,
|
||||
formattedFiatAmount:
|
||||
dashboardViewModel.balanceViewModel.isFiatDisabled
|
||||
? ''
|
||||
: item.formattedFiatAmount,
|
||||
isPending: transaction.isPending,
|
||||
title: item.formattedTitle + item.formattedStatus));
|
||||
}
|
||||
return Observer(
|
||||
builder: (_) => TransactionRow(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.transactionDetails,
|
||||
arguments: transaction),
|
||||
direction: transaction.direction,
|
||||
formattedDate: DateFormat('HH:mm')
|
||||
.format(transaction.date),
|
||||
formattedAmount: item.formattedCryptoAmount,
|
||||
formattedFiatAmount: dashboardViewModel
|
||||
.balanceViewModel.isFiatDisabled
|
||||
? ''
|
||||
: item.formattedFiatAmount,
|
||||
isPending: transaction.isPending,
|
||||
title: item.formattedTitle +
|
||||
item.formattedStatus));
|
||||
}
|
||||
|
||||
if (item is AnonpayTransactionListItem) {
|
||||
final transactionInfo = item.transaction;
|
||||
if (item is AnonpayTransactionListItem) {
|
||||
final transactionInfo = item.transaction;
|
||||
|
||||
return AnonpayTransactionRow(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.anonPayDetailsPage, arguments: transactionInfo),
|
||||
currency: transactionInfo.fiatAmount != null
|
||||
? transactionInfo.fiatEquiv ?? ''
|
||||
: CryptoCurrency.fromFullName(transactionInfo.coinTo)
|
||||
.name
|
||||
.toUpperCase(),
|
||||
provider: transactionInfo.provider,
|
||||
amount: transactionInfo.fiatAmount?.toString() ??
|
||||
(transactionInfo.amountTo?.toString() ?? ''),
|
||||
createdAt: DateFormat('HH:mm').format(transactionInfo.createdAt),
|
||||
);
|
||||
}
|
||||
return AnonpayTransactionRow(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.anonPayDetailsPage,
|
||||
arguments: transactionInfo),
|
||||
currency: transactionInfo.fiatAmount != null
|
||||
? transactionInfo.fiatEquiv ?? ''
|
||||
: CryptoCurrency.fromFullName(
|
||||
transactionInfo.coinTo)
|
||||
.name
|
||||
.toUpperCase(),
|
||||
provider: transactionInfo.provider,
|
||||
amount: transactionInfo.fiatAmount?.toString() ??
|
||||
(transactionInfo.amountTo?.toString() ?? ''),
|
||||
createdAt: DateFormat('HH:mm')
|
||||
.format(transactionInfo.createdAt),
|
||||
);
|
||||
}
|
||||
|
||||
if (item is TradeListItem) {
|
||||
final trade = item.trade;
|
||||
if (item is TradeListItem) {
|
||||
final trade = item.trade;
|
||||
|
||||
return Observer(
|
||||
builder: (_) => TradeRow(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.tradeDetails, arguments: trade),
|
||||
provider: trade.provider,
|
||||
from: trade.from,
|
||||
to: trade.to,
|
||||
createdAtFormattedDate: trade.createdAt != null
|
||||
? DateFormat('HH:mm').format(trade.createdAt!)
|
||||
: null,
|
||||
formattedAmount: item.tradeFormattedAmount));
|
||||
}
|
||||
|
||||
if (item is OrderListItem) {
|
||||
final order = item.order;
|
||||
|
||||
return Observer(
|
||||
builder: (_) => OrderRow(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.orderDetails, arguments: order),
|
||||
provider: order.provider,
|
||||
from: order.from!,
|
||||
to: order.to!,
|
||||
return Observer(
|
||||
builder: (_) => TradeRow(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.tradeDetails,
|
||||
arguments: trade),
|
||||
provider: trade.provider,
|
||||
from: trade.from,
|
||||
to: trade.to,
|
||||
createdAtFormattedDate:
|
||||
DateFormat('HH:mm').format(order.createdAt),
|
||||
formattedAmount: item.orderFormattedAmount,
|
||||
));
|
||||
}
|
||||
trade.createdAt != null
|
||||
? DateFormat('HH:mm')
|
||||
.format(trade.createdAt!)
|
||||
: null,
|
||||
formattedAmount: item.tradeFormattedAmount));
|
||||
}
|
||||
|
||||
return Container(color: Colors.transparent, height: 1);
|
||||
})
|
||||
: Center(
|
||||
child: Text(
|
||||
S.of(context).placeholder_transactions,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).primaryTextTheme!.labelSmall!.decorationColor!),
|
||||
),
|
||||
);
|
||||
}))
|
||||
],
|
||||
if (item is OrderListItem) {
|
||||
final order = item.order;
|
||||
|
||||
return Observer(
|
||||
builder: (_) => OrderRow(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.orderDetails,
|
||||
arguments: order),
|
||||
provider: order.provider,
|
||||
from: order.from!,
|
||||
to: order.to!,
|
||||
createdAtFormattedDate: DateFormat('HH:mm')
|
||||
.format(order.createdAt),
|
||||
formattedAmount: item.orderFormattedAmount,
|
||||
));
|
||||
}
|
||||
|
||||
return Container(color: Colors.transparent, height: 1);
|
||||
})
|
||||
: Center(
|
||||
child: Text(
|
||||
S.of(context).placeholder_transactions,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.labelSmall!
|
||||
.decorationColor!),
|
||||
),
|
||||
);
|
||||
}))
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,11 @@ import 'package:cake_wallet/routes.dart';
|
|||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/typography.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_gift_cards_list_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
class IoniaWelcomePage extends BasePage {
|
||||
IoniaWelcomePage(this._cardsListViewModel);
|
||||
IoniaWelcomePage();
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) {
|
||||
|
@ -25,15 +22,8 @@ class IoniaWelcomePage extends BasePage {
|
|||
);
|
||||
}
|
||||
|
||||
final IoniaGiftCardsListViewModel _cardsListViewModel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
reaction((_) => _cardsListViewModel.isLoggedIn, (bool state) {
|
||||
if (state) {
|
||||
Navigator.pushReplacementNamed(context, Routes.ioniaManageCardsPage);
|
||||
}
|
||||
});
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
|
@ -41,7 +31,7 @@ class IoniaWelcomePage extends BasePage {
|
|||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 100),
|
||||
SizedBox(height: 90),
|
||||
Text(
|
||||
S.of(context).about_cake_pay,
|
||||
style: TextStyle(
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
|||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
class IoniaManageCardsPage extends BasePage {
|
||||
IoniaManageCardsPage(this._cardsListViewModel) {
|
||||
IoniaManageCardsPage(this._cardsListViewModel): searchFocusNode = FocusNode() {
|
||||
_searchController.addListener(() {
|
||||
if (_searchController.text != _cardsListViewModel.searchString) {
|
||||
_searchDebounce.run(() {
|
||||
|
@ -29,6 +29,7 @@ class IoniaManageCardsPage extends BasePage {
|
|||
_cardsListViewModel.getMerchants();
|
||||
|
||||
}
|
||||
final FocusNode searchFocusNode;
|
||||
final IoniaGiftCardsListViewModel _cardsListViewModel;
|
||||
|
||||
final _searchDebounce = Debounce(Duration(milliseconds: 500));
|
||||
|
@ -86,7 +87,14 @@ class IoniaManageCardsPage extends BasePage {
|
|||
//highlightColor: Colors.transparent,
|
||||
//splashColor: Colors.transparent,
|
||||
//padding: EdgeInsets.all(0),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: (){
|
||||
if (searchFocusNode.hasFocus) {
|
||||
searchFocusNode.unfocus();
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: _backButton),
|
||||
),
|
||||
);
|
||||
|
@ -149,6 +157,7 @@ class IoniaManageCardsPage extends BasePage {
|
|||
Expanded(
|
||||
child: _SearchWidget(
|
||||
controller: _searchController,
|
||||
focusNode: searchFocusNode,
|
||||
)),
|
||||
SizedBox(width: 10),
|
||||
filterButton
|
||||
|
@ -266,9 +275,10 @@ class _SearchWidget extends StatelessWidget {
|
|||
const _SearchWidget({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
required this.focusNode,
|
||||
}) : super(key: key);
|
||||
final TextEditingController controller;
|
||||
|
||||
final FocusNode focusNode;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final searchIcon = Padding(
|
||||
|
@ -280,6 +290,7 @@ class _SearchWidget extends StatelessWidget {
|
|||
);
|
||||
|
||||
return TextField(
|
||||
focusNode: focusNode,
|
||||
style: TextStyle(color: Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!),
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
|
|
|
@ -27,8 +27,7 @@ class AnonPayInvoicePage extends BasePage {
|
|||
AnonPayInvoicePage(
|
||||
this.anonInvoicePageViewModel,
|
||||
this.receiveOptionViewModel,
|
||||
) : _amountFocusNode = FocusNode() {
|
||||
}
|
||||
) : _amountFocusNode = FocusNode() {}
|
||||
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
|
@ -53,6 +52,11 @@ class AnonPayInvoicePage extends BasePage {
|
|||
@override
|
||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||
|
||||
@override
|
||||
void onClose(BuildContext context) {
|
||||
Navigator.popUntil(context, ModalRoute.withName(Routes.dashboard));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) =>
|
||||
PresentReceiveOptionPicker(receiveOptionViewModel: receiveOptionViewModel);
|
||||
|
@ -65,114 +69,125 @@ class AnonPayInvoicePage extends BasePage {
|
|||
anonInvoicePageViewModel.reset();
|
||||
});
|
||||
|
||||
Future<bool> _onNavigateBack(BuildContext context) async {
|
||||
onClose(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _setReactions(context));
|
||||
|
||||
return KeyboardActions(
|
||||
disableScroll: true,
|
||||
config: KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||
keyboardBarColor: Theme.of(context)
|
||||
return WillPopScope(
|
||||
onWillPop: () => _onNavigateBack(context),
|
||||
child: KeyboardActions(
|
||||
disableScroll: true,
|
||||
config: KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||
keyboardBarColor: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.bodyLarge!
|
||||
.backgroundColor!,
|
||||
nextFocus: false,
|
||||
actions: [
|
||||
KeyboardActionsItem(
|
||||
focusNode: _amountFocusNode,
|
||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
||||
),
|
||||
]),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Container(
|
||||
decoration: DeviceInfo.instance.isMobile ? BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Theme.of(context).primaryTextTheme!.titleSmall!.color!,
|
||||
Theme.of(context).primaryTextTheme!.titleSmall!.decorationColor!,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
nextFocus: false,
|
||||
actions: [
|
||||
KeyboardActionsItem(
|
||||
focusNode: _amountFocusNode,
|
||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
||||
),
|
||||
) : null,
|
||||
child: Observer(builder: (_) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 120, 24, 0),
|
||||
child: AnonInvoiceForm(
|
||||
nameController: _nameController,
|
||||
descriptionController: _descriptionController,
|
||||
amountController: _amountController,
|
||||
emailController: _emailController,
|
||||
depositAmountFocus: _amountFocusNode,
|
||||
formKey: _formKey,
|
||||
isInvoice: receiveOptionViewModel.selectedReceiveOption ==
|
||||
ReceivePageOption.anonPayInvoice,
|
||||
anonInvoicePageViewModel: anonInvoicePageViewModel,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: Observer(builder: (_) {
|
||||
final isInvoice =
|
||||
receiveOptionViewModel.selectedReceiveOption == ReceivePageOption.anonPayInvoice;
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
isInvoice
|
||||
? S.of(context).anonpay_description("an invoice", "pay")
|
||||
: S.of(context).anonpay_description("a donation link", "donate"),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
]),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Container(
|
||||
decoration: DeviceInfo.instance.isMobile
|
||||
? BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Theme.of(context).primaryTextTheme!.titleSmall!.color!,
|
||||
Theme.of(context).primaryTextTheme!.titleSmall!.decorationColor!,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
child: Observer(builder: (_) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 120, 24, 0),
|
||||
child: AnonInvoiceForm(
|
||||
nameController: _nameController,
|
||||
descriptionController: _descriptionController,
|
||||
amountController: _amountController,
|
||||
emailController: _emailController,
|
||||
depositAmountFocus: _amountFocusNode,
|
||||
formKey: _formKey,
|
||||
isInvoice: receiveOptionViewModel.selectedReceiveOption ==
|
||||
ReceivePageOption.anonPayInvoice,
|
||||
anonInvoicePageViewModel: anonInvoicePageViewModel,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: Observer(builder: (_) {
|
||||
final isInvoice =
|
||||
receiveOptionViewModel.selectedReceiveOption == ReceivePageOption.anonPayInvoice;
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
isInvoice
|
||||
? S.of(context).anonpay_description("an invoice", "pay")
|
||||
: S.of(context).anonpay_description("a donation link", "donate"),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme!
|
||||
.displayLarge!
|
||||
.decorationColor!,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
LoadingPrimaryButton(
|
||||
text:
|
||||
isInvoice ? S.of(context).create_invoice : S.of(context).create_donation_link,
|
||||
onPressed: () {
|
||||
anonInvoicePageViewModel.setRequestParams(
|
||||
inputAmount: _amountController.text,
|
||||
inputName: _nameController.text,
|
||||
inputEmail: _emailController.text,
|
||||
inputDescription: _descriptionController.text,
|
||||
);
|
||||
if (anonInvoicePageViewModel.receipientEmail.isNotEmpty &&
|
||||
_formKey.currentState != null &&
|
||||
!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
if (isInvoice) {
|
||||
anonInvoicePageViewModel.createInvoice();
|
||||
} else {
|
||||
anonInvoicePageViewModel.generateDonationLink();
|
||||
}
|
||||
},
|
||||
color: Theme.of(context)
|
||||
LoadingPrimaryButton(
|
||||
text: isInvoice
|
||||
? S.of(context).create_invoice
|
||||
: S.of(context).create_donation_link,
|
||||
onPressed: () {
|
||||
anonInvoicePageViewModel.setRequestParams(
|
||||
inputAmount: _amountController.text,
|
||||
inputName: _nameController.text,
|
||||
inputEmail: _emailController.text,
|
||||
inputDescription: _descriptionController.text,
|
||||
);
|
||||
if (anonInvoicePageViewModel.receipientEmail.isNotEmpty &&
|
||||
_formKey.currentState != null &&
|
||||
!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
if (isInvoice) {
|
||||
anonInvoicePageViewModel.createInvoice();
|
||||
} else {
|
||||
anonInvoicePageViewModel.generateDonationLink();
|
||||
}
|
||||
},
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.bodyLarge!
|
||||
.color!,
|
||||
textColor: Colors.white,
|
||||
isLoading: anonInvoicePageViewModel.state is IsExecutingState,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
textColor: Colors.white,
|
||||
isLoading: anonInvoicePageViewModel.state is IsExecutingState,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -266,6 +266,8 @@ class WalletRestorePage extends BasePage {
|
|||
}
|
||||
|
||||
void _confirmForm() {
|
||||
// Dismissing all visible keyboard to provide context for navigation
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
final formContext = walletRestoreViewModel.mode == WalletRestoreMode.seed
|
||||
? walletRestoreFromSeedFormKey.currentContext
|
||||
: walletRestoreFromKeysFormKey.currentContext;
|
||||
|
|
|
@ -145,216 +145,247 @@ class SendPage extends BasePage {
|
|||
Widget body(BuildContext context) {
|
||||
_setEffects(context);
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: FocusTraversalGroup(
|
||||
policy: OrderedTraversalPolicy(),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: _sendCardHeight(context),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
return PageView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: controller,
|
||||
itemCount: sendViewModel.outputs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final output = sendViewModel.outputs[index];
|
||||
|
||||
return SendCard(
|
||||
key: output.key,
|
||||
output: output,
|
||||
sendViewModel: sendViewModel,
|
||||
initialPaymentRequest: initialPaymentRequest,
|
||||
);
|
||||
});
|
||||
},
|
||||
)),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10),
|
||||
child: Container(
|
||||
height: 10,
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final count = sendViewModel.outputs.length;
|
||||
|
||||
return count > 1
|
||||
? SmoothPageIndicator(
|
||||
controller: controller,
|
||||
count: count,
|
||||
effect: ScrollingDotsEffect(
|
||||
spacing: 6.0,
|
||||
radius: 6.0,
|
||||
dotWidth: 6.0,
|
||||
dotHeight: 6.0,
|
||||
dotColor: Theme.of(context)
|
||||
.primaryTextTheme!.displaySmall!
|
||||
.backgroundColor!,
|
||||
activeDotColor: Theme.of(context)
|
||||
.primaryTextTheme!.displayMedium!
|
||||
.backgroundColor!),
|
||||
)
|
||||
: Offstage();
|
||||
},
|
||||
return GestureDetector(
|
||||
onLongPress: () => sendViewModel.balanceViewModel.isReversing =
|
||||
!sendViewModel.balanceViewModel.isReversing,
|
||||
onLongPressUp: () => sendViewModel.balanceViewModel.isReversing =
|
||||
!sendViewModel.balanceViewModel.isReversing,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: FocusTraversalGroup(
|
||||
policy: OrderedTraversalPolicy(),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: _sendCardHeight(context),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
return PageView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: controller,
|
||||
itemCount: sendViewModel.outputs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final output = sendViewModel.outputs[index];
|
||||
|
||||
return SendCard(
|
||||
key: output.key,
|
||||
output: output,
|
||||
sendViewModel: sendViewModel,
|
||||
initialPaymentRequest: initialPaymentRequest,
|
||||
);
|
||||
});
|
||||
},
|
||||
)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10, left: 24, right: 24, bottom: 10),
|
||||
child: Container(
|
||||
height: 10,
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final count = sendViewModel.outputs.length;
|
||||
|
||||
return count > 1
|
||||
? SmoothPageIndicator(
|
||||
controller: controller,
|
||||
count: count,
|
||||
effect: ScrollingDotsEffect(
|
||||
spacing: 6.0,
|
||||
radius: 6.0,
|
||||
dotWidth: 6.0,
|
||||
dotHeight: 6.0,
|
||||
dotColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
!.displaySmall!
|
||||
.backgroundColor!,
|
||||
activeDotColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
!.displayMedium!
|
||||
.backgroundColor!),
|
||||
)
|
||||
: Offstage();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (sendViewModel.hasMultiRecipient)
|
||||
Container(
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final templates = sendViewModel.templates;
|
||||
final itemCount = templates.length;
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
AddTemplateButton(
|
||||
onTap: () => Navigator.of(context).pushNamed(Routes.sendTemplate),
|
||||
currentTemplatesLength: templates.length,
|
||||
),
|
||||
ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
final template = templates[index];
|
||||
return TemplateTile(
|
||||
key: UniqueKey(),
|
||||
to: template.name,
|
||||
amount: template.isCurrencySelected ? template.amount : template.amountFiat,
|
||||
from: template.isCurrencySelected ? template.cryptoCurrency : template.fiatCurrency,
|
||||
onTap: () async {
|
||||
final fiatFromTemplate = FiatCurrency.all.singleWhere((element) => element.title == template.fiatCurrency);
|
||||
final output = _defineCurrentOutput();
|
||||
output.address = template.address;
|
||||
if(template.isCurrencySelected){
|
||||
output.setCryptoAmount(template.amount);
|
||||
}else{
|
||||
sendViewModel.setFiatCurrency(fiatFromTemplate);
|
||||
output.setFiatAmount(template.amountFiat);
|
||||
}
|
||||
output.resetParsedAddress();
|
||||
await output.fetchParsedAddress(context);
|
||||
},
|
||||
onRemove: () {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).template,
|
||||
alertContent: S
|
||||
.of(context)
|
||||
.confirm_delete_template,
|
||||
rightButtonText: S.of(context).delete,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
sendViewModel.sendTemplateViewModel
|
||||
.removeTemplate(
|
||||
template: template);
|
||||
},
|
||||
actionLeftButton: () =>
|
||||
Navigator.of(dialogContext)
|
||||
.pop());
|
||||
if (sendViewModel.hasMultiRecipient)
|
||||
Container(
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final templates = sendViewModel.templates;
|
||||
final itemCount = templates.length;
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
AddTemplateButton(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.sendTemplate),
|
||||
currentTemplatesLength: templates.length,
|
||||
),
|
||||
ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
final template = templates[index];
|
||||
return TemplateTile(
|
||||
key: UniqueKey(),
|
||||
to: template.name,
|
||||
amount: template.isCurrencySelected
|
||||
? template.amount
|
||||
: template.amountFiat,
|
||||
from: template.isCurrencySelected
|
||||
? template.cryptoCurrency
|
||||
: template.fiatCurrency,
|
||||
onTap: () async {
|
||||
final fiatFromTemplate = FiatCurrency
|
||||
.all
|
||||
.singleWhere((element) =>
|
||||
element.title ==
|
||||
template.fiatCurrency);
|
||||
final output = _defineCurrentOutput();
|
||||
output.address = template.address;
|
||||
if (template.isCurrencySelected) {
|
||||
output
|
||||
.setCryptoAmount(template.amount);
|
||||
} else {
|
||||
sendViewModel.setFiatCurrency(
|
||||
fiatFromTemplate);
|
||||
output.setFiatAmount(
|
||||
template.amountFiat);
|
||||
}
|
||||
output.resetParsedAddress();
|
||||
await output
|
||||
.fetchParsedAddress(context);
|
||||
},
|
||||
onRemove: () {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle:
|
||||
S.of(context).template,
|
||||
alertContent: S
|
||||
.of(context)
|
||||
.confirm_delete_template,
|
||||
rightButtonText:
|
||||
S.of(context).delete,
|
||||
leftButtonText:
|
||||
S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(dialogContext)
|
||||
.pop();
|
||||
sendViewModel
|
||||
.sendTemplateViewModel
|
||||
.removeTemplate(
|
||||
template: template);
|
||||
},
|
||||
actionLeftButton: () =>
|
||||
Navigator.of(dialogContext)
|
||||
.pop());
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomSectionPadding:
|
||||
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: Column(
|
||||
children: [
|
||||
if (sendViewModel.hasCurrecyChanger)
|
||||
Observer(builder: (_) =>
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => presentCurrencyPicker(context),
|
||||
text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
|
||||
color: Colors.transparent,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme!.displaySmall!
|
||||
.decorationColor!,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
if (sendViewModel.hasMultiRecipient)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {
|
||||
sendViewModel.addOutput();
|
||||
Future.delayed(const Duration(milliseconds: 250), () {
|
||||
controller.jumpToPage(sendViewModel.outputs.length - 1);
|
||||
});
|
||||
},
|
||||
text: S.of(context).add_receiver,
|
||||
color: Colors.transparent,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme!.displaySmall!
|
||||
.decorationColor!,
|
||||
isDottedBorder: true,
|
||||
borderColor: Theme.of(context)
|
||||
.primaryTextTheme!.displaySmall!
|
||||
.decorationColor!,
|
||||
)),
|
||||
Observer(
|
||||
builder: (_) {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
|
||||
if (sendViewModel.outputs.length > 1) {
|
||||
showErrorValidationAlert(context);
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomSectionPadding:
|
||||
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: Column(
|
||||
children: [
|
||||
if (sendViewModel.hasCurrecyChanger)
|
||||
Observer(
|
||||
builder: (_) => Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => presentCurrencyPicker(context),
|
||||
text:
|
||||
'Change your asset (${sendViewModel.selectedCryptoCurrency})',
|
||||
color: Colors.transparent,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
!.displaySmall!
|
||||
.decorationColor!,
|
||||
))),
|
||||
if (sendViewModel.hasMultiRecipient)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {
|
||||
sendViewModel.addOutput();
|
||||
Future.delayed(const Duration(milliseconds: 250), () {
|
||||
controller
|
||||
.jumpToPage(sendViewModel.outputs.length - 1);
|
||||
});
|
||||
},
|
||||
text: S.of(context).add_receiver,
|
||||
color: Colors.transparent,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
!.displaySmall!
|
||||
.decorationColor!,
|
||||
isDottedBorder: true,
|
||||
borderColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
!.displaySmall!
|
||||
.decorationColor!,
|
||||
)),
|
||||
Observer(
|
||||
builder: (_) {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState != null &&
|
||||
!_formKey.currentState!.validate()) {
|
||||
if (sendViewModel.outputs.length > 1) {
|
||||
showErrorValidationAlert(context);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
final notValidItems = sendViewModel.outputs
|
||||
.where((item) =>
|
||||
item.address.isEmpty ||
|
||||
item.cryptoAmount.isEmpty)
|
||||
.toList();
|
||||
|
||||
final notValidItems = sendViewModel.outputs
|
||||
.where((item) =>
|
||||
item.address.isEmpty || item.cryptoAmount.isEmpty)
|
||||
.toList();
|
||||
if (notValidItems.isNotEmpty ?? false) {
|
||||
showErrorValidationAlert(context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (notValidItems.isNotEmpty ?? false) {
|
||||
showErrorValidationAlert(context);
|
||||
return;
|
||||
}
|
||||
|
||||
await sendViewModel.createTransaction();
|
||||
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color: Theme.of(context).accentTextTheme!.bodyLarge!.color!,
|
||||
textColor: Colors.white,
|
||||
isLoading: sendViewModel.state is IsExecutingState ||
|
||||
sendViewModel.state is TransactionCommitting,
|
||||
isDisabled: !sendViewModel.isReadyForSend,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
)),
|
||||
await sendViewModel.createTransaction();
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color:
|
||||
Theme.of(context).accentTextTheme!.bodyLarge!.color!,
|
||||
textColor: Colors.white,
|
||||
isLoading: sendViewModel.state is IsExecutingState ||
|
||||
sendViewModel.state is TransactionCommitting,
|
||||
isDisabled: !sendViewModel.isReadyForSend,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -382,51 +413,54 @@ class SendPage extends BasePage {
|
|||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (context.mounted) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ConfirmSendingAlert(
|
||||
alertTitle: S.of(context).confirm_sending,
|
||||
amount: S.of(context).send_amount,
|
||||
amountValue:
|
||||
sendViewModel.pendingTransaction!.amountFormatted,
|
||||
fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
|
||||
fee: S.of(context).send_fee,
|
||||
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
||||
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
|
||||
outputs: sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop();
|
||||
sendViewModel.commitTransaction();
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Observer(builder: (_) {
|
||||
final state = sendViewModel.state;
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ConfirmSendingAlert(
|
||||
alertTitle: S.of(context).confirm_sending,
|
||||
amount: S.of(context).send_amount,
|
||||
amountValue:
|
||||
sendViewModel.pendingTransaction!.amountFormatted,
|
||||
fiatAmountValue:
|
||||
sendViewModel.pendingTransactionFiatAmountFormatted,
|
||||
fee: S.of(context).send_fee,
|
||||
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
||||
feeFiatAmount: sendViewModel
|
||||
.pendingTransactionFeeFiatAmountFormatted,
|
||||
outputs: sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop();
|
||||
sendViewModel.commitTransaction();
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Observer(builder: (_) {
|
||||
final state = sendViewModel.state;
|
||||
|
||||
if (state is FailureState) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: '',
|
||||
alertContent: S.of(context).send_success(
|
||||
sendViewModel.selectedCryptoCurrency.toString()),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
RequestReviewHandler.requestReview();
|
||||
});
|
||||
if (state is FailureState) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
return Offstage();
|
||||
if (state is TransactionCommitted) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: '',
|
||||
alertContent: S.of(context).send_success(
|
||||
sendViewModel.selectedCryptoCurrency
|
||||
.toString()),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
RequestReviewHandler.requestReview();
|
||||
});
|
||||
}
|
||||
|
||||
return Offstage();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop());
|
||||
});
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -461,16 +495,18 @@ class SendPage extends BasePage {
|
|||
});
|
||||
}
|
||||
|
||||
void presentCurrencyPicker(BuildContext context) async {
|
||||
void presentCurrencyPicker(BuildContext context) async {
|
||||
await showPopUp<CryptoCurrency>(
|
||||
builder: (_) => Picker(
|
||||
items: sendViewModel.currencies,
|
||||
displayItem: (Object item) => item.toString(),
|
||||
selectedAtIndex: sendViewModel.currencies.indexOf(sendViewModel.selectedCryptoCurrency),
|
||||
title: S.of(context).please_select,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
onItemSelected: (CryptoCurrency cur) => sendViewModel.selectedCryptoCurrency = cur,
|
||||
),
|
||||
items: sendViewModel.currencies,
|
||||
displayItem: (Object item) => item.toString(),
|
||||
selectedAtIndex: sendViewModel.currencies
|
||||
.indexOf(sendViewModel.selectedCryptoCurrency),
|
||||
title: S.of(context).please_select,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
onItemSelected: (CryptoCurrency cur) =>
|
||||
sendViewModel.selectedCryptoCurrency = cur,
|
||||
),
|
||||
context: context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,26 +43,24 @@ class TotpAuthCodePageState extends State<TotpAuthCodePage> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
_reaction ??= reaction((_) => widget.setup2FAViewModel.state, (ExecutionState state) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
if(widget.totpArguments.onTotpAuthenticationFinished != null) {
|
||||
_reaction ??= reaction((_) => widget.setup2FAViewModel.state, (ExecutionState state) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(true, this);
|
||||
});
|
||||
}
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(true, this);
|
||||
}
|
||||
|
||||
if (state is FailureState) {
|
||||
print(state.error);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(false, this);
|
||||
});
|
||||
}
|
||||
if (state is FailureState) {
|
||||
print(state.error);
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(false, this);
|
||||
}
|
||||
|
||||
if (state is AuthenticationBanned) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(false, this);
|
||||
});
|
||||
}
|
||||
if (state is AuthenticationBanned) {
|
||||
widget.totpArguments.onTotpAuthenticationFinished!(false, this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
|
|
@ -150,12 +150,26 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
|
||||
return wallet.isCurrent
|
||||
? row
|
||||
: Slidable(
|
||||
key: Key('${wallet.key}'),
|
||||
startActionPane: _actionPane(wallet),
|
||||
endActionPane: _actionPane(wallet),
|
||||
child: row,
|
||||
);
|
||||
: Row(children: [
|
||||
Expanded(child: row),
|
||||
GestureDetector(
|
||||
onTap: () => _removeWallet(wallet),
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 44,
|
||||
padding: EdgeInsets.only(right: 20),
|
||||
child: Center(
|
||||
child: Image.asset('assets/images/trash.png',
|
||||
height: 16,
|
||||
width: 16,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.titleLarge!
|
||||
.color),
|
||||
),
|
||||
),
|
||||
)
|
||||
]);
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -280,18 +294,4 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
_progressBar = null;
|
||||
});
|
||||
}
|
||||
|
||||
ActionPane _actionPane(WalletListItem wallet) => ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
extentRatio: 0.3,
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (_) => _removeWallet(wallet),
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: CupertinoIcons.delete,
|
||||
label: S.of(context).delete,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
17
lib/view_model/dashboard/market_place_view_model.dart
Normal file
17
lib/view_model/dashboard/market_place_view_model.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'market_place_view_model.g.dart';
|
||||
|
||||
class MarketPlaceViewModel = MarketPlaceViewModelBase with _$MarketPlaceViewModel;
|
||||
|
||||
abstract class MarketPlaceViewModelBase with Store {
|
||||
final IoniaService _ioniaService;
|
||||
|
||||
MarketPlaceViewModelBase(this._ioniaService);
|
||||
|
||||
|
||||
Future<bool> isIoniaUserAuthenticated() async {
|
||||
return await _ioniaService.isLogined();
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
|||
import 'package:cw_core/keyable.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
||||
|
||||
class TransactionListItem extends ActionListItem with Keyable {
|
||||
TransactionListItem(
|
||||
{required this.transaction,
|
||||
|
@ -28,7 +27,7 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
|
||||
FiatCurrency get fiatCurrency => settingsStore.fiatCurrency;
|
||||
|
||||
BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
|
||||
BalanceDisplayMode get displayMode => balanceViewModel.displayMode;
|
||||
|
||||
@override
|
||||
dynamic get keyIndex => transaction.id;
|
||||
|
|
|
@ -47,7 +47,7 @@ abstract class ExchangeTradeViewModelBase with Store {
|
|||
case ExchangeProviderDescription.simpleSwap:
|
||||
_provider = SimpleSwapExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.trocador:
|
||||
case ExchangeProviderDescription.trocador:
|
||||
_provider = TrocadorExchangeProvider();
|
||||
break;
|
||||
}
|
||||
|
@ -114,6 +114,10 @@ abstract class ExchangeTradeViewModelBase with Store {
|
|||
updatedTrade.createdAt = trade.createdAt;
|
||||
}
|
||||
|
||||
if (updatedTrade.amount.isEmpty) {
|
||||
updatedTrade.amount = trade.amount;
|
||||
}
|
||||
|
||||
trade = updatedTrade;
|
||||
|
||||
_updateItems();
|
||||
|
@ -123,7 +127,8 @@ abstract class ExchangeTradeViewModelBase with Store {
|
|||
}
|
||||
|
||||
void _updateItems() {
|
||||
final tagFrom = tradesStore.trade!.from.tag != null ? '${tradesStore.trade!.from.tag}' + ' ' : '';
|
||||
final tagFrom =
|
||||
tradesStore.trade!.from.tag != null ? '${tradesStore.trade!.from.tag}' + ' ' : '';
|
||||
final tagTo = tradesStore.trade!.to.tag != null ? '${tradesStore.trade!.to.tag}' + ' ' : '';
|
||||
items.clear();
|
||||
items.add(ExchangeTradeItem(
|
||||
|
|
|
@ -443,7 +443,9 @@ abstract class ExchangeViewModelBase with Store {
|
|||
request = SideShiftRequest(
|
||||
depositMethod: depositCurrency,
|
||||
settleMethod: receiveCurrency,
|
||||
depositAmount: depositAmount.replaceAll(',', '.'),
|
||||
depositAmount: isFixedRateMode
|
||||
? receiveAmount.replaceAll(',', '.')
|
||||
: depositAmount.replaceAll(',', '.'),
|
||||
settleAddress: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
);
|
||||
|
|
|
@ -16,12 +16,10 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
|||
ioniaCategories = IoniaCategory.allCategories,
|
||||
selectedIndices = ObservableList<IoniaCategory>.of([IoniaCategory.all]),
|
||||
scrollOffsetFromTop = 0.0,
|
||||
isLoggedIn = false,
|
||||
merchantState = InitialIoniaMerchantLoadingState(),
|
||||
createCardState = IoniaCreateCardState(),
|
||||
searchString = '',
|
||||
ioniaMerchantList = <IoniaMerchant>[] {
|
||||
_getAuthStatus().then((value) => isLoggedIn = value);
|
||||
}
|
||||
|
||||
final IoniaService ioniaService;
|
||||
|
@ -45,24 +43,17 @@ abstract class IoniaGiftCardsListViewModelBase with Store {
|
|||
@observable
|
||||
List<IoniaMerchant> ioniaMerchants;
|
||||
|
||||
@observable
|
||||
bool isLoggedIn;
|
||||
|
||||
@observable
|
||||
List<IoniaCategory> ioniaCategories;
|
||||
|
||||
@observable
|
||||
ObservableList<IoniaCategory> selectedIndices;
|
||||
|
||||
Future<bool> _getAuthStatus() async {
|
||||
return await ioniaService.isLogined();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> createCard() async {
|
||||
try {
|
||||
createCardState = IoniaCreateCardLoading();
|
||||
final card = await ioniaService.createCard();
|
||||
await ioniaService.createCard();
|
||||
createCardState = IoniaCreateCardSuccess();
|
||||
} catch (e) {
|
||||
createCardState = IoniaCreateCardFailure(error: e.toString());
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import connectivity_macos
|
||||
import connectivity_plus_macos
|
||||
import cw_monero
|
||||
import device_info_plus
|
||||
import devicelocale
|
||||
|
|
|
@ -56,8 +56,8 @@ dependencies:
|
|||
# password: ^1.0.0
|
||||
basic_utils: ^4.3.0
|
||||
get_it: ^7.2.0
|
||||
connectivity: ^3.0.3
|
||||
# connectivity_plus: ^2.3.5
|
||||
# connectivity: ^3.0.3
|
||||
connectivity_plus: ^2.3.5
|
||||
keyboard_actions: ^4.0.1
|
||||
another_flushbar: ^1.12.29
|
||||
archive: ^3.3.0
|
||||
|
|
|
@ -685,14 +685,14 @@
|
|||
"arrive_in_this_address" : "${currency} ${tag}arrivera à cette adresse",
|
||||
"do_not_send": "Ne pas envoyer",
|
||||
"error_dialog_content": "Oups, nous avons rencontré une erreur.\n\nMerci d'envoyer le rapport d'erreur à notre équipe d'assistance afin de nous permettre d'améliorer l'application.",
|
||||
"scan_qr_code": "Scannez le code QR",
|
||||
"cold_or_recover_wallet": "Ajoutez un cold wallet ou récupérez un paper wallet",
|
||||
"please_wait": "S'il vous plaît, attendez",
|
||||
"sweeping_wallet": "Portefeuille de balayage",
|
||||
"sweeping_wallet_alert": "Cela ne devrait pas prendre longtemps. NE QUITTEZ PAS CET ÉCRAN OU LES FONDS BALAYÉS POURRAIENT ÊTRE PERDUS",
|
||||
"scan_qr_code": "Scannez le QR code",
|
||||
"cold_or_recover_wallet": "Ajoutez un portefeuille froid (cold wallet) ou récupérez un portefeuille papier (paper wallet)",
|
||||
"please_wait": "Merci de patienter",
|
||||
"sweeping_wallet": "Portefeuille (wallet) de consolidation",
|
||||
"sweeping_wallet_alert": "Cette opération ne devrait pas prendre longtemps. NE QUITTEZ PAS CET ÉCRAN OU LES FONDS CONSOLIDÉS POURRAIENT ÊTRE PERDUS",
|
||||
"decimal_places_error": "Trop de décimales",
|
||||
"edit_node": "Modifier le nœud",
|
||||
"frozen_balance": "Équilibre gelé",
|
||||
"frozen_balance": "Solde gelé",
|
||||
"invoice_details": "Détails de la facture",
|
||||
"donation_link_details": "Détails du lien de don",
|
||||
"anonpay_description": "Générez ${type}. Le destinataire peut ${method} avec n'importe quelle crypto-monnaie prise en charge, et vous recevrez des fonds dans ce portefeuille (wallet).",
|
||||
|
@ -709,22 +709,22 @@
|
|||
"error_text_input_above_maximum_limit" : "Le montant est supérieur au maximum",
|
||||
"show_market_place" :"Afficher la place de marché",
|
||||
"prevent_screenshots": "Empêcher les captures d'écran et l'enregistrement d'écran",
|
||||
"modify_2fa": "Modifier le gâteau 2FA",
|
||||
"disable_cake_2fa": "Désactiver le gâteau 2FA",
|
||||
"question_to_disable_2fa":"Êtes-vous sûr de vouloir désactiver Cake 2FA ? Un code 2FA ne sera plus nécessaire pour accéder au portefeuille et à certaines fonctions.",
|
||||
"modify_2fa": "Modifier les paramètres Cake 2FA",
|
||||
"disable_cake_2fa": "Désactiver Cake 2FA",
|
||||
"question_to_disable_2fa":"Êtes-vous sûr de vouloir désactiver Cake 2FA ? Un code 2FA ne sera plus nécessaire pour accéder au portefeuille (wallet) et à certaines fonctions.",
|
||||
"disable": "Désactiver",
|
||||
"setup_2fa": "Gâteau d'installation 2FA",
|
||||
"setup_2fa": "Paramétrer Cake 2FA",
|
||||
"verify_with_2fa": "Vérifier avec Cake 2FA",
|
||||
"totp_code": "Code TOTP",
|
||||
"please_fill_totp": "Veuillez renseigner le code à 8 chiffres présent sur votre autre appareil",
|
||||
"totp_2fa_success": "Succès! Cake 2FA activé pour ce portefeuille. N'oubliez pas de sauvegarder votre graine mnémonique au cas où vous perdriez l'accès au portefeuille.",
|
||||
"please_fill_totp": "Veuillez renseigner le code à 8 chiffres affiché sur votre autre appareil",
|
||||
"totp_2fa_success": "Succès! Cake 2FA est activé pour ce portefeuille. N'oubliez pas de sauvegarder votre phrase secrète (seed) au cas où vous perdriez l'accès au portefeuille (wallet).",
|
||||
"totp_verification_success" :"Vérification réussie !",
|
||||
"totp_2fa_failure": "Code incorrect. Veuillez essayer un code différent ou générer une nouvelle clé secrète. Utilisez une application 2FA compatible qui prend en charge les codes à 8 chiffres et SHA512.",
|
||||
"totp_2fa_failure": "Code incorrect. Veuillez essayer un code différent ou générer un nouveau secret TOTP. Utilisez une application 2FA compatible qui prend en charge les codes à 8 chiffres et SHA512.",
|
||||
"enter_totp_code": "Veuillez entrer le code TOTP.",
|
||||
"add_secret_code":"Ajouter ce code secret à un autre appareil",
|
||||
"totp_secret_code":"Code secret TOTP",
|
||||
"add_secret_code":"Configurer un autre appareil à l'aide de ce secret TOTP",
|
||||
"totp_secret_code":"Secret TOTP",
|
||||
"important_note": "Note importante",
|
||||
"setup_2fa_text": "Cake 2FA n'est PAS aussi sûr que le stockage à froid. 2FA protège contre les types d'attaques de base, comme votre ami fournissant votre empreinte digitale pendant que vous dormez.\n\n Cake 2FA ne protège PAS contre un appareil compromis par un attaquant sophistiqué.\n\n Si vous perdez l'accès à vos codes 2FA , VOUS PERDREZ L'ACCÈS À CE PORTEFEUILLE. Vous devrez restaurer votre portefeuille à partir de graines mnémotechniques. VOUS DEVEZ DONC SAUVEGARDER VOS SEMENCES MNEMONIQUES ! De plus, quelqu'un ayant accès à vos graines mnémoniques pourra voler vos fonds, en contournant Cake 2FA.\n\n Le personnel d'assistance de Cake ne pourra pas vous aider si vous perdez l'accès à vos graines mnémoniques, puisque Cake est un portefeuille non dépositaire.",
|
||||
"setup_2fa_text": "Cake 2FA (Authentification à 2 Facteurs) n'est PAS aussi sûr que le stockage à froid. Cake 2FA protège contre les attaques basiques, comme un ami fournissant votre empreinte digitale pendant que vous dormez.\n\n Cake 2FA ne protège PAS contre un appareil compromis par un attaquant sophistiqué.\n\n Si vous perdez l'accès à vos codes 2FA , VOUS PERDREZ L'ACCÈS À CE PORTEFEUILLE (WALLET). Vous devrez restaurer votre portefeuille à partir de sa phrase secrète (seed). VOUS DEVEZ DONC SAUVEGARDER VOTRE PHRASE SECRÈTE ! De plus, quelqu'un ayant accès à votre phrase secrète pourra voler vos fonds, en contournant Cake 2FA.\n\n Le personnel d'assistance de Cake ne pourra pas vous aider si vous perdez l'accès à votre phrase secrète, puisque Cake est un portefeuille non dépositaire (non custodial).",
|
||||
"setup_totp_recommended": "Configurer TOTP (recommandé)",
|
||||
"disable_buy": "Désactiver l'action d'achat",
|
||||
"disable_sell": "Désactiver l'action de vente"
|
||||
|
|
|
@ -20,7 +20,6 @@ class SecretKey {
|
|||
SecretKey('moonPayApiKey', () => ''),
|
||||
SecretKey('moonPaySecretKey', () => ''),
|
||||
SecretKey('sideShiftAffiliateId', () => ''),
|
||||
SecretKey('sideShiftApiKey', () => ''),
|
||||
SecretKey('simpleSwapApiKey', () => ''),
|
||||
SecretKey('simpleSwapApiKeyDesktop', () => ''),
|
||||
SecretKey('anypayToken', () => ''),
|
||||
|
|
Loading…
Reference in a new issue