zwallet/lib/transaction.dart

74 lines
2.3 KiB
Dart
Raw Normal View History

2021-07-09 22:44:34 -07:00
import 'package:flutter/material.dart';
2021-07-10 22:20:53 -07:00
import 'package:url_launcher/url_launcher.dart';
2021-07-09 22:44:34 -07:00
2021-08-13 20:44:53 -07:00
import 'main.dart';
2022-03-07 06:53:18 -08:00
import 'settings.dart';
2021-07-09 22:44:34 -07:00
import 'store.dart';
2021-08-15 09:18:09 -07:00
import 'generated/l10n.dart';
2021-07-09 22:44:34 -07:00
class TransactionPage extends StatefulWidget {
2022-03-16 09:12:05 -07:00
final int txIndex;
2021-07-09 22:44:34 -07:00
2022-03-16 09:12:05 -07:00
TransactionPage(this.txIndex);
2021-07-09 22:44:34 -07:00
@override
State<StatefulWidget> createState() => TransactionState();
}
class TransactionState extends State<TransactionPage> {
2022-03-16 09:12:05 -07:00
late int txIndex;
@override
void initState() {
super.initState();
txIndex = widget.txIndex;
}
Tx get tx => active.sortedTxs[txIndex];
2021-07-09 22:44:34 -07:00
@override
Widget build(BuildContext context) {
2022-03-16 09:12:05 -07:00
final n = active.sortedTxs.length;
2021-07-09 22:44:34 -07:00
return Scaffold(
2021-08-15 09:18:09 -07:00
appBar: AppBar(title: Text(S.of(context).transactionDetails)),
2021-07-09 22:44:34 -07:00
body: ListView(padding: EdgeInsets.all(16), children: [
ListTile(
2022-06-16 03:16:32 -07:00
title: Text('TXID'), subtitle: SelectableText('${tx.fullTxId}')),
2021-07-09 22:44:34 -07:00
ListTile(
2022-03-16 09:12:05 -07:00
title: Text(S.of(context).height), subtitle: SelectableText('${tx.height}')),
2021-09-09 03:09:14 -07:00
ListTile(
2022-03-16 09:12:05 -07:00
title: Text(S.of(context).confs), subtitle: SelectableText('${syncStatus.latestHeight - tx.height + 1}')),
2021-07-09 22:44:34 -07:00
ListTile(
2021-08-15 09:18:09 -07:00
title: Text(S.of(context).timestamp),
2022-03-16 09:12:05 -07:00
subtitle: Text('${tx.timestamp}')),
ListTile(title: Text(S.of(context).amount), subtitle: SelectableText(decimalFormat(tx.value, 8))),
2021-07-09 22:44:34 -07:00
ListTile(
2022-03-16 09:12:05 -07:00
title: Text(S.of(context).address), subtitle: SelectableText('${tx.address}')),
ListTile(
2022-03-16 09:12:05 -07:00
title: Text(S.of(context).contactName), subtitle: SelectableText('${tx.contact ?? "N/A"}')),
ListTile(title: Text(S.of(context).memo), subtitle: SelectableText('${tx.memo}')),
ButtonBar(alignment: MainAxisAlignment.center, children: [
IconButton(onPressed: txIndex > 0 ? _prev : null, icon: Icon(Icons.chevron_left)),
ElevatedButton(onPressed: _onOpen, child: Text(S.of(context).openInExplorer)),
IconButton(onPressed: txIndex < n-1 ? _next : null, icon: Icon(Icons.chevron_right)),
]),
2021-07-09 22:44:34 -07:00
]));
}
2021-07-10 22:20:53 -07:00
_onOpen() {
2022-03-16 09:12:05 -07:00
launch("${activeCoin().explorerUrl}${tx.fullTxId}");
}
_prev() {
setState(() {
txIndex -= 1;
});
}
_next() {
setState(() {
txIndex += 1;
});
2021-07-10 22:20:53 -07:00
}
2021-07-09 22:44:34 -07:00
}