update
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user