diff --git a/lib/customWidget/dialogues/success_dialogue.dart b/lib/customWidget/dialogues/success_dialogue.dart index 1e3d1463e5f74c65d0d9dc5249f2d8fec7f6b1a1..5fd057f4093aa7a60441918926545072a6196f68 100644 --- a/lib/customWidget/dialogues/success_dialogue.dart +++ b/lib/customWidget/dialogues/success_dialogue.dart @@ -10,40 +10,41 @@ Future<dynamic> verificationSuccess( required String title, required String subtitle}) { return Get.dialog( - barrierDismissible: false, barrierColor: AppColor.black.withOpacity(0.5), Center( child: SingleChildScrollView( - child: AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(12.0))), - backgroundColor: AppColor.white, - contentPadding: EdgeInsets.zero, - content: Padding( - padding: EdgeInsets.all(24.0.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - assetName, - width: 64, - height: 64, - ), - AppText( - text: title, - fontSize: TextSize.textSubHeadingSize, - fontWeight: FontWeight.w500, - textColor: AppColor.slateGray, - ).paddingOnly(top: 16.0), - AppText( - text: subtitle, - fontSize: TextSize.textSmallSize, - fontWeight: FontWeight.w400, - textColor: AppColor.lightGrey, - maxLine: 2, - textAlign: TextAlign.center, - ).paddingOnly(top: 8.0), - ], + child: PopScope(canPop: false, + child: AlertDialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(12.0))), + backgroundColor: AppColor.white, + contentPadding: EdgeInsets.zero, + content: Padding( + padding: EdgeInsets.all(24.0.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + assetName, + width: 64, + height: 64, + ), + AppText( + text: title, + fontSize: TextSize.textSubHeadingSize, + fontWeight: FontWeight.w500, + textColor: AppColor.slateGray, + ).paddingOnly(top: 16.0), + AppText( + text: subtitle, + fontSize: TextSize.textSmallSize, + fontWeight: FontWeight.w400, + textColor: AppColor.lightGrey, + maxLine: 2, + textAlign: TextAlign.center, + ).paddingOnly(top: 8.0), + ], + ), ), ), ), diff --git a/lib/serverRequest/all_request.dart b/lib/serverRequest/all_request.dart index e88ecebe9be868a11be00175360e6401dec0f97b..437072ac47091cf0c61e2905d76762e319690e5a 100644 --- a/lib/serverRequest/all_request.dart +++ b/lib/serverRequest/all_request.dart @@ -115,8 +115,7 @@ class AllHttpRequest { try { ///Generate authorization token for send otp String url = '$baseUrlForSendOtp/api/sendsms/token?action=generate'; - // String username = 'Exidehtptrans1'; - // String password = '_<P)>lnL0{'; + String basicAuth = 'Basic ${base64.encode(utf8.encode('${AppConstants.username}:${AppConstants.password}'))}'; Map<String, String>? headers = { @@ -134,10 +133,12 @@ class AllHttpRequest { sendOtp(); } else { Fluttertoast.showToast(msg: apiError.tr); + log("Error generate auth--${response.statusCode}"); throw Error(); } } catch (e) { Fluttertoast.showToast(msg: apiError.tr); + log("Error generate auth--$e"); throw Error(); } } @@ -165,10 +166,12 @@ class AllHttpRequest { ///If success do nothing } else { Fluttertoast.showToast(msg: apiError.tr); + log("Error generate auth--${response.statusCode}"); throw Error(); } } catch (e) { Fluttertoast.showToast(msg: apiError.tr); + log("Error generate auth--$e"); throw Error(); } } diff --git a/lib/views/verifyOTP/controller/verify_otp_controller.dart b/lib/views/verifyOTP/controller/verify_otp_controller.dart index 04324bb6c31879da5dd2a4f0f85ac4a97efbef4a..4e5803796bc472c199e33db184a2ab27b04afc63 100644 --- a/lib/views/verifyOTP/controller/verify_otp_controller.dart +++ b/lib/views/verifyOTP/controller/verify_otp_controller.dart @@ -11,9 +11,8 @@ import '../../../customWidget/dialogues/success_dialogue.dart'; class VerifyOtpController extends GetxController { final baseController = Get.find<BaseController>(); - RxInt counter = 20.obs; + RxInt counter = 90.obs; Timer? timer; - RxString enteredOtp = "".obs; StreamController<ErrorAnimationType> errorController = StreamController<ErrorAnimationType>(); TextEditingController otpTextController = TextEditingController(); @@ -26,10 +25,16 @@ class VerifyOtpController extends GetxController { super.onInit(); } + @override + void onClose() { + timer?.cancel(); + super.onClose(); + } + onClickVerifyHandler(BuildContext context) { verifyLoader(true); Future.delayed( - const Duration(seconds: 30), + const Duration(seconds: 2), () => { if (baseController.generatedOtp.value == otpTextController.value.text) @@ -42,10 +47,9 @@ class VerifyOtpController extends GetxController { } else { - otpTextController.clear(), - verifyLoader(false), + resetLoading(), Fluttertoast.showToast(msg: incorrectOTPError.tr) - } + }, }); update(); @@ -53,11 +57,12 @@ class VerifyOtpController extends GetxController { onClickResendOTP() { resetTimer(); - startTimer(); - otpTextController.clear(); + resetLoading(); + + ///During resend otp auth is fetched from state variable and is not regenerated + AllHttpRequest().sendOtp(); update(); - AllHttpRequest().generateAuth(); } startTimer() { @@ -76,4 +81,10 @@ class VerifyOtpController extends GetxController { ///Set counter to 90s counter = 90.obs; } + + resetLoading() { + ///Reset Loading and clear otp in pintextfield + otpTextController.clear(); + verifyLoader(false); + } } diff --git a/lib/views/verifyOTP/view/verify_otp_screen.dart b/lib/views/verifyOTP/view/verify_otp_screen.dart index 1b9d85cd81cdae9aff6391a6d0a42961c64d8308..7a0104f406f0101f9b2fc7b6de3a4b6b026c24a0 100644 --- a/lib/views/verifyOTP/view/verify_otp_screen.dart +++ b/lib/views/verifyOTP/view/verify_otp_screen.dart @@ -1,22 +1,10 @@ -import 'package:exide_crr/constants/image_constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:pin_code_fields/pin_code_fields.dart'; -import '../../../appLocalization/language_key.dart'; import '../../../constants/app_constants.dart'; -import '../../../constants/font_constants.dart'; -import '../../../customWidget/app_text.dart'; -import '../../../customWidget/button_widget.dart'; import '../../../customWidget/otp_text_field/otp_text_field.dart'; -import '../../../customWidget/otp_text_field/otp_text_field_style.dart'; import '../../../res/app_color_text_size.dart'; -import '../../../serverRequest/all_request.dart'; -import '../../../utils/res/styles.dart'; import '../controller/verify_otp_controller.dart'; -import '../../../customWidget/dialogues/success_dialogue.dart'; import '../widgets/floating_button.dart'; import '../widgets/pincode_text_field.dart'; import '../widgets/resend_otp_text.dart'; diff --git a/lib/views/verifyOTP/widgets/pincode_text_field.dart b/lib/views/verifyOTP/widgets/pincode_text_field.dart index 7edec68f1f858b55f7b202f22dbab3e34ab48228..01c249c173323e06997ca866195d7b1e214016d1 100644 --- a/lib/views/verifyOTP/widgets/pincode_text_field.dart +++ b/lib/views/verifyOTP/widgets/pincode_text_field.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:google_fonts/google_fonts.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; - -import '../../../constants/font_constants.dart'; import '../../../res/app_color_text_size.dart'; import '../../../utils/res/styles.dart'; import '../controller/verify_otp_controller.dart'; -Widget pinCodeField(VerifyOtpController controller,BuildContext context) { +Widget pinCodeField(VerifyOtpController controller, BuildContext context) { return PinCodeTextField( keyboardType: TextInputType.number, length: 4, @@ -33,10 +30,6 @@ Widget pinCodeField(VerifyOtpController controller,BuildContext context) { animationDuration: const Duration(milliseconds: 300), errorAnimationController: controller.errorController, controller: controller.otpTextController, - // Pass it here - onChanged: (text) { - controller.enteredOtp(text); - }, appContext: context, - ).paddingOnly(top: 8.0.h, bottom: 16.0.h, right: 92.w); + ).paddingOnly(top: 8.0.h, bottom: 16, right: 92.w); }