Add Beneficiary Validation API integration
This commit is contained in:
@@ -1,18 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:confetti/confetti.dart';
|
||||
import 'dart:math';
|
||||
|
||||
class BeneficiaryResultPage extends StatelessWidget {
|
||||
class BeneficiaryResultPage extends StatefulWidget {
|
||||
final bool isSuccess;
|
||||
|
||||
const BeneficiaryResultPage({super.key, required this.isSuccess});
|
||||
|
||||
@override
|
||||
State<BeneficiaryResultPage> createState() => _BeneficiaryResultPageState();
|
||||
}
|
||||
|
||||
class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
||||
late ConfettiController _confettiController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_confettiController =
|
||||
ConfettiController(duration: const Duration(seconds: 3));
|
||||
if (widget.isSuccess) {
|
||||
_confettiController.play();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_confettiController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final successAnimation = 'assets/animations/done.json';
|
||||
final errorAnimation = 'assets/animations/error.json';
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Text(
|
||||
isSuccess ? 'Beneficiary Added Successfully!' : 'Beneficiary Addition Failed!',
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
||||
body: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Lottie.asset(
|
||||
widget.isSuccess ? successAnimation : errorAnimation,
|
||||
width: 150,
|
||||
height: 150,
|
||||
repeat: false,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
widget.isSuccess
|
||||
? 'Beneficiary Added Successfully!'
|
||||
: 'Beneficiary Addition Failed!',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: widget.isSuccess ? Colors.green : Colors.red,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.isSuccess)
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ConfettiWidget(
|
||||
confettiController: _confettiController,
|
||||
blastDirection: pi / 2,
|
||||
maxBlastForce: 10,
|
||||
minBlastForce: 5,
|
||||
emissionFrequency: 0.05,
|
||||
numberOfParticles: 20,
|
||||
gravity: 0.2,
|
||||
shouldLoop: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user