diff --git a/android/build.gradle b/android/build.gradle index ed45c65..09fbd64 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() diff --git a/lib/api/client/user_api_client.dart b/lib/api/client/user_api_client.dart index 81c46ec..2b1cd4e 100644 --- a/lib/api/client/user_api_client.dart +++ b/lib/api/client/user_api_client.dart @@ -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 ChangePassword(String currentPasswor, String newPassword) async { + Future ChangePassword(String currentPasswor, String newPassword) async { var postParams = { - "currentPasswor": currentPasswor, + "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); } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 02a17a2..b4fe535 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -66,7 +66,7 @@ class AppRoutes { defineLicense: (context) => DefineLicensePage(), vertifyPassword: (context) => VerifyPasswordPage(), 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 dashboard: (context) => DashboardPage(), diff --git a/lib/pages/user/change_password_page.dart b/lib/pages/user/change_password_page.dart index 8db8397..86f1cd3 100644 --- a/lib/pages/user/change_password_page.dart +++ b/lib/pages/user/change_password_page.dart @@ -18,10 +18,10 @@ import 'package:flutter/material.dart'; import 'dart:convert'; import 'package:http/http.dart'; -class ChangePasswordPage extends StatefulWidget { - String userToken; +import '../../models/m_response.dart'; - ChangePasswordPage(this.userToken, {Key? key}) : super(key: key); +class ChangePasswordPage extends StatefulWidget { + ChangePasswordPage({Key? key}) : super(key: key); @override State createState() => _ChangePasswordPageState(); @@ -48,7 +48,7 @@ class _ChangePasswordPageState extends State { decoration: InputDecoration( hintText: "Enter Old Password", hintStyle: TextStyle(color: Colors.grey), - border: OutlineInputBorder( + border: OutlineInputBorder( borderRadius: const BorderRadius.all( const Radius.circular(5.0), ), @@ -62,7 +62,7 @@ class _ChangePasswordPageState extends State { decoration: InputDecoration( hintText: "Inter New Password", hintStyle: TextStyle(color: Colors.grey), - border: OutlineInputBorder( + border: OutlineInputBorder( borderRadius: const BorderRadius.all( const Radius.circular(5.0), ), @@ -75,7 +75,8 @@ class _ChangePasswordPageState extends State { ShowFillButton( title: "Confirm", width: double.infinity, - onPressed: () {changePassword(context); + onPressed: () { + changePassword(context); }, ), ], @@ -86,25 +87,25 @@ class _ChangePasswordPageState extends State { } Future changePassword(BuildContext context) async { - if(validateStructure(newPassword??"")){ + if (validateStructure(newPassword ?? "")) { Utils.showLoading(context); - Response res = await UserApiClent().ChangePassword(currentPasswor, 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.loginWithPassword); + // navigateWithName(context, AppRoutes.loginWithPassword); + Navigator.of(context) + .pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route 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); } diff --git a/lib/pages/user/complete_profile_page.dart b/lib/pages/user/complete_profile_page.dart index 53d2f96..1a8fdf2 100644 --- a/lib/pages/user/complete_profile_page.dart +++ b/lib/pages/user/complete_profile_page.dart @@ -43,7 +43,7 @@ class _CompleteProfilePageState extends State { height: double.infinity, child: SingleChildScrollView( child: Padding( - padding: EdgeInsets.all(40), + padding: EdgeInsets.all(20), child: Column( children: [ "Complete Profile".toText24(), diff --git a/pubspec.lock b/pubspec.lock index caa035b..c2b3b93 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: