Add Beneficiary Animations

This commit is contained in:
2025-08-07 21:07:32 +05:30
parent 2dd7f4079b
commit a1365b19d5

View File

@@ -28,7 +28,7 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
final TextEditingController phoneController = TextEditingController();
bool _isLoading2 = false;
late String accountType;
@override
@@ -41,46 +41,10 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
});
}
/*void _submitForm() {
if (_formKey.currentState!.validate()) {
// Handle successful submission
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.grey[900],
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.all(12),
duration: const Duration(seconds: 5),
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
AppLocalizations.of(context).beneficiaryAdded,
style: TextStyle(color: Theme.of(context).dialogBackgroundColor),
),
),
TextButton(
onPressed: () {
// Navigate to Payment Screen or do something
},
style: TextButton.styleFrom(foregroundColor: Theme.of(context).primaryColorLight),
child: Text(AppLocalizations.of(context).payNow),
),
IconButton(
icon: Icon(Icons.close, color: Theme.of(context).scaffoldBackgroundColor),
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
],
),
),
);
}
}*/
ifsc? _ifscData;
bool _isLoading = false;
bool _isLoading = false; //for validateIFSC()
void _validateIFSC() async {
var beneficiaryService = getIt<BeneficiaryService>();
@@ -115,9 +79,19 @@ bool _isLoading = false;
String _selectedAccountType = 'Savings'; // default value
void validateAndAddBeneficiary() async {
setState(() {
_isLoading = true;
});
// Show spinner and disable UI
showDialog(
context: context,
barrierDismissible: false, // Prevent dismiss on tap outside
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async => false, // Disable back button
child: const Center(
child: CircularProgressIndicator(),
),
);
},
);
final beneficiary = Beneficiary(
accountNo: accountNumberController.text.trim(),
@@ -133,6 +107,7 @@ bool _isLoading = false;
bool isFound = await service.checkIfFound(beneficiary.accountNo);
if (context.mounted) {
Navigator.pop(context); // Close the spinner
Navigator.push(
context,
MaterialPageRoute(
@@ -141,15 +116,10 @@ bool _isLoading = false;
);
}
} catch (e) {
Navigator.pop(context); // Close the spinner
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Something went wrong during validation.")),
);
} finally {
if (mounted) {
setState(() {
_isLoading2 = false;
});
}
}
}
@@ -466,7 +436,7 @@ bool _isLoading = false;
child: SizedBox(
width: 250,
child: ElevatedButton(
onPressed: _isLoading2 ? null :
onPressed:
validateAndAddBeneficiary,
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),