show n confirmations on tx details screen

This commit is contained in:
julian 2024-07-15 14:55:39 -06:00 committed by julian-CStack
parent 80d6a1bed7
commit 4acfbde791
2 changed files with 332 additions and 137 deletions

View file

@ -15,14 +15,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.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/blockchain_data/transaction.dart';
import '../../../models/isar/models/ethereum/eth_contract.dart'; import '../../../models/isar/models/ethereum/eth_contract.dart';
import '../../../notifications/show_flush_bar.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/db/main_db_provider.dart';
import '../../../providers/global/address_book_service_provider.dart'; import '../../../providers/global/address_book_service_provider.dart';
import '../../../providers/providers.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/icon_widgets/pencil_icon.dart';
import '../../../widgets/rounded_white_container.dart'; import '../../../widgets/rounded_white_container.dart';
import '../../../widgets/stack_dialog.dart'; import '../../../widgets/stack_dialog.dart';
import 'package:tuple/tuple.dart'; import '../../receive_view/addresses/address_details_view.dart';
import 'package:url_launcher/url_launcher.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 { class TransactionDetailsView extends ConsumerStatefulWidget {
const TransactionDetailsView({ const TransactionDetailsView({
@ -1157,34 +1158,49 @@ class _TransactionDetailsViewState
: const SizedBox( : const SizedBox(
height: 12, height: 12,
), ),
RoundedWhiteContainer( Builder(
padding: isDesktop
? const EdgeInsets.all(16)
: const EdgeInsets.all(12),
child: Builder(
builder: (context) { builder: (context) {
final String height; final String height;
final String confirmations;
final confirms = _transaction.getConfirmations(
currentHeight,
);
if (widget.coin is Bitcoincash || if (widget.coin is Bitcoincash ||
widget.coin is Ecash) { widget.coin is Ecash) {
height = height = _transaction.height != null &&
"${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; _transaction.height! > 0
? "${_transaction.height!}"
: "Pending";
confirmations = confirms.toString();
} else if (widget.coin is Epiccash &&
_transaction.slateId == null) {
confirmations = "Unknown";
height = "Unknown";
} else { } else {
height = widget.coin is! Epiccash && final confirmed = _transaction.isConfirmed(
_transaction.isConfirmed(
currentHeight, currentHeight,
minConfirms, minConfirms,
) );
? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" if (widget.coin is! Epiccash && confirmed) {
: _transaction.getConfirmations( height =
currentHeight, "${_transaction.height == 0 ? "Unknown" : _transaction.height}";
) > } else {
0 height = confirms > 0
? "${_transaction.height}" ? "${_transaction.height}"
: "Pending"; : "Pending";
} }
return Row( confirmations = confirms.toString();
}
return Column(
children: [
RoundedWhiteContainer(
padding: isDesktop
? const EdgeInsets.all(16)
: const EdgeInsets.all(12),
child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
crossAxisAlignment: crossAxisAlignment:
@ -1217,12 +1233,14 @@ class _TransactionDetailsViewState
.desktopTextExtraExtraSmall( .desktopTextExtraExtraSmall(
context, context,
).copyWith( ).copyWith(
color: Theme.of(context) color: Theme.of(
context)
.extension< .extension<
StackColors>()! StackColors>()!
.textDark, .textDark,
) )
: STextStyles.itemSubtitle12( : STextStyles
.itemSubtitle12(
context, context,
), ),
), ),
@ -1237,7 +1255,8 @@ class _TransactionDetailsViewState
context, context,
).copyWith( ).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<
StackColors>()!
.textDark, .textDark,
) )
: STextStyles.itemSubtitle12( : STextStyles.itemSubtitle12(
@ -1247,10 +1266,89 @@ class _TransactionDetailsViewState
if (isDesktop) if (isDesktop)
IconCopyButton(data: height), IconCopyButton(data: height),
], ],
),
),
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)
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) if (coin is Ethereum)
isDesktop isDesktop
? const _Divider() ? const _Divider()

View file

@ -1463,34 +1463,49 @@ class _TransactionV2DetailsViewState
: const SizedBox( : const SizedBox(
height: 12, height: 12,
), ),
RoundedWhiteContainer( Builder(
padding: isDesktop
? const EdgeInsets.all(16)
: const EdgeInsets.all(12),
child: Builder(
builder: (context) { builder: (context) {
final String height; final String height;
final String confirmations;
final confirms = _transaction.getConfirmations(
currentHeight,
);
if (widget.coin is Bitcoincash || if (widget.coin is Bitcoincash ||
widget.coin is Ecash) { widget.coin is Ecash) {
height = height = _transaction.height != null &&
"${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; _transaction.height! > 0
? "${_transaction.height!}"
: "Pending";
confirmations = confirms.toString();
} else if (widget.coin is Epiccash &&
_transaction.slateId == null) {
confirmations = "Unknown";
height = "Unknown";
} else { } else {
height = widget.coin is! Epiccash && final confirmed = _transaction.isConfirmed(
_transaction.isConfirmed(
currentHeight, currentHeight,
minConfirms, minConfirms,
) );
? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" if (widget.coin is! Epiccash && confirmed) {
: _transaction.getConfirmations( height =
currentHeight, "${_transaction.height == 0 ? "Unknown" : _transaction.height}";
) > } else {
0 height = confirms > 0
? "${_transaction.height}" ? "${_transaction.height}"
: "Pending"; : "Pending";
} }
return Row( confirmations = confirms.toString();
}
return Column(
children: [
RoundedWhiteContainer(
padding: isDesktop
? const EdgeInsets.all(16)
: const EdgeInsets.all(12),
child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
crossAxisAlignment: crossAxisAlignment:
@ -1523,12 +1538,14 @@ class _TransactionV2DetailsViewState
.desktopTextExtraExtraSmall( .desktopTextExtraExtraSmall(
context, context,
).copyWith( ).copyWith(
color: Theme.of(context) color: Theme.of(
context)
.extension< .extension<
StackColors>()! StackColors>()!
.textDark, .textDark,
) )
: STextStyles.itemSubtitle12( : STextStyles
.itemSubtitle12(
context, context,
), ),
), ),
@ -1543,7 +1560,8 @@ class _TransactionV2DetailsViewState
context, context,
).copyWith( ).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<
StackColors>()!
.textDark, .textDark,
) )
: STextStyles.itemSubtitle12( : STextStyles.itemSubtitle12(
@ -1553,10 +1571,89 @@ class _TransactionV2DetailsViewState
if (isDesktop) if (isDesktop)
IconCopyButton(data: height), IconCopyButton(data: height),
], ],
),
),
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)
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) if (kDebugMode)
isDesktop isDesktop