forked from SatoshiPortal/bullbitcoin-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathark_transaction_details_page.dart
More file actions
156 lines (150 loc) · 5.91 KB
/
Copy pathark_transaction_details_page.dart
File metadata and controls
156 lines (150 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import 'package:ark_wallet/ark_wallet.dart' as ark_wallet;
import 'package:bb_mobile/core/themes/app_theme.dart';
import 'package:bb_mobile/core/utils/build_context_x.dart';
import 'package:bb_mobile/core/utils/mempool_url.dart';
import 'package:bb_mobile/core/utils/string_formatting.dart';
import 'package:bb_mobile/core/widgets/badges/transaction_direction_badge.dart';
import 'package:bb_mobile/core/widgets/navbar/top_bar.dart';
import 'package:bb_mobile/core/widgets/tables/details_table.dart';
import 'package:bb_mobile/core/widgets/tables/details_table_item.dart';
import 'package:bb_mobile/core/widgets/text/text.dart';
import 'package:bb_mobile/features/bitcoin_price/ui/currency_text.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
class ArkTransactionDetailsPage extends StatelessWidget {
const ArkTransactionDetailsPage({super.key, required this.transaction});
final ark_wallet.Transaction transaction;
@override
Widget build(BuildContext context) {
String txid;
int sats;
DateTime? date;
String type;
String statusLabel;
bool isIncoming = true;
bool isSwap = false;
switch (transaction) {
case final ark_wallet.Transaction_Boarding tx:
txid = tx.txid;
sats = tx.sats;
if (tx.confirmedAt != null) {
date = DateTime.fromMillisecondsSinceEpoch(tx.confirmedAt! * 1000);
}
type = context.loc.arkTxBoarding;
statusLabel = date != null ? context.loc.arkStatusConfirmed : context.loc.arkTxPending;
case final ark_wallet.Transaction_Commitment tx:
txid = tx.txid;
sats = tx.sats;
date = DateTime.fromMillisecondsSinceEpoch(tx.createdAt * 1000);
type = context.loc.arkTxSettlement;
statusLabel = context.loc.arkStatusConfirmed;
isIncoming = false;
isSwap = true;
case final ark_wallet.Transaction_Redeem tx:
txid = tx.txid;
sats = tx.sats;
date = DateTime.fromMillisecondsSinceEpoch(tx.createdAt * 1000);
type = context.loc.arkTxPayment;
statusLabel = tx.isSettled ? context.loc.arkStatusSettled : context.loc.arkTxPending;
isIncoming = false;
}
final isBoarding = transaction is ark_wallet.Transaction_Boarding;
final mempoolUrl =
isBoarding ? MempoolUrl.bitcoinTxidUrl(txid, isTestnet: false) : null;
return Scaffold(
appBar: AppBar(
forceMaterialTransparency: true,
automaticallyImplyLeading: false,
flexibleSpace: TopBar(
title: context.loc.arkTransactionDetails,
actionIcon: Icons.close,
onAction: () => context.pop(),
),
),
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Center(
child: Column(
children: [
TransactionDirectionBadge(
isIncoming: isIncoming,
isSwap: isSwap,
),
const Gap(24),
BBText(
statusLabel,
style: context.font.titleMedium?.copyWith(
color: context.appColors.textMuted,
),
),
const Gap(8),
CurrencyText(
sats,
showFiat: false,
style: context.font.displaySmall?.copyWith(
color: context.appColors.onSurface,
fontWeight: .w500,
),
fiatAmount: null,
fiatCurrency: null,
),
const Gap(16),
DetailsTable(
items: [
DetailsTableItem(
label: context.loc.arkTransactionId,
displayValue: StringFormatting.truncateMiddle(txid),
copyValue: txid,
displayWidget:
mempoolUrl != null
? GestureDetector(
onTap: () async {
await launchUrl(Uri.parse(mempoolUrl));
},
child: Text(
StringFormatting.truncateMiddle(txid),
style: TextStyle(
color: context.appColors.primary,
),
textAlign: .end,
),
)
: null,
),
DetailsTableItem(label: context.loc.arkType, displayValue: type),
DetailsTableItem(
label: context.loc.arkStatus,
displayValue: statusLabel,
),
DetailsTableItem(
label: context.loc.arkAmount,
displayValue: '$sats ${context.loc.arkSatsUnit}',
),
// Note: Network fee is not currently available from the ark_wallet library
// When the library exposes fee information, it can be added here like:
// if (fee != null)
// DetailsTableItem(
// label: 'Network Fee',
// displayValue: '$fee sats',
// ),
if (date != null)
DetailsTableItem(
label: context.loc.arkDate,
displayValue: DateFormat(
'MMM d, y, h:mm a',
).format(date),
),
],
),
],
),
),
),
),
);
}
}