|
|
|
|
@ -3,9 +3,11 @@ import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:car_customer_app/api/shared_prefrence.dart';
|
|
|
|
|
import 'package:car_customer_app/api/user_api_client.dart';
|
|
|
|
|
import 'package:car_customer_app/classes/app_state.dart';
|
|
|
|
|
import 'package:car_customer_app/classes/utils.dart';
|
|
|
|
|
import 'package:car_customer_app/config/routes.dart';
|
|
|
|
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:car_customer_app/models/user/change_password.dart';
|
|
|
|
|
import 'package:car_customer_app/models/user/email_verify.dart';
|
|
|
|
|
import 'package:car_customer_app/models/user/email_verify_otp.dart';
|
|
|
|
|
import 'package:car_customer_app/utils/navigator.dart';
|
|
|
|
|
@ -27,7 +29,7 @@ class EditAccountPage extends StatefulWidget {
|
|
|
|
|
class _EditAccountPageState extends State<EditAccountPage> {
|
|
|
|
|
String userID = "";
|
|
|
|
|
String email = '';
|
|
|
|
|
bool isVerified = false;
|
|
|
|
|
//bool isVerified = true;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -72,8 +74,11 @@ class _EditAccountPageState extends State<EditAccountPage> {
|
|
|
|
|
Icon(Icons.email, color: Colors.blue,),
|
|
|
|
|
"Change Email".toText12(),
|
|
|
|
|
InkWell(
|
|
|
|
|
child: "Verify".toText12(),
|
|
|
|
|
onTap:() {
|
|
|
|
|
child:((AppState().getUser.data!.userInfo!.isEmailVerified??false)?"Verified" :"Verify").toText12(),
|
|
|
|
|
onTap:
|
|
|
|
|
(AppState().getUser.data!.userInfo!.isEmailVerified??false) ?
|
|
|
|
|
null
|
|
|
|
|
:(){
|
|
|
|
|
verifyEmail(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -89,21 +94,6 @@ class _EditAccountPageState extends State<EditAccountPage> {
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
// ListTile(
|
|
|
|
|
// leading: Icon(Icons.phone_android_sharp, color: Colors.blue,),
|
|
|
|
|
// title: "Change Mobile".toText12(),
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// navigateWithName(context, AppRoutes.changeMobilePage);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ListTile(
|
|
|
|
|
// leading: Icon(Icons.email_outlined, color: Colors.blue,),
|
|
|
|
|
// title: "Change Email".toText12(),
|
|
|
|
|
// onTap: () {
|
|
|
|
|
// navigateWithName(context, AppRoutes.changeEmailPage);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -120,22 +110,18 @@ class _EditAccountPageState extends State<EditAccountPage> {
|
|
|
|
|
onClick: (String code) async {
|
|
|
|
|
pop(context);
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
VerifyEmailOTP otpCompare = await UserApiClent().EmailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code);
|
|
|
|
|
MResponse otpCompare = await UserApiClent().EmailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (otpCompare.success == true) {
|
|
|
|
|
showMDialog(
|
|
|
|
|
context,
|
|
|
|
|
child: MessageDialog(
|
|
|
|
|
title: "Email Verified",
|
|
|
|
|
onClick: () {
|
|
|
|
|
// !isVerified;
|
|
|
|
|
pop(context);
|
|
|
|
|
// Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.dashboard, (Route<dynamic> route) => false);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
|
AppState().getUser.data!.userInfo!.isEmailVerified=true;
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
Utils.showToast("Email is verified successfully");
|
|
|
|
|
pop(context);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(otpCompare.errors ?? "");
|
|
|
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
|