Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-20-rework-templates-on-exchange-screen

This commit is contained in:
Godwin Asuquo 2022-01-31 14:20:40 +01:00
commit 26f108ceb6
11 changed files with 98 additions and 45 deletions

View file

@ -42,4 +42,11 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
</manifest> </manifest>

View file

@ -1,5 +1,4 @@
import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/transaction_direction.dart';
//import 'package:cake_wallet/utils/mobx.dart';
import 'package:cw_core/keyable.dart'; import 'package:cw_core/keyable.dart';
abstract class TransactionInfo extends Object with Keyable { abstract class TransactionInfo extends Object with Keyable {
@ -18,4 +17,6 @@ abstract class TransactionInfo extends Object with Keyable {
@override @override
dynamic get keyIndex => id; dynamic get keyIndex => id;
Map<String, dynamic> additionalInfo;
} }

View file

@ -23,7 +23,13 @@ class MoneroTransactionInfo extends TransactionInfo {
accountIndex = int.parse(map['accountIndex'] as String), accountIndex = int.parse(map['accountIndex'] as String),
addressIndex = map['addressIndex'] as int, addressIndex = map['addressIndex'] as int,
key = getTxKey((map['hash'] ?? '') as String), key = getTxKey((map['hash'] ?? '') as String),
fee = map['fee'] as int ?? 0; fee = map['fee'] as int ?? 0 {
additionalInfo = {
'key': key,
'accountIndex': accountIndex,
'addressIndex': addressIndex
};
}
MoneroTransactionInfo.fromRow(TransactionInfoRow row) MoneroTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(), : id = row.getHash(),
@ -36,7 +42,13 @@ class MoneroTransactionInfo extends TransactionInfo {
accountIndex = row.subaddrAccount, accountIndex = row.subaddrAccount,
addressIndex = row.subaddrIndex, addressIndex = row.subaddrIndex,
key = getTxKey(row.getHash()), key = getTxKey(row.getHash()),
fee = row.fee; fee = row.fee {
additionalInfo = {
'key': key,
'accountIndex': accountIndex,
'addressIndex': addressIndex
};
}
final String id; final String id;
final int height; final int height;

View file

@ -288,4 +288,9 @@ class CWMonero extends Monero {
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource) { WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource) {
return MoneroWalletService(walletInfoSource); return MoneroWalletService(walletInfoSource);
} }
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
final moneroWallet = wallet as MoneroWallet;
return moneroWallet.getTransactionAddress(accountIndex, addressIndex);
}
} }

View file

@ -3,9 +3,13 @@ import 'package:cake_wallet/exchange/exchange_provider.dart';
import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:keyboard_actions/keyboard_actions_config.dart';
import 'package:keyboard_actions/keyboard_actions_item.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
@ -28,6 +32,8 @@ class ExchangeTemplatePage extends BasePage {
final depositKey = GlobalKey<ExchangeCardState>(); final depositKey = GlobalKey<ExchangeCardState>();
final receiveKey = GlobalKey<ExchangeCardState>(); final receiveKey = GlobalKey<ExchangeCardState>();
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
final _depositAmountFocus = FocusNode();
final _receiveAmountFocus = FocusNode();
var _isReactionsSet = false; var _isReactionsSet = false;
@override @override
@ -36,9 +42,6 @@ class ExchangeTemplatePage extends BasePage {
@override @override
Color get titleColor => Colors.white; Color get titleColor => Colors.white;
@override
bool get resizeToAvoidBottomInset => false;
@override @override
bool get extendBodyBehindAppBar => true; bool get extendBodyBehindAppBar => true;
@ -74,7 +77,22 @@ class ExchangeTemplatePage extends BasePage {
WidgetsBinding.instance WidgetsBinding.instance
.addPostFrameCallback((_) => _setReactions(context, exchangeViewModel)); .addPostFrameCallback((_) => _setReactions(context, exchangeViewModel));
return Container( return KeyboardActions(
disableScroll: true,
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor:
Theme.of(context).accentTextTheme.body2.backgroundColor,
nextFocus: false,
actions: [
KeyboardActionsItem(
focusNode: _depositAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()]),
KeyboardActionsItem(
focusNode: _receiveAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()])
]),
child: Container(
color: Theme.of(context).backgroundColor, color: Theme.of(context).backgroundColor,
child: Form( child: Form(
key: _formKey, key: _formKey,
@ -121,6 +139,7 @@ class ExchangeTemplatePage extends BasePage {
padding: EdgeInsets.fromLTRB(24, 90, 24, 32), padding: EdgeInsets.fromLTRB(24, 90, 24, 32),
child: Observer( child: Observer(
builder: (_) => ExchangeCard( builder: (_) => ExchangeCard(
amountFocusNode: _depositAmountFocus,
key: depositKey, key: depositKey,
title: S.of(context).you_will_send, title: S.of(context).you_will_send,
initialCurrency: initialCurrency:
@ -160,6 +179,7 @@ class ExchangeTemplatePage extends BasePage {
padding: EdgeInsets.only(top: 29, left: 24, right: 24), padding: EdgeInsets.only(top: 29, left: 24, right: 24),
child: Observer( child: Observer(
builder: (_) => ExchangeCard( builder: (_) => ExchangeCard(
amountFocusNode: _receiveAmountFocus,
key: receiveKey, key: receiveKey,
title: S.of(context).you_will_get, title: S.of(context).you_will_get,
initialCurrency: initialCurrency:
@ -244,6 +264,7 @@ class ExchangeTemplatePage extends BasePage {
textColor: Colors.white), textColor: Colors.white),
]), ]),
)) ))
)
); );
} }

View file

@ -197,7 +197,6 @@ class SendPage extends BasePage {
itemCount: itemCount, itemCount: itemCount,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final template = templates[index]; final template = templates[index];
return TemplateTile( return TemplateTile(
key: UniqueKey(), key: UniqueKey(),
to: template.name, to: template.name,

View file

@ -29,8 +29,11 @@ part 'send_view_model.g.dart';
class SendViewModel = SendViewModelBase with _$SendViewModel; class SendViewModel = SendViewModelBase with _$SendViewModel;
abstract class SendViewModelBase with Store { abstract class SendViewModelBase with Store {
SendViewModelBase(this._wallet, this._settingsStore, SendViewModelBase(
this.sendTemplateViewModel, this._fiatConversationStore, this._wallet,
this._settingsStore,
this.sendTemplateViewModel,
this._fiatConversationStore,
this.transactionDescriptionBox) this.transactionDescriptionBox)
: state = InitialExecutionState() { : state = InitialExecutionState() {
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
@ -127,15 +130,17 @@ abstract class SendViewModelBase with Store {
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus; bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
@computed @computed
ObservableList<Template> get templates => sendTemplateViewModel.templates; List<Template> get templates => sendTemplateViewModel.templates
.where((template) => _isEqualCurrency(template.cryptoCurrency))
.toList();
@computed @computed
bool get isElectrumWallet => _wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin; bool get isElectrumWallet =>
_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
bool get hasYat bool get hasYat => outputs.any((out) =>
=> outputs.any((out) => out.isParsedAddress out.isParsedAddress &&
&& out.parsedAddress.parseFrom == ParseFrom.yatRecord); out.parsedAddress.parseFrom == ParseFrom.yatRecord);
WalletType get walletType => _wallet.type; WalletType get walletType => _wallet.type;
final WalletBase _wallet; final WalletBase _wallet;
@ -200,19 +205,16 @@ abstract class SendViewModelBase with Store {
case WalletType.bitcoin: case WalletType.bitcoin:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return bitcoin.createBitcoinTransactionCredentials( return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
outputs, priority);
case WalletType.litecoin: case WalletType.litecoin:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return bitcoin.createBitcoinTransactionCredentials( return bitcoin.createBitcoinTransactionCredentials(outputs, priority);
outputs, priority);
case WalletType.monero: case WalletType.monero:
final priority = _settingsStore.priority[_wallet.type]; final priority = _settingsStore.priority[_wallet.type];
return monero.createMoneroTransactionCreationCredentials( return monero.createMoneroTransactionCreationCredentials(
outputs: outputs, outputs: outputs, priority: priority);
priority: priority);
default: default:
return null; return null;
} }
@ -229,4 +231,7 @@ abstract class SendViewModelBase with Store {
return priority.toString(); return priority.toString();
} }
bool _isEqualCurrency(String currency) =>
currency.toLowerCase() == _wallet.currency.title.toLowerCase();
} }

View file

@ -13,6 +13,7 @@ import 'package:mobx/mobx.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:cake_wallet/monero/monero.dart';
part 'transaction_details_view_model.g.dart'; part 'transaction_details_view_model.g.dart';
@ -31,6 +32,9 @@ abstract class TransactionDetailsViewModelBase with Store {
final dateFormat = DateFormatter.withCurrentLocal(); final dateFormat = DateFormatter.withCurrentLocal();
final tx = transactionInfo; final tx = transactionInfo;
final key = tx.additionalInfo['key'] as String;
final accountIndex = tx.additionalInfo['accountIndex'] as int;
final addressIndex = tx.additionalInfo['addressIndex'] as int;
if (wallet.type == WalletType.monero) { if (wallet.type == WalletType.monero) {
final _items = [ final _items = [
@ -46,30 +50,27 @@ abstract class TransactionDetailsViewModelBase with Store {
value: tx.amountFormatted()), value: tx.amountFormatted()),
StandartListItem( StandartListItem(
title: S.current.transaction_details_fee, value: tx.feeFormatted()), title: S.current.transaction_details_fee, value: tx.feeFormatted()),
if (key?.isNotEmpty ?? false)
StandartListItem(title: S.current.transaction_key, value: key)
]; ];
//if (tx.key?.isNotEmpty ?? null) { if (tx.direction == TransactionDirection.incoming &&
// _items.add( accountIndex != null &&
// StandartListItem(title: S.current.transaction_key, value: tx.key)); addressIndex != null) {
//} try {
final address = monero.getTransactionAddress(wallet, accountIndex, addressIndex);
//if (tx.direction == TransactionDirection.incoming) { if (address?.isNotEmpty ?? false) {
// try { isRecipientAddressShown = true;
// final accountIndex = tx.accountIndex; _items.add(
// final addressIndex = tx.addressIndex; StandartListItem(
//final address = moneroUtils.getTransactionAddress(wallet, accountIndex, addressIndex); title: S.current.transaction_details_recipient_address,
value: address));
//if (address?.isNotEmpty ?? false) { }
// isRecipientAddressShown = true; } catch (e) {
// _items.add( print(e.toString());
// StandartListItem( }
// title: S.current.transaction_details_recipient_address, }
// value: address));
//}
// } catch (e) {
// print(e.toString());
// }
//}
items.addAll(_items); items.addAll(_items);
} }

View file

@ -20,7 +20,7 @@ MONERO_COM_PACKAGE="com.monero.app"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.3.5" CAKEWALLET_VERSION="4.3.5"
CAKEWALLET_BUILD_NUMBER=84 CAKEWALLET_BUILD_NUMBER=85
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet" CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet" CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"

View file

@ -18,7 +18,7 @@ MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.3.5" CAKEWALLET_VERSION="4.3.5"
CAKEWALLET_BUILD_NUMBER=78 CAKEWALLET_BUILD_NUMBER=80
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
if ! [[ " ${TYPES[*]} " =~ " ${APP_IOS_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_IOS_TYPE} " ]]; then

View file

@ -204,6 +204,8 @@ abstract class Monero {
MoneroWalletDetails getMoneroWalletDetails(Object wallet); MoneroWalletDetails getMoneroWalletDetails(Object wallet);
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
int getHeigthByDate({DateTime date}); int getHeigthByDate({DateTime date});
TransactionPriority getDefaultTransactionPriority(); TransactionPriority getDefaultTransactionPriority();
TransactionPriority deserializeMoneroTransactionPriority({int raw}); TransactionPriority deserializeMoneroTransactionPriority({int raw});