fixed issues
parent
6e055b568e
commit
b19e042b1e
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
ChanEmail changeEmailFromJson(String str) => ChanEmail.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String changeEmailToJson(ChanEmail data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class ChanEmail {
|
||||||
|
int? messageStatus;
|
||||||
|
Null? totalItemsCount;
|
||||||
|
Data? data;
|
||||||
|
String? message;
|
||||||
|
|
||||||
|
ChanEmail(
|
||||||
|
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||||
|
|
||||||
|
ChanEmail.fromJson(Map<String, dynamic> json) {
|
||||||
|
messageStatus = json['messageStatus'];
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||||
|
message = json['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['messageStatus'] = this.messageStatus;
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data!.toJson();
|
||||||
|
}
|
||||||
|
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,50 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
ChangeMobile changeMobileFromJson(String str) => ChangeMobile.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String changeMobileToJson(ChangeMobile data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class ChangeMobile {
|
||||||
|
int? messageStatus;
|
||||||
|
Null? totalItemsCount;
|
||||||
|
Data? data;
|
||||||
|
String? message;
|
||||||
|
|
||||||
|
ChangeMobile(
|
||||||
|
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||||
|
|
||||||
|
ChangeMobile.fromJson(Map<String, dynamic> json) {
|
||||||
|
messageStatus = json['messageStatus'];
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||||
|
message = json['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['messageStatus'] = this.messageStatus;
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data!.toJson();
|
||||||
|
}
|
||||||
|
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,30 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
MResponse mResponseFromJson(String str) => MResponse.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String mResponseToJson(MResponse data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class MResponse {
|
||||||
|
MResponse({
|
||||||
|
this.totalItemsCount,
|
||||||
|
this.messageStatus,
|
||||||
|
this.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? totalItemsCount;
|
||||||
|
int? messageStatus;
|
||||||
|
String? message;
|
||||||
|
|
||||||
|
factory MResponse.fromJson(Map<String, dynamic> json) => MResponse(
|
||||||
|
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||||
|
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||||
|
message: json["message"] == null ? null : json["message"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||||
|
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||||
|
"message": message == null ? null : message,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
ConfirmEmail confirmEmailFromJson(String str) => ConfirmEmail.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String confirmEmailToJson(ConfirmEmail data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class ConfirmEmail {
|
||||||
|
int? messageStatus;
|
||||||
|
Null? totalItemsCount;
|
||||||
|
Data? data;
|
||||||
|
String? message;
|
||||||
|
|
||||||
|
ConfirmEmail(
|
||||||
|
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||||
|
|
||||||
|
ConfirmEmail.fromJson(Map<String, dynamic> json) {
|
||||||
|
messageStatus = json['messageStatus'];
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||||
|
message = json['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['messageStatus'] = this.messageStatus;
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data!.toJson();
|
||||||
|
}
|
||||||
|
data['message'] = this.message;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
String? userID;
|
||||||
|
|
||||||
|
Data({this.userID});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
userID = json['userID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['userID'] = this.userID;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
ConfirmMobile confirmMobileFromJson(String str) => ConfirmMobile.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String confirmMobileToJson(ConfirmMobile data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
|
||||||
|
class ConfirmMobile {
|
||||||
|
int? messageStatus;
|
||||||
|
Null? totalItemsCount;
|
||||||
|
Data? data;
|
||||||
|
String? message;
|
||||||
|
|
||||||
|
ConfirmMobile(
|
||||||
|
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||||
|
|
||||||
|
ConfirmMobile.fromJson(Map<String, dynamic> json) {
|
||||||
|
messageStatus = json['messageStatus'];
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||||
|
message = json['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['messageStatus'] = this.messageStatus;
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data!.toJson();
|
||||||
|
}
|
||||||
|
data['message'] = this.message;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
String? userID;
|
||||||
|
|
||||||
|
Data({this.userID});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
userID = json['userID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['userID'] = this.userID;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_email.dart';
|
||||||
|
import 'package:car_customer_app/models/user/confirm_email.dart';
|
||||||
|
import 'package:car_customer_app/utils/navigator.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.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:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
class ChangeEmailPage extends StatefulWidget {
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChangeEmailPage> createState() => _ChangeEmailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangeEmailPageState extends State<ChangeEmailPage> {
|
||||||
|
String password = "";
|
||||||
|
String email = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(title: "Change Email"),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
"Enter Email".toText24(),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter New Email",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: false,
|
||||||
|
onChanged: (v) => email = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter Current Password",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => password = v,
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: "Confirm",
|
||||||
|
width: double.infinity,
|
||||||
|
onPressed: () {
|
||||||
|
changeEmail(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeEmail(BuildContext context) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ChanEmail otpRequest = await UserApiClent().ChangeEmailOTPRequest(email, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ConfirmEmail otpCompare = await UserApiClent().ChangeEmail(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
showMDialog(
|
||||||
|
context,
|
||||||
|
child: MessageDialog(
|
||||||
|
title: "Email Verified",
|
||||||
|
onClick: () {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_mobile.dart';
|
||||||
|
import 'package:car_customer_app/models/user/confirm_mobile.dart';
|
||||||
|
import 'package:car_customer_app/models/user/confirm_password.dart';
|
||||||
|
import 'package:car_customer_app/utils/navigator.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.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:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
class ChangeMobilePage extends StatefulWidget {
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChangeMobilePage> createState() => _ChangeMobilePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangeMobilePageState extends State<ChangeMobilePage> {
|
||||||
|
int countryID=1 ;
|
||||||
|
String mobileNo = '';
|
||||||
|
String password = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(title: "Change Mobile Number"),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
"Enter New Phone Number".toText24(),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter New Phone Number",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: false,
|
||||||
|
onChanged: (v) => mobileNo = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter Current Password",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => password = v,
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: "Confirm",
|
||||||
|
width: double.infinity,
|
||||||
|
onPressed: () {
|
||||||
|
changeMobile(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeMobile(BuildContext context) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ChangeMobile otpRequest = await UserApiClent().ChangeMobileNoOTPRequest(countryID, mobileNo, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ConfirmMobile otpCompare = await UserApiClent().ChangeMobileNo(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
showMDialog(
|
||||||
|
context,
|
||||||
|
child: MessageDialog(
|
||||||
|
title: "Phone Number Verified",
|
||||||
|
onClick: () {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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/int_extensions.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/confirm_password.dart';
|
||||||
|
import 'package:car_customer_app/utils/navigator.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
class ChangePasswordPage extends StatefulWidget {
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
||||||
|
String newPassword = "";
|
||||||
|
String currentPassword = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(title: "Change Password"),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
"Enter New Password".toText24(),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter Old Password",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => currentPassword = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Enter New Password",
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
const Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => newPassword = v,
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: "Confirm",
|
||||||
|
width: double.infinity,
|
||||||
|
onPressed: () {changePassword(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changePassword(BuildContext context) async {
|
||||||
|
if (validateStructure(newPassword ?? "")) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
MResponse res = await UserApiClent().ChangePassword(currentPassword, newPassword);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (res.messageStatus == 1) {
|
||||||
|
Utils.showToast("Password is Updated");
|
||||||
|
// navigateWithName(context, AppRoutes.loginWithPassword);
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(res.message ?? "");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool validateStructure(String value){
|
||||||
|
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
||||||
|
RegExp regExp = new RegExp(pattern);
|
||||||
|
return regExp.hasMatch(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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/constants.dart';
|
||||||
|
import 'package:car_customer_app/config/routes.dart';
|
||||||
|
import 'package:car_customer_app/models/user/forget_password_otp_compare.dart';
|
||||||
|
import 'package:car_customer_app/models/user/login_password.dart';
|
||||||
|
import 'package:car_customer_app/models/user/register_user.dart';
|
||||||
|
import 'package:car_customer_app/models/user/user.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/widgets/button/show_image_button.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/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:car_customer_app/widgets/dialog/otp_dialog.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
class ForgetPasswordMethodPage extends StatefulWidget {
|
||||||
|
String userToken;
|
||||||
|
|
||||||
|
ForgetPasswordMethodPage(this.userToken);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ForgetPasswordMethodPage> createState() => _ForgetPasswordMethodPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ForgetPasswordMethodPageState extends State<ForgetPasswordMethodPage> {
|
||||||
|
int otpType = 1;
|
||||||
|
String userOTP = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(title: "Forget Password"),
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
"Select Method".toText24(),
|
||||||
|
12.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
otpType = 1;
|
||||||
|
forgetPasswordOTPMethod(context);
|
||||||
|
},
|
||||||
|
title: 'With SMS',
|
||||||
|
icon: icons + "ic_sms.png",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.width,
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
otpType = 1;
|
||||||
|
forgetPasswordOTPMethod(context);
|
||||||
|
},
|
||||||
|
title: 'With Whatsapp',
|
||||||
|
icon: icons + "ic_whatsapp.png",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
mFlex(10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> forgetPasswordOTPMethod(BuildContext context) async {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response res = await UserApiClent().ForgetPasswordOTPCompare(widget.userToken?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
PasswordOTPCompare otpCompare = PasswordOTPCompare.fromJson(jsonDecode(res.body));
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
var userToken = otpCompare.data!.userToken;
|
||||||
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue