This commit is contained in:
Manasit.K
2024-12-12 10:12:19 +07:00
parent 43c32ef6cf
commit ed510b00d1
52 changed files with 1256 additions and 1027 deletions

View File

@@ -10,6 +10,7 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import '../api/api.dart';
import '../utils/color_custom.dart';
TextEditingController _textEditingController = TextEditingController();
@@ -85,24 +86,29 @@ class _OtpPageState extends State<OtpPage> {
// String otp = "";
String refno = "";
String token = "";
String otpConfirm = "";
getOtp() async {
var param = jsonEncode(<dynamic, dynamic>{"key": Api.API_KEY, "secret": Api.API_SECRET, "msisdn": widget.phone});
Api.postGetMessage(context, Api.otp, param).then((value) => {
Api.getRaw(context, Api.otpEmail + widget.email).then((value) => {
print(value),
setState(() {
token = value["token"];
refno = value["refno"];
otpConfirm = value.toString();
})
});
}
verify(String otp) {
var param = jsonEncode(<dynamic, dynamic>{"key": Api.API_KEY, "secret": Api.API_SECRET, "token": token, "pin": otp});
Api.postStatus(context, Api.verify, param).then((value) => {
print(value),
if (value != null) {Navigator.pushNamed(context, '/PolicyPage')} else {Utils.showAlertDialog(context, "รหัส OTP ไม่ถูกต้อง")}
});
if (otp == otpConfirm) {
Navigator.pushNamed(context, '/PolicyPage');
} else {
Utils.showAlertDialog(context, "รหัส OTP ไม่ถูกต้อง");
}
// var param = jsonEncode(<dynamic, dynamic>{"key": Api.API_KEY, "secret": Api.API_SECRET, "token": token, "pin": otp});
// Api.postStatus(context, Api.verify, param).then((value) => {
// print(value),
// if (value != null) {Navigator.pushNamed(context, '/PolicyPage')} else {Utils.showAlertDialog(context, "รหัส OTP ไม่ถูกต้อง")}
// });
}
Widget build(BuildContext context) {
@@ -142,7 +148,7 @@ class _OtpPageState extends State<OtpPage> {
padding: EdgeInsets.all(10),
child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [
Text(
"${"Please enter the OTP code.".tr()}\n${"The code will be sent to".tr()}${widget.phone}\nRef:$refno",
"${"Please enter the OTP code.".tr()}\n${"The code will be sent to".tr()}${widget.email}\nRef:$refno",
textAlign: TextAlign.center,
style: GoogleFonts.kanit(
color: Color(0xff65676b),
@@ -287,28 +293,24 @@ class _OtpPageState extends State<OtpPage> {
onTap: () {
verify(_textEditingController.text);
},
child: Container(
child: SizedBox(
width: 374,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xff9d001b),
),
padding: EdgeInsets.all(10),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40),
),
child: Container(
padding: EdgeInsets.all(10),
child: Text(
"Confirm".tr(),
textAlign: TextAlign.center,
style: GoogleFonts.kanit(
color: Colors.white,
color: ColorCustom.greyBorder,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
],
),
),
),
)