Conflicts:
	lib/api/client/user_api_client.dart
	lib/pages/user/change_password_page.dart
fatima
Fatimah Alshammari 4 years ago
commit 0de7d3bcb5

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.6.10'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()

@ -13,6 +13,8 @@ import 'package:car_provider_app/models/surah_model.dart';
import 'package:car_provider_app/models/user/basic_otp.dart'; import 'package:car_provider_app/models/user/basic_otp.dart';
import 'package:car_provider_app/models/user/register_user.dart'; import 'package:car_provider_app/models/user/register_user.dart';
import '../../classes/app_state.dart';
import '../../models/m_response.dart';
import '../api_client.dart'; import '../api_client.dart';
@ -107,12 +109,16 @@ 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 currentPassword, String newPassword) async { Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
var postParams = { var postParams = {
"currentPassword": currentPassword, "currentPassword": currentPasswor,
"newPassword": newPassword, "newPassword": newPassword,
}; };
return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams); // return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
String t = AppState().getUser.data!.accessToken ?? "";
print("tokeen " + t);
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
} }

@ -18,8 +18,10 @@ import 'package:flutter/material.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
class ChangePasswordPage extends StatefulWidget { import '../../models/m_response.dart';
class ChangePasswordPage extends StatefulWidget {
ChangePasswordPage({Key? key}) : super(key: key);
@override @override
State<ChangePasswordPage> createState() => _ChangePasswordPageState(); State<ChangePasswordPage> createState() => _ChangePasswordPageState();
@ -27,7 +29,7 @@ class ChangePasswordPage extends StatefulWidget {
class _ChangePasswordPageState extends State<ChangePasswordPage> { class _ChangePasswordPageState extends State<ChangePasswordPage> {
String newPassword = ""; String newPassword = "";
String currentPassword = " "; String currentPasswor = '';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -46,21 +48,21 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter Old Password", hintText: "Enter Old Password",
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
const Radius.circular(5.0), const Radius.circular(5.0),
), ),
), ),
), ),
obscureText: true, obscureText: true,
onChanged: (v) => currentPassword = v, onChanged: (v) => currentPasswor = v,
), ),
12.height, 12.height,
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Inter New Password", hintText: "Inter New Password",
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
const Radius.circular(5.0), const Radius.circular(5.0),
), ),
@ -85,25 +87,25 @@ 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(currentPassword, newPassword); MResponse res = await UserApiClent().ChangePassword(currentPasswor, newPassword);
Utils.hideLoading(context); Utils.hideLoading(context);
ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body)); if (res.messageStatus == 1) {
if (data.messageStatus == 1) {
Utils.showToast("Password is Updated"); Utils.showToast("Password is Updated");
navigateWithName(context, AppRoutes.dashboard); // navigateWithName(context, AppRoutes.loginWithPassword);
Navigator.of(context)
.pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
} else { } else {
Utils.showToast(data.message ?? ""); Utils.showToast(res.message ?? "");
} }
}else{ } else {
Utils.showToast("Password Should contains Character, Number, Capital and small letters"); Utils.showToast("Password Should contains Character, Number, Capital and small letters");
} }
} }
bool validateStructure(String value) {
bool validateStructure(String value){ String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern); RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value); return regExp.hasMatch(value);
} }

@ -43,7 +43,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
height: double.infinity, height: double.infinity,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: EdgeInsets.all(40), padding: EdgeInsets.all(20),
child: Column( child: Column(
children: [ children: [
"Complete Profile".toText24(), "Complete Profile".toText24(),

@ -301,6 +301,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -571,7 +578,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.3" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

Loading…
Cancel
Save