228 lines
8.9 KiB
Dart
228 lines
8.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:glassmorphism/glassmorphism.dart';
|
|
import 'package:pin_code_fields/pin_code_fields.dart';
|
|
import 'package:regroup/Common/base_manager.dart';
|
|
import 'package:regroup/Utils/Common/CommonAppbar.dart';
|
|
import 'package:regroup/Utils/Common/CustomNextButton.dart';
|
|
import 'package:regroup/Utils/Common/blureffect.dart';
|
|
import 'package:regroup/Utils/Common/sized_box.dart';
|
|
import 'package:regroup/Utils/texts.dart';
|
|
import 'package:regroup/onboarding/forgotPass/ViewModel/ForgotPassAPI.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class ForgotOtp extends StatefulWidget {
|
|
const ForgotOtp({super.key});
|
|
|
|
@override
|
|
State<ForgotOtp> createState() => _ForgotOtpState();
|
|
}
|
|
|
|
class _ForgotOtpState extends State<ForgotOtp> {
|
|
TextEditingController? pincode = TextEditingController();
|
|
final String emailAddress = Get.arguments;
|
|
|
|
double? principleId;
|
|
|
|
get utils => null;
|
|
|
|
// principleId = prefs.getString('email').toString();
|
|
|
|
checkValidation() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
principleId = prefs.getInt('principal_xid')!.toDouble();
|
|
if (pincode!.text.isEmpty) {
|
|
utils.showToast('Pin field is empty');
|
|
} else {
|
|
Map<String, String> updata = {
|
|
"iam_principal_xid": principleId.toString(),
|
|
"otp": pincode!.text,
|
|
};
|
|
final data = await ForgotPassAPI().verifyotp(updata);
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
// btnController.success();
|
|
// btnController.reset();
|
|
Get.snackbar(
|
|
"Success!",
|
|
'OTP verification successful!',
|
|
duration: Duration(seconds: 2),
|
|
colorText: Colors.white,
|
|
backgroundColor: Colors.green,
|
|
margin: EdgeInsets.all(8),
|
|
snackStyle: SnackStyle.FLOATING,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
);
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
Get.toNamed(RouteName.newpassword, arguments: emailAddress);
|
|
});
|
|
// print('success');
|
|
} else {
|
|
// btnController.error();
|
|
// btnController.reset();
|
|
Get.snackbar(
|
|
"Error!",
|
|
data.data['message'],
|
|
duration: Duration(seconds: 2),
|
|
colorText: Colors.white,
|
|
backgroundColor: Colors.red,
|
|
margin: EdgeInsets.all(8),
|
|
snackStyle: SnackStyle.FLOATING,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Color.fromARGB(255, 18, 32, 47),
|
|
appBar: CommonAppbar(
|
|
titleTxt: '',
|
|
),
|
|
body: Stack(
|
|
children: [
|
|
// CommonBlurLeftSecond(),
|
|
Positioned(top: 150, right: -30, child: CommonBlurRightSecond()),
|
|
Positioned(top: 350, left: -30, child: CommonBlurLeftBlue()),
|
|
GlassmorphicContainer(
|
|
width: MediaQuery.of(context).size.width,
|
|
height:
|
|
// 500.h,
|
|
MediaQuery.of(context).size.height,
|
|
borderRadius: 2,
|
|
blur: 6,
|
|
alignment: Alignment.bottomLeft,
|
|
border: 2,
|
|
linearGradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
],
|
|
),
|
|
borderGradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
|
|
Color(0XFF222935).withOpacity(0.60),
|
|
],
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
sizedBoxHeight(20.h),
|
|
text22400white('Check your email'),
|
|
sizedBoxHeight(10.h),
|
|
text14400white(
|
|
'Enter the verification code that we sent to $emailAddress'),
|
|
sizedBoxHeight(40.h),
|
|
text16400white('Enter code'),
|
|
sizedBoxHeight(20.h),
|
|
PinCodeTextField(
|
|
validator: (value) {
|
|
if (value != null && value.isEmpty) {
|
|
return "Please Enter verification code";
|
|
} else if (value != null && value.length < 4) {
|
|
return "OTP length should be at least 4";
|
|
}
|
|
return null;
|
|
},
|
|
keyboardType: TextInputType.number,
|
|
inputFormatters: [
|
|
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
|
],
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
length: 4,
|
|
obscureText: false,
|
|
animationType: AnimationType.fade,
|
|
pinTheme: PinTheme(
|
|
selectedFillColor: Color(0xFF434A53),
|
|
inactiveFillColor: Color(0xFF434A53),
|
|
inactiveColor: Color(0xFF434A53),
|
|
activeColor: Color(0xFF434A53),
|
|
selectedColor: Color(0xFF434A53),
|
|
shape: PinCodeFieldShape.underline,
|
|
borderRadius: BorderRadius.circular(5),
|
|
fieldHeight: 70,
|
|
fieldWidth: 70,
|
|
activeFillColor:
|
|
// Colors.white
|
|
Color(0xFF303030).withOpacity(0.4),
|
|
// textStyle: TextStyle(color: Colors.white, fontSize: 20), // Change text color and font size
|
|
),
|
|
animationDuration: Duration(milliseconds: 300),
|
|
enableActiveFill: true,
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
controller: pincode,
|
|
onCompleted: (v) {
|
|
print("Completed");
|
|
},
|
|
onChanged: (value) {
|
|
print(value);
|
|
setState(() {
|
|
// currentText = value;
|
|
});
|
|
},
|
|
cursorColor: Colors.white,
|
|
textStyle: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 20.sp,
|
|
fontFamily: 'Helvetica',
|
|
),
|
|
beforeTextPaste: (text) {
|
|
print("Allowing to paste $text");
|
|
return true;
|
|
},
|
|
appContext: context,
|
|
),
|
|
const Spacer(
|
|
flex: 3,
|
|
),
|
|
CustomButton(
|
|
text: 'Continue',
|
|
onPressed: () {
|
|
// if (pincode!.text.isEmpty) {
|
|
// utils.showToast('Pin field is empty');
|
|
// } else {
|
|
// if (accounttype == 'Individual') {
|
|
// print('individual selected');
|
|
// Get.toNamed(RouteName.tellusindividualscreen);
|
|
// } else if (accounttype == 'Business') {
|
|
// print('business selected');
|
|
// Get.toNamed(RouteName.tellusbusinessscreen);
|
|
// }
|
|
// }
|
|
checkValidation();
|
|
}),
|
|
const Spacer(
|
|
// flex: 2,
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
);;
|
|
}
|
|
} |