bug fixes on UI
This commit is contained in:
@@ -31,31 +31,31 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
final _emailController = TextEditingController();
|
||||
final _phoneController = TextEditingController();
|
||||
bool showAdditionalRecipientDetails = false;
|
||||
String selectedCountryCode = '+263'; // Default to ZW
|
||||
String selectedCountryCode = '263'; // Default to ZW
|
||||
|
||||
// Common country codes with flags and names
|
||||
final List<Map<String, String>> countryCodes = [
|
||||
{'code': '+263', 'name': 'ZW', 'flag': '🇿🇼'},
|
||||
{'code': '+27', 'name': 'ZA', 'flag': '🇿🇦'},
|
||||
{'code': '+1', 'name': 'US', 'flag': '🇺🇸'},
|
||||
{'code': '+44', 'name': 'UK', 'flag': '🇬🇧'},
|
||||
{'code': '+61', 'name': 'AU', 'flag': '🇦🇺'},
|
||||
{'code': '+91', 'name': 'IN', 'flag': '🇮🇳'},
|
||||
{'code': '+86', 'name': 'CN', 'flag': '🇨🇳'},
|
||||
{'code': '+81', 'name': 'JP', 'flag': '🇯🇵'},
|
||||
{'code': '+49', 'name': 'DE', 'flag': '🇩🇪'},
|
||||
{'code': '+33', 'name': 'FR', 'flag': '🇫🇷'},
|
||||
{'code': '+39', 'name': 'IT', 'flag': '🇮🇹'},
|
||||
{'code': '+34', 'name': 'ES', 'flag': '🇪🇸'},
|
||||
{'code': '+7', 'name': 'RU', 'flag': '🇷🇺'},
|
||||
{'code': '+55', 'name': 'BR', 'flag': '🇧🇷'},
|
||||
{'code': '+52', 'name': 'MX', 'flag': '🇲🇽'},
|
||||
{'code': '+971', 'name': 'AE', 'flag': '🇦🇪'},
|
||||
{'code': '+966', 'name': 'SA', 'flag': '🇸🇦'},
|
||||
{'code': '+234', 'name': 'NG', 'flag': '🇳🇬'},
|
||||
{'code': '+254', 'name': 'KE', 'flag': '🇰🇪'},
|
||||
{'code': '+233', 'name': 'GH', 'flag': '🇬🇭'},
|
||||
{'code': '+256', 'name': 'UG', 'flag': '🇺🇬'},
|
||||
{'code': '263', 'name': 'ZW', 'flag': '🇿🇼'},
|
||||
{'code': '27', 'name': 'ZA', 'flag': '🇿🇦'},
|
||||
{'code': '1', 'name': 'US', 'flag': '🇺🇸'},
|
||||
{'code': '44', 'name': 'UK', 'flag': '🇬🇧'},
|
||||
{'code': '61', 'name': 'AU', 'flag': '🇦🇺'},
|
||||
{'code': '91', 'name': 'IN', 'flag': '🇮🇳'},
|
||||
{'code': '86', 'name': 'CN', 'flag': '🇨🇳'},
|
||||
{'code': '81', 'name': 'JP', 'flag': '🇯🇵'},
|
||||
{'code': '49', 'name': 'DE', 'flag': '🇩🇪'},
|
||||
{'code': '33', 'name': 'FR', 'flag': '🇫🇷'},
|
||||
{'code': '39', 'name': 'IT', 'flag': '🇮🇹'},
|
||||
{'code': '34', 'name': 'ES', 'flag': '🇪🇸'},
|
||||
{'code': '7', 'name': 'RU', 'flag': '🇷🇺'},
|
||||
{'code': '55', 'name': 'BR', 'flag': '🇧🇷'},
|
||||
{'code': '52', 'name': 'MX', 'flag': '🇲🇽'},
|
||||
{'code': '971', 'name': 'AE', 'flag': '🇦🇪'},
|
||||
{'code': '966', 'name': 'SA', 'flag': '🇸🇦'},
|
||||
{'code': '234', 'name': 'NG', 'flag': '🇳🇬'},
|
||||
{'code': '254', 'name': 'KE', 'flag': '🇰🇪'},
|
||||
{'code': '233', 'name': 'GH', 'flag': '🇬🇭'},
|
||||
{'code': '256', 'name': 'UG', 'flag': '🇺🇬'},
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -110,20 +110,24 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
|
||||
_setupData() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
// check logged in phone number and prefill if exists
|
||||
if (prefs.containsKey('phone')) {
|
||||
updatePhoneNumber(prefs.getString('phone')!);
|
||||
}
|
||||
// or else check if there's a phone number from a previous transaction and prefill that
|
||||
else if (transactionController.model.formData.debitPhone != null) {
|
||||
updatePhoneNumber(transactionController.model.formData.debitPhone!);
|
||||
}
|
||||
|
||||
_nameController.text =
|
||||
transactionController.model.formData.creditName ?? '';
|
||||
_emailController.text =
|
||||
transactionController.model.formData.creditEmail ?? '';
|
||||
_amountController.text = transactionController.model.formData.amount;
|
||||
_phoneController.text =
|
||||
transactionController.model.formData.debitPhone ?? '';
|
||||
}
|
||||
|
||||
Future<void> updatePhoneNumber(String newNumber) async {
|
||||
newNumber = newNumber.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
for (var country in countryCodes) {
|
||||
if (newNumber.startsWith(country['code']!)) {
|
||||
setState(() {
|
||||
@@ -135,6 +139,10 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
}
|
||||
}
|
||||
|
||||
String getCountryName(String code) {
|
||||
return countryCodes.firstWhere((c) => c['code'] == code)['name']!;
|
||||
}
|
||||
|
||||
Future<void> _submitPayment(PaymentProcessor e, BuildContext context) async {
|
||||
controller.updateAmount(_amountController.text);
|
||||
if (!controller.model.selectedProvider!.requiresAmount) {
|
||||
@@ -155,6 +163,8 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
controller.updateSelectedPaymentProcessor(e);
|
||||
transactionController.updateSelectedPaymentProcessor(e);
|
||||
|
||||
controller.model.region = getCountryName(selectedCountryCode);
|
||||
|
||||
final apiResponse = await controller.doTransaction();
|
||||
|
||||
if (!apiResponse.isSuccess) {
|
||||
|
||||
Reference in New Issue
Block a user