From 3fc1263ad41e9a35fa148d9ed0ad43e87e0559f9 Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 7 Feb 2023 14:00:55 +0200 Subject: [PATCH] transaction view model refactoring --- cw_monero/lib/api/structs/transaction_info_row.dart | 1 + cw_monero/lib/monero_transaction_info.dart | 7 +++---- lib/di.dart | 2 +- .../transaction_details/transaction_details_page.dart | 2 +- .../{ => transactions}/transaction_details_view_model.dart | 0 5 files changed, 6 insertions(+), 6 deletions(-) rename lib/view_model/{ => transactions}/transaction_details_view_model.dart (100%) diff --git a/cw_monero/lib/api/structs/transaction_info_row.dart b/cw_monero/lib/api/structs/transaction_info_row.dart index cd7f4dacb..809fb3d9d 100644 --- a/cw_monero/lib/api/structs/transaction_info_row.dart +++ b/cw_monero/lib/api/structs/transaction_info_row.dart @@ -41,4 +41,5 @@ class TransactionInfoRow extends Struct { bool getIsPending() => isPending != 0; String getHash() => hash.toDartString(); String getPaymentId() => paymentId.toDartString(); + int getUnlockTime() => unlockTime * 2; } diff --git a/cw_monero/lib/monero_transaction_info.dart b/cw_monero/lib/monero_transaction_info.dart index 05f332c1d..359c3d9b5 100644 --- a/cw_monero/lib/monero_transaction_info.dart +++ b/cw_monero/lib/monero_transaction_info.dart @@ -19,7 +19,7 @@ class MoneroTransactionInfo extends TransactionInfo { amount = row.getAmount(), accountIndex = row.subaddrAccount, addressIndex = row.subaddrIndex, - unlockTime = row.unlockTime, + unlockTime = row.getUnlockTime(), key = getTxKey(row.getHash()), fee = row.fee { additionalInfo = { @@ -59,14 +59,13 @@ class MoneroTransactionInfo extends TransactionInfo { @override String? unlockTimeFormatted() { - final formattedTime = unlockTime * 2; if (direction == TransactionDirection.outgoing || unlockTime == 0) { return null; } - if (formattedTime > 500000) { + if (unlockTime > 500000) { return '>1 year'; } - return '~ $formattedTime minutes'; + return '~ $unlockTime minutes'; } } diff --git a/lib/di.dart b/lib/di.dart index ae55c0ce6..d989a244e 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -112,7 +112,7 @@ import 'package:cake_wallet/view_model/restore_from_backup_view_model.dart'; import 'package:cake_wallet/view_model/send/send_template_view_model.dart'; import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart'; import 'package:cake_wallet/view_model/support_view_model.dart'; -import 'package:cake_wallet/view_model/transaction_details_view_model.dart'; +import 'package:cake_wallet/view_model/transactions/transaction_details_view_model.dart'; import 'package:cake_wallet/view_model/trade_details_view_model.dart'; import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_details_view_model.dart'; import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart'; diff --git a/lib/src/screens/transaction_details/transaction_details_page.dart b/lib/src/screens/transaction_details/transaction_details_page.dart index 1b79ceeb0..9d52be2d1 100644 --- a/lib/src/screens/transaction_details/transaction_details_page.dart +++ b/lib/src/screens/transaction_details/transaction_details_page.dart @@ -2,7 +2,7 @@ import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item. import 'package:cake_wallet/src/screens/transaction_details/widgets/textfield_list_row.dart'; import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/utils/show_bar.dart'; -import 'package:cake_wallet/view_model/transaction_details_view_model.dart'; +import 'package:cake_wallet/view_model/transactions/transaction_details_view_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:cake_wallet/generated/i18n.dart'; diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transactions/transaction_details_view_model.dart similarity index 100% rename from lib/view_model/transaction_details_view_model.dart rename to lib/view_model/transactions/transaction_details_view_model.dart