@@ -88,22 +88,15 @@ class TransactionDetailsTable extends StatelessWidget {
8888 label: context.loc.transactionDetailLabelLiquidTxId,
8989 displayValue: StringFormatting .truncateMiddle (liquidTxId),
9090 copyValue: liquidTxId,
91- displayWidget: GestureDetector (
92- onTap: () async {
93- final mempoolUrlBuilder = locator <MempoolUrlBuilder >();
94- final unblindedUrl = liquidTxId == txId
95- ? (walletTransaction? .unblindedUrl ?? 'tx/$liquidTxId ' )
96- : 'tx/$liquidTxId ' ;
97- final mempoolUrl = await mempoolUrlBuilder.liquidTxidUrl (
98- unblindedUrl,
99- isTestnet: isTestnet,
100- );
101- await launchUrl (Uri .parse (mempoolUrl));
102- },
103- child: Text (
104- StringFormatting .truncateMiddle (liquidTxId),
105- style: TextStyle (color: context.appColors.primary),
106- textAlign: TextAlign .end,
91+ displayWidget: _mempoolLink (
92+ context,
93+ liquidTxId,
94+ buildUrl: () => locator <MempoolUrlBuilder >().liquidTxid (
95+ liquidTxId,
96+ isTestnet: isTestnet,
97+ unblindedUrl: liquidTxId == txId
98+ ? walletTransaction? .unblindedUrl
99+ : null ,
107100 ),
108101 ),
109102 ),
@@ -144,19 +137,12 @@ class TransactionDetailsTable extends StatelessWidget {
144137 label: context.loc.transactionDetailLabelBitcoinTxId,
145138 displayValue: StringFormatting .truncateMiddle (bitcoinTxId),
146139 copyValue: bitcoinTxId,
147- displayWidget: GestureDetector (
148- onTap: () async {
149- final mempoolUrlBuilder = locator <MempoolUrlBuilder >();
150- final mempoolUrl = await mempoolUrlBuilder.bitcoinTxidUrl (
151- bitcoinTxId,
152- isTestnet: isTestnet,
153- );
154- await launchUrl (Uri .parse (mempoolUrl));
155- },
156- child: Text (
157- StringFormatting .truncateMiddle (bitcoinTxId),
158- style: TextStyle (color: context.appColors.primary),
159- textAlign: TextAlign .end,
140+ displayWidget: _mempoolLink (
141+ context,
142+ bitcoinTxId,
143+ buildUrl: () => locator <MempoolUrlBuilder >().bitcoinTxid (
144+ bitcoinTxId,
145+ isTestnet: isTestnet,
160146 ),
161147 ),
162148 ),
@@ -197,30 +183,20 @@ class TransactionDetailsTable extends StatelessWidget {
197183 label: context.loc.transactionDetailLabelTransactionId,
198184 displayValue: StringFormatting .truncateMiddle (txId),
199185 copyValue: txId,
200- displayWidget: GestureDetector (
201- onTap: () async {
202- final mempoolUrlBuilder = locator <MempoolUrlBuilder >();
203-
204- final String mempoolUrl;
205- if (isLiquid) {
206- mempoolUrl = await mempoolUrlBuilder.liquidTxidUrl (
207- transaction? .walletTransaction? .unblindedUrl ?? '' ,
208- isTestnet: isTestnet,
209- );
210- } else {
211- mempoolUrl = await mempoolUrlBuilder.bitcoinTxidUrl (
212- txId,
213- isTestnet: isTestnet,
214- );
215- }
216-
217- await launchUrl (Uri .parse (mempoolUrl));
218- },
219- child: Text (
220- StringFormatting .truncateMiddle (txId),
221- style: TextStyle (color: context.appColors.primary),
222- textAlign: TextAlign .end,
223- ),
186+ displayWidget: _mempoolLink (
187+ context,
188+ txId,
189+ buildUrl: () => isLiquid
190+ ? locator <MempoolUrlBuilder >().liquidTxid (
191+ txId,
192+ isTestnet: isTestnet,
193+ unblindedUrl:
194+ transaction? .walletTransaction? .unblindedUrl,
195+ )
196+ : locator <MempoolUrlBuilder >().bitcoinTxid (
197+ txId,
198+ isTestnet: isTestnet,
199+ ),
224200 ),
225201 ),
226202 if (labels.isNotEmpty && txId != null )
@@ -889,29 +865,21 @@ class TransactionDetailsTable extends StatelessWidget {
889865 : context.loc.transactionDetailLabelAddress,
890866 displayValue: StringFormatting .truncateMiddle (toAddress),
891867 copyValue: toAddress,
892- displayWidget: GestureDetector (
893- onTap : () async {
894- final mempoolUrlBuilder = locator < MempoolUrlBuilder >();
895- final String mempoolUrl;
868+ displayWidget: _mempoolLink (
869+ context,
870+ toAddress,
871+ buildUrl : () {
896872 final addressIsLiquid = swap.isChainSwap ? ! isLiquid : false ;
897- if (addressIsLiquid) {
898- mempoolUrl = await mempoolUrlBuilder.liquidAddressUrl (
899- toAddress,
900- isTestnet: isTestnet,
901- );
902- } else {
903- mempoolUrl = await mempoolUrlBuilder.bitcoinAddressUrl (
904- toAddress,
905- isTestnet: isTestnet,
906- );
907- }
908- await launchUrl (Uri .parse (mempoolUrl));
873+ return addressIsLiquid
874+ ? locator <MempoolUrlBuilder >().liquidAddress (
875+ toAddress,
876+ isTestnet: isTestnet,
877+ )
878+ : locator <MempoolUrlBuilder >().bitcoinAddress (
879+ toAddress,
880+ isTestnet: isTestnet,
881+ );
909882 },
910- child: Text (
911- StringFormatting .truncateMiddle (toAddress),
912- style: TextStyle (color: context.appColors.primary),
913- textAlign: TextAlign .end,
914- ),
915883 ),
916884 ),
917885 if (addressLabels.isNotEmpty && toAddress != null )
@@ -1108,14 +1076,32 @@ Widget _sectionHeader(BuildContext context, String title) {
11081076 padding: const EdgeInsets .only (bottom: 6 ),
11091077 child: Text (
11101078 title,
1111- style: Theme . of ( context).textTheme .labelMedium? .copyWith (
1079+ style: context.font .labelMedium? .copyWith (
11121080 color: context.appColors.onSurfaceVariant,
11131081 fontWeight: FontWeight .w600,
11141082 ),
11151083 ),
11161084 );
11171085}
11181086
1087+ Widget _mempoolLink (
1088+ BuildContext context,
1089+ String value, {
1090+ required Future <String > Function () buildUrl,
1091+ }) {
1092+ return GestureDetector (
1093+ onTap: () async {
1094+ final mempoolUrl = await buildUrl ();
1095+ await launchUrl (Uri .parse (mempoolUrl));
1096+ },
1097+ child: Text (
1098+ StringFormatting .truncateMiddle (value),
1099+ style: TextStyle (color: context.appColors.primary),
1100+ textAlign: TextAlign .end,
1101+ ),
1102+ );
1103+ }
1104+
11191105Widget _feeRow (BuildContext context, String label, int amt) {
11201106 return Padding (
11211107 padding: const EdgeInsets .symmetric (vertical: 4 ),
0 commit comments