import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:tunas/pages/transactions/widgets/transaction_add_dialog.dart'; import 'package:tunas/repositories/account/models/transaction.dart'; class TransactionLine extends StatelessWidget { final Transaction transaction; final double subTotal; const TransactionLine({super.key, required this.transaction, required this.subTotal}); @override Widget build(BuildContext context) { return InkWell( onTap: () => TransactionAddDialog.show(context, transaction), child: MergeSemantics( child: Container( padding: const EdgeInsets.symmetric(vertical: 9, horizontal: 10), margin: const EdgeInsets.symmetric(vertical: 2, horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( width: 100, child: Text(DateFormat('dd-MM-yyyy', 'fr_FR').format(transaction.date)) ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( transaction.category, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18) ), Text(transaction.description), ], ), ), SizedBox( width: 100, child: Text(transaction.account), ), SizedBox( width: 120, child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( NumberFormat(transaction.value > 0 ? '+#######.00 €' : '#######.00 €', 'fr_FR').format(transaction.value), style: TextStyle( color: transaction.value > 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error ) ), Text( NumberFormat('#######.00 €', 'fr_FR').format(subTotal), style: TextStyle( color: subTotal > 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.error ) ), ], ), ) ], ) ) ) ); } }