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

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

@ -301,6 +301,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@ -571,7 +578,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.4.8"
typed_data:
dependency: transitive
description:

Loading…
Cancel
Save