adding CityWallet functionality

This commit is contained in:
Prince
2026-06-11 16:33:22 +02:00
parent b10d233428
commit ad79bf2af8
7 changed files with 301 additions and 84 deletions

View File

@@ -78,6 +78,41 @@ class _ConfirmScreenState extends State<ConfirmScreen>
if (!mounted) return;
// Check if the selected payment processor is a wallet (e.g. Velocity)
if (controller
.transactionController
.model
.selectedPaymentProcessor
.label ==
'WALLET') {
final otp = await _showOtpBottomSheet();
if (otp == null) return; // User cancelled or dismissed the bottom sheet
if (!mounted) return;
final transactionId =
controller.transactionController.model.confirmationData['id'];
final otpResponse = await controller.updateVelocityTransactionOtp(
transactionId,
{'verificationCode': otp},
);
if (!otpResponse.isSuccess) {
if (context.mounted) {
AppSnackBar.showError(
context,
controller.model.errorMessage ??
otpResponse.error ??
"OTP verification failed",
);
}
return;
}
if (!mounted) return;
}
// Proceed with normal flow after OTP step (or skip if not WALLET)
if (controller
.transactionController
.model
@@ -99,6 +134,101 @@ class _ConfirmScreenState extends State<ConfirmScreen>
}
}
Future<String?> _showOtpBottomSheet() {
final otpController = TextEditingController();
final formKey = GlobalKey<FormState>();
return showModalBottomSheet<String>(
context: context,
isDismissible: false,
enableDrag: false,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (context) {
return Padding(
padding: EdgeInsets.only(
left: 24,
right: 24,
top: 24,
bottom: MediaQuery.of(context).viewInsets.bottom + 24,
),
child: Form(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(2),
),
),
),
const SizedBox(height: 20),
Text(
'OTP Verification',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 8),
Text(
'Please enter the OTP sent to your mobile/email',
style: TextStyle(fontSize: 14, color: Colors.grey.shade600),
),
const SizedBox(height: 20),
TextFormField(
controller: otpController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Enter OTP',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
validator: (value) {
if (value == null || value.trim().isEmpty) {
return 'Please enter the OTP';
}
return null;
},
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
if (formKey.currentState!.validate()) {
Navigator.of(context).pop(otpController.text.trim());
}
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'Submit OTP',
style: TextStyle(fontSize: 16),
),
),
),
],
),
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(