mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 16:55:58 +00:00
Another beautiful day changes
This commit is contained in:
parent
41b436d9d4
commit
9db6e233c7
24 changed files with 406 additions and 265 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:quiver/core.dart';
|
||||||
|
|
||||||
class BitcoinAddressRecord {
|
class BitcoinAddressRecord {
|
||||||
BitcoinAddressRecord(this.address, {this.index});
|
BitcoinAddressRecord(this.address, {this.index});
|
||||||
|
@ -10,8 +11,15 @@ class BitcoinAddressRecord {
|
||||||
index: decoded['index'] as int);
|
index: decoded['index'] as int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object o) =>
|
||||||
|
o is BitcoinAddressRecord && address == o.address;
|
||||||
|
|
||||||
final String address;
|
final String address;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => address.hashCode;
|
||||||
|
|
||||||
String toJSON() => json.encode({'address': address, 'index': index});
|
String toJSON() => json.encode({'address': address, 'index': index});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
||||||
import 'package:cake_wallet/entities/balance.dart';
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
|
|
||||||
class BitcoinBalance extends Balance {
|
class BitcoinBalance extends Balance {
|
||||||
const BitcoinBalance({@required this.confirmed, @required this.unconfirmed})
|
const BitcoinBalance({@required this.confirmed, @required this.unconfirmed})
|
||||||
: super(const [
|
: super(confirmed, unconfirmed);
|
||||||
BalanceDisplayMode.availableBalance,
|
|
||||||
BalanceDisplayMode.fullBalance
|
|
||||||
]);
|
|
||||||
|
|
||||||
factory BitcoinBalance.fromJSON(String jsonSource) {
|
factory BitcoinBalance.fromJSON(String jsonSource) {
|
||||||
if (jsonSource == null) {
|
if (jsonSource == null) {
|
||||||
|
@ -27,31 +23,12 @@ class BitcoinBalance extends Balance {
|
||||||
final int confirmed;
|
final int confirmed;
|
||||||
final int unconfirmed;
|
final int unconfirmed;
|
||||||
|
|
||||||
int get total => confirmed + unconfirmed;
|
@override
|
||||||
|
String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed);
|
||||||
int get availableBalance =>
|
|
||||||
(confirmed ?? 0) + (unconfirmed < 0 ? unconfirmed : 0);
|
|
||||||
|
|
||||||
String get confirmedFormatted => bitcoinAmountToString(amount: confirmed);
|
|
||||||
|
|
||||||
String get unconfirmedFormatted => bitcoinAmountToString(amount: unconfirmed);
|
|
||||||
|
|
||||||
String get totalFormatted => bitcoinAmountToString(amount: total);
|
|
||||||
|
|
||||||
String get availableBalanceFormatted =>
|
|
||||||
bitcoinAmountToString(amount: availableBalance);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String formattedBalance(BalanceDisplayMode mode) {
|
String get formattedAdditionalBalance =>
|
||||||
switch (mode) {
|
bitcoinAmountToString(amount: unconfirmed);
|
||||||
case BalanceDisplayMode.fullBalance:
|
|
||||||
return totalFormatted;
|
|
||||||
case BalanceDisplayMode.availableBalance:
|
|
||||||
return availableBalanceFormatted;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String toJSON() =>
|
String toJSON() =>
|
||||||
json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed});
|
json.encode({'confirmed': confirmed, 'unconfirmed': unconfirmed});
|
||||||
|
|
|
@ -47,7 +47,7 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
||||||
network: bitcoin.bitcoin)
|
network: bitcoin.bitcoin)
|
||||||
.derivePath("m/0'/0"),
|
.derivePath("m/0'/0"),
|
||||||
addresses = initialAddresses != null
|
addresses = initialAddresses != null
|
||||||
? ObservableList<BitcoinAddressRecord>.of(initialAddresses)
|
? ObservableList<BitcoinAddressRecord>.of(initialAddresses.toSet())
|
||||||
: ObservableList<BitcoinAddressRecord>(),
|
: ObservableList<BitcoinAddressRecord>(),
|
||||||
syncStatus = NotConnectedSyncStatus(),
|
syncStatus = NotConnectedSyncStatus(),
|
||||||
_password = password,
|
_password = password,
|
||||||
|
@ -267,14 +267,14 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
||||||
final fee = feeAmountForPriority(transactionCredentials.priority);
|
final fee = feeAmountForPriority(transactionCredentials.priority);
|
||||||
final amount = transactionCredentials.amount != null
|
final amount = transactionCredentials.amount != null
|
||||||
? stringDoubleToBitcoinAmount(transactionCredentials.amount)
|
? stringDoubleToBitcoinAmount(transactionCredentials.amount)
|
||||||
: balance.availableBalance - fee;
|
: balance.confirmed - fee;
|
||||||
final totalAmount = amount + fee;
|
final totalAmount = amount + fee;
|
||||||
final txb = bitcoin.TransactionBuilder(network: bitcoin.bitcoin);
|
final txb = bitcoin.TransactionBuilder(network: bitcoin.bitcoin);
|
||||||
final changeAddress = address;
|
final changeAddress = address;
|
||||||
var leftAmount = totalAmount;
|
var leftAmount = totalAmount;
|
||||||
var totalInputAmount = 0;
|
var totalInputAmount = 0;
|
||||||
|
|
||||||
if (totalAmount > balance.availableBalance) {
|
if (totalAmount > balance.confirmed) {
|
||||||
throw BitcoinTransactionWrongBalanceException();
|
throw BitcoinTransactionWrongBalanceException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:cake_wallet/entities/wallet_info.dart';
|
import 'package:cake_wallet/entities/wallet_info.dart';
|
||||||
import 'package:cake_wallet/core/pending_transaction.dart';
|
import 'package:cake_wallet/core/pending_transaction.dart';
|
||||||
|
@ -9,7 +10,7 @@ import 'package:cake_wallet/entities/sync_status.dart';
|
||||||
import 'package:cake_wallet/entities/node.dart';
|
import 'package:cake_wallet/entities/node.dart';
|
||||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||||
|
|
||||||
abstract class WalletBase<BalaceType> {
|
abstract class WalletBase<BalaceType extends Balance> {
|
||||||
WalletBase(this.walletInfo);
|
WalletBase(this.walletInfo);
|
||||||
|
|
||||||
static String idFor(String name, WalletType type) =>
|
static String idFor(String name, WalletType type) =>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
|
||||||
|
|
||||||
abstract class Balance {
|
abstract class Balance {
|
||||||
const Balance(this.availableModes);
|
const Balance(this.available, this.additional);
|
||||||
|
|
||||||
final List<BalanceDisplayMode> availableModes;
|
final int available;
|
||||||
|
|
||||||
String formattedBalance(BalanceDisplayMode mode);
|
final int additional;
|
||||||
|
|
||||||
|
String get formattedAvailableBalance;
|
||||||
|
|
||||||
|
String get formattedAdditionalBalance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,16 @@ class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
|
||||||
: super(title: title, raw: raw);
|
: super(title: title, raw: raw);
|
||||||
|
|
||||||
static const all = [
|
static const all = [
|
||||||
BalanceDisplayMode.fullBalance,
|
BalanceDisplayMode.hiddenBalance,
|
||||||
BalanceDisplayMode.availableBalance,
|
BalanceDisplayMode.displayableBalance,
|
||||||
BalanceDisplayMode.hiddenBalance
|
|
||||||
];
|
];
|
||||||
static const fullBalance = BalanceDisplayMode(raw: 0, title: 'Full Balance');
|
static const fullBalance = BalanceDisplayMode(raw: 0, title: 'Full Balance');
|
||||||
static const availableBalance =
|
static const availableBalance =
|
||||||
BalanceDisplayMode(raw: 1, title: 'Available Balance');
|
BalanceDisplayMode(raw: 1, title: 'Available Balance');
|
||||||
static const hiddenBalance =
|
static const hiddenBalance =
|
||||||
BalanceDisplayMode(raw: 2, title: 'Hidden Balance');
|
BalanceDisplayMode(raw: 2, title: 'Hidden Balance');
|
||||||
|
static const displayableBalance =
|
||||||
|
BalanceDisplayMode(raw: 3, title: 'Displayable Balance');
|
||||||
|
|
||||||
static BalanceDisplayMode deserialize({int raw}) {
|
static BalanceDisplayMode deserialize({int raw}) {
|
||||||
switch (raw) {
|
switch (raw) {
|
||||||
|
@ -25,6 +26,8 @@ class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
|
||||||
return availableBalance;
|
return availableBalance;
|
||||||
case 2:
|
case 2:
|
||||||
return hiddenBalance;
|
return hiddenBalance;
|
||||||
|
case 3:
|
||||||
|
return displayableBalance;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +42,8 @@ class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
|
||||||
return S.current.xmr_available_balance;
|
return S.current.xmr_available_balance;
|
||||||
case BalanceDisplayMode.hiddenBalance:
|
case BalanceDisplayMode.hiddenBalance:
|
||||||
return S.current.xmr_hidden;
|
return S.current.xmr_hidden;
|
||||||
|
case BalanceDisplayMode.displayableBalance:
|
||||||
|
return S.current.displayable;
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,11 @@ Future defaultSettingsMigration(
|
||||||
case 5:
|
case 5:
|
||||||
await addAddressesForMoneroWallets(walletInfoSource);
|
await addAddressesForMoneroWallets(walletInfoSource);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
await updateDisplayModes(sharedPreferences);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -220,3 +225,10 @@ Future<void> addAddressesForMoneroWallets(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> updateDisplayModes(SharedPreferences sharedPreferences) async {
|
||||||
|
final currentBalanceDisplayMode =
|
||||||
|
sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey);
|
||||||
|
final balanceDisplayMode = currentBalanceDisplayMode < 2 ? 3 : 2;
|
||||||
|
await sharedPreferences.setInt(PreferencesKey.currentBalanceDisplayModeKey, balanceDisplayMode);
|
||||||
|
}
|
||||||
|
|
|
@ -374,6 +374,10 @@ class S implements WidgetsLocalizations {
|
||||||
String wallet_list_failed_to_remove(String wallet_name, String error) => "Failed to remove ${wallet_name} wallet. ${error}";
|
String wallet_list_failed_to_remove(String wallet_name, String error) => "Failed to remove ${wallet_name} wallet. ${error}";
|
||||||
String wallet_list_loading_wallet(String wallet_name) => "Loading ${wallet_name} wallet";
|
String wallet_list_loading_wallet(String wallet_name) => "Loading ${wallet_name} wallet";
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Removing ${wallet_name} wallet";
|
String wallet_list_removing_wallet(String wallet_name) => "Removing ${wallet_name} wallet";
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "If you want to exchange XMR from your Cake Wallet Monero balance, please switch to your Monero wallet first.";
|
||||||
|
String get confirmed => 'Confirmed';
|
||||||
|
String get unconfirmed => 'Unconfirmed';
|
||||||
|
String get displayable => 'Displayable';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $de extends S {
|
class $de extends S {
|
||||||
|
@ -1088,6 +1092,14 @@ class $de extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Laden fehlgeschlagen ${wallet_name} Wallet. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Laden fehlgeschlagen ${wallet_name} Wallet. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Entfernen ${wallet_name} Wallet";
|
String wallet_list_removing_wallet(String wallet_name) => "Entfernen ${wallet_name} Wallet";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Wenn Sie XMR von Ihrem Cake Wallet Monero-Guthaben austauschen möchten, wechseln Sie bitte zuerst zu Ihrem Monero Wallet.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Bestätigt';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'Unbestätigt';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Anzeigebar';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $hi extends S {
|
class $hi extends S {
|
||||||
|
@ -1802,6 +1814,14 @@ class $hi extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "लोड करने में विफल ${wallet_name} बटुआ. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "लोड करने में विफल ${wallet_name} बटुआ. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "निकाला जा रहा है ${wallet_name} बटुआ";
|
String wallet_list_removing_wallet(String wallet_name) => "निकाला जा रहा है ${wallet_name} बटुआ";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "यदि आप अपने केक वॉलेट मोनेरो बैलेंस से एक्सएमआर का आदान-प्रदान करना चाहते हैं, तो कृपया अपने मोनेरो वॉलेट में जाएं।";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'की पुष्टि की';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'अपुष्ट';
|
||||||
|
@override
|
||||||
|
String get displayable => 'प्रदर्शन योग्य';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $ru extends S {
|
class $ru extends S {
|
||||||
|
@ -2516,6 +2536,14 @@ class $ru extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Ошибка при загрузке ${wallet_name} кошелька. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Ошибка при загрузке ${wallet_name} кошелька. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Удаление ${wallet_name} кошелька";
|
String wallet_list_removing_wallet(String wallet_name) => "Удаление ${wallet_name} кошелька";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Если вы хотите обменять XMR со своего баланса Monero в Cake Wallet, сначала переключитесь на свой кошелек Monero.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Подтверждено';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'Неподтвержденный';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Отображаемый';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $ko extends S {
|
class $ko extends S {
|
||||||
|
@ -3230,6 +3258,14 @@ class $ko extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "불러 오지 못했습니다 ${wallet_name} 지갑. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "불러 오지 못했습니다 ${wallet_name} 지갑. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "풀이 ${wallet_name} 지갑";
|
String wallet_list_removing_wallet(String wallet_name) => "풀이 ${wallet_name} 지갑";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Cake Wallet Monero 잔액에서 XMR을 교환하려면 먼저 Monero 지갑으로 전환하십시오.";
|
||||||
|
@override
|
||||||
|
String get confirmed => '확인';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => '미확인';
|
||||||
|
@override
|
||||||
|
String get displayable => '표시 가능';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $pt extends S {
|
class $pt extends S {
|
||||||
|
@ -3944,6 +3980,14 @@ class $pt extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Falha ao abrir a carteira ${wallet_name}. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Falha ao abrir a carteira ${wallet_name}. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Removendo a carteira ${wallet_name}";
|
String wallet_list_removing_wallet(String wallet_name) => "Removendo a carteira ${wallet_name}";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Se você deseja trocar o XMR de seu saldo da Carteira Monero Cake, troque primeiro para sua carteira Monero.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Confirmada';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'Não confirmado';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Exibível';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $uk extends S {
|
class $uk extends S {
|
||||||
|
@ -4658,6 +4702,14 @@ class $uk extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Помилка при завантаженні ${wallet_name} гаманця. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Помилка при завантаженні ${wallet_name} гаманця. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Видалення ${wallet_name} гаманця";
|
String wallet_list_removing_wallet(String wallet_name) => "Видалення ${wallet_name} гаманця";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Якщо ви хочете обміняти XMR із вашого балансу Cake Wallet Monero, спочатку перейдіть на свій гаманець Monero.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Підтверджено';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'Непідтверджений';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Відображуваний';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $ja extends S {
|
class $ja extends S {
|
||||||
|
@ -5372,6 +5424,14 @@ class $ja extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "読み込みに失敗しました ${wallet_name} 財布. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "読み込みに失敗しました ${wallet_name} 財布. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "取りはずし ${wallet_name} 財布";
|
String wallet_list_removing_wallet(String wallet_name) => "取りはずし ${wallet_name} 財布";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Cake Wallet Moneroの残高からXMRを交換する場合は、最初にMoneroウォレットに切り替えてください。";
|
||||||
|
@override
|
||||||
|
String get confirmed => '確認済み';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => '未確認';
|
||||||
|
@override
|
||||||
|
String get displayable => '表示可能';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $en extends S {
|
class $en extends S {
|
||||||
|
@ -6090,6 +6150,14 @@ class $pl extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Nie udało się załadować ${wallet_name} portfel. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Nie udało się załadować ${wallet_name} portfel. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Usuwanie ${wallet_name} portfel";
|
String wallet_list_removing_wallet(String wallet_name) => "Usuwanie ${wallet_name} portfel";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Jeśli chcesz wymienić XMR z salda Cake Wallet Monero, najpierw przełącz się na portfel Monero.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Potwierdzony';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'niepotwierdzony';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Wyświetlane';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $es extends S {
|
class $es extends S {
|
||||||
|
@ -6804,6 +6872,14 @@ class $es extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "No se pudo cargar ${wallet_name} la billetera. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "No se pudo cargar ${wallet_name} la billetera. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Retirar ${wallet_name} billetera";
|
String wallet_list_removing_wallet(String wallet_name) => "Retirar ${wallet_name} billetera";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Si desea intercambiar XMR de su saldo de Cake Wallet Monero, primero cambie a su billetera Monero.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'Confirmada';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'inconfirmado';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Visualizable';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $nl extends S {
|
class $nl extends S {
|
||||||
|
@ -7518,6 +7594,14 @@ class $nl extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "Laden mislukt ${wallet_name} portemonnee. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "Laden mislukt ${wallet_name} portemonnee. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "Verwijderen ${wallet_name} portemonnee";
|
String wallet_list_removing_wallet(String wallet_name) => "Verwijderen ${wallet_name} portemonnee";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "Als u XMR wilt omwisselen van uw Cake Wallet Monero-saldo, moet u eerst overschakelen naar uw Monero-portemonnee.";
|
||||||
|
@override
|
||||||
|
String get confirmed => 'bevestigd';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => 'niet bevestigd';
|
||||||
|
@override
|
||||||
|
String get displayable => 'Weer te geven';
|
||||||
}
|
}
|
||||||
|
|
||||||
class $zh extends S {
|
class $zh extends S {
|
||||||
|
@ -8232,6 +8316,14 @@ class $zh extends S {
|
||||||
String wallet_list_failed_to_load(String wallet_name, String error) => "加载失败 ${wallet_name} 钱包. ${error}";
|
String wallet_list_failed_to_load(String wallet_name, String error) => "加载失败 ${wallet_name} 钱包. ${error}";
|
||||||
@override
|
@override
|
||||||
String wallet_list_removing_wallet(String wallet_name) => "拆下 ${wallet_name} 钱包";
|
String wallet_list_removing_wallet(String wallet_name) => "拆下 ${wallet_name} 钱包";
|
||||||
|
@override
|
||||||
|
String get exchange_incorrect_current_wallet_for_xmr => "如果要从Cake Wallet Monero余额中兑换XMR,请先切换到Monero钱包。";
|
||||||
|
@override
|
||||||
|
String get confirmed => '已确认';
|
||||||
|
@override
|
||||||
|
String get unconfirmed => '未经证实';
|
||||||
|
@override
|
||||||
|
String get displayable => '可显示';
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
|
class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/bitcoin/bitcoin_address_record.dart';
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -54,11 +55,11 @@ void main() async {
|
||||||
TransactionDescription.boxName,
|
TransactionDescription.boxName,
|
||||||
encryptionKey: transactionDescriptionsBoxKey);
|
encryptionKey: transactionDescriptionsBoxKey);
|
||||||
final trades =
|
final trades =
|
||||||
await Hive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
|
await Hive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
|
||||||
final walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
final walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||||
final templates = await Hive.openBox<Template>(Template.boxName);
|
final templates = await Hive.openBox<Template>(Template.boxName);
|
||||||
final exchangeTemplates =
|
final exchangeTemplates =
|
||||||
await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
|
await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
|
||||||
await initialSetup(
|
await initialSetup(
|
||||||
sharedPreferences: await SharedPreferences.getInstance(),
|
sharedPreferences: await SharedPreferences.getInstance(),
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
|
@ -77,24 +78,24 @@ void main() async {
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
margin:
|
margin:
|
||||||
EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20),
|
EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Error:\n${e.toString()}',
|
'Error:\n${e.toString()}',
|
||||||
style: TextStyle(fontSize: 22),
|
style: TextStyle(fontSize: 22),
|
||||||
)))));
|
)))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Future<void> initialSetup(
|
|
||||||
{@required SharedPreferences sharedPreferences,
|
Future<void> initialSetup({@required SharedPreferences sharedPreferences,
|
||||||
@required Box<Node> nodes,
|
@required Box<Node> nodes,
|
||||||
@required Box<WalletInfo> walletInfoSource,
|
@required Box<WalletInfo> walletInfoSource,
|
||||||
@required Box<Contact> contactSource,
|
@required Box<Contact> contactSource,
|
||||||
@required Box<Trade> tradesSource,
|
@required Box<Trade> tradesSource,
|
||||||
// @required FiatConvertationService fiatConvertationService,
|
// @required FiatConvertationService fiatConvertationService,
|
||||||
@required Box<Template> templates,
|
@required Box<Template> templates,
|
||||||
@required Box<ExchangeTemplate> exchangeTemplates,
|
@required Box<ExchangeTemplate> exchangeTemplates,
|
||||||
@required Box<TransactionDescription> transactionDescriptions,
|
@required Box<TransactionDescription> transactionDescriptions,
|
||||||
int initialMigrationVersion = 5}) async {
|
int initialMigrationVersion = 6}) async {
|
||||||
await defaultSettingsMigration(
|
await defaultSettingsMigration(
|
||||||
version: initialMigrationVersion,
|
version: initialMigrationVersion,
|
||||||
sharedPreferences: sharedPreferences,
|
sharedPreferences: sharedPreferences,
|
||||||
|
@ -122,7 +123,9 @@ class App extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final settingsStore = getIt.get<AppStore>().settingsStore;
|
final settingsStore = getIt
|
||||||
|
.get<AppStore>()
|
||||||
|
.settingsStore;
|
||||||
final statusBarColor = Colors.transparent;
|
final statusBarColor = Colors.transparent;
|
||||||
final authenticationStore = getIt.get<AuthenticationStore>();
|
final authenticationStore = getIt.get<AuthenticationStore>();
|
||||||
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
||||||
|
@ -132,11 +135,11 @@ class App extends StatelessWidget {
|
||||||
return Observer(builder: (BuildContext context) {
|
return Observer(builder: (BuildContext context) {
|
||||||
final currentTheme = settingsStore.currentTheme;
|
final currentTheme = settingsStore.currentTheme;
|
||||||
final statusBarBrightness = currentTheme.type == ThemeType.dark
|
final statusBarBrightness = currentTheme.type == ThemeType.dark
|
||||||
? Brightness.light
|
? Brightness.light
|
||||||
: Brightness.dark;
|
: Brightness.dark;
|
||||||
final statusBarIconBrightness = currentTheme.type == ThemeType.dark
|
final statusBarIconBrightness = currentTheme.type == ThemeType.dark
|
||||||
? Brightness.light
|
? Brightness.light
|
||||||
: Brightness.dark;
|
: Brightness.dark;
|
||||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||||
statusBarColor: statusBarColor,
|
statusBarColor: statusBarColor,
|
||||||
statusBarBrightness: statusBarBrightness,
|
statusBarBrightness: statusBarBrightness,
|
||||||
|
|
|
@ -8,20 +8,15 @@ class MoneroBalance extends Balance {
|
||||||
: formattedFullBalance = moneroAmountToString(amount: fullBalance),
|
: formattedFullBalance = moneroAmountToString(amount: fullBalance),
|
||||||
formattedUnlockedBalance =
|
formattedUnlockedBalance =
|
||||||
moneroAmountToString(amount: unlockedBalance),
|
moneroAmountToString(amount: unlockedBalance),
|
||||||
super(const [
|
super(unlockedBalance, fullBalance);
|
||||||
BalanceDisplayMode.availableBalance,
|
|
||||||
BalanceDisplayMode.fullBalance
|
|
||||||
]);
|
|
||||||
|
|
||||||
MoneroBalance.fromString(
|
MoneroBalance.fromString(
|
||||||
{@required this.formattedFullBalance,
|
{@required this.formattedFullBalance,
|
||||||
@required this.formattedUnlockedBalance})
|
@required this.formattedUnlockedBalance})
|
||||||
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
|
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
|
||||||
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
|
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
|
||||||
super(const [
|
super(moneroParseAmount(amount: formattedUnlockedBalance),
|
||||||
BalanceDisplayMode.availableBalance,
|
moneroParseAmount(amount: formattedFullBalance));
|
||||||
BalanceDisplayMode.fullBalance
|
|
||||||
]);
|
|
||||||
|
|
||||||
final int fullBalance;
|
final int fullBalance;
|
||||||
final int unlockedBalance;
|
final int unlockedBalance;
|
||||||
|
@ -29,14 +24,8 @@ class MoneroBalance extends Balance {
|
||||||
final String formattedUnlockedBalance;
|
final String formattedUnlockedBalance;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String formattedBalance(BalanceDisplayMode mode) {
|
String get formattedAvailableBalance => formattedUnlockedBalance;
|
||||||
switch (mode) {
|
|
||||||
case BalanceDisplayMode.fullBalance:
|
@override
|
||||||
return formattedFullBalance;
|
String get formattedAdditionalBalance => formattedFullBalance;
|
||||||
case BalanceDisplayMode.availableBalance:
|
|
||||||
return formattedUnlockedBalance;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:cake_wallet/di.dart';
|
import 'package:cake_wallet/di.dart';
|
||||||
|
@ -19,7 +20,7 @@ void startCurrentWalletChangeReaction(AppStore appStore,
|
||||||
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||||
|
|
||||||
_onCurrentWalletChangeReaction =
|
_onCurrentWalletChangeReaction =
|
||||||
reaction((_) => appStore.wallet, (WalletBase wallet) async {
|
reaction((_) => appStore.wallet, (WalletBase<Balance> wallet) async {
|
||||||
try {
|
try {
|
||||||
final node = settingsStore.getCurrentNode(wallet.type);
|
final node = settingsStore.getCurrentNode(wallet.type);
|
||||||
startWalletSyncStatusChangeReaction(wallet);
|
startWalletSyncStatusChangeReaction(wallet);
|
||||||
|
@ -44,7 +45,7 @@ void startCurrentWalletChangeReaction(AppStore appStore,
|
||||||
});
|
});
|
||||||
|
|
||||||
_onCurrentWalletChangeFiatRateUpdateReaction =
|
_onCurrentWalletChangeFiatRateUpdateReaction =
|
||||||
reaction((_) => appStore.wallet, (WalletBase wallet) async {
|
reaction((_) => appStore.wallet, (WalletBase<Balance> wallet) async {
|
||||||
try {
|
try {
|
||||||
fiatConversionStore.prices[wallet.currency] = 0;
|
fiatConversionStore.prices[wallet.currency] = 0;
|
||||||
fiatConversionStore.prices[wallet.currency] =
|
fiatConversionStore.prices[wallet.currency] =
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/core/wallet_base.dart';
|
import 'package:cake_wallet/core/wallet_base.dart';
|
||||||
import 'package:cake_wallet/entities/sync_status.dart';
|
import 'package:cake_wallet/entities/sync_status.dart';
|
||||||
|
|
||||||
ReactionDisposer _onWalletSyncStatusChangeReaction;
|
ReactionDisposer _onWalletSyncStatusChangeReaction;
|
||||||
|
|
||||||
void startWalletSyncStatusChangeReaction(WalletBase wallet) {
|
void startWalletSyncStatusChangeReaction(WalletBase<Balance> wallet) {
|
||||||
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
|
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
|
||||||
_onWalletSyncStatusChangeReaction =
|
_onWalletSyncStatusChangeReaction =
|
||||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||||
|
|
|
@ -19,6 +19,9 @@ class AddressPage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return KeyboardActions(
|
return KeyboardActions(
|
||||||
|
autoScroll: false,
|
||||||
|
disableScroll: true,
|
||||||
|
tapOutsideToDismiss: true,
|
||||||
config: KeyboardActionsConfig(
|
config: KeyboardActionsConfig(
|
||||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||||
keyboardBarColor:
|
keyboardBarColor:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
@ -10,77 +11,87 @@ class BalancePage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return Container(
|
||||||
onTapUp: (_) {
|
color: Colors.transparent,
|
||||||
if (dashboardViewModel.balanceViewModel.canReverse) {
|
padding: EdgeInsets.all(24),
|
||||||
dashboardViewModel.balanceViewModel.isReversing = false;
|
child: Column(
|
||||||
}
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
},
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
onTapDown: (_) {
|
children: <Widget>[
|
||||||
if (dashboardViewModel.balanceViewModel.canReverse) {
|
Observer(builder: (_) {
|
||||||
dashboardViewModel.balanceViewModel.isReversing = true;
|
return Text(
|
||||||
}
|
dashboardViewModel.balanceViewModel.currency.toString(),
|
||||||
},
|
style: TextStyle(
|
||||||
child: Container(
|
fontSize: 40,
|
||||||
color: Colors.transparent,
|
fontWeight: FontWeight.bold,
|
||||||
padding: EdgeInsets.all(24),
|
color: Theme.of(context)
|
||||||
child: Column(
|
.accentTextTheme
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
.display2
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
.backgroundColor,
|
||||||
children: <Widget>[
|
height: 1),
|
||||||
Observer(builder: (_) {
|
);
|
||||||
return Text(
|
}),
|
||||||
dashboardViewModel.balanceViewModel.currency.toString(),
|
SizedBox(height: 10),
|
||||||
style: TextStyle(
|
Observer(builder: (_) {
|
||||||
fontSize: 40,
|
return Text(
|
||||||
fontWeight: FontWeight.bold,
|
'${dashboardViewModel.balanceViewModel.availableBalanceLabel} (${dashboardViewModel.balanceViewModel.availableFiatBalance.toString()})',
|
||||||
color: Theme.of(context)
|
style: TextStyle(
|
||||||
.accentTextTheme
|
fontSize: 12,
|
||||||
.display2
|
fontWeight: FontWeight.w600,
|
||||||
.backgroundColor,
|
color: Theme.of(context)
|
||||||
height: 1),
|
.accentTextTheme
|
||||||
);
|
.display2
|
||||||
}),
|
.backgroundColor,
|
||||||
Observer(builder: (_) {
|
height: 1),
|
||||||
return Text(
|
);
|
||||||
dashboardViewModel.balanceViewModel.displayMode.toString(),
|
}),
|
||||||
style: TextStyle(
|
SizedBox(height: 10),
|
||||||
fontSize: 12,
|
Observer(builder: (_) {
|
||||||
fontWeight: FontWeight.w600,
|
return AutoSizeText(
|
||||||
color: Theme.of(context)
|
dashboardViewModel.balanceViewModel.availableBalance,
|
||||||
.accentTextTheme
|
style: TextStyle(
|
||||||
.display2
|
fontSize: 54,
|
||||||
.backgroundColor,
|
fontWeight: FontWeight.bold,
|
||||||
height: 1),
|
color: Theme.of(context)
|
||||||
);
|
.accentTextTheme
|
||||||
}),
|
.display3
|
||||||
SizedBox(height: 10),
|
.backgroundColor,
|
||||||
Observer(builder: (_) {
|
height: 1),
|
||||||
return AutoSizeText(
|
maxLines: 1,
|
||||||
dashboardViewModel.balanceViewModel.cryptoBalance,
|
textAlign: TextAlign.center);
|
||||||
style: TextStyle(
|
}),
|
||||||
fontSize: 54,
|
SizedBox(height: 10),
|
||||||
fontWeight: FontWeight.bold,
|
Observer(builder: (_) {
|
||||||
color: Theme.of(context)
|
return Text(
|
||||||
.accentTextTheme
|
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel} (${dashboardViewModel.balanceViewModel.additionalFiatBalance.toString()})',
|
||||||
.display3
|
style: TextStyle(
|
||||||
.backgroundColor,
|
fontSize: 12,
|
||||||
height: 1),
|
fontWeight: FontWeight.w600,
|
||||||
maxLines: 1,
|
color: Theme.of(context)
|
||||||
textAlign: TextAlign.center);
|
.accentTextTheme
|
||||||
}),
|
.display2
|
||||||
SizedBox(height: 10),
|
.backgroundColor,
|
||||||
Observer(builder: (_) {
|
height: 1),
|
||||||
return Text(dashboardViewModel.balanceViewModel.fiatBalance,
|
);
|
||||||
style: TextStyle(
|
}),
|
||||||
fontSize: 18,
|
SizedBox(height: 10),
|
||||||
fontWeight: FontWeight.w500,
|
Observer(builder: (_) {
|
||||||
color: Theme.of(context).indicatorColor,
|
return AutoSizeText(
|
||||||
height: 1),
|
dashboardViewModel.balanceViewModel.additionalBalance
|
||||||
textAlign: TextAlign.center);
|
.toString(),
|
||||||
}),
|
style: TextStyle(
|
||||||
],
|
fontSize: 18,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
));
|
color: Theme.of(context)
|
||||||
|
.accentTextTheme
|
||||||
|
.display3
|
||||||
|
.backgroundColor,
|
||||||
|
height: 1),
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.center);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:cake_wallet/entities/sync_status.dart';
|
import 'package:cake_wallet/entities/sync_status.dart';
|
||||||
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||||
import 'package:dotted_border/dotted_border.dart';
|
import 'package:dotted_border/dotted_border.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -183,9 +184,30 @@ class ExchangePage extends BasePage {
|
||||||
isAmountEstimated: false,
|
isAmountEstimated: false,
|
||||||
hasRefundAddress: true,
|
hasRefundAddress: true,
|
||||||
currencies: CryptoCurrency.all,
|
currencies: CryptoCurrency.all,
|
||||||
onCurrencySelected: (currency) =>
|
onCurrencySelected: (currency) {
|
||||||
exchangeViewModel.changeDepositCurrency(
|
// FIXME: need to move it into view model
|
||||||
currency: currency),
|
if (currency == CryptoCurrency.xmr &&
|
||||||
|
exchangeViewModel.wallet.type ==
|
||||||
|
WalletType.bitcoin) {
|
||||||
|
showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialogContext) {
|
||||||
|
return AlertWithOneAction(
|
||||||
|
alertTitle: S.of(context).error,
|
||||||
|
alertContent: S
|
||||||
|
.of(context)
|
||||||
|
.exchange_incorrect_current_wallet_for_xmr,
|
||||||
|
buttonText: S.of(context).ok,
|
||||||
|
buttonAction: () =>
|
||||||
|
Navigator.of(dialogContext)
|
||||||
|
.pop());
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
exchangeViewModel.changeDepositCurrency(
|
||||||
|
currency: currency);
|
||||||
|
},
|
||||||
imageArrow: arrowBottomPurple,
|
imageArrow: arrowBottomPurple,
|
||||||
currencyButtonColor: Colors.transparent,
|
currencyButtonColor: Colors.transparent,
|
||||||
addressButtonsColor:
|
addressButtonsColor:
|
||||||
|
|
|
@ -235,33 +235,40 @@ class ExchangeCardState extends State<ExchangeCard> {
|
||||||
)),
|
)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 5),
|
padding: EdgeInsets.only(top: 5),
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: <
|
child: Container(
|
||||||
Widget>[
|
height: 15,
|
||||||
_min != null
|
child: Row(
|
||||||
? Text(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
S.of(context).min_value(_min, _selectedCurrency.toString()),
|
children: <Widget>[
|
||||||
style: TextStyle(
|
_min != null
|
||||||
fontSize: 10,
|
? Text(
|
||||||
height: 1.2,
|
S
|
||||||
color: Theme.of(context)
|
.of(context)
|
||||||
.accentTextTheme
|
.min_value(_min, _selectedCurrency.toString()),
|
||||||
.display4
|
style: TextStyle(
|
||||||
.decorationColor),
|
fontSize: 10,
|
||||||
)
|
height: 1.2,
|
||||||
: Offstage(),
|
color: Theme.of(context)
|
||||||
_min != null ? SizedBox(width: 10) : Offstage(),
|
.accentTextTheme
|
||||||
_max != null
|
.display4
|
||||||
? Text(
|
.decorationColor),
|
||||||
S.of(context).max_value(_max, _selectedCurrency.toString()),
|
)
|
||||||
style: TextStyle(
|
: Offstage(),
|
||||||
fontSize: 10,
|
_min != null ? SizedBox(width: 10) : Offstage(),
|
||||||
height: 1.2,
|
_max != null
|
||||||
color: Theme.of(context)
|
? Text(
|
||||||
.accentTextTheme
|
S
|
||||||
.display4
|
.of(context)
|
||||||
.decorationColor))
|
.max_value(_max, _selectedCurrency.toString()),
|
||||||
: Offstage(),
|
style: TextStyle(
|
||||||
]),
|
fontSize: 10,
|
||||||
|
height: 1.2,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.accentTextTheme
|
||||||
|
.display4
|
||||||
|
.decorationColor))
|
||||||
|
: Offstage(),
|
||||||
|
])),
|
||||||
),
|
),
|
||||||
!_isAddressEditable && widget.hasRefundAddress
|
!_isAddressEditable && widget.hasRefundAddress
|
||||||
? Padding(
|
? Padding(
|
||||||
|
|
|
@ -54,7 +54,7 @@ class QRWidget extends StatelessWidget {
|
||||||
]),
|
]),
|
||||||
isAmountFieldShow
|
isAmountFieldShow
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: EdgeInsets.only(top: 60),
|
padding: EdgeInsets.only(top: 40),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/core/wallet_base.dart';
|
import 'package:cake_wallet/core/wallet_base.dart';
|
||||||
import 'package:cake_wallet/store/wallet_list_store.dart';
|
import 'package:cake_wallet/store/wallet_list_store.dart';
|
||||||
|
@ -19,7 +20,7 @@ abstract class AppStoreBase with Store {
|
||||||
AuthenticationStore authenticationStore;
|
AuthenticationStore authenticationStore;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
WalletBase wallet;
|
WalletBase<Balance> wallet;
|
||||||
|
|
||||||
WalletListStore walletList;
|
WalletListStore walletList;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_balance.dart';
|
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||||
import 'package:cake_wallet/core/wallet_base.dart';
|
import 'package:cake_wallet/core/wallet_base.dart';
|
||||||
import 'package:cake_wallet/entities/balance.dart';
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||||
import 'package:cake_wallet/monero/monero_balance.dart';
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||||
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||||
import 'package:cake_wallet/entities/calculate_fiat_amount.dart';
|
import 'package:cake_wallet/entities/calculate_fiat_amount.dart';
|
||||||
import 'package:cake_wallet/store/app_store.dart';
|
import 'package:cake_wallet/store/app_store.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/wallet_balance.dart';
|
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -51,8 +50,7 @@ abstract class BalanceViewModelBase with Store {
|
||||||
final SettingsStore settingsStore;
|
final SettingsStore settingsStore;
|
||||||
final FiatConversionStore fiatConvertationStore;
|
final FiatConversionStore fiatConvertationStore;
|
||||||
|
|
||||||
bool get canReverse =>
|
bool get canReverse => false;
|
||||||
(appStore.wallet.balance.availableModes as List).length > 1;
|
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
bool isReversing;
|
bool isReversing;
|
||||||
|
@ -61,7 +59,7 @@ abstract class BalanceViewModelBase with Store {
|
||||||
Balance balance;
|
Balance balance;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
WalletBase wallet;
|
WalletBase<Balance> wallet;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
double get price => fiatConvertationStore.prices[appStore.wallet.currency];
|
double get price => fiatConvertationStore.prices[appStore.wallet.currency];
|
||||||
|
@ -77,63 +75,80 @@ abstract class BalanceViewModelBase with Store {
|
||||||
: savedDisplayMode;
|
: savedDisplayMode;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
String get cryptoBalance {
|
String get availableBalanceLabel {
|
||||||
final walletBalance = _walletBalance;
|
if (wallet.type == WalletType.monero) {
|
||||||
var _balance = '---';
|
return S.current.xmr_available_balance;
|
||||||
|
|
||||||
if (displayMode == BalanceDisplayMode.availableBalance) {
|
|
||||||
_balance = walletBalance.unlockedBalance ?? '0.0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayMode == BalanceDisplayMode.fullBalance) {
|
return S.current.confirmed;
|
||||||
_balance = walletBalance.totalBalance ?? '0.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return _balance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
String get fiatBalance {
|
String get additionalBalanceLabel {
|
||||||
|
if (wallet.type == WalletType.monero) {
|
||||||
|
return S.current.xmr_full_balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S.current.unconfirmed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
String get availableBalance {
|
||||||
|
final walletBalance = _walletBalance;
|
||||||
|
|
||||||
|
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
|
||||||
|
return '---';
|
||||||
|
}
|
||||||
|
|
||||||
|
return walletBalance.formattedAvailableBalance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
String get additionalBalance {
|
||||||
|
final walletBalance = _walletBalance;
|
||||||
|
|
||||||
|
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
|
||||||
|
return '---';
|
||||||
|
}
|
||||||
|
|
||||||
|
return walletBalance.formattedAdditionalBalance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
String get availableFiatBalance {
|
||||||
final walletBalance = _walletBalance;
|
final walletBalance = _walletBalance;
|
||||||
final fiatCurrency = settingsStore.fiatCurrency;
|
final fiatCurrency = settingsStore.fiatCurrency;
|
||||||
var _balance = '---';
|
|
||||||
|
|
||||||
final totalBalance =
|
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
|
||||||
_getFiatBalance(price: price, cryptoAmount: walletBalance.totalBalance);
|
return '---';
|
||||||
|
|
||||||
final unlockedBalance = _getFiatBalance(
|
|
||||||
price: price, cryptoAmount: walletBalance.unlockedBalance);
|
|
||||||
|
|
||||||
if (displayMode == BalanceDisplayMode.availableBalance) {
|
|
||||||
_balance = fiatCurrency.toString() + ' ' + unlockedBalance ?? '0.00';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayMode == BalanceDisplayMode.fullBalance) {
|
return fiatCurrency.toString() +
|
||||||
_balance = fiatCurrency.toString() + ' ' + totalBalance ?? '0.00';
|
' ' +
|
||||||
}
|
_getFiatBalance(
|
||||||
|
price: price,
|
||||||
return _balance;
|
cryptoAmount: walletBalance.formattedAvailableBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
WalletBalance get _walletBalance {
|
String get additionalFiatBalance {
|
||||||
final _balance = balance;
|
final walletBalance = _walletBalance;
|
||||||
|
final fiatCurrency = settingsStore.fiatCurrency;
|
||||||
|
|
||||||
if (_balance is MoneroBalance) {
|
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
|
||||||
return WalletBalance(
|
return '---';
|
||||||
unlockedBalance: _balance.formattedUnlockedBalance,
|
|
||||||
totalBalance: _balance.formattedFullBalance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_balance is BitcoinBalance) {
|
return fiatCurrency.toString() +
|
||||||
return WalletBalance(
|
' ' +
|
||||||
unlockedBalance: _balance.availableBalanceFormatted,
|
_getFiatBalance(
|
||||||
totalBalance: _balance.totalFormatted);
|
price: price,
|
||||||
}
|
cryptoAmount: walletBalance.formattedAdditionalBalance);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
Balance get _walletBalance => wallet.balance;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
CryptoCurrency get currency => appStore.wallet.currency;
|
CryptoCurrency get currency => appStore.wallet.currency;
|
||||||
|
|
||||||
|
@ -141,24 +156,14 @@ abstract class BalanceViewModelBase with Store {
|
||||||
ReactionDisposer _reaction;
|
ReactionDisposer _reaction;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void _onWalletChange(WalletBase wallet) {
|
void _onWalletChange(WalletBase<Balance> wallet) {
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
|
|
||||||
if (wallet is MoneroWallet) {
|
balance = wallet.balance;
|
||||||
balance = wallet.balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wallet is BitcoinWallet) {
|
|
||||||
balance = wallet.balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||||
_onCurrentWalletChangeReaction =
|
_onCurrentWalletChangeReaction = reaction<Balance>(
|
||||||
reaction<void>((_) => wallet.balance, (dynamic balance) {
|
(_) => wallet.balance, (Balance balance) => this.balance = balance);
|
||||||
if (balance is Balance) {
|
|
||||||
this.balance = balance;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getFiatBalance({double price, String cryptoAmount}) {
|
String _getFiatBalance({double price, String cryptoAmount}) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:cake_wallet/entities/transaction_history.dart';
|
import 'package:cake_wallet/entities/transaction_history.dart';
|
||||||
import 'package:cake_wallet/monero/account.dart';
|
import 'package:cake_wallet/monero/account.dart';
|
||||||
import 'package:cake_wallet/monero/monero_balance.dart';
|
import 'package:cake_wallet/monero/monero_balance.dart';
|
||||||
|
@ -184,7 +185,7 @@ abstract class DashboardViewModelBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
WalletBase wallet;
|
WalletBase<Balance> wallet;
|
||||||
|
|
||||||
bool get hasRescan => wallet.type == WalletType.monero;
|
bool get hasRescan => wallet.type == WalletType.monero;
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ abstract class DashboardViewModelBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void _onWalletChange(WalletBase wallet) {
|
void _onWalletChange(WalletBase<Balance> wallet) {
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
type = wallet.type;
|
type = wallet.type;
|
||||||
name = wallet.name;
|
name = wallet.name;
|
||||||
|
|
|
@ -301,7 +301,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
@action
|
@action
|
||||||
void calculateDepositAllAmount() {
|
void calculateDepositAllAmount() {
|
||||||
if (wallet is BitcoinWallet) {
|
if (wallet is BitcoinWallet) {
|
||||||
final availableBalance = wallet.balance.availableBalance as int;
|
final availableBalance = wallet.balance.available;
|
||||||
final fee = BitcoinWalletBase.feeAmountForPriority(
|
final fee = BitcoinWalletBase.feeAmountForPriority(
|
||||||
_settingsStore.transactionPriority);
|
_settingsStore.transactionPriority);
|
||||||
|
|
||||||
|
|
|
@ -134,9 +134,7 @@ abstract class SendViewModelBase with Store {
|
||||||
PendingTransaction pendingTransaction;
|
PendingTransaction pendingTransaction;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
String get balance =>
|
String get balance => _wallet.balance.formattedAvailableBalance ?? '0.0';
|
||||||
_wallet.balance.formattedBalance(BalanceDisplayMode.availableBalance)
|
|
||||||
as String ?? '0.0';
|
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
||||||
|
@ -183,11 +181,12 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
if (pendingTransaction.id?.isNotEmpty ?? false) {
|
if (pendingTransaction.id?.isNotEmpty ?? false) {
|
||||||
_settingsStore.shouldSaveRecipientAddress
|
_settingsStore.shouldSaveRecipientAddress
|
||||||
? await transactionDescriptionBox.add(TransactionDescription(
|
? await transactionDescriptionBox.add(TransactionDescription(
|
||||||
id: pendingTransaction.id, recipientAddress: address,
|
id: pendingTransaction.id,
|
||||||
transactionNote: note))
|
recipientAddress: address,
|
||||||
: await transactionDescriptionBox.add(TransactionDescription(
|
transactionNote: note))
|
||||||
id: pendingTransaction.id, transactionNote: note));
|
: await transactionDescriptionBox.add(TransactionDescription(
|
||||||
|
id: pendingTransaction.id, transactionNote: note));
|
||||||
}
|
}
|
||||||
|
|
||||||
state = TransactionCommitted();
|
state = TransactionCommitted();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
import 'package:cake_wallet/themes/theme_list.dart';
|
import 'package:cake_wallet/themes/theme_list.dart';
|
||||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||||
|
@ -28,7 +29,7 @@ part 'settings_view_model.g.dart';
|
||||||
class SettingsViewModel = SettingsViewModelBase with _$SettingsViewModel;
|
class SettingsViewModel = SettingsViewModelBase with _$SettingsViewModel;
|
||||||
|
|
||||||
abstract class SettingsViewModelBase with Store {
|
abstract class SettingsViewModelBase with Store {
|
||||||
SettingsViewModelBase(this._settingsStore, WalletBase wallet)
|
SettingsViewModelBase(this._settingsStore, WalletBase<Balance> wallet)
|
||||||
: itemHeaders = {},
|
: itemHeaders = {},
|
||||||
_walletType = wallet.type,
|
_walletType = wallet.type,
|
||||||
_biometricAuth = BiometricAuth() {
|
_biometricAuth = BiometricAuth() {
|
||||||
|
@ -45,13 +46,12 @@ abstract class SettingsViewModelBase with Store {
|
||||||
|
|
||||||
sections = [
|
sections = [
|
||||||
[
|
[
|
||||||
if ((wallet.balance.availableModes as List).length > 1)
|
PickerListItem(
|
||||||
PickerListItem(
|
title: S.current.settings_display_balance_as,
|
||||||
title: S.current.settings_display_balance_as,
|
items: BalanceDisplayMode.all,
|
||||||
items: BalanceDisplayMode.all,
|
selectedItem: () => balanceDisplayMode,
|
||||||
selectedItem: () => balanceDisplayMode,
|
onItemSelected: (BalanceDisplayMode mode) =>
|
||||||
onItemSelected: (BalanceDisplayMode mode) =>
|
_settingsStore.balanceDisplayMode = mode),
|
||||||
_settingsStore.balanceDisplayMode = mode),
|
|
||||||
PickerListItem(
|
PickerListItem(
|
||||||
title: S.current.settings_currency,
|
title: S.current.settings_currency,
|
||||||
items: FiatCurrency.all,
|
items: FiatCurrency.all,
|
||||||
|
@ -120,7 +120,7 @@ abstract class SettingsViewModelBase with Store {
|
||||||
items: ThemeList.all,
|
items: ThemeList.all,
|
||||||
selectedItem: () => theme,
|
selectedItem: () => theme,
|
||||||
onItemSelected: (ThemeBase theme) =>
|
onItemSelected: (ThemeBase theme) =>
|
||||||
_settingsStore.currentTheme = theme)
|
_settingsStore.currentTheme = theme)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
LinkListItem(
|
LinkListItem(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/balance.dart';
|
||||||
import 'package:cake_wallet/store/app_store.dart';
|
import 'package:cake_wallet/store/app_store.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
@ -60,7 +61,7 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||||
_appStore = appStore;
|
_appStore = appStore;
|
||||||
_wallet = _appStore.wallet;
|
_wallet = _appStore.wallet;
|
||||||
hasAccounts = _wallet?.type == WalletType.monero;
|
hasAccounts = _wallet?.type == WalletType.monero;
|
||||||
_onWalletChangeReaction = reaction((_) => _appStore.wallet, (WalletBase wallet) {
|
_onWalletChangeReaction = reaction((_) => _appStore.wallet, (WalletBase<Balance> wallet) {
|
||||||
_wallet = wallet;
|
_wallet = wallet;
|
||||||
hasAccounts = _wallet.type == WalletType.monero;
|
hasAccounts = _wallet.type == WalletType.monero;
|
||||||
});
|
});
|
||||||
|
@ -145,7 +146,7 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||||
bool get hasAddressList => _wallet.type == WalletType.monero;
|
bool get hasAddressList => _wallet.type == WalletType.monero;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
WalletBase _wallet;
|
WalletBase<Balance> _wallet;
|
||||||
|
|
||||||
List<ListItem> _baseItems;
|
List<ListItem> _baseItems;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue