verify email
parent
3274875215
commit
184ac7859d
@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmail verifyEmailFromJson(String str) => VerifyEmail.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailToJson(VerifyEmail data) => json.encode(data.toJson());
|
||||
|
||||
|
||||
class VerifyEmail {
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
VerifyEmail(
|
||||
{this.totalItemsCount, this.data, this.messageStatus, this.message});
|
||||
|
||||
VerifyEmail.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmailOTP verifyEmailOTPFromJson(String str) => VerifyEmailOTP.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailOTPToJson(VerifyEmailOTP data) => json.encode(data.toJson());
|
||||
|
||||
class VerifyEmailOTP {
|
||||
bool? success;
|
||||
Null? errors;
|
||||
|
||||
VerifyEmailOTP({this.success, this.errors});
|
||||
|
||||
VerifyEmailOTP.fromJson(Map<String, dynamic> json) {
|
||||
success = json['success'];
|
||||
errors = json['errors'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['success'] = this.success;
|
||||
data['errors'] = this.errors;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
|
||||
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/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/email_verify.dart';
|
||||
import 'package:car_customer_app/models/user/email_verify_otp.dart';
|
||||
import 'package:car_customer_app/utils/navigator.dart';
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/widgets/dialog/dialogs.dart';
|
||||
import 'package:car_customer_app/widgets/dialog/message_dialog.dart';
|
||||
import 'package:car_customer_app/widgets/dialog/otp_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
|
||||
class EditAccountPage extends StatefulWidget {
|
||||
@override
|
||||
State<EditAccountPage> createState() => _EditAccountPageState();
|
||||
}
|
||||
|
||||
class _EditAccountPageState extends State<EditAccountPage> {
|
||||
String userID = "";
|
||||
String email = '';
|
||||
bool isVerified = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: appBar(title: "Edit Account"),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.lock, color: Colors.blue,),
|
||||
title: "Change Password".toText12(),
|
||||
onTap: () {
|
||||
navigateWithName(context, AppRoutes.changePasswordPage);
|
||||
},
|
||||
),
|
||||
15.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Icon(Icons.phone_android_sharp, color: Colors.blue,),
|
||||
"Change Mobile".toText12(),
|
||||
"Verify".toText12(),
|
||||
RaisedButton(
|
||||
onPressed: (){
|
||||
navigateWithName(context, AppRoutes.changeMobilePage);
|
||||
},
|
||||
child: Text("Change",
|
||||
style: TextStyle(fontSize: 14,
|
||||
fontWeight: FontWeight.w600,),),color:Colors.blue,
|
||||
textColor: Colors.white,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8)
|
||||
)
|
||||
],
|
||||
),
|
||||
20.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Icon(Icons.email, color: Colors.blue,),
|
||||
"Change Email".toText12(),
|
||||
InkWell(
|
||||
child: "Verify".toText12(),
|
||||
onTap:() {
|
||||
verifyEmail(context);
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
onPressed: (){
|
||||
navigateWithName(context, AppRoutes.changeEmailPage);
|
||||
},
|
||||
child: Text("Change",
|
||||
style: TextStyle(fontSize: 14,
|
||||
fontWeight: FontWeight.w600,),),color:Colors.blue,
|
||||
textColor: Colors.white,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8)
|
||||
)
|
||||
],
|
||||
)
|
||||
// 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);
|
||||
// },
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future<void> verifyEmail(BuildContext context) async {
|
||||
Utils.showLoading(context);
|
||||
VerifyEmail otpRequest = await UserApiClent().EmailVerify(email, userID);
|
||||
Utils.hideLoading(context);
|
||||
if (otpRequest.messageStatus == 1) {
|
||||
showMDialog(context, child: OtpDialog(
|
||||
onClick: (String code) async {
|
||||
pop(context);
|
||||
Utils.showLoading(context);
|
||||
VerifyEmailOTP 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);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Utils.showToast(otpCompare.errors ?? "");
|
||||
}
|
||||
},
|
||||
));
|
||||
} else {
|
||||
Utils.showToast(otpRequest.message ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue