Skip to content

Commit a7798fd

Browse files
committed
feat: add transaction detail flow with navigation and tests
1 parent 96dbdf7 commit a7798fd

5 files changed

Lines changed: 489 additions & 129 deletions

File tree

bdk_demo/lib/core/router/app_router.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:go_router/go_router.dart';
22
import 'package:bdk_demo/features/shared/widgets/placeholder_page.dart';
33
import 'package:bdk_demo/features/wallet_setup/active_wallets_page.dart';
4+
import 'package:bdk_demo/features/wallet_setup/transaction_detail_page.dart';
45
import 'package:bdk_demo/features/wallet_setup/wallet_choice_page.dart';
56

67
abstract final class AppRoutes {
@@ -72,7 +73,7 @@ GoRouter createRouter() => GoRouter(
7273
name: 'transactionDetail',
7374
builder: (context, state) {
7475
final txid = state.pathParameters['txid'] ?? '';
75-
return PlaceholderPage(title: 'Transaction $txid');
76+
return TransactionDetailPage(txid: txid);
7677
},
7778
),
7879

bdk_demo/lib/features/wallet_setup/active_wallets_page.dart

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_riverpod/flutter_riverpod.dart';
3+
import 'package:go_router/go_router.dart';
34

45
import 'package:bdk_demo/core/theme/app_theme.dart';
56
import 'package:bdk_demo/core/utils/formatters.dart';
@@ -95,6 +96,13 @@ class _ActiveWalletsPageState extends ConsumerState<ActiveWalletsPage> {
9596
return '${descriptor.substring(0, 24)}...${descriptor.substring(descriptor.length - 18)}';
9697
}
9798

99+
void _openTransactionDetail(TxDetails transaction) {
100+
context.pushNamed(
101+
'transactionDetail',
102+
pathParameters: {'txid': transaction.txid},
103+
);
104+
}
105+
98106
@override
99107
Widget build(BuildContext context) {
100108
final theme = Theme.of(context);
@@ -289,7 +297,11 @@ class _ActiveWalletsPageState extends ConsumerState<ActiveWalletsPage> {
289297
index < _transactions.length;
290298
index++
291299
) ...[
292-
_TransactionRow(transaction: _transactions[index]),
300+
_TransactionRow(
301+
transaction: _transactions[index],
302+
onTap: () =>
303+
_openTransactionDetail(_transactions[index]),
304+
),
293305
if (index < _transactions.length - 1)
294306
const SizedBox(height: 12),
295307
],
@@ -464,8 +476,9 @@ class _DetailRow extends StatelessWidget {
464476

465477
class _TransactionRow extends StatelessWidget {
466478
final TxDetails transaction;
479+
final VoidCallback onTap;
467480

468-
const _TransactionRow({required this.transaction});
481+
const _TransactionRow({required this.transaction, required this.onTap});
469482

470483
@override
471484
Widget build(BuildContext context) {
@@ -485,46 +498,54 @@ class _TransactionRow extends StatelessWidget {
485498
? 'Confirmed'
486499
: 'Block ${transaction.blockHeight}';
487500

488-
return Container(
489-
width: double.infinity,
490-
padding: const EdgeInsets.all(16),
491-
decoration: BoxDecoration(
501+
return Material(
502+
color: Colors.transparent,
503+
child: InkWell(
492504
borderRadius: BorderRadius.circular(16),
493-
border: Border.all(color: theme.colorScheme.outlineVariant),
494-
),
495-
child: Column(
496-
crossAxisAlignment: CrossAxisAlignment.start,
497-
children: [
498-
Row(
505+
onTap: onTap,
506+
child: Ink(
507+
width: double.infinity,
508+
padding: const EdgeInsets.all(16),
509+
decoration: BoxDecoration(
510+
borderRadius: BorderRadius.circular(16),
511+
border: Border.all(color: theme.colorScheme.outlineVariant),
512+
),
513+
child: Column(
514+
crossAxisAlignment: CrossAxisAlignment.start,
499515
children: [
500-
Expanded(
501-
child: Text(
502-
amountLabel,
503-
style: theme.textTheme.titleMedium?.copyWith(
504-
fontWeight: FontWeight.w700,
505-
color: accentColor,
516+
Row(
517+
children: [
518+
Expanded(
519+
child: Text(
520+
amountLabel,
521+
style: theme.textTheme.titleMedium?.copyWith(
522+
fontWeight: FontWeight.w700,
523+
color: accentColor,
524+
),
525+
),
506526
),
527+
const SizedBox(width: 12),
528+
_StatusChip(status: transaction.statusLabel),
529+
],
530+
),
531+
const SizedBox(height: 8),
532+
Text(
533+
transaction.shortTxid,
534+
style: AppTheme.monoStyle.copyWith(
535+
fontSize: 13,
536+
color: theme.colorScheme.onSurface,
537+
),
538+
),
539+
const SizedBox(height: 4),
540+
Text(
541+
subtitle,
542+
style: theme.textTheme.bodySmall?.copyWith(
543+
color: theme.colorScheme.onSurface.withAlpha(170),
507544
),
508545
),
509-
_StatusChip(status: transaction.statusLabel),
510546
],
511547
),
512-
const SizedBox(height: 8),
513-
Text(
514-
transaction.shortTxid,
515-
style: AppTheme.monoStyle.copyWith(
516-
fontSize: 13,
517-
color: theme.colorScheme.onSurface,
518-
),
519-
),
520-
const SizedBox(height: 4),
521-
Text(
522-
subtitle,
523-
style: theme.textTheme.bodySmall?.copyWith(
524-
color: theme.colorScheme.onSurface.withAlpha(170),
525-
),
526-
),
527-
],
548+
),
528549
),
529550
);
530551
}

0 commit comments

Comments
 (0)