|
|
|
|
@ -113,6 +113,8 @@ class SMSOTP {
|
|
|
|
|
Utils.changeAppLanguage(context: context);
|
|
|
|
|
},
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
top: false,
|
|
|
|
|
bottom: Platform.isIOS ? false : true,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 21, vertical: 20),
|
|
|
|
|
child: Column(
|
|
|
|
|
@ -147,7 +149,6 @@ class SMSOTP {
|
|
|
|
|
pinTextAnimatedSwitcherDuration: Duration(milliseconds: 300),
|
|
|
|
|
pinBoxRadius: 18,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 30),
|
|
|
|
|
@ -181,103 +182,6 @@ class SMSOTP {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// return showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// barrierColor: Colors.black.withOpacity(0.63),
|
|
|
|
|
// builder: (context) {
|
|
|
|
|
// projectProvider = Provider.of(context);
|
|
|
|
|
//
|
|
|
|
|
// return Dialog(
|
|
|
|
|
// backgroundColor: Colors.white,
|
|
|
|
|
// shape: RoundedRectangleBorder(),
|
|
|
|
|
// insetPadding: EdgeInsets.only(left: 21, right: 21),
|
|
|
|
|
// child: StatefulBuilder(builder: (context, setState) {
|
|
|
|
|
// if (displayTime == '') {
|
|
|
|
|
// startTimer(setState);
|
|
|
|
|
// if (Platform.isAndroid ) {
|
|
|
|
|
// if (type == 1) checkSignature();
|
|
|
|
|
// else if(type == 4) _listenWhatsAppCode();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return Container(
|
|
|
|
|
// padding: EdgeInsets.only(left: 21, right: 18, top: 39, bottom: 59),
|
|
|
|
|
// child: Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// Row(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// children: [
|
|
|
|
|
// SvgPicture.asset(
|
|
|
|
|
// type == 1 ? "assets/images/new/verify_sms.svg" : "assets/images/new/verify_whatsapp.svg",
|
|
|
|
|
// height: 50,
|
|
|
|
|
// width: 50,
|
|
|
|
|
// ),
|
|
|
|
|
// IconButton(
|
|
|
|
|
// padding: EdgeInsets.zero,
|
|
|
|
|
// icon: Icon(Icons.close),
|
|
|
|
|
// constraints: BoxConstraints(),
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
//
|
|
|
|
|
// this.onFailure();
|
|
|
|
|
// },
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 22),
|
|
|
|
|
// Text(
|
|
|
|
|
// TranslationBase.of(context).pleaseEnterTheVerificationCode + ' xxxxxxxx' + mobileNo.toString().substring(mobileNo.toString().length - 3),
|
|
|
|
|
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48),
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 18),
|
|
|
|
|
// Directionality(
|
|
|
|
|
// textDirection: TextDirection.ltr,
|
|
|
|
|
// child: Center(
|
|
|
|
|
// child: OTPWidget(
|
|
|
|
|
// autoFocus: true,
|
|
|
|
|
// controller: _pinPutController,
|
|
|
|
|
// defaultBorderColor: Color(0xffD8D8D8),
|
|
|
|
|
// maxLength: 4,
|
|
|
|
|
// onTextChanged: (text) {},
|
|
|
|
|
// pinBoxColor: Colors.white,
|
|
|
|
|
// onDone: (code) => _onOtpCallBack(code, false),
|
|
|
|
|
// textBorderColor: Color(0xffD8D8D8),
|
|
|
|
|
// pinBoxWidth: 60,
|
|
|
|
|
// pinBoxHeight: 60,
|
|
|
|
|
// pinTextStyle: TextStyle(
|
|
|
|
|
// fontSize: 24.0,
|
|
|
|
|
// color: Color(0xff2B353E),
|
|
|
|
|
// ),
|
|
|
|
|
// pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
|
|
|
|
|
// pinTextAnimatedSwitcherDuration: Duration(milliseconds: 300),
|
|
|
|
|
// pinBoxRadius: 10,
|
|
|
|
|
// keyboardType: TextInputType.number,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// SizedBox(height: 30),
|
|
|
|
|
// RichText(
|
|
|
|
|
// text: TextSpan(
|
|
|
|
|
// text: TranslationBase.of(context).validationMessage + '\n',
|
|
|
|
|
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48),
|
|
|
|
|
// children: <TextSpan>[
|
|
|
|
|
// TextSpan(
|
|
|
|
|
// text: displayTime,
|
|
|
|
|
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.48),
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// }),
|
|
|
|
|
// );
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextStyle buildTextStyle() {
|
|
|
|
|
@ -289,26 +193,18 @@ class SMSOTP {
|
|
|
|
|
InputDecoration buildInputDecoration(BuildContext context) {
|
|
|
|
|
return InputDecoration(
|
|
|
|
|
counterText: " ",
|
|
|
|
|
|
|
|
|
|
// ts/images/password_icon.png
|
|
|
|
|
|
|
|
|
|
// contentPadding: EdgeInsets.only(top: 20, bottom: 20),
|
|
|
|
|
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
|
|
|
borderSide: BorderSide(color: Colors.black),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
|
|
|
borderSide: BorderSide(color: Theme.of(context).primaryColor),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
|
|
|
borderSide: BorderSide(color: CustomColors.accentColor),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
|
|
|
borderSide: BorderSide(color: CustomColors.accentColor),
|
|
|
|
|
@ -383,16 +279,42 @@ class SMSOTP {
|
|
|
|
|
_timer = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void hideSMSBox(context) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
// New method for flexible timer handling - pause timer without disposing
|
|
|
|
|
void pauseTimer() {
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onOtpCallBack(String otpCode, bool isAutofill) {
|
|
|
|
|
if (otpCode.length == 4) {
|
|
|
|
|
onSuccess(otpCode);
|
|
|
|
|
// Method to resume the timer from current remaining time
|
|
|
|
|
void resumeTimer(setState) {
|
|
|
|
|
if (!_isDisposed && remainingTime > 0) {
|
|
|
|
|
startTimer(setState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Method to reset timer to original time and restart
|
|
|
|
|
void resetTimer(setState, {int? newTime}) {
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
if (newTime != null) {
|
|
|
|
|
remainingTime = newTime;
|
|
|
|
|
} else {
|
|
|
|
|
remainingTime = 120; // Reset to original 2 minutes
|
|
|
|
|
}
|
|
|
|
|
if (!_isDisposed) {
|
|
|
|
|
startTimer(setState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Method to check if timer is currently running
|
|
|
|
|
bool isTimerRunning() {
|
|
|
|
|
return _timer != null && _timer!.isActive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Method to get current remaining time
|
|
|
|
|
int getCurrentRemainingTime() {
|
|
|
|
|
return remainingTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkSignature() async {
|
|
|
|
|
SmsVerification.startListeningSms().then((message) {
|
|
|
|
|
// setState(() {
|
|
|
|
|
@ -427,4 +349,14 @@ class SMSOTP {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void hideSMSBox(context) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onOtpCallBack(String otpCode, bool isAutofill) {
|
|
|
|
|
if (otpCode.length == 4) {
|
|
|
|
|
onSuccess(otpCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|