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 { const TransactionSuccessScreen({super.key}); @override State createState() => _TransactionSuccessScreen(); } class _TransactionSuccessScreen extends State { final String transactionDate = "18th March, 2025 04:30 PM"; final String referenceNumber = "TXN32131093012931993"; 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) { return Scaffold( body: SafeArea( child: Stack( children: [ // Main content Align( alignment: Alignment.center, child: Column( mainAxisSize: MainAxisSize.min, children: [ const CircleAvatar( radius: 50, backgroundColor: Colors.blue, child: Icon( Icons.check, color: Colors.white, size: 60, ), ), const SizedBox(height: 24), const Text( "Transaction Successful", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, ), textAlign: TextAlign.center, ), const SizedBox(height: 6), Text( "On $transactionDate", style: const TextStyle( fontSize: 14, color: Colors.black54, ), textAlign: TextAlign.center, ), const SizedBox(height: 16), Text( "Reference No: $referenceNumber", style: const TextStyle( fontSize: 12, color: Colors.black87, ), 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: const Text("Share"), style: ElevatedButton.styleFrom( shape: const StadiumBorder(), padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: Colors.white, foregroundColor: Colors.blueAccent, side: const BorderSide(color: Colors.black, width: 1), elevation: 0 ), ), ), 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: Colors.blue[900], foregroundColor: Colors.white, ), child: const Text("Done"), ), ), ], ), ), ), ], ), ), ); } }