fixed issues

fatima
Fatimah Alshammari 4 years ago
parent 47f10738d7
commit 5b8750702e

@ -107,9 +107,9 @@ class UserApiClent {
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams); //return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
} }
Future<Response> ChangePassword(String currentPasswor, String newPassword) async { Future<Response> ChangePassword(String currentPassword, String newPassword) async {
var postParams = { var postParams = {
"currentPasswor": currentPasswor, "currentPassword": currentPassword,
"newPassword": newPassword, "newPassword": newPassword,
}; };
return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams); return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);

@ -66,7 +66,7 @@ class AppRoutes {
defineLicense: (context) => DefineLicensePage(), defineLicense: (context) => DefineLicensePage(),
vertifyPassword: (context) => VerifyPasswordPage(), vertifyPassword: (context) => VerifyPasswordPage(),
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String), confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String),
changePassword: (context) => ChangePasswordPage(ModalRoute.of(context)!.settings.arguments as String), changePassword: (context) => ChangePasswordPage(),
//Home page //Home page
dashboard: (context) => DashboardPage(), dashboard: (context) => DashboardPage(),

@ -3,7 +3,7 @@
import 'dart:convert'; import 'dart:convert';
ChangePassword confirmPasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str)); ChangePassword changePasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str));
String changePasswordToJson(ChangePassword data) => json.encode(data.toJson()); String changePasswordToJson(ChangePassword data) => json.encode(data.toJson());

@ -19,9 +19,7 @@ import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
class ChangePasswordPage extends StatefulWidget { class ChangePasswordPage extends StatefulWidget {
String userToken;
ChangePasswordPage(this.userToken, {Key? key}) : super(key: key);
@override @override
State<ChangePasswordPage> createState() => _ChangePasswordPageState(); State<ChangePasswordPage> createState() => _ChangePasswordPageState();
@ -29,7 +27,7 @@ class ChangePasswordPage extends StatefulWidget {
class _ChangePasswordPageState extends State<ChangePasswordPage> { class _ChangePasswordPageState extends State<ChangePasswordPage> {
String newPassword = ""; String newPassword = "";
String currentPasswor = ''; String currentPassword = " ";
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -55,7 +53,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
), ),
), ),
obscureText: true, obscureText: true,
onChanged: (v) => currentPasswor = v, onChanged: (v) => currentPassword = v,
), ),
12.height, 12.height,
TextFormField( TextFormField(
@ -75,7 +73,8 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
ShowFillButton( ShowFillButton(
title: "Confirm", title: "Confirm",
width: double.infinity, width: double.infinity,
onPressed: () {changePassword(context); onPressed: () {
changePassword(context);
}, },
), ),
], ],
@ -88,12 +87,12 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
Future<void> changePassword(BuildContext context) async { Future<void> changePassword(BuildContext context) async {
if(validateStructure(newPassword??"")){ if(validateStructure(newPassword??"")){
Utils.showLoading(context); Utils.showLoading(context);
Response res = await UserApiClent().ChangePassword(currentPasswor, newPassword); Response res = await UserApiClent().ChangePassword(currentPassword, newPassword);
Utils.hideLoading(context); Utils.hideLoading(context);
ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body)); ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body));
if (data.messageStatus == 1) { if (data.messageStatus == 1) {
Utils.showToast("Password is Updated"); Utils.showToast("Password is Updated");
navigateWithName(context, AppRoutes.loginWithPassword); navigateWithName(context, AppRoutes.dashboard);
} else { } else {
Utils.showToast(data.message ?? ""); Utils.showToast(data.message ?? "");
} }

Loading…
Cancel
Save