mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 03:49:43 +00:00
fix unlock time display
This commit is contained in:
parent
f8ed0f8a80
commit
efcfd625ec
7 changed files with 33 additions and 20 deletions
|
@ -16,7 +16,6 @@ abstract class TransactionInfo extends Object with Keyable {
|
||||||
String? feeFormatted();
|
String? feeFormatted();
|
||||||
void changeFiatAmount(String amount);
|
void changeFiatAmount(String amount);
|
||||||
String? unlockTimeFormatted();
|
String? unlockTimeFormatted();
|
||||||
bool get isLocked;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic get keyIndex => id;
|
dynamic get keyIndex => id;
|
||||||
|
|
|
@ -44,5 +44,4 @@ class TransactionInfoRow extends Struct {
|
||||||
String getHash() => hash.toDartString();
|
String getHash() => hash.toDartString();
|
||||||
String getPaymentId() => paymentId.toDartString();
|
String getPaymentId() => paymentId.toDartString();
|
||||||
String getAssetType() => assetType.toDartString();
|
String getAssetType() => assetType.toDartString();
|
||||||
int getUnlockTime() => unlockTime * 2;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:cw_core/parseBoolFromString.dart';
|
||||||
import 'package:cw_core/transaction_direction.dart';
|
import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cw_core/format_amount.dart';
|
import 'package:cw_core/format_amount.dart';
|
||||||
import 'package:cw_haven/api/transaction_history.dart';
|
import 'package:cw_haven/api/transaction_history.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class HavenTransactionInfo extends TransactionInfo {
|
class HavenTransactionInfo extends TransactionInfo {
|
||||||
HavenTransactionInfo(this.id, this.height, this.direction, this.date,
|
HavenTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||||
|
@ -20,7 +21,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
unlockTime = row.getUnlockTime(),
|
unlockTime = row.unlockTime,
|
||||||
confirmations = row.confirmations,
|
confirmations = row.confirmations,
|
||||||
key = null, //getTxKey(row.getHash()),
|
key = null, //getTxKey(row.getHash()),
|
||||||
fee = row.fee,
|
fee = row.fee,
|
||||||
|
@ -58,16 +59,21 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? unlockTimeFormatted() {
|
String? unlockTimeFormatted() {
|
||||||
if (direction == TransactionDirection.outgoing || unlockTime == 0) {
|
if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlockTime > 500000) {
|
if (unlockTime < 500000000) {
|
||||||
return '>1 year';
|
return (unlockTime - height) * 2 > 500000
|
||||||
|
? '>1 year'
|
||||||
|
: '~${(unlockTime - height) * 2} minutes';
|
||||||
}
|
}
|
||||||
return '~ $unlockTime minutes';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||||
bool get isLocked => direction == TransactionDirection.incoming && unlockTime > 0;
|
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||||
|
final String formattedUnlockTime =
|
||||||
|
formatter.format(DateTime.fromMillisecondsSinceEpoch(unlockTime));
|
||||||
|
|
||||||
|
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,5 +41,4 @@ class TransactionInfoRow extends Struct {
|
||||||
bool getIsPending() => isPending != 0;
|
bool getIsPending() => isPending != 0;
|
||||||
String getHash() => hash.toDartString();
|
String getHash() => hash.toDartString();
|
||||||
String getPaymentId() => paymentId.toDartString();
|
String getPaymentId() => paymentId.toDartString();
|
||||||
int getUnlockTime() => unlockTime * 2;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:cw_core/parseBoolFromString.dart';
|
||||||
import 'package:cw_core/transaction_direction.dart';
|
import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cw_core/format_amount.dart';
|
import 'package:cw_core/format_amount.dart';
|
||||||
import 'package:cw_monero/api/transaction_history.dart';
|
import 'package:cw_monero/api/transaction_history.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class MoneroTransactionInfo extends TransactionInfo {
|
class MoneroTransactionInfo extends TransactionInfo {
|
||||||
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||||
|
@ -20,7 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
unlockTime = row.getUnlockTime(),
|
unlockTime = row.unlockTime,
|
||||||
confirmations = row.confirmations,
|
confirmations = row.confirmations,
|
||||||
key = getTxKey(row.getHash()),
|
key = getTxKey(row.getHash()),
|
||||||
fee = row.fee {
|
fee = row.fee {
|
||||||
|
@ -62,16 +63,21 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? unlockTimeFormatted() {
|
String? unlockTimeFormatted() {
|
||||||
if (direction == TransactionDirection.outgoing || unlockTime == 0) {
|
if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlockTime > 500000) {
|
if (unlockTime < 500000000) {
|
||||||
return '>1 year';
|
return (unlockTime - height) * 2 > 500000
|
||||||
|
? '>1 year'
|
||||||
|
: '~${(unlockTime - height) * 2} minutes';
|
||||||
}
|
}
|
||||||
return '~ $unlockTime minutes';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||||
bool get isLocked => direction == TransactionDirection.incoming && unlockTime > 0;
|
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||||
|
final String formattedUnlockTime =
|
||||||
|
formatter.format(DateTime.fromMillisecondsSinceEpoch(unlockTime));
|
||||||
|
|
||||||
|
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ class TransactionsPage extends StatelessWidget {
|
||||||
dashboardViewModel.balanceViewModel.isFiatDisabled
|
dashboardViewModel.balanceViewModel.isFiatDisabled
|
||||||
? '' : item.formattedFiatAmount,
|
? '' : item.formattedFiatAmount,
|
||||||
isPending: transaction.isPending,
|
isPending: transaction.isPending,
|
||||||
title: item.formattedTitle + item.formattedStatus));
|
title: item.formattedTitle + item.formattedStatus
|
||||||
|
+ item.formattedLockedStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is TradeListItem) {
|
if (item is TradeListItem) {
|
||||||
|
|
|
@ -63,6 +63,9 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||||
return transaction.isPending ? S.current.pending : '';
|
return transaction.isPending ? S.current.pending : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get formattedLockedStatus => transaction.unlockTimeFormatted() == null ? ''
|
||||||
|
: ' ' + S.current.locked;
|
||||||
|
|
||||||
String get formattedFiatAmount {
|
String get formattedFiatAmount {
|
||||||
var amount = '';
|
var amount = '';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue