import '../../../l10n/app_localizations.dart'; import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:screenshot/screenshot.dart'; import '../../../app.dart'; class TransactionSuccessScreen extends StatefulWidget { final String creditAccount; const TransactionSuccessScreen({super.key, required this.creditAccount}); @override State createState() => _TransactionSuccessScreen(); } class _TransactionSuccessScreen extends State { final ScreenshotController _screenshotController = ScreenshotController(); Future _shareScreenshot() async { final Uint8List? imageBytes = await _screenshotController.capture(); if (imageBytes != null) { final directory = await getTemporaryDirectory(); final imagePath = File('${directory.path}/transaction_success.png'); await imagePath.writeAsBytes(imageBytes); // SocialShare.shareOptions( // "Transaction Successful", // imagePath: imagePath.path, // ); } } @override Widget build(BuildContext context) { final String transactionDate = DateTime.now().toLocal().toString().split( ' ', )[0]; final String creditAccount = widget.creditAccount; return Scaffold( body: SafeArea( child: Stack( children: [ // Main content Align( alignment: Alignment.center, child: Column( mainAxisSize: MainAxisSize.min, children: [ CircleAvatar( radius: 50, backgroundColor: Theme.of(context).primaryColor, child: Icon(Icons.check, color: Theme.of(context).scaffoldBackgroundColor, size: 60), ), const SizedBox(height: 24), Text( AppLocalizations.of(context).transactionSuccess, style: const TextStyle( fontSize: 18, fontWeight: FontWeight.w600), textAlign: TextAlign.center, ), const SizedBox(height: 6), Text( "On $transactionDate", style: TextStyle(fontSize: 14, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6)), textAlign: TextAlign.center, ), const SizedBox(height: 16), Text( "${AppLocalizations.of(context).toAccountNumber}: $creditAccount", style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8)), textAlign: TextAlign.center, ), ], ), ), // Buttons at the bottom Align( alignment: Alignment.bottomCenter, child: Padding( padding: const EdgeInsets.fromLTRB(36, 0, 36, 25), child: Row( children: [ Expanded( child: OutlinedButton.icon( onPressed: _shareScreenshot, icon: const Icon(Icons.share, size: 18), label: Text(AppLocalizations.of(context).share, style: TextStyle(color: Theme.of(context).colorScheme.onPrimaryContainer), ), style: ElevatedButton.styleFrom( shape: const StadiumBorder(), padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: Theme.of(context).primaryColorDark, foregroundColor: Theme.of(context).scaffoldBackgroundColor, ), ), ), const SizedBox(width: 12), Expanded( child: ElevatedButton( onPressed: () { // Done action Navigator.push( context, MaterialPageRoute( builder: (context) => const NavigationScaffold(), ), ); }, style: ElevatedButton.styleFrom( shape: const StadiumBorder(), padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: Theme.of(context).primaryColorDark, foregroundColor: Theme.of(context).scaffoldBackgroundColor, ), child: Text(AppLocalizations.of(context).done), ), ), ], ), ), ), ], ), ), ); } }