diff --git a/lib/src/screens/transaction_details/blockexplorer_list_item.dart b/lib/src/screens/transaction_details/blockexplorer_list_item.dart new file mode 100644 index 000000000..4b24e8f1a --- /dev/null +++ b/lib/src/screens/transaction_details/blockexplorer_list_item.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; +import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart'; + +class BlockExplorerListItem extends TransactionDetailsListItem { + BlockExplorerListItem({String title, String value, this.onTap}) + : super(title: title, value: value); + final Function() onTap; +} diff --git a/lib/src/screens/transaction_details/transaction_details_page.dart b/lib/src/screens/transaction_details/transaction_details_page.dart index d7a265a9a..5732856b9 100644 --- a/lib/src/screens/transaction_details/transaction_details_page.dart +++ b/lib/src/screens/transaction_details/transaction_details_page.dart @@ -7,8 +7,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/standart_list_row.dart'; +import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; +import 'package:cake_wallet/utils/date_formatter.dart'; + +import 'package:url_launcher/url_launcher.dart'; + +import 'package:hive/hive.dart'; class TransactionDetailsPage extends BasePage { TransactionDetailsPage({this.transactionDetailsViewModel}); @@ -33,9 +39,16 @@ class TransactionDetailsPage extends BasePage { showBar(context, S.of(context).transaction_details_copied(item.title)); }, - child: StandartListRow( - title: '${item.title}:', - value: item.value), + child: + StandartListRow(title: '${item.title}:', value: item.value), + ); + } + + if (item is BlockExplorerListItem) { + return GestureDetector( + onTap: item.onTap, + child: + StandartListRow(title: '${item.title}:', value: item.value), ); } diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index f83f23527..67822e207 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -4,12 +4,14 @@ import 'package:cake_wallet/monero/monero_transaction_info.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart'; import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart'; +import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_list_item.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/generated/i18n.dart'; +import 'package:url_launcher/url_launcher.dart'; part 'transaction_details_view_model.g.dart'; @@ -41,6 +43,12 @@ abstract class TransactionDetailsViewModelBase with Store { value: tx.amountFormatted()), StandartListItem( title: S.current.transaction_details_fee, value: tx.feeFormatted()), + BlockExplorerListItem( + title: "View in Block Explorer", + value: "View Transaction on XMRChain.net", + onTap: () { + launch("https://xmrchain.net/search?value=${tx.id}"); + }) ]; if (tx.key?.isNotEmpty ?? null) { @@ -69,7 +77,13 @@ abstract class TransactionDetailsViewModelBase with Store { if (tx.feeFormatted()?.isNotEmpty) StandartListItem( title: S.current.transaction_details_fee, - value: tx.feeFormatted()) + value: tx.feeFormatted()), + BlockExplorerListItem( + title: "View in Block Explorer", + value: "View Transaction on Blockchain.com", + onTap: () { + launch("https://www.blockchain.com/btc/tx/${tx.id}"); + }) ]; items.addAll(_items);