2024-09-20 14:24:25 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-24 14:37:24 +02:00
|
|
|
import 'package:cw_core/transaction_direction.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
|
|
|
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
|
|
|
|
class TransactionRow extends StatelessWidget {
|
2024-09-20 14:24:25 +00:00
|
|
|
TransactionRow({
|
|
|
|
required this.direction,
|
|
|
|
required this.formattedDate,
|
|
|
|
required this.formattedAmount,
|
|
|
|
required this.formattedFiatAmount,
|
|
|
|
required this.isPending,
|
|
|
|
required this.isReceivedSilentPayment,
|
|
|
|
required this.title,
|
|
|
|
required this.onTap,
|
|
|
|
});
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-01-08 14:26:34 +02:00
|
|
|
final VoidCallback onTap;
|
|
|
|
final TransactionDirection direction;
|
|
|
|
final String formattedDate;
|
|
|
|
final String formattedAmount;
|
|
|
|
final String formattedFiatAmount;
|
|
|
|
final bool isPending;
|
2024-09-20 14:24:25 +00:00
|
|
|
final bool isReceivedSilentPayment;
|
2023-02-08 18:47:12 +02:00
|
|
|
final String title;
|
2020-01-08 14:26:34 +02:00
|
|
|
|
2020-01-04 21:31:52 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
2020-12-18 20:02:08 +02:00
|
|
|
padding: EdgeInsets.fromLTRB(24, 8, 24, 8),
|
2020-07-22 13:04:11 +03:00
|
|
|
color: Colors.transparent,
|
|
|
|
child: Row(
|
2020-12-18 20:02:08 +02:00
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: 36,
|
|
|
|
width: 36,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
2024-09-20 14:24:25 +00:00
|
|
|
color: Theme.of(context).extension<TransactionTradeTheme>()!.rowsColor),
|
|
|
|
child: Image.asset(direction == TransactionDirection.incoming
|
|
|
|
? 'assets/images/down_arrow.png'
|
|
|
|
: 'assets/images/up_arrow.png'),
|
2020-12-18 20:02:08 +02:00
|
|
|
),
|
|
|
|
SizedBox(width: 12),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
2024-09-20 14:24:25 +00:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
|
|
|
)),
|
|
|
|
if (isReceivedSilentPayment) TxTag(tag: S.of(context).silent_payment),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Text(formattedAmount,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor))
|
|
|
|
]),
|
|
|
|
SizedBox(height: 5),
|
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[
|
|
|
|
Text(formattedDate,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor)),
|
|
|
|
Text(formattedFiatAmount,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color:
|
|
|
|
Theme.of(context).extension<CakeTextTheme>()!.dateSectionRowColor))
|
|
|
|
])
|
|
|
|
],
|
|
|
|
))
|
2020-12-18 20:02:08 +02:00
|
|
|
],
|
|
|
|
),
|
2020-01-04 21:31:52 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
2024-09-20 14:24:25 +00:00
|
|
|
|
|
|
|
// A tag to add context to a transaction
|
|
|
|
// example use: differ silent payments from regular txs
|
|
|
|
class TxTag extends StatelessWidget {
|
|
|
|
TxTag({required this.tag});
|
|
|
|
|
|
|
|
final String tag;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
height: 17,
|
|
|
|
padding: EdgeInsets.only(left: 6, right: 6),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8.5)),
|
|
|
|
color: Theme.of(context).extension<TransactionTradeTheme>()!.rowsColor,
|
|
|
|
),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
tag.toLowerCase(),
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
|
|
|
|
fontSize: 9,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|