mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
Block explorer row in transaction details is now implemented as an item subclass rather than being index dependent in the list
This commit is contained in:
parent
027e94f524
commit
248cb3a0da
3 changed files with 41 additions and 45 deletions
|
@ -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;
|
||||
}
|
|
@ -7,6 +7,7 @@ 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';
|
||||
|
@ -15,19 +16,6 @@ import 'package:url_launcher/url_launcher.dart';
|
|||
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
String stripURLToTXID(String inputString) {
|
||||
final RegExp txidRegex = new RegExp('[a-z0-9]{64}');
|
||||
return txidRegex.allMatches(inputString).first.group(0);
|
||||
}
|
||||
|
||||
String blockExplorerName(String inputName) {
|
||||
if (inputName.contains("xmrchain")) {
|
||||
return "XMRChain.net";
|
||||
} else {
|
||||
return "Blockchain.com";
|
||||
}
|
||||
}
|
||||
|
||||
class TransactionDetailsPage extends BasePage {
|
||||
TransactionDetailsPage({this.transactionDetailsViewModel});
|
||||
|
||||
|
@ -45,31 +33,23 @@ class TransactionDetailsPage extends BasePage {
|
|||
final item = transactionDetailsViewModel.items[index];
|
||||
|
||||
if (item is StandartListItem) {
|
||||
final isFinalBlockExplorerItem =
|
||||
index == transactionDetailsViewModel.items.length - 1
|
||||
? true
|
||||
: false;
|
||||
if (isFinalBlockExplorerItem == false) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: item.value));
|
||||
showBar<void>(context,
|
||||
S.of(context).transaction_details_copied(item.title));
|
||||
},
|
||||
child:
|
||||
StandartListRow(title: '${item.title}:', value: item.value),
|
||||
);
|
||||
} else {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
launch(item.value);
|
||||
},
|
||||
child: StandartListRow(
|
||||
title: '${item.title}:',
|
||||
value:
|
||||
"View transaction on ${blockExplorerName(item.value)}"),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: item.value));
|
||||
showBar<void>(context,
|
||||
S.of(context).transaction_details_copied(item.title));
|
||||
},
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
if (item is TextFieldListItem) {
|
||||
|
|
|
@ -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) {
|
||||
|
@ -49,9 +57,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
}
|
||||
|
||||
items.addAll(_items);
|
||||
items.add(StandartListItem(
|
||||
title: "View in Block Explorer",
|
||||
value: "https://xmrchain.net/search?value=${tx.id}"));
|
||||
}
|
||||
|
||||
if (tx is BitcoinTransactionInfo) {
|
||||
|
@ -72,13 +77,16 @@ 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);
|
||||
items.add(StandartListItem(
|
||||
title: "View in Block Explorer",
|
||||
value: "https://www.blockchain.com/btc/tx/${tx.id}"));
|
||||
}
|
||||
|
||||
if (showRecipientAddress) {
|
||||
|
|
Loading…
Reference in a new issue