Files
kmobile/lib/features/fund_transfer/screens/transaction_success_screen.dart
2025-08-18 03:32:51 +05:30

138 lines
5.0 KiB
Dart

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<TransactionSuccessScreen> createState() => _TransactionSuccessScreen();
}
class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
final ScreenshotController _screenshotController = ScreenshotController();
Future<void> _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: const TextStyle(fontSize: 14, color: Colors.black54),
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
Text(
"${AppLocalizations.of(context).toAccountNumber}: $creditAccount",
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: Text(AppLocalizations.of(context).share),
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(vertical: 16),
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Theme.of(context).primaryColorLight,
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: Theme.of(context).primaryColorDark,
foregroundColor:
Theme.of(context).scaffoldBackgroundColor,
),
child: Text(AppLocalizations.of(context).done),
),
),
],
),
),
),
],
),
),
);
}
}