This commit is contained in:
M 2021-01-05 22:37:25 +02:00
parent 1d37aa68aa
commit 5fa0a9c912

View file

@ -13,14 +13,15 @@ import 'package:cake_wallet/generated/i18n.dart';
part 'transaction_details_view_model.g.dart'; part 'transaction_details_view_model.g.dart';
class TransactionDetailsViewModel = TransactionDetailsViewModelBase with _$TransactionDetailsViewModel; class TransactionDetailsViewModel = TransactionDetailsViewModelBase
with _$TransactionDetailsViewModel;
abstract class TransactionDetailsViewModelBase with Store { abstract class TransactionDetailsViewModelBase with Store {
TransactionDetailsViewModelBase({ TransactionDetailsViewModelBase(
this.transactionInfo, {this.transactionInfo,
this.transactionDescriptionBox, this.transactionDescriptionBox,
this.settingsStore}) : items = [] { this.settingsStore})
: items = [] {
showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false; showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false;
final dateFormat = DateFormatter.withCurrentLocal(); final dateFormat = DateFormatter.withCurrentLocal();
@ -39,14 +40,12 @@ abstract class TransactionDetailsViewModelBase with Store {
title: S.current.transaction_details_amount, title: S.current.transaction_details_amount,
value: tx.amountFormatted()), value: tx.amountFormatted()),
StandartListItem( StandartListItem(
title: S.current.transaction_details_fee, title: S.current.transaction_details_fee, value: tx.feeFormatted()),
value: tx.feeFormatted()),
]; ];
if (tx.key?.isNotEmpty ?? null) { if (tx.key?.isNotEmpty ?? null) {
_items.add(StandartListItem( _items.add(
title: S.current.transaction_key, StandartListItem(title: S.current.transaction_key, value: tx.key));
value: tx.key));
} }
items.addAll(_items); items.addAll(_items);
@ -60,7 +59,8 @@ abstract class TransactionDetailsViewModelBase with Store {
title: S.current.transaction_details_date, title: S.current.transaction_details_date,
value: dateFormat.format(tx.date)), value: dateFormat.format(tx.date)),
StandartListItem( StandartListItem(
title: S.current.confirmations, value: tx.confirmations?.toString()), title: S.current.confirmations,
value: tx.confirmations?.toString()),
StandartListItem( StandartListItem(
title: S.current.transaction_details_height, value: '${tx.height}'), title: S.current.transaction_details_height, value: '${tx.height}'),
StandartListItem( StandartListItem(
@ -88,17 +88,21 @@ abstract class TransactionDetailsViewModelBase with Store {
} }
final description = transactionDescriptionBox.values.firstWhere( final description = transactionDescriptionBox.values.firstWhere(
(val) => val.id == transactionInfo.id, orElse: () => null); (val) => val.id == transactionInfo.id,
orElse: () => TransactionDescription(id: transactionInfo.id));
if (description != null) {
items.add(TextFieldListItem( items.add(TextFieldListItem(
title: S.current.note_tap_to_change, title: S.current.note_tap_to_change,
value: description.note, value: description.note,
onSubmitted: (value) { onSubmitted: (value) {
description.transactionNote = value; description.transactionNote = value;
if (description.isInBox) {
description.save(); description.save();
})); } else {
transactionDescriptionBox.add(description);
} }
}));
} }
final TransactionInfo transactionInfo; final TransactionInfo transactionInfo;