|
|
|
@ -11,10 +11,12 @@ import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/otp_widget.dart';
|
|
|
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
|
|
|
|
|
|
final ValueNotifier<String> otpFieldClear = ValueNotifier<String>("");
|
|
|
|
|
|
|
|
|
|
class OtpDialog {
|
|
|
|
|
final int type;
|
|
|
|
|
final int? mobileNo;
|
|
|
|
|
final Function(String) onSuccess;
|
|
|
|
|
final Function(String, TextEditingController _pinPutController) onSuccess;
|
|
|
|
|
final Function onFailure;
|
|
|
|
|
final BuildContext context;
|
|
|
|
|
final Function onResendCode;
|
|
|
|
@ -96,58 +98,70 @@ class OtpDialog {
|
|
|
|
|
6.height,
|
|
|
|
|
(LocaleKeys.pleaseEnterTheVerificationCodeSentTo.tr() + ' xxxxxxxx' + mobileNo.toString().substring(mobileNo.toString().length - 3)).toText16(),
|
|
|
|
|
18.height,
|
|
|
|
|
Directionality(
|
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: OTPWidget(
|
|
|
|
|
autoFocus: true,
|
|
|
|
|
controller: _pinPutController,
|
|
|
|
|
defaultBorderColor: const Color(0xffD8D8D8),
|
|
|
|
|
maxLength: 4,
|
|
|
|
|
onTextChanged: (text) {},
|
|
|
|
|
pinBoxColor: Colors.white,
|
|
|
|
|
onDone: (code) => _onOtpCallBack(code, null),
|
|
|
|
|
textBorderColor: const Color(0xffD8D8D8),
|
|
|
|
|
pinBoxWidth: 60,
|
|
|
|
|
pinBoxHeight: 60,
|
|
|
|
|
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
|
|
|
|
|
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
|
|
|
|
|
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
|
|
|
|
|
pinBoxRadius: 10,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
10.height,
|
|
|
|
|
stopTimer
|
|
|
|
|
? Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LocaleKeys.codeExpire.tr().toText16(
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
12.width,
|
|
|
|
|
Image.asset(
|
|
|
|
|
"assets/icons/ic_alarm.png",
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: LocaleKeys.theVerificationCodeWillExpireIn.tr() + '\n',
|
|
|
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, letterSpacing: -0.48),
|
|
|
|
|
children: <TextSpan>[
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: displayTime,
|
|
|
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.textMixColor, letterSpacing: -0.48),
|
|
|
|
|
ValueListenableBuilder<String>(
|
|
|
|
|
builder: (BuildContext context, String value, Widget? child) {
|
|
|
|
|
// This builder will only get called when the _counter
|
|
|
|
|
// is updated.
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Directionality(
|
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: OTPWidget(
|
|
|
|
|
autoFocus: true,
|
|
|
|
|
controller: _pinPutController,
|
|
|
|
|
defaultBorderColor: const Color(0xffD8D8D8),
|
|
|
|
|
maxLength: 4,
|
|
|
|
|
onTextChanged: (text) {},
|
|
|
|
|
pinBoxColor: Colors.white,
|
|
|
|
|
onDone: (code) => _onOtpCallBack(code, null),
|
|
|
|
|
textBorderColor: const Color(0xffD8D8D8),
|
|
|
|
|
pinBoxWidth: 60,
|
|
|
|
|
pinBoxHeight: 60,
|
|
|
|
|
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
|
|
|
|
|
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
|
|
|
|
|
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
|
|
|
|
|
pinBoxRadius: 10,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
10.height,
|
|
|
|
|
stopTimer
|
|
|
|
|
? Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: LocaleKeys.codeExpire.tr().toText16(
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
12.width,
|
|
|
|
|
Image.asset(
|
|
|
|
|
"assets/icons/ic_alarm.png",
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: LocaleKeys.theVerificationCodeWillExpireIn.tr() + '\n',
|
|
|
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.darkTextColor, letterSpacing: -0.48),
|
|
|
|
|
children: <TextSpan>[
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: displayTime,
|
|
|
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.textMixColor, letterSpacing: -0.48),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
valueListenable: otpFieldClear,
|
|
|
|
|
),
|
|
|
|
|
18.height,
|
|
|
|
|
DefaultButton(
|
|
|
|
|
stopTimer ? LocaleKeys.resend.tr() : LocaleKeys.cancel.tr(),
|
|
|
|
@ -238,14 +252,15 @@ class OtpDialog {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void hideSMSBox(context) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
void hideSMSBox(context) {
|
|
|
|
|
onFailure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onOtpCallBack(String otpCode, bool? isAutofill) {
|
|
|
|
|
if (otpCode.length == 4) {
|
|
|
|
|
stopTimer = true;
|
|
|
|
|
onSuccess(otpCode);
|
|
|
|
|
// stopTimer = true;
|
|
|
|
|
otpFieldClear.value = otpCode;
|
|
|
|
|
onSuccess(otpCode, _pinPutController);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|