From 4acfbde79148473e79e507a5369108d3598547ee Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 15 Jul 2024 14:55:39 -0600 Subject: [PATCH] show n confirmations on tx details screen --- .../transaction_details_view.dart | 242 ++++++++++++------ .../tx_v2/transaction_v2_details_view.dart | 227 +++++++++++----- 2 files changed, 332 insertions(+), 137 deletions(-) diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index dad531969..346dc823e 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -15,14 +15,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:tuple/tuple.dart'; +import 'package:url_launcher/url_launcher.dart'; + import '../../../models/isar/models/blockchain_data/transaction.dart'; import '../../../models/isar/models/ethereum/eth_contract.dart'; import '../../../notifications/show_flush_bar.dart'; -import '../../receive_view/addresses/address_details_view.dart'; -import '../sub_widgets/tx_icon.dart'; -import 'dialogs/cancelling_transaction_progress_dialog.dart'; -import 'edit_note_view.dart'; -import '../wallet_view.dart'; import '../../../providers/db/main_db_provider.dart'; import '../../../providers/global/address_book_service_provider.dart'; import '../../../providers/providers.dart'; @@ -52,8 +50,11 @@ import '../../../widgets/icon_widgets/copy_icon.dart'; import '../../../widgets/icon_widgets/pencil_icon.dart'; import '../../../widgets/rounded_white_container.dart'; import '../../../widgets/stack_dialog.dart'; -import 'package:tuple/tuple.dart'; -import 'package:url_launcher/url_launcher.dart'; +import '../../receive_view/addresses/address_details_view.dart'; +import '../sub_widgets/tx_icon.dart'; +import '../wallet_view.dart'; +import 'dialogs/cancelling_transaction_progress_dialog.dart'; +import 'edit_note_view.dart'; class TransactionDetailsView extends ConsumerStatefulWidget { const TransactionDetailsView({ @@ -1157,59 +1158,95 @@ class _TransactionDetailsViewState : const SizedBox( height: 12, ), - RoundedWhiteContainer( - padding: isDesktop - ? const EdgeInsets.all(16) - : const EdgeInsets.all(12), - child: Builder( - builder: (context) { - final String height; + Builder( + builder: (context) { + final String height; + final String confirmations; + final confirms = _transaction.getConfirmations( + currentHeight, + ); - if (widget.coin is Bitcoincash || - widget.coin is Ecash) { + if (widget.coin is Bitcoincash || + widget.coin is Ecash) { + height = _transaction.height != null && + _transaction.height! > 0 + ? "${_transaction.height!}" + : "Pending"; + confirmations = confirms.toString(); + } else if (widget.coin is Epiccash && + _transaction.slateId == null) { + confirmations = "Unknown"; + height = "Unknown"; + } else { + final confirmed = _transaction.isConfirmed( + currentHeight, + minConfirms, + ); + if (widget.coin is! Epiccash && confirmed) { height = - "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; + "${_transaction.height == 0 ? "Unknown" : _transaction.height}"; } else { - height = widget.coin is! Epiccash && - _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.getConfirmations( - currentHeight, - ) > - 0 - ? "${_transaction.height}" - : "Pending"; + height = confirms > 0 + ? "${_transaction.height}" + : "Pending"; } - return Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Column( + confirmations = confirms.toString(); + } + + return Column( + children: [ + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - "Block height", - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context, - ) - : STextStyles.itemSubtitle( - context, - ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Block height", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, + ), + if (isDesktop) + SelectableText( + height, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], ), - if (isDesktop) - const SizedBox( - height: 2, - ), - if (isDesktop) + if (!isDesktop) SelectableText( height, style: isDesktop @@ -1226,30 +1263,91 @@ class _TransactionDetailsViewState context, ), ), + if (isDesktop) + IconCopyButton(data: height), ], ), - if (!isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context, + ), + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Confirmations", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, ), - ), - if (isDesktop) - IconCopyButton(data: height), - ], - ); - }, - ), + if (isDesktop) + SelectableText( + confirmations, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], + ), + if (!isDesktop) + SelectableText( + confirmations, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles.itemSubtitle12( + context, + ), + ), + if (isDesktop) + IconCopyButton(data: height), + ], + ), + ), + ], + ); + }, ), if (coin is Ethereum) isDesktop diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart index 3114a841d..666d8d041 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart @@ -1463,59 +1463,95 @@ class _TransactionV2DetailsViewState : const SizedBox( height: 12, ), - RoundedWhiteContainer( - padding: isDesktop - ? const EdgeInsets.all(16) - : const EdgeInsets.all(12), - child: Builder( - builder: (context) { - final String height; + Builder( + builder: (context) { + final String height; + final String confirmations; + final confirms = _transaction.getConfirmations( + currentHeight, + ); - if (widget.coin is Bitcoincash || - widget.coin is Ecash) { + if (widget.coin is Bitcoincash || + widget.coin is Ecash) { + height = _transaction.height != null && + _transaction.height! > 0 + ? "${_transaction.height!}" + : "Pending"; + confirmations = confirms.toString(); + } else if (widget.coin is Epiccash && + _transaction.slateId == null) { + confirmations = "Unknown"; + height = "Unknown"; + } else { + final confirmed = _transaction.isConfirmed( + currentHeight, + minConfirms, + ); + if (widget.coin is! Epiccash && confirmed) { height = - "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; + "${_transaction.height == 0 ? "Unknown" : _transaction.height}"; } else { - height = widget.coin is! Epiccash && - _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.getConfirmations( - currentHeight, - ) > - 0 - ? "${_transaction.height}" - : "Pending"; + height = confirms > 0 + ? "${_transaction.height}" + : "Pending"; } - return Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Column( + confirmations = confirms.toString(); + } + + return Column( + children: [ + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - "Block height", - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context, - ) - : STextStyles.itemSubtitle( - context, - ), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Block height", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, + ), + if (isDesktop) + SelectableText( + height, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], ), - if (isDesktop) - const SizedBox( - height: 2, - ), - if (isDesktop) + if (!isDesktop) SelectableText( height, style: isDesktop @@ -1532,30 +1568,91 @@ class _TransactionV2DetailsViewState context, ), ), + if (isDesktop) + IconCopyButton(data: height), ], ), - if (!isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context, + ), + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Confirmations", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, ), - ), - if (isDesktop) - IconCopyButton(data: height), - ], - ); - }, - ), + if (isDesktop) + SelectableText( + confirmations, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], + ), + if (!isDesktop) + SelectableText( + confirmations, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles.itemSubtitle12( + context, + ), + ), + if (isDesktop) + IconCopyButton(data: height), + ], + ), + ), + ], + ); + }, ), if (kDebugMode)