Transaction Details page
This commit is contained in:
160
lib/features/accounts/screens/transaction_details_screen.dart
Normal file
160
lib/features/accounts/screens/transaction_details_screen.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
class TransactionDetailsScreen extends StatelessWidget {
|
||||
final dynamic transaction;
|
||||
|
||||
const TransactionDetailsScreen({super.key, required this.transaction});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isCredit = transaction.type?.toUpperCase() == 'CR';
|
||||
|
||||
// Future<void> _shareScreenshot() async {
|
||||
// try {
|
||||
// RenderRepaintBoundary boundary =
|
||||
// _shareKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
|
||||
// ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
||||
// ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
// Uint8List pngBytes = byteData!.buffer.asUint8List();
|
||||
|
||||
// final tempDir = await getTemporaryDirectory();
|
||||
// final file = await File('${tempDir.path}/payment_result.png').create();
|
||||
// await file.writeAsBytes(pngBytes);
|
||||
|
||||
// await Share.shareXFiles(
|
||||
// [XFile(file.path)],
|
||||
// text: AppLocalizations.of(context).paymentResult,
|
||||
// );
|
||||
// } catch (e) {
|
||||
// if (!mounted) return;
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(
|
||||
// '${AppLocalizations.of(context).failedToShareScreenshot}: $e',
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Transaction Details")),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
// Absolute center for amount + icon + date + details + share button
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Amount + icon + Share Button
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"₹ ${transaction.amount}",
|
||||
style: const TextStyle(
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
isCredit ? Symbols.call_received : Symbols.call_made,
|
||||
color: isCredit ? Colors.green : Colors.red,
|
||||
size: 28,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Date centered
|
||||
Text(
|
||||
transaction.date ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
// All details
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildDetailRow("Transaction Type", transaction.type ?? ""),
|
||||
_buildDetailRow("Transfer Type", transaction.name.split("/").first ?? ""),
|
||||
if(transaction.name.length> 12) ... [
|
||||
_buildDetailRow("UTR No", transaction.name.split("= ")[1].split(" ")[0] ?? ""),
|
||||
_buildDetailRow("Beneficiary Account No", transaction.name.split("A/C ").last ?? "")
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
// ElevatedButton.icon(
|
||||
// onPressed: _shareScreenshot,
|
||||
// icon: Icon(
|
||||
// Icons.share_rounded,
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// ),
|
||||
// label: Text(
|
||||
// AppLocalizations.of(context).share,
|
||||
// style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
// ),
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 12),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// side: BorderSide(color: Theme.of(context).primaryColor, width: 1),
|
||||
// borderRadius: BorderRadius.circular(30),
|
||||
// ),
|
||||
// textStyle: const TextStyle(
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"$label: ",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user