mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CAKE-345 | added monero_output.dart to the app; fixed transaction_history.dart; renamed SendItem on Output; calculated formattedCryptoAmount in the output.dart; used outputs list instead sendItemList; fixed bitcoin_transaction_credentials.dart, electrum_wallet.dart, monero_transaction_creation_credentials.dart, monero_wallet.dart, exchange and send pages, view models
This commit is contained in:
@@ -385,8 +385,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
.pendingTransactionFiatAmount +
|
||||
' ' +
|
||||
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
|
||||
sendItemList: widget.exchangeTradeViewModel.sendViewModel
|
||||
.sendItemList);
|
||||
outputs: widget.exchangeTradeViewModel.sendViewModel
|
||||
.outputs);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:cake_wallet/src/screens/send/widgets/parse_address_from_domain_a
|
||||
import 'package:cake_wallet/src/screens/send/widgets/send_card.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_item.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
@@ -55,16 +55,16 @@ class SendPage extends BasePage {
|
||||
onPressed: () {
|
||||
var pageToJump = controller.page.round() - 1;
|
||||
pageToJump = pageToJump > 0 ? pageToJump : 0;
|
||||
final item = _defineCurrentSendItem();
|
||||
sendViewModel.removeSendItem(item);
|
||||
final output = _defineCurrentOutput();
|
||||
sendViewModel.removeOutput(output);
|
||||
controller.jumpToPage(pageToJump);
|
||||
})
|
||||
: TrailButton(
|
||||
caption: S.of(context).clear,
|
||||
onPressed: () {
|
||||
final item = _defineCurrentSendItem();
|
||||
final output = _defineCurrentOutput();
|
||||
_formKey.currentState.reset();
|
||||
item.reset();
|
||||
output.reset();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,13 +85,13 @@ class SendPage extends BasePage {
|
||||
return PageView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: controller,
|
||||
itemCount: sendViewModel.sendItemList.length,
|
||||
itemCount: sendViewModel.outputs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = sendViewModel.sendItemList[index];
|
||||
final output = sendViewModel.outputs[index];
|
||||
|
||||
return SendCard(
|
||||
key: item.key,
|
||||
item: item,
|
||||
key: output.key,
|
||||
output: output,
|
||||
sendViewModel: sendViewModel,
|
||||
);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class SendPage extends BasePage {
|
||||
child: Container(
|
||||
height: 10,
|
||||
child: Observer(builder: (_) {
|
||||
final count = sendViewModel.sendItemList.length;
|
||||
final count = sendViewModel.outputs.length;
|
||||
|
||||
return count > 1
|
||||
? SmoothPageIndicator(
|
||||
@@ -211,11 +211,11 @@ class SendPage extends BasePage {
|
||||
amount: template.amount,
|
||||
from: template.cryptoCurrency,
|
||||
onTap: () async {
|
||||
final item = _defineCurrentSendItem();
|
||||
item.address =
|
||||
final output = _defineCurrentOutput();
|
||||
output.address =
|
||||
template.address;
|
||||
item.setCryptoAmount(template.amount);
|
||||
final parsedAddress = await item
|
||||
output.setCryptoAmount(template.amount);
|
||||
final parsedAddress = await output
|
||||
.applyOpenaliasOrUnstoppableDomains();
|
||||
showAddressAlert(context, parsedAddress);
|
||||
},
|
||||
@@ -263,7 +263,7 @@ class SendPage extends BasePage {
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () {
|
||||
sendViewModel.addSendItem();
|
||||
sendViewModel.addOutput();
|
||||
},
|
||||
text: S.of(context).add_receiver,
|
||||
color: Colors.green,
|
||||
@@ -274,16 +274,16 @@ class SendPage extends BasePage {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () async {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
if (sendViewModel.sendItemList.length > 1) {
|
||||
if (sendViewModel.outputs.length > 1) {
|
||||
showErrorValidationAlert(context);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final notValidItems = sendViewModel.sendItemList
|
||||
final notValidItems = sendViewModel.outputs
|
||||
.where((item) =>
|
||||
item.address.isEmpty || item.cryptoAmount.isEmpty)
|
||||
item.address.isEmpty || item.cryptoAmount.isEmpty)
|
||||
.toList();
|
||||
|
||||
if (notValidItems?.isNotEmpty ?? false) {
|
||||
@@ -343,7 +343,7 @@ class SendPage extends BasePage {
|
||||
feeValue: sendViewModel.pendingTransaction.feeFormatted,
|
||||
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmount
|
||||
+ ' ' + sendViewModel.fiat.title,
|
||||
sendItemList: sendViewModel.sendItemList,
|
||||
outputs: sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
@@ -381,7 +381,7 @@ class SendPage extends BasePage {
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
sendViewModel.clearSendItemList();
|
||||
sendViewModel.clearOutputs();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -389,9 +389,9 @@ class SendPage extends BasePage {
|
||||
_effectsInstalled = true;
|
||||
}
|
||||
|
||||
SendItem _defineCurrentSendItem() {
|
||||
Output _defineCurrentOutput() {
|
||||
final itemCount = controller.page.round();
|
||||
return sendViewModel.sendItemList[itemCount];
|
||||
return sendViewModel.outputs[itemCount];
|
||||
}
|
||||
|
||||
void showErrorValidationAlert(BuildContext context) async {
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
|
||||
class SendTemplatePage extends BasePage {
|
||||
SendTemplatePage({@required this.sendTemplateViewModel}) {
|
||||
sendTemplateViewModel.sendItem.reset();
|
||||
sendTemplateViewModel.output.reset();
|
||||
}
|
||||
|
||||
final SendTemplateViewModel sendTemplateViewModel;
|
||||
@@ -258,21 +258,21 @@ class SendTemplatePage extends BasePage {
|
||||
return;
|
||||
}
|
||||
|
||||
final item = sendTemplateViewModel.sendItem;
|
||||
final output = sendTemplateViewModel.output;
|
||||
|
||||
reaction((_) => item.fiatAmount, (String amount) {
|
||||
reaction((_) => output.fiatAmount, (String amount) {
|
||||
if (amount != _fiatAmountController.text) {
|
||||
_fiatAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.cryptoAmount, (String amount) {
|
||||
reaction((_) => output.cryptoAmount, (String amount) {
|
||||
if (amount != _cryptoAmountController.text) {
|
||||
_cryptoAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.address, (String address) {
|
||||
reaction((_) => output.address, (String address) {
|
||||
if (address != _addressController.text) {
|
||||
_addressController.text = address;
|
||||
}
|
||||
@@ -281,24 +281,24 @@ class SendTemplatePage extends BasePage {
|
||||
_cryptoAmountController.addListener(() {
|
||||
final amount = _cryptoAmountController.text;
|
||||
|
||||
if (amount != item.cryptoAmount) {
|
||||
item.setCryptoAmount(amount);
|
||||
if (amount != output.cryptoAmount) {
|
||||
output.setCryptoAmount(amount);
|
||||
}
|
||||
});
|
||||
|
||||
_fiatAmountController.addListener(() {
|
||||
final amount = _fiatAmountController.text;
|
||||
|
||||
if (amount != item.fiatAmount) {
|
||||
item.setFiatAmount(amount);
|
||||
if (amount != output.fiatAmount) {
|
||||
output.setFiatAmount(amount);
|
||||
}
|
||||
});
|
||||
|
||||
_addressController.addListener(() {
|
||||
final address = _addressController.text;
|
||||
|
||||
if (item.address != address) {
|
||||
item.address = address;
|
||||
if (output.address != address) {
|
||||
output.address = address;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_item.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
@@ -13,14 +13,14 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
@required this.fee,
|
||||
@required this.feeValue,
|
||||
@required this.feeFiatAmount,
|
||||
@required this.sendItemList,
|
||||
@required this.outputs,
|
||||
@required this.leftButtonText,
|
||||
@required this.rightButtonText,
|
||||
@required this.actionLeftButton,
|
||||
@required this.actionRightButton,
|
||||
this.alertBarrierDismissible = true
|
||||
}) {
|
||||
itemCount = sendItemList.length;
|
||||
itemCount = outputs.length;
|
||||
recipientTitle = itemCount > 1
|
||||
? S.current.transaction_details_recipient_address
|
||||
: S.current.recipient_address;
|
||||
@@ -33,7 +33,7 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
final String fee;
|
||||
final String feeValue;
|
||||
final String feeFiatAmount;
|
||||
final List<SendItem> sendItemList;
|
||||
final List<Output> outputs;
|
||||
final String leftButtonText;
|
||||
final String rightButtonText;
|
||||
final VoidCallback actionLeftButton;
|
||||
@@ -179,10 +179,10 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
final item = sendItemList[index];
|
||||
final item = outputs[index];
|
||||
final _address = item.address;
|
||||
final _amount =
|
||||
item.cryptoAmount.replaceAll(',', '.');
|
||||
item.cryptoAmount.replaceAll(',', '.');
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -225,7 +225,7 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
: Padding(
|
||||
padding: EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
sendItemList.first.address,
|
||||
outputs.first.address,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/parse_address_from_domain_alert.dart';
|
||||
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_item.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -19,21 +19,21 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
||||
class SendCard extends StatefulWidget {
|
||||
SendCard({Key key, @required this.item, @required this.sendViewModel}) : super(key: key);
|
||||
SendCard({Key key, @required this.output, @required this.sendViewModel}) : super(key: key);
|
||||
|
||||
final SendItem item;
|
||||
final Output output;
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
@override
|
||||
SendCardState createState() => SendCardState(
|
||||
item: item,
|
||||
output: output,
|
||||
sendViewModel: sendViewModel
|
||||
);
|
||||
}
|
||||
|
||||
class SendCardState extends State<SendCard>
|
||||
with AutomaticKeepAliveClientMixin<SendCard> {
|
||||
SendCardState({@required this.item, @required this.sendViewModel})
|
||||
SendCardState({@required this.output, @required this.sendViewModel})
|
||||
: addressController = TextEditingController(),
|
||||
cryptoAmountController = TextEditingController(),
|
||||
fiatAmountController = TextEditingController(),
|
||||
@@ -45,7 +45,7 @@ class SendCardState extends State<SendCard>
|
||||
static const prefixIconWidth = 34.0;
|
||||
static const prefixIconHeight = 34.0;
|
||||
|
||||
final SendItem item;
|
||||
final Output output;
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
final TextEditingController addressController;
|
||||
@@ -143,7 +143,7 @@ class SendCardState extends State<SendCard>
|
||||
.decorationColor),
|
||||
onPushPasteButton: (context) async {
|
||||
final parsedAddress =
|
||||
await item.applyOpenaliasOrUnstoppableDomains();
|
||||
await output.applyOpenaliasOrUnstoppableDomains();
|
||||
showAddressAlert(context, parsedAddress);
|
||||
},
|
||||
validator: sendViewModel.addressValidator,
|
||||
@@ -189,7 +189,7 @@ class SendCardState extends State<SendCard>
|
||||
.decorationColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator: item.sendAll
|
||||
validator: output.sendAll
|
||||
? sendViewModel.allAmountValidator
|
||||
: sendViewModel
|
||||
.amountValidator),
|
||||
@@ -201,7 +201,7 @@ class SendCardState extends State<SendCard>
|
||||
height: prefixIconHeight,
|
||||
child: InkWell(
|
||||
onTap: () async =>
|
||||
item.setSendAll(),
|
||||
output.setSendAll(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
@@ -349,7 +349,7 @@ class SendCardState extends State<SendCard>
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
item
|
||||
output
|
||||
.estimatedFee
|
||||
.toString() +
|
||||
' ' +
|
||||
@@ -366,7 +366,7 @@ class SendCardState extends State<SendCard>
|
||||
padding:
|
||||
EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
item
|
||||
output
|
||||
.estimatedFeeFiatAmount
|
||||
+ ' ' +
|
||||
sendViewModel
|
||||
@@ -435,10 +435,10 @@ class SendCardState extends State<SendCard>
|
||||
}
|
||||
|
||||
void _setEffects(BuildContext context) {
|
||||
addressController.text = item.address;
|
||||
cryptoAmountController.text = item.cryptoAmount;
|
||||
fiatAmountController.text = item.fiatAmount;
|
||||
noteController.text = item.note;
|
||||
addressController.text = output.address;
|
||||
cryptoAmountController.text = output.cryptoAmount;
|
||||
fiatAmountController.text = output.fiatAmount;
|
||||
noteController.text = output.note;
|
||||
|
||||
if (_effectsInstalled) {
|
||||
return;
|
||||
@@ -447,48 +447,48 @@ class SendCardState extends State<SendCard>
|
||||
cryptoAmountController.addListener(() {
|
||||
final amount = cryptoAmountController.text;
|
||||
|
||||
if (item.sendAll && amount != S.current.all) {
|
||||
item.sendAll = false;
|
||||
if (output.sendAll && amount != S.current.all) {
|
||||
output.sendAll = false;
|
||||
}
|
||||
|
||||
if (amount != item.cryptoAmount) {
|
||||
item.setCryptoAmount(amount);
|
||||
if (amount != output.cryptoAmount) {
|
||||
output.setCryptoAmount(amount);
|
||||
}
|
||||
});
|
||||
|
||||
fiatAmountController.addListener(() {
|
||||
final amount = fiatAmountController.text;
|
||||
|
||||
if (amount != item.fiatAmount) {
|
||||
item.sendAll = false;
|
||||
item.setFiatAmount(amount);
|
||||
if (amount != output.fiatAmount) {
|
||||
output.sendAll = false;
|
||||
output.setFiatAmount(amount);
|
||||
}
|
||||
});
|
||||
|
||||
noteController.addListener(() {
|
||||
final note = noteController.text ?? '';
|
||||
|
||||
if (note != item.note) {
|
||||
item.note = note;
|
||||
if (note != output.note) {
|
||||
output.note = note;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.sendAll, (bool all) {
|
||||
reaction((_) => output.sendAll, (bool all) {
|
||||
if (all) {
|
||||
cryptoAmountController.text = S.current.all;
|
||||
fiatAmountController.text = null;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.fiatAmount, (String amount) {
|
||||
reaction((_) => output.fiatAmount, (String amount) {
|
||||
if (amount != fiatAmountController.text) {
|
||||
fiatAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.cryptoAmount, (String amount) {
|
||||
if (item.sendAll && amount != S.current.all) {
|
||||
item.sendAll = false;
|
||||
reaction((_) => output.cryptoAmount, (String amount) {
|
||||
if (output.sendAll && amount != S.current.all) {
|
||||
output.sendAll = false;
|
||||
}
|
||||
|
||||
if (amount != cryptoAmountController.text) {
|
||||
@@ -496,7 +496,7 @@ class SendCardState extends State<SendCard>
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.address, (String address) {
|
||||
reaction((_) => output.address, (String address) {
|
||||
if (address != addressController.text) {
|
||||
addressController.text = address;
|
||||
}
|
||||
@@ -505,12 +505,12 @@ class SendCardState extends State<SendCard>
|
||||
addressController.addListener(() {
|
||||
final address = addressController.text;
|
||||
|
||||
if (item.address != address) {
|
||||
item.address = address;
|
||||
if (output.address != address) {
|
||||
output.address = address;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => item.note, (String note) {
|
||||
reaction((_) => output.note, (String note) {
|
||||
if (note != noteController.text) {
|
||||
noteController.text = note;
|
||||
}
|
||||
@@ -518,7 +518,7 @@ class SendCardState extends State<SendCard>
|
||||
|
||||
addressFocusNode.addListener(() async {
|
||||
if (!addressFocusNode.hasFocus && addressController.text.isNotEmpty) {
|
||||
final parsedAddress = await item.applyOpenaliasOrUnstoppableDomains();
|
||||
final parsedAddress = await output.applyOpenaliasOrUnstoppableDomains();
|
||||
showAddressAlert(context, parsedAddress);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user