Merge branch 'faiz_development' into 'master'
Upgraded the App's Architecture See merge request mirza.shafique/car_customer_app!1mirza_development
commit
dc7548fea4
@ -1,69 +1,57 @@
|
|||||||
import 'dart:async';
|
// import 'dart:async';
|
||||||
import 'package:car_customer_app/classes/app_state.dart';
|
//
|
||||||
import 'package:car_customer_app/models/m_response.dart';
|
// import 'package:car_customer_app/classes/app_state.dart';
|
||||||
import 'package:car_customer_app/models/profile/branch.dart';
|
// import 'package:car_customer_app/classes/consts.dart';
|
||||||
import 'package:car_customer_app/models/profile/categroy.dart';
|
// import 'package:car_customer_app/config/dependencies.dart';
|
||||||
import 'package:car_customer_app/models/profile/document.dart';
|
// import 'package:car_customer_app/models/m_response.dart';
|
||||||
import 'package:car_customer_app/models/profile/services.dart';
|
// import 'package:car_customer_app/models/profile/branch.dart';
|
||||||
import 'package:car_customer_app/models/user/country.dart';
|
// import 'package:car_customer_app/models/profile/categroy.dart';
|
||||||
import 'package:car_customer_app/models/user/role.dart';
|
// import 'package:car_customer_app/models/profile/services.dart';
|
||||||
import 'package:http/http.dart';
|
//
|
||||||
import 'package:car_customer_app/classes/consts.dart';
|
// import '../api_client.dart';
|
||||||
import 'package:car_customer_app/models/content_info_model.dart';
|
//
|
||||||
import 'package:car_customer_app/models/member_model.dart';
|
// class BranchApiClient {
|
||||||
import 'package:car_customer_app/models/surah_model.dart';
|
//
|
||||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
// Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
||||||
import 'package:car_customer_app/models/user/register_user.dart';
|
// var postParams = {
|
||||||
|
// // "id": 0,
|
||||||
import '../api_client.dart';
|
// "serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
||||||
|
// "branchName": branchName,
|
||||||
class BranchApiClent {
|
// "branchDescription": branchDescription,
|
||||||
static final BranchApiClent _instance = BranchApiClent._internal();
|
// "cityID": cityId,
|
||||||
|
// "address": address,
|
||||||
BranchApiClent._internal();
|
// "latitude": latitude,
|
||||||
|
// "longitude": longitude,
|
||||||
factory BranchApiClent() => _instance;
|
// "isActive": true
|
||||||
|
// };
|
||||||
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
var postParams = {
|
// print("tokeen " + t);
|
||||||
// "id": 0,
|
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
||||||
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
// }
|
||||||
"branchName": branchName,
|
//
|
||||||
"branchDescription": branchDescription,
|
// Future<Branch> fetchAllBranches() async {
|
||||||
"cityID": cityId,
|
// var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||||
"address": address,
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
"latitude": latitude,
|
// print("tokeen " + t);
|
||||||
"longitude": longitude,
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
||||||
"isActive": true
|
// }
|
||||||
};
|
//
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// Future<Category> fetchBranchCategory() async {
|
||||||
print("tokeen " + t);
|
// var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
}
|
// print("tokeen " + t);
|
||||||
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, token: t);
|
||||||
Future<Branch> fetchAllBranches() async {
|
// }
|
||||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
//
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// Future<Services> fetchServices(String serviceCategoryId) async {
|
||||||
print("tokeen " + t);
|
// var postParams = {"ServiceCategoryID": serviceCategoryId};
|
||||||
return await ApiClient().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
}
|
// print("tokeen " + t);
|
||||||
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.Services_Get, queryParameters: postParams, token: t);
|
||||||
Future<Category> fetchBranchCategory() async {
|
// }
|
||||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
//
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// Future<MResponse> createService(List<Map<String, dynamic>> map) async {
|
||||||
print("tokeen " + t);
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
return await ApiClient().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, token: t);
|
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
Future<Services> fetchServices(String serviceCategoryId) async {
|
|
||||||
var postParams = {"ServiceCategoryID": serviceCategoryId};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
print("tokeen " + t);
|
|
||||||
return await ApiClient().getJsonForObject((json) => Services.fromJson(json), ApiConsts.Services_Get, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<MResponse> createService(List<Map<String, dynamic>> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,52 +1,47 @@
|
|||||||
import 'dart:async';
|
// import 'dart:async';
|
||||||
import 'package:car_customer_app/classes/app_state.dart';
|
//
|
||||||
import 'package:car_customer_app/models/m_response.dart';
|
// import 'package:car_customer_app/classes/app_state.dart';
|
||||||
import 'package:car_customer_app/models/profile/document.dart';
|
// import 'package:car_customer_app/classes/consts.dart';
|
||||||
import 'package:car_customer_app/models/user/country.dart';
|
// import 'package:car_customer_app/config/dependencies.dart';
|
||||||
import 'package:car_customer_app/models/user/role.dart';
|
// import 'package:car_customer_app/models/m_response.dart';
|
||||||
import 'package:http/http.dart';
|
// import 'package:car_customer_app/models/profile/document.dart';
|
||||||
import 'package:car_customer_app/classes/consts.dart';
|
// import 'package:flutter/cupertino.dart';
|
||||||
import 'package:car_customer_app/models/content_info_model.dart';
|
//
|
||||||
import 'package:car_customer_app/models/member_model.dart';
|
// import '../api_client.dart';
|
||||||
import 'package:car_customer_app/models/surah_model.dart';
|
//
|
||||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
// class ProfileApiClient {
|
||||||
import 'package:car_customer_app/models/user/register_user.dart';
|
// static final ProfileApiClient _instance = ProfileApiClient._internal();
|
||||||
|
//
|
||||||
import '../api_client.dart';
|
// ProfileApiClient._internal();
|
||||||
|
//
|
||||||
class ProfileApiClent {
|
// factory ProfileApiClient() => _instance;
|
||||||
static final ProfileApiClent _instance = ProfileApiClent._internal();
|
//
|
||||||
|
// Future<Document> getServiceProviderDocument(dynamic userId) async {
|
||||||
ProfileApiClent._internal();
|
// var queryParameters = {
|
||||||
|
// "ServiceProviderID": userId.toString(),
|
||||||
factory ProfileApiClent() => _instance;
|
// };
|
||||||
|
// String? token = AppState().getUser.data?.accessToken;
|
||||||
Future<Document> getServiceProviderDocument(dynamic userId) async {
|
// debugPrint(token);
|
||||||
var queryParameters = {
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Document.fromJson(json), ApiConsts.GetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
||||||
"ServiceProviderID": userId.toString(),
|
// }
|
||||||
};
|
//
|
||||||
String? token = AppState().getUser.data?.accessToken;
|
// Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents) async {
|
||||||
print(token);
|
// List<Map<String, dynamic>> map = [];
|
||||||
return await ApiClient().getJsonForObject((json) => Document.fromJson(json), ApiConsts.GetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
// for (int i = 0; i < documents!.length; i++) {
|
||||||
}
|
// if (documents[i].document != null) {
|
||||||
|
// var postParams = {
|
||||||
Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents) async {
|
// "id": documents[i].id,
|
||||||
List<Map<String, dynamic>> map = [];
|
// "serviceProviderID": documents[i].serviceProviderId,
|
||||||
for (int i = 0; i < documents!.length; i++) {
|
// "documentID": documents[i].documentId,
|
||||||
if (documents[i].document != null) {
|
// "documentExt": documents[i].fileExt,
|
||||||
var postParams = {
|
// "documentImage": documents[i].document,
|
||||||
"id": documents[i].id,
|
// "isActive": true
|
||||||
"serviceProviderID": documents[i].serviceProviderId,
|
// };
|
||||||
"documentID": documents[i].documentId,
|
// map.add(postParams);
|
||||||
"documentExt": documents[i].fileExt,
|
// }
|
||||||
"documentImage": documents[i].document,
|
// }
|
||||||
"isActive": true
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
};
|
// debugPrint("token " + t);
|
||||||
map.add(postParams);
|
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderDocument_Update, map, token: t);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
print("tokeen " + t);
|
|
||||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderDocument_Update, map, token: t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,226 +1,214 @@
|
|||||||
import 'dart:async';
|
// import 'dart:async';
|
||||||
import 'dart:convert';
|
// import 'dart:convert';
|
||||||
import 'package:car_customer_app/models/user/change_email.dart';
|
//
|
||||||
import 'package:car_customer_app/models/user/change_mobile.dart';
|
// import 'package:car_customer_app/classes/consts.dart';
|
||||||
import 'package:car_customer_app/models/user/cities.dart';
|
// import 'package:car_customer_app/config/dependencies.dart';
|
||||||
import 'package:car_customer_app/models/user/confirm_email.dart';
|
// import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||||
import 'package:car_customer_app/models/user/confirm_mobile.dart';
|
// import 'package:car_customer_app/models/user/change_email.dart';
|
||||||
import 'package:car_customer_app/models/user/country.dart';
|
// import 'package:car_customer_app/models/user/change_mobile.dart';
|
||||||
import 'package:car_customer_app/models/user/image_response.dart';
|
// import 'package:car_customer_app/models/user/cities.dart';
|
||||||
import 'package:car_customer_app/models/user/refresh_token.dart';
|
// import 'package:car_customer_app/models/user/confirm_email.dart';
|
||||||
import 'package:car_customer_app/models/user/refresh_token.dart';
|
// import 'package:car_customer_app/models/user/confirm_mobile.dart';
|
||||||
import 'package:car_customer_app/models/user/role.dart';
|
// import 'package:car_customer_app/models/user/country.dart';
|
||||||
import 'package:car_customer_app/models/user/confirm_password.dart';
|
// import 'package:car_customer_app/models/user/image_response.dart';
|
||||||
import 'package:car_customer_app/models/user/forget_password_otp_compare.dart';
|
// import 'package:car_customer_app/models/user/refresh_token.dart';
|
||||||
import 'package:car_customer_app/models/user/forget_password_otp_request.dart';
|
// import 'package:car_customer_app/models/user/register_user.dart';
|
||||||
import 'package:car_customer_app/models/user/verify_email.dart';
|
// import 'package:car_customer_app/models/user/role.dart';
|
||||||
import 'package:car_customer_app/models/user/verify_email_otp.dart';
|
// import 'package:car_customer_app/models/user/verify_email.dart';
|
||||||
import 'package:http/http.dart';
|
// import 'package:http/http.dart';
|
||||||
import 'package:car_customer_app/classes/consts.dart';
|
//
|
||||||
import 'package:car_customer_app/models/content_info_model.dart';
|
// import '../../classes/app_state.dart';
|
||||||
import 'package:car_customer_app/models/member_model.dart';
|
// import '../../models/m_response.dart';
|
||||||
import 'package:car_customer_app/models/surah_model.dart';
|
// import '../../models/user/user.dart';
|
||||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
// import '../api_client.dart';
|
||||||
import 'package:car_customer_app/models/user/register_user.dart';
|
// import '../../utils/shared_prefrence.dart';
|
||||||
|
//
|
||||||
import '../../classes/app_state.dart';
|
// class UserApiClient {
|
||||||
import '../../models/m_response.dart';
|
//
|
||||||
|
// Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}) async {
|
||||||
import '../../models/user/user.dart';
|
// var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId};
|
||||||
import '../api_client.dart';
|
// return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams);
|
||||||
import '../shared_prefrence.dart';
|
// }
|
||||||
|
//
|
||||||
class UserApiClent {
|
// Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken) async {
|
||||||
static final UserApiClent _instance = UserApiClent._internal();
|
// var postParams = {
|
||||||
|
// "userMobileNo": phoneNo,
|
||||||
UserApiClent._internal();
|
// "userOTP": otp,
|
||||||
|
// "userToken": userToken,
|
||||||
factory UserApiClent() => _instance;
|
// };
|
||||||
|
// return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams);
|
||||||
Future<BasicOtp> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}) async {
|
// }
|
||||||
var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId};
|
//
|
||||||
return await ApiClient().postJsonForObject((json) => BasicOtp.fromJson(json), ApiConsts.BasicOTP, postParams);
|
// Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
|
||||||
}
|
// var postParams;
|
||||||
|
// if (email.isEmpty) {
|
||||||
Future<RegisterUser> basicVerify(String phoneNo, String otp, String userToken) async {
|
// postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password};
|
||||||
var postParams = {
|
// } else {
|
||||||
"userMobileNo": phoneNo,
|
// postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password};
|
||||||
"userOTP": otp,
|
// }
|
||||||
"userToken": userToken,
|
//
|
||||||
};
|
// return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams);
|
||||||
return await ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicVerify, postParams);
|
// }
|
||||||
}
|
//
|
||||||
|
// Future<Response> login_V1(String phoneNo, String password) async {
|
||||||
Future<RegisterUser> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
|
// var postParams = {
|
||||||
var postParams;
|
// "mobileorEmail": phoneNo,
|
||||||
if (email.isEmpty) {
|
// "password": password,
|
||||||
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password};
|
// };
|
||||||
} else {
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V1, postParams);
|
||||||
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password};
|
// //return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtp.fromJson(json), ApiConsts.Login_V1, postParams);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return await ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicComplete, postParams);
|
// Future<Response> login_V2_OTP(String userToken, String loginType) async {
|
||||||
}
|
// var postParams = {
|
||||||
|
// "userToken": userToken,
|
||||||
Future<Response> login_V1(String phoneNo, String password) async {
|
// "loginType": loginType,
|
||||||
var postParams = {
|
// };
|
||||||
"mobileorEmail": phoneNo,
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTP, postParams);
|
||||||
"password": password,
|
// }
|
||||||
};
|
//
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V1, postParams);
|
// Future<Response> login_V2_OTPVerify(String userToken, String otp) async {
|
||||||
//return await ApiClient().postJsonForObject((json) => BasicOtp.fromJson(json), ApiConsts.Login_V1, postParams);
|
// var postParams = {"userToken": userToken, "userOTP": otp};
|
||||||
}
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTPVerify, postParams);
|
||||||
|
// }
|
||||||
Future<Response> login_V2_OTP(String userToken, String loginType) async {
|
//
|
||||||
var postParams = {
|
// Future<RefreshToken> RefreshTokenAPI(String token, String refreshToken) async {
|
||||||
"userToken": userToken,
|
// var postParams = {"token": token, "refreshToken": refreshToken};
|
||||||
"loginType": loginType,
|
// // String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
};
|
// return await injector.get<ApiClient>().postJsonForObject((json) => RefreshToken.fromJson(json), ApiConsts.RefreshToken, postParams);
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V2_OTP, postParams);
|
// }
|
||||||
}
|
//
|
||||||
|
// Future<Country> getAllCountries() async {
|
||||||
Future<Response> login_V2_OTPVerify(String userToken, String otp) async {
|
// var postParams = {};
|
||||||
var postParams = {"userToken": userToken, "userOTP": otp};
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V2_OTPVerify, postParams);
|
// }
|
||||||
}
|
//
|
||||||
|
// Future<Cities> getAllCites(String countryId) async {
|
||||||
Future<RefreshToken> RefreshTokenAPI(String token, String refreshToken) async {
|
// var postParams = {
|
||||||
var postParams = {"token": token, "refreshToken": refreshToken};
|
// "CountryID": countryId,
|
||||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
// };
|
||||||
return await ApiClient().postJsonForObject((json) => RefreshToken.fromJson(json), ApiConsts.RefreshToken, postParams);
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future<Country> getAllCountries() async {
|
// Future<Role> getRoles() async {
|
||||||
var postParams = {};
|
// return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
||||||
return await ApiClient().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
// }
|
||||||
}
|
//
|
||||||
|
// Future<Response> ForgetPasswordOTPRequest(String userName, int otpType) async {
|
||||||
Future<Cities> getAllCites(String countryId) async {
|
// var postParams = {
|
||||||
var postParams = {
|
// "userName": userName,
|
||||||
"CountryID": countryId,
|
// "otpType": 1,
|
||||||
};
|
// };
|
||||||
return await ApiClient().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||||
}
|
// //return await injector.get<ApiClient>().postJsonForObject((json) => PasswordOTPRequest.fromJson(json), ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||||
|
// }
|
||||||
Future<Role> getRoles() async {
|
//
|
||||||
return await ApiClient().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
// Future<Response> ForgetPasswordOTPCompare(String userToken, String userOTP) async {
|
||||||
}
|
// var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPasswordOTPCompare, postParams);
|
||||||
Future<Response> ForgetPasswordOTPRequest(String userName, int otpType) async {
|
// // return await injector.get<ApiClient>().postJsonForObject((json) => PasswordOTPCompare.fromJson(json), ApiConsts.ForgetPasswordOTPCompare, postParams);
|
||||||
var postParams = {
|
// }
|
||||||
"userName": userName,
|
//
|
||||||
"otpType": 1,
|
// Future<Response> ForgetPassword(String userToken, String newPassword) async {
|
||||||
};
|
// var postParams = {
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPasswordOTPRequest, postParams);
|
// "userToken": userToken,
|
||||||
//return await ApiClient().postJsonForObject((json) => PasswordOTPRequest.fromJson(json), ApiConsts.ForgetPasswordOTPRequest, postParams);
|
// "newPassword": newPassword,
|
||||||
}
|
// };
|
||||||
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPassword, postParams);
|
||||||
Future<Response> ForgetPasswordOTPCompare(String userToken, String userOTP) async {
|
// //return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
|
||||||
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
// }
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPasswordOTPCompare, postParams);
|
//
|
||||||
// return await ApiClient().postJsonForObject((json) => PasswordOTPCompare.fromJson(json), ApiConsts.ForgetPasswordOTPCompare, postParams);
|
// Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
|
||||||
}
|
// var postParams = {
|
||||||
|
// "currentPassword": currentPasswor,
|
||||||
Future<Response> ForgetPassword(String userToken, String newPassword) async {
|
// "newPassword": newPassword,
|
||||||
var postParams = {
|
// };
|
||||||
"userToken": userToken,
|
// // return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
"newPassword": newPassword,
|
//
|
||||||
};
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPassword, postParams);
|
// print("tokeen " + t);
|
||||||
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
|
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
|
// Future<ChangeMobileRespModel> ChangeMobileNoOTPRequest(
|
||||||
var postParams = {
|
// countryID,
|
||||||
"currentPassword": currentPasswor,
|
// String mobileNo,
|
||||||
"newPassword": newPassword,
|
// String password,
|
||||||
};
|
// ) async {
|
||||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
// var postParams = {"countryID": 1, "mobileNo": mobileNo, "password": password};
|
||||||
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ChangeMobileRespModel.fromJson(json), ApiConsts.ChangeMobileNoOTPRequest, postParams, token: t);
|
||||||
print("tokeen " + t);
|
// }
|
||||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
|
//
|
||||||
}
|
// Future<ConfirmMobileRespModel> ChangeMobileNo(String userToken, String userOTP) async {
|
||||||
|
// var postParams = {
|
||||||
Future<ChangeMobile> ChangeMobileNoOTPRequest(
|
// "userToken": userToken,
|
||||||
countryID,
|
// "userOTP": userOTP,
|
||||||
String mobileNo,
|
// };
|
||||||
String password,
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
) async {
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmMobileRespModel.fromJson(json), ApiConsts.ChangeMobileNo, postParams, token: t);
|
||||||
var postParams = {"countryID": 1, "mobileNo": mobileNo, "password": password};
|
// }
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
//
|
||||||
return await ApiClient().postJsonForObject((json) => ChangeMobile.fromJson(json), ApiConsts.ChangeMobileNoOTPRequest, postParams, token: t);
|
// Future<ChanEmailRespModel> ChangeEmailOTPRequest(String email, String password) async {
|
||||||
}
|
// var postParams = {"email": email, "password": password};
|
||||||
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
Future<ConfirmMobile> ChangeMobileNo(String userToken, String userOTP) async {
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ChanEmailRespModel.fromJson(json), ApiConsts.ChangeEmailOTPRequest, postParams, token: t);
|
||||||
var postParams = {
|
// }
|
||||||
"userToken": userToken,
|
//
|
||||||
"userOTP": userOTP,
|
// Future<ConfirmEmailRespModel> ChangeEmail(String userToken, String userOTP) async {
|
||||||
};
|
// var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
return await ApiClient().postJsonForObject((json) => ConfirmMobile.fromJson(json), ApiConsts.ChangeMobileNo, postParams, token: t);
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmEmailRespModel.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future<ChanEmail> ChangeEmailOTPRequest(String email, String password) async {
|
// Future<VerifyEmailRespModel> EmailVerify(String email, String userID) async {
|
||||||
var postParams = {"email": email, "password": password};
|
// var postParams = {
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// // "email": email,
|
||||||
return await ApiClient().postJsonForObject((json) => ChanEmail.fromJson(json), ApiConsts.ChangeEmailOTPRequest, postParams, token: t);
|
// // "userID": userID,
|
||||||
}
|
// "email": AppState().getUser.data!.userInfo!.email ?? "",
|
||||||
|
// "userID": AppState().getUser.data!.userInfo!.userId ?? "",
|
||||||
Future<ConfirmEmail> ChangeEmail(String userToken, String userOTP) async {
|
// };
|
||||||
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
//
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
return await ApiClient().postJsonForObject((json) => ConfirmEmail.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
|
// return await injector.get<ApiClient>().postJsonForObject((json) => VerifyEmailRespModel.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Future<VerifyEmail> EmailVerify(String email, String userID) async {
|
// Future<MResponse> EmailVerifyOTPVerify(String userToken, String userOTP) async {
|
||||||
var postParams = {
|
// var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
// "email": email,
|
//
|
||||||
// "userID": userID,
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
"email": AppState().getUser.data!.userInfo!.email ?? "",
|
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t);
|
||||||
"userID": AppState().getUser.data!.userInfo!.userId ?? "",
|
// }
|
||||||
};
|
//
|
||||||
|
// Future<ImageResponse> UpdateUserImage(String image) async {
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// var postParams = {"userID": AppState().getUser.data!.userInfo!.userId, "userImage": image};
|
||||||
return await ApiClient().postJsonForObject((json) => VerifyEmail.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
|
// // return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
}
|
//
|
||||||
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
Future<MResponse> EmailVerifyOTPVerify(String userToken, String userOTP) async {
|
// print("tokeen " + t);
|
||||||
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||||
|
// }
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
//
|
||||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t);
|
// Future<ImageResponse> GetUserImage(String image) async {
|
||||||
}
|
// var postParams = {};
|
||||||
|
// // return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
Future<ImageResponse> UpdateUserImage(String image) async {
|
//
|
||||||
var postParams = {"userID": AppState().getUser.data!.userInfo!.userId, "userImage": image};
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
// print("tokeen " + t);
|
||||||
|
// return await injector.get<ApiClient>().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// }
|
||||||
print("tokeen " + t);
|
//
|
||||||
return await ApiClient().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
// Future<String> UpdateUserToken() async {
|
||||||
}
|
// String token = await SharedPrefManager.getUserToken();
|
||||||
|
// String refreshToken = await SharedPrefManager.getRefreshToken();
|
||||||
Future<ImageResponse> GetUserImage(String image) async {
|
// RefreshToken refresh = await RefreshTokenAPI(token, refreshToken);
|
||||||
var postParams = {};
|
// SharedPrefManager.setUserToken(refresh.data!.accessToken ?? "");
|
||||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
// SharedPrefManager.setRefreshToken(refresh.data!.refreshToken ?? "");
|
||||||
|
// String mdata = await SharedPrefManager.getData();
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
// UserInfo info = UserInfo.fromJson(jsonDecode(mdata));
|
||||||
print("tokeen " + t);
|
// User user = new User();
|
||||||
return await ApiClient().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
// user.data = new UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info);
|
||||||
}
|
// AppState().setUser = user;
|
||||||
|
// return refresh.data!.accessToken??"";
|
||||||
Future<String> UpdateUserToken() async {
|
// }
|
||||||
String token = await SharedPrefManager.getUserToken();
|
// }
|
||||||
String refreshToken = await SharedPrefManager.getRefreshToken();
|
|
||||||
RefreshToken refresh = await RefreshTokenAPI(token, refreshToken);
|
|
||||||
SharedPrefManager.setUserToken(refresh.data!.accessToken ?? "");
|
|
||||||
SharedPrefManager.setRefreshToken(refresh.data!.refreshToken ?? "");
|
|
||||||
String mdata = await SharedPrefManager.getData();
|
|
||||||
UserInfo info = UserInfo.fromJson(jsonDecode(mdata));
|
|
||||||
User user = new User();
|
|
||||||
user.data = new UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info);
|
|
||||||
AppState().setUser = user;
|
|
||||||
return refresh.data!.accessToken??"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:car_customer_app/classes/consts.dart';
|
|
||||||
import 'package:car_customer_app/models/content_info_model.dart';
|
|
||||||
import 'package:car_customer_app/models/member_model.dart';
|
|
||||||
import 'package:car_customer_app/models/surah_model.dart';
|
|
||||||
|
|
||||||
import 'api_client.dart';
|
|
||||||
|
|
||||||
class TangheemUserApiClient {
|
|
||||||
static final TangheemUserApiClient _instance = TangheemUserApiClient._internal();
|
|
||||||
|
|
||||||
TangheemUserApiClient._internal();
|
|
||||||
|
|
||||||
factory TangheemUserApiClient() => _instance;
|
|
||||||
|
|
||||||
Future<SurahModel> getSurahs() async {
|
|
||||||
String url = "${ApiConsts.baseUrl}AlSuar_Get";
|
|
||||||
var postParams = {};
|
|
||||||
return await ApiClient().postJsonForObject((json) => SurahModel.fromJson(json), url, postParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<MemberModel> getMembers() async {
|
|
||||||
String url = "${ApiConsts.baseUrl}Committee_Get";
|
|
||||||
var postParams = {};
|
|
||||||
return await ApiClient().postJsonForObject((json) => MemberModel.fromJson(json), url, postParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ContentInfoModel> getContentInfo(int contentId) async {
|
|
||||||
String url = "${ApiConsts.baseUrl}ContentInfo_Get";
|
|
||||||
var postParams = {"contentTypeId": contentId};
|
|
||||||
return await ApiClient().postJsonForObject((json) => ContentInfoModel.fromJson(json), url, postParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class MyColors {
|
|
||||||
static const Color darkPrimaryColor = Color(0xffF47F20);
|
|
||||||
static const Color primaryColor = Color(0xffF69521);
|
|
||||||
static const Color accentColor = Colors.blue;
|
|
||||||
static const Color lightTextColor = Color(0xff969696);
|
|
||||||
static const Color textColor = Color(0xff777777);
|
|
||||||
static const Color textFieldColor = Color(0xffF3F5F7);
|
|
||||||
static const Color darkIconColor = Color(0xff28323A);
|
|
||||||
static const Color darkTextColor = Color(0xff2B353E);
|
|
||||||
static const Color normalTextColor = Color(0xff5A5A5A);
|
|
||||||
static const Color gradiantStartColor = Color(0xff33c0a5);
|
|
||||||
static const Color gradiantEndColor = Color(0xff259db7);
|
|
||||||
static const Color textMixColor = Color(0xff2BB8A6);
|
|
||||||
static const Color backgroundColor = Color(0xffF8F8F8);
|
|
||||||
static const Color grey57Color = Color(0xff575757);
|
|
||||||
static const Color grey77Color = Color(0xff777777);
|
|
||||||
static const Color grey70Color = Color(0xff707070);
|
|
||||||
static const Color greyACColor = Color(0xffACACAC);
|
|
||||||
static const Color grey98Color = Color(0xff989898);
|
|
||||||
static const Color lightGreyEFColor = Color(0xffEFEFEF);
|
|
||||||
static const Color lightGreyEDColor = Color(0xffEDEDED);
|
|
||||||
static const Color lightGreyEAColor = Color(0xffEAEAEA);
|
|
||||||
static const Color darkWhiteColor = Color(0xffE0E0E0);
|
|
||||||
static const Color redColor = Color(0xffD02127);
|
|
||||||
static const Color yellowColor = Color(0xffF4E31C);
|
|
||||||
static const Color backgroundBlackColor = Color(0xff202529);
|
|
||||||
static const Color black = Color(0xff000000);
|
|
||||||
static const Color white = Color(0xffffffff);
|
|
||||||
static const Color green = Color(0xffffffff);
|
|
||||||
static const Color borderColor = Color(0xffE8E8E8);
|
|
||||||
|
|
||||||
static Decoration gradient = BoxDecoration(
|
|
||||||
gradient: new LinearGradient(colors: [
|
|
||||||
darkPrimaryColor,
|
|
||||||
primaryColor,
|
|
||||||
]),
|
|
||||||
boxShadow: [
|
|
||||||
new BoxShadow(
|
|
||||||
color: primaryColor.withOpacity(0.5),
|
|
||||||
blurRadius: 20.0,
|
|
||||||
spreadRadius: 1.0,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
static Decoration gradientButton = BoxDecoration(
|
|
||||||
gradient: new LinearGradient(colors: [
|
|
||||||
darkPrimaryColor,
|
|
||||||
primaryColor,
|
|
||||||
]),
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
boxShadow: [
|
|
||||||
new BoxShadow(
|
|
||||||
color: primaryColor.withOpacity(0.2),
|
|
||||||
blurRadius: 4.0,
|
|
||||||
spreadRadius: 0.5,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
import 'package:car_customer_app/widgets/loading_dialog.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
// import 'package:fluttertoast/fluttertoast.dart';
|
|
||||||
import 'package:car_customer_app/exceptions/api_exception.dart';
|
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
|
||||||
|
|
||||||
class Utils {
|
|
||||||
static bool _isLoadingVisible = false;
|
|
||||||
|
|
||||||
static bool get isLoading => _isLoadingVisible;
|
|
||||||
|
|
||||||
static void showToast(String message) {
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 2, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static dynamic getNotNullValue(List<dynamic> list, int index) {
|
|
||||||
try {
|
|
||||||
return list[index];
|
|
||||||
} catch (ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int stringToHex(String colorCode) {
|
|
||||||
try {
|
|
||||||
return int.parse(colorCode.replaceAll("#", "0xff"));
|
|
||||||
} catch (ex) {
|
|
||||||
return (0xff000000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void showLoading(BuildContext context) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_isLoadingVisible = true;
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierColor: Colors.black.withOpacity(0.5),
|
|
||||||
builder: (BuildContext context) => LoadingDialog(),
|
|
||||||
).then((value) {
|
|
||||||
_isLoadingVisible = false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static void hideLoading(BuildContext context) {
|
|
||||||
if (_isLoadingVisible) {
|
|
||||||
_isLoadingVisible = false;
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
_isLoadingVisible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handleException(dynamic exception, Function(String)? onErrorMessage) {
|
|
||||||
String errorMessage;
|
|
||||||
if (exception is APIException) {
|
|
||||||
if (exception.message == APIException.UNAUTHORIZED) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
errorMessage = exception.error?.errorMessage ?? exception.message;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorMessage = APIException.UNKNOWN;
|
|
||||||
}
|
|
||||||
if (onErrorMessage != null) {
|
|
||||||
onErrorMessage(errorMessage);
|
|
||||||
} else {
|
|
||||||
showToast(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
// import 'package:car_customer_app/provider/counter.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class AppProvider extends StatelessWidget {
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
AppProvider({required this.child});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return child;
|
|
||||||
// return MultiProvider(
|
|
||||||
// providers: [
|
|
||||||
// ChangeNotifierProvider(create: (_) => Counter()),
|
|
||||||
// ],
|
|
||||||
// child: child,
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
// import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:car_customer_app/api/api_client.dart';
|
||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/repositories/branch_repo.dart';
|
||||||
|
import 'package:car_customer_app/repositories/user_repo.dart';
|
||||||
|
import 'package:car_customer_app/services/services.dart';
|
||||||
|
import 'package:injector/injector.dart';
|
||||||
|
|
||||||
|
Injector injector = Injector.appInstance;
|
||||||
|
|
||||||
|
class AppDependencies {
|
||||||
|
static void addDependencies() {
|
||||||
|
//services
|
||||||
|
injector.registerSingleton<AppState>(() => AppState());
|
||||||
|
injector.registerSingleton<ApiClient>(() => ApiClientImp());
|
||||||
|
injector.registerSingleton<CommonServices>(() => CommonServicesImp());
|
||||||
|
|
||||||
|
//repos
|
||||||
|
injector.registerSingleton<UserRepo>(() => UserRepoImp());
|
||||||
|
injector.registerSingleton<BranchRepo>(() => BranchRepoImp());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,62 +1,81 @@
|
|||||||
import 'package:car_customer_app/classes/app_state.dart';
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
import 'package:car_customer_app/config/app_provider.dart';
|
import 'package:car_customer_app/config/dependencies.dart';
|
||||||
import 'package:car_customer_app/models/post_params_model.dart';
|
import 'package:car_customer_app/models/post_params_model.dart';
|
||||||
|
import 'package:car_customer_app/repositories/user_repo.dart';
|
||||||
|
import 'package:car_customer_app/services/services.dart';
|
||||||
import 'package:car_customer_app/theme/app_theme.dart';
|
import 'package:car_customer_app/theme/app_theme.dart';
|
||||||
|
import 'package:car_customer_app/view_models/base_view_model.dart';
|
||||||
|
import 'package:car_customer_app/view_models/dashboard_view_model.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sizer/sizer.dart';
|
import 'package:sizer/sizer.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:provider/single_child_widget.dart';
|
||||||
|
|
||||||
import 'config/routes.dart';
|
import 'config/routes.dart';
|
||||||
|
import 'generated/codegen_loader.g.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
AppDependencies.addDependencies();
|
||||||
await EasyLocalization.ensureInitialized();
|
await EasyLocalization.ensureInitialized();
|
||||||
runApp(
|
runApp(
|
||||||
EasyLocalization(
|
EasyLocalization(
|
||||||
supportedLocales: [
|
supportedLocales: const [Locale('ar', 'SA'), Locale('en', 'US')],
|
||||||
Locale('ar', 'SA'),
|
fallbackLocale: const Locale('en', 'US'),
|
||||||
Locale('en', 'US')
|
startLocale: const Locale('en', 'US'),
|
||||||
|
assetLoader: const CodegenLoader(),
|
||||||
],
|
path: "assetsl/langs",
|
||||||
fallbackLocale: Locale('en', 'US'),
|
child: MultiProvider(
|
||||||
// startLocale: Locale('ar', 'SA'),
|
providers: <SingleChildWidget>[
|
||||||
startLocale: Locale('en', 'US'),
|
ChangeNotifierProvider<BaseVM>(
|
||||||
path: 'resources/langs',
|
create: (_) => BaseVM(),
|
||||||
child: MyApp(),
|
),
|
||||||
|
ChangeNotifierProvider<DashboardVM>(
|
||||||
|
create: (_) => DashboardVM(
|
||||||
|
userRepo: injector.get<UserRepo>(),
|
||||||
|
commonServices: injector.get<CommonServices>(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider<UserVM>(
|
||||||
|
create: (_) => UserVM(userRepo: injector.get<UserRepo>()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: const MyApp(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo terminal command to genertate translation files
|
// todo terminal command to generate translation files
|
||||||
// flutter pub run easy_localization:generate --source-dir ./resources/langs
|
// flutter pub run easy_localization:generate --source-dir ./assets/langs
|
||||||
// todo terminal command to genertate translation keys
|
// todo terminal command to generate translation keys
|
||||||
// flutter pub run easy_localization:generate --source-dir ./resources/langs -f keys -o locale_keys.g.dart
|
// flutter pub run easy_localization:generate --source-dir ./assets/langs -f keys -o locale_keys.g.dart
|
||||||
// command to generate languages data from json
|
// command to generate languages data from json
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
|
const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AppProvider(
|
return Sizer(
|
||||||
child: Sizer(
|
builder: (context, orientation, deviceType) {
|
||||||
builder: (context, orientation, deviceType) {
|
AppState().setPostParamsModel(
|
||||||
AppState().setPostParamsModel(
|
PostParamsModel(
|
||||||
PostParamsModel(languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,),
|
languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,
|
||||||
);
|
),
|
||||||
return MaterialApp(
|
);
|
||||||
theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"),
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"),
|
||||||
localizationsDelegates: context.localizationDelegates,
|
debugShowCheckedModeBanner: false,
|
||||||
supportedLocales: context.supportedLocales,
|
localizationsDelegates: context.localizationDelegates,
|
||||||
locale: context.locale,
|
supportedLocales: context.supportedLocales,
|
||||||
initialRoute: AppRoutes.initialRoute,
|
locale: context.locale,
|
||||||
routes: AppRoutes.routes,
|
initialRoute: AppRoutes.initialRoute,
|
||||||
);
|
routes: AppRoutes.routes,
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,294 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/shared_prefrence.dart';
|
|
||||||
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:car_customer_app/theme/colors.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: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:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../../api/client/user_api_client.dart';
|
|
||||||
import '../../classes/app_state.dart';
|
|
||||||
import '../../classes/colors.dart';
|
|
||||||
import '../../classes/consts.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import '../../classes/utils.dart';
|
|
||||||
import '../../config/routes.dart';
|
|
||||||
import '../../models/user/image_response.dart';
|
|
||||||
import '../../utils/utils.dart';
|
|
||||||
|
|
||||||
class DashboardPage extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
State<DashboardPage> createState() => _DashboardPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DashboardPageState extends State<DashboardPage> {
|
|
||||||
String userName = "";
|
|
||||||
|
|
||||||
// void _handleURLButtonPress(BuildContext context, var type) {
|
|
||||||
// Navigator.push(context,
|
|
||||||
// MaterialPageRoute(builder: (context) => ImageFromGalleryEx(type)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
File? imagePicked;
|
|
||||||
String image64 = "";
|
|
||||||
final _picker = ImagePicker();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
super.initState();
|
|
||||||
fetchUsername();
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchUsername() async {
|
|
||||||
userName = await SharedPrefManager.getPhoneOrEmail();
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(context, title: "Logo/Brand", isRemoveBackButton: true),
|
|
||||||
drawer: showDrawer(context),
|
|
||||||
body: Center(
|
|
||||||
child: LocaleKeys.dashboard.tr().toText24(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget showDrawer(BuildContext context) {
|
|
||||||
return Drawer(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Stack(children: [
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 200,
|
|
||||||
color: MyColors.darkPrimaryColor.withOpacity(0.01),
|
|
||||||
child: Image.network(
|
|
||||||
ApiConsts.baseUrlServices + AppState().getUser.data!.userInfo!.userImageUrl.toString(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 10,
|
|
||||||
right: 10,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey[200],
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.edit,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
).onPress(() {
|
|
||||||
_openImagePicker();
|
|
||||||
// _handleURLButtonPress(context, ImageSourceType.camera);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
Container(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey[200],
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.delete,
|
|
||||||
color: Colors.red,
|
|
||||||
).onPress(() async {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
ImageResponse response = await UserApiClent().UpdateUserImage("");
|
|
||||||
if (response.messageStatus == 1) {
|
|
||||||
Utils.showToast("Image is Deleted");
|
|
||||||
setState(() {
|
|
||||||
AppState().getUser.data!.userInfo!.userImageUrl = response.data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
color: MyColors.darkPrimaryColor.withOpacity(0.1),
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
userName.toText20(isBold: true),
|
|
||||||
AppState().getUser.data!.userInfo!.roleName!.toText10(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.edit.tr(),
|
|
||||||
fontSize: 12,
|
|
||||||
maxHeight: 35,
|
|
||||||
maxWidth: 70,
|
|
||||||
onPressed: () {
|
|
||||||
navigateWithName(context, AppRoutes.editAccoundPage);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Icons.notifications,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
),
|
|
||||||
title: LocaleKeys.notifications.tr().toText12(),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Icons.settings,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
),
|
|
||||||
title: LocaleKeys.general.tr().toText12(),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Icons.person,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
),
|
|
||||||
title: LocaleKeys.account.tr().toText12(),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Image.asset(
|
|
||||||
"assets/images/ic_world.png",
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
),
|
|
||||||
title: LocaleKeys.english.tr().toText12(),
|
|
||||||
onTap: () {
|
|
||||||
if (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA")
|
|
||||||
context.setLocale(const Locale("en", "US"));
|
|
||||||
else
|
|
||||||
context.setLocale(const Locale('ar', 'SA'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(
|
|
||||||
Icons.logout,
|
|
||||||
color: MyColors.darkPrimaryColor,
|
|
||||||
),
|
|
||||||
title: LocaleKeys.signOut.tr().toText12(),
|
|
||||||
onTap: () {
|
|
||||||
pop(context);
|
|
||||||
navigateReplaceWithName(context, AppRoutes.registerSelection);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _openImagePicker() {
|
|
||||||
showDialog<ImageSource>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
content: const Text("Choose image source"),
|
|
||||||
actions: [
|
|
||||||
TextButton(child: const Text("Camera"), onPressed: () => cameraImage()),
|
|
||||||
TextButton(child: const Text("Gallery"), onPressed: () => gallaryImage()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// .then((ImageSource source) async {
|
|
||||||
// if (source != null) {
|
|
||||||
// final pickedFile = await ImagePicker().getImage(source: source);
|
|
||||||
// setState(() => imagePicked = File(pickedFile.path));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gallaryImage() async {
|
|
||||||
final picker = ImagePicker();
|
|
||||||
final pickedImage = await picker.pickImage(
|
|
||||||
source: ImageSource.gallery,
|
|
||||||
);
|
|
||||||
final pickedImageFile = File(pickedImage!.path);
|
|
||||||
int sizeInBytes = pickedImageFile.lengthSync();
|
|
||||||
// double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
||||||
if (sizeInBytes > 1000) {
|
|
||||||
Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
||||||
//("File is larger then 1KB");
|
|
||||||
} else {
|
|
||||||
image64 = convertFileToBase64(pickedImageFile);
|
|
||||||
|
|
||||||
Utils.showLoading(context);
|
|
||||||
ImageResponse response = await UserApiClent().UpdateUserImage(image64);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
Navigator.pop(context);
|
|
||||||
if (response.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.imageUploaded.tr());
|
|
||||||
//("Image is uploaded");
|
|
||||||
AppState().getUser.data!.userInfo!.userImageUrl = response.data;
|
|
||||||
} else {
|
|
||||||
Utils.showToast(response.message ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
imagePicked = pickedImageFile;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cameraImage() async {
|
|
||||||
final picker = ImagePicker();
|
|
||||||
final pickedImage = await picker.pickImage(
|
|
||||||
source: ImageSource.camera,
|
|
||||||
);
|
|
||||||
final pickedImageFile = File(pickedImage!.path);
|
|
||||||
int sizeInBytes = pickedImageFile.lengthSync();
|
|
||||||
// double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
||||||
if (sizeInBytes > 1000) {
|
|
||||||
Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
||||||
//("File is larger then 1KB");
|
|
||||||
} else {
|
|
||||||
image64 = convertFileToBase64(pickedImageFile);
|
|
||||||
|
|
||||||
Utils.showLoading(context);
|
|
||||||
ImageResponse response = await UserApiClent().UpdateUserImage(image64);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
Navigator.pop(context);
|
|
||||||
if (response.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.imageUploaded.tr());
|
|
||||||
//("Image is uploaded");
|
|
||||||
AppState().getUser.data!.userInfo!.userImageUrl = response.data;
|
|
||||||
} else {
|
|
||||||
Utils.showToast(response.message ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
imagePicked = pickedImageFile;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.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:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
import '../../widgets/txt_field.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(context, title: LocaleKeys.changeEmail.tr()),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.enterEmail.tr().toText24(),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterNewEmail.tr(),
|
|
||||||
onChanged: (v) => email = v,
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterCurrentPassword.tr(),
|
|
||||||
onChanged: (v) => password = v,
|
|
||||||
),
|
|
||||||
40.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.confirm.tr(),
|
|
||||||
maxWidth: 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: LocaleKeys.emailChangedSuccessfully.tr(),
|
|
||||||
//"Email is Changed Successfully",
|
|
||||||
onClick: () {
|
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpCompare.message ?? "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpRequest.message ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
|
|
||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.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/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:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
import '../../widgets/txt_field.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(context, title: LocaleKeys.changeMobile.tr()),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.enterNewPhoneNumber.tr().toText24(),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterNewPhoneNumber.tr(),
|
|
||||||
onChanged: (v) => mobileNo = v,
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterCurrentPassword.tr(),
|
|
||||||
onChanged: (v) => password = v,
|
|
||||||
),
|
|
||||||
20.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.confirm.tr(),
|
|
||||||
maxWidth: 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:LocaleKeys.phoneNumberVerified.tr(),
|
|
||||||
//"Phone Number Verified",
|
|
||||||
onClick: () {
|
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpCompare.message ?? "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpRequest.message ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.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/utils/utils.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/show_fill_button.dart';
|
|
||||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
||||||
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
import '../../models/m_response.dart';
|
|
||||||
|
|
||||||
class ChangePasswordPage extends StatefulWidget {
|
|
||||||
ChangePasswordPage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
||||||
String newPassword = "";
|
|
||||||
String currentPasswor = '';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(context, title: LocaleKeys.changePassword.tr()),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(40),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.enterNewPassword.tr().toText24(),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterOldPassword.tr(),
|
|
||||||
onChanged: (v) => currentPasswor = v,
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.enterNewPassword.tr(),
|
|
||||||
onChanged: (v) => newPassword = v,
|
|
||||||
),
|
|
||||||
20.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.confirm.tr(),
|
|
||||||
maxWidth: double.infinity,
|
|
||||||
onPressed: () {
|
|
||||||
changePassword(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> changePassword(BuildContext context) async {
|
|
||||||
if (validateStructure(newPassword)) {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
MResponse res = await UserApiClent().ChangePassword(currentPasswor, newPassword);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
if (res.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
||||||
//("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(LocaleKeys.passwordShouldContains.tr());
|
|
||||||
//("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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,295 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.dart';
|
|
||||||
import 'package:car_customer_app/models/m_response.dart';
|
|
||||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
|
||||||
import 'package:car_customer_app/models/user/register_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/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:car_customer_app/extensions/widget_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_password_strength/flutter_password_strength.dart';
|
|
||||||
|
|
||||||
import '../../classes/colors.dart';
|
|
||||||
|
|
||||||
class CompleteProfilePage extends StatefulWidget {
|
|
||||||
RegisterUser user;
|
|
||||||
|
|
||||||
CompleteProfilePage(this.user);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CompleteProfilePage> createState() => _CompleteProfilePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
||||||
String? firstName = "",
|
|
||||||
lastName = "",
|
|
||||||
email = "",
|
|
||||||
confirmPassword = "";
|
|
||||||
late String password = "";
|
|
||||||
bool isChecked = false;
|
|
||||||
|
|
||||||
double _strength = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
// TODO: implement initState
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(
|
|
||||||
context,
|
|
||||||
title: LocaleKeys.signUp.tr(),
|
|
||||||
),
|
|
||||||
body: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
6.height,
|
|
||||||
LocaleKeys.completeProfile.tr().toText24(),
|
|
||||||
12.height,
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: LocaleKeys.profileMsg.tr().toText14(
|
|
||||||
color: MyColors.lightTextColor,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.firstName.tr(),
|
|
||||||
value: firstName,
|
|
||||||
onChanged: (v) {
|
|
||||||
firstName = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.surname.tr(),
|
|
||||||
value: lastName,
|
|
||||||
onChanged: (v) {
|
|
||||||
lastName = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.email.tr(),
|
|
||||||
value: email,
|
|
||||||
// isButtonEnable: email!.length > 0 ? true : false,
|
|
||||||
buttonTitle: LocaleKeys.verify.tr(),
|
|
||||||
onChanged: (v) {
|
|
||||||
email = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.createPass.tr(),
|
|
||||||
isPasswordEnabled: true,
|
|
||||||
maxLines: 1,
|
|
||||||
value: password,
|
|
||||||
onChanged: (v) {
|
|
||||||
password = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TxtField(
|
|
||||||
hint: LocaleKeys.confirmPass.tr(),
|
|
||||||
isPasswordEnabled: true,
|
|
||||||
maxLines: 1,
|
|
||||||
value: confirmPassword,
|
|
||||||
onChanged: (v) {
|
|
||||||
confirmPassword = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// 12.height,
|
|
||||||
// TxtField(
|
|
||||||
// hint: "Phone Number",
|
|
||||||
// ),
|
|
||||||
50.height,
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
buildCheckbox(),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.termsOfService.tr().toText12(),
|
|
||||||
LocaleKeys.terms.tr().toText12(color: MyColors.darkPrimaryColor),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Theme(
|
|
||||||
data: ThemeData(unselectedWidgetColor: Colors.transparent),
|
|
||||||
child: Checkbox(
|
|
||||||
value: false,
|
|
||||||
onChanged: (_) {},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
16.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.save.tr(),
|
|
||||||
maxWidth: double.infinity,
|
|
||||||
onPressed: () {
|
|
||||||
if (validation()) performCompleteProfile();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
16.height,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildCheckbox() =>
|
|
||||||
Checkbox(
|
|
||||||
value: isChecked,
|
|
||||||
activeColor: Colors.blue,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
isChecked = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Future<void> performCompleteProfile() async {
|
|
||||||
// if(validateStructure(password??"")){
|
|
||||||
// if (password == confirmPassword) {
|
|
||||||
// print(widget.user.data!.userId??"userId");
|
|
||||||
// Utils.showLoading(context);
|
|
||||||
// RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
|
|
||||||
// Utils.hideLoading(context);
|
|
||||||
// if (user.messageStatus == 1) {
|
|
||||||
// Utils.showToast( "Successfully registered, Please login once");
|
|
||||||
// pop(context);
|
|
||||||
// // pop(context);
|
|
||||||
// // navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
|
|
||||||
// } else {
|
|
||||||
// Utils.showToast(user.message ?? "");
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// Utils.showToast("Please enter same password");
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// Utils.showToast("Password Should contains character, Number, Capital and small letters");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<void> performCompleteProfile() async {
|
|
||||||
if (validateStructure(password)) {
|
|
||||||
if (password == confirmPassword) {
|
|
||||||
print(widget.user.data!.userId?? "userId");
|
|
||||||
Utils.showLoading(context);
|
|
||||||
RegisterUser user = await UserApiClent().basicComplete(widget.user.data!.userId ?? "", firstName!, lastName!, email!, password);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
if (user.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.successfullyRegistered.tr());
|
|
||||||
//("Successfully Registered, Please login once");
|
|
||||||
pop(context);
|
|
||||||
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(user.message ?? "");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
|
||||||
//("Please enter same password");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
|
||||||
//("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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool isEmail(String em) {
|
|
||||||
String p = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
|
||||||
RegExp regExp = new RegExp(p);
|
|
||||||
return regExp.hasMatch(em);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validation() {
|
|
||||||
bool isValid = true;
|
|
||||||
if (firstName!.isEmpty) {
|
|
||||||
Utils.showToast(LocaleKeys.firstNameMandatory.tr());
|
|
||||||
//("First name is mandatory");
|
|
||||||
isValid = false;
|
|
||||||
} else if (lastName!.isEmpty) {
|
|
||||||
Utils.showToast(LocaleKeys.surnameNameMandatory.tr());
|
|
||||||
//("Surname is mandatory");
|
|
||||||
isValid = false;
|
|
||||||
} else if (email!.isNotEmpty) {
|
|
||||||
if (!isEmail(email!)) {
|
|
||||||
Utils.showToast(LocaleKeys.enterValidEmail.tr());
|
|
||||||
//("Enter Valid Email");
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
} else if (password.isEmpty) {
|
|
||||||
Utils.showToast(LocaleKeys.passwordNameMandatory.tr());
|
|
||||||
//("Password is mandatory");
|
|
||||||
isValid = false;
|
|
||||||
} else if (!isChecked) {
|
|
||||||
Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr());
|
|
||||||
//("Please accept terms");
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
return isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegExp numReg = RegExp(r".*[0-9].*");
|
|
||||||
RegExp letterReg = RegExp(r".*[A-Za-z].*");
|
|
||||||
|
|
||||||
String _displayText = '';
|
|
||||||
|
|
||||||
void _checkPassword(String value) {
|
|
||||||
password = value.trim();
|
|
||||||
if (password.length <= 6) {
|
|
||||||
setState(() {
|
|
||||||
_strength = 1 / 4;
|
|
||||||
_displayText = 'Your password is too short';
|
|
||||||
});
|
|
||||||
} else if (password.length < 8) {
|
|
||||||
setState(() {
|
|
||||||
_strength = 2 / 4;
|
|
||||||
_displayText = 'Your password is acceptable but not strong';
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (!letterReg.hasMatch(password) || !numReg.hasMatch(password)) {
|
|
||||||
setState(() {
|
|
||||||
_strength = 3 / 4;
|
|
||||||
_displayText = 'Your password is strong';
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_strength = 1;
|
|
||||||
_displayText = 'Your password is very strong';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.dart';
|
|
||||||
import 'package:car_customer_app/models/user/confirm_password.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/dialog/dialogs.dart';
|
|
||||||
import 'package:car_customer_app/widgets/dialog/message_dialog.dart';
|
|
||||||
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
|
||||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
||||||
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
class ConfirmNewPasswordPage extends StatefulWidget {
|
|
||||||
String userToken;
|
|
||||||
|
|
||||||
ConfirmNewPasswordPage(this.userToken, {Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ConfirmNewPasswordPage> createState() => _ConfirmNewPasswordPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
|
|
||||||
String newPassword = "";
|
|
||||||
String confirmPassword = '';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(context,title: LocaleKeys.forgetPassword.tr()),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(40),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.newPassword.toText24(),
|
|
||||||
12.height,
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
// hintText: "Enter New Password",
|
|
||||||
hintText: LocaleKeys.enterNewPassword.tr(),
|
|
||||||
hintStyle: TextStyle(color: Colors.grey),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
const Radius.circular(5.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
obscureText: true,
|
|
||||||
onChanged: (v) => newPassword = v,
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
// hintText: "Confirm Password",
|
|
||||||
hintText: LocaleKeys.confirmPassword.tr(),
|
|
||||||
hintStyle: TextStyle(color: Colors.grey),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
const Radius.circular(5.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
obscureText: true,
|
|
||||||
onChanged: (v) => confirmPassword = v,
|
|
||||||
),
|
|
||||||
40.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.confirm.tr(),
|
|
||||||
maxWidth: double.infinity,
|
|
||||||
onPressed: () {
|
|
||||||
if (validation()) confirmPasswordOTP(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> confirmPasswordOTP(BuildContext context) async {
|
|
||||||
if(validateStructure(newPassword)){
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
ConfirmPassword data = ConfirmPassword.fromJson(jsonDecode(res.body));
|
|
||||||
if (data.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
||||||
//("Password is Updated");
|
|
||||||
navigateWithName(context, AppRoutes.loginWithPassword);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(data.message ?? "");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
|
||||||
//("Password Should contains Character, Number, Capital and small letters");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validation() {
|
|
||||||
bool isValid = true;
|
|
||||||
if (newPassword != confirmPassword) {
|
|
||||||
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
return isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validateStructure(String value){
|
|
||||||
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
|
||||||
RegExp regExp = new RegExp(pattern);
|
|
||||||
return regExp.hasMatch(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:car_customer_app/api/client/user_api_client.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/extensions/int_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:car_customer_app/models/user/forget_password_otp_compare.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/otp_dialog.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.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(context, title: LocaleKeys.forgetPassword.tr()),
|
|
||||||
body: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(40),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.selectMethod.tr().toText24(),
|
|
||||||
12.height,
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
otpType = 1;
|
|
||||||
forgetPasswordOTPMethod(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.SMS.tr(),
|
|
||||||
icon: icons + "ic_sms.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
20.width,
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
otpType = 1;
|
|
||||||
forgetPasswordOTPMethod(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.whatsapp.tr(),
|
|
||||||
icon: icons + "ic_whatsapp.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
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 ?? "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,196 +0,0 @@
|
|||||||
import 'package:car_customer_app/api/client/user_api_client.dart';
|
|
||||||
import 'package:car_customer_app/api/shared_prefrence.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/generated/locale_keys.g.dart';
|
|
||||||
import 'package:car_customer_app/models/user/forget_password_otp_compare.dart';
|
|
||||||
import 'package:car_customer_app/models/user/forget_password_otp_request.dart';
|
|
||||||
import 'package:car_customer_app/pages/user/vertify_password_page.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/widgets/dialog/otp_dialog.dart';
|
|
||||||
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
|
||||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
|
||||||
import 'package:car_customer_app/extensions/widget_extensions.dart';
|
|
||||||
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
||||||
import 'package:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:car_customer_app/models/user/user.dart';
|
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
import '../../classes/colors.dart';
|
|
||||||
import '../../models/user/country.dart';
|
|
||||||
import '../../widgets/dropdown/dropdow_field.dart';
|
|
||||||
import '../../widgets/tab/login_email_tab.dart';
|
|
||||||
|
|
||||||
class ForgetPasswordPage extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
State<ForgetPasswordPage> createState() => _ForgetPasswordPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ForgetPasswordPageState extends State<ForgetPasswordPage> {
|
|
||||||
int otpType = 1;
|
|
||||||
|
|
||||||
String userName = "";
|
|
||||||
ClassType type = ClassType.EMAIL;
|
|
||||||
Country? _country;
|
|
||||||
String countryCode = "";
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
getCountryList();
|
|
||||||
}
|
|
||||||
|
|
||||||
getCountryList() async {
|
|
||||||
_country = await UserApiClent().getAllCountries();
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(context,title: LocaleKeys.changePassword.tr()),
|
|
||||||
body: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Container(
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
12.height,
|
|
||||||
LocaleKeys.forgetPassword.tr().toText20(),
|
|
||||||
20.height,
|
|
||||||
LocaleKeys.retrievePassword.tr().toText14(
|
|
||||||
color: MyColors.lightTextColor,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
30.height,
|
|
||||||
LoginEmailTab(
|
|
||||||
onSelection: (ClassType type) {
|
|
||||||
setState(() {
|
|
||||||
this.type = type;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
12.height,
|
|
||||||
type == ClassType.NUMBER
|
|
||||||
? Column(
|
|
||||||
children: [
|
|
||||||
getCountry(),
|
|
||||||
6.height,
|
|
||||||
TxtField(
|
|
||||||
hint: "5********",
|
|
||||||
value: userName,
|
|
||||||
onChanged: (v) {
|
|
||||||
userName = v;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: TxtField(
|
|
||||||
hint: LocaleKeys.emailAddress.tr(),
|
|
||||||
value: userName,
|
|
||||||
onChanged: (v) {
|
|
||||||
userName = v;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
20.height,
|
|
||||||
(type == ClassType.NUMBER ? LocaleKeys.retriveOnPhone.tr() : LocaleKeys.retriveOnEmail.tr()).toText14(
|
|
||||||
color: MyColors.lightTextColor,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
30.height,
|
|
||||||
ShowFillButton(
|
|
||||||
title: LocaleKeys.send.tr(),
|
|
||||||
maxWidth: double.infinity,
|
|
||||||
onPressed: () {
|
|
||||||
if (userName.isNum() && type == ClassType.NUMBER) {
|
|
||||||
forgetPasswordPhoneOTP(context);
|
|
||||||
} else if (!userName.isNum() && type == ClassType.EMAIL) {
|
|
||||||
forgetPasswordEmailOTP(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
mFlex(10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getCountry() {
|
|
||||||
if (_country != null) {
|
|
||||||
List<DropValue> dropList = [];
|
|
||||||
_country!.data?.forEach((element) {
|
|
||||||
dropList.add(new DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? ""));
|
|
||||||
});
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(2.0),
|
|
||||||
child: DropdownField((DropValue value) {
|
|
||||||
countryCode = value.subValue;
|
|
||||||
}, list: dropList, hint: LocaleKeys.selectCountryCode.tr()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> forgetPasswordPhoneOTP(BuildContext context) async {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response response = await UserApiClent().ForgetPasswordOTPRequest(countryCode+userName, otpType);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
PasswordOTPRequest otpRequest = PasswordOTPRequest.fromJson(jsonDecode(response.body));
|
|
||||||
if (otpRequest.messageStatus == 1) {
|
|
||||||
var userToken = otpRequest.data!.userToken;
|
|
||||||
navigateReplaceWithName(context, AppRoutes.forgetPasswordMethodPage, arguments: userToken);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpRequest.message ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> forgetPasswordEmailOTP(BuildContext context) async {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response response = await UserApiClent().ForgetPasswordOTPRequest(userName, otpType);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
PasswordOTPRequest otpRequest = PasswordOTPRequest.fromJson(jsonDecode(response.body));
|
|
||||||
if (otpRequest.messageStatus == 1) {
|
|
||||||
Utils.showToast(LocaleKeys.codeSentToEmail.tr());
|
|
||||||
showMDialog(context, child: OtpDialog(
|
|
||||||
onClick: (String code) async {
|
|
||||||
pop(context);
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response res = await UserApiClent().ForgetPasswordOTPCompare(otpRequest.data!.userToken ?? "", code);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
PasswordOTPCompare otpCompare = PasswordOTPCompare.fromJson(jsonDecode(res.body));
|
|
||||||
if (otpCompare.messageStatus == 1) {
|
|
||||||
var userToken = otpCompare.data!.userToken;
|
|
||||||
print("token is ________");
|
|
||||||
print(userToken);
|
|
||||||
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpCompare.message ?? "");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
Utils.showToast(otpRequest.message ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:car_customer_app/api/shared_prefrence.dart';
|
|
||||||
import 'package:car_customer_app/api/client/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/generated/locale_keys.g.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:easy_localization/src/public_ext.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:http/http.dart';
|
|
||||||
|
|
||||||
class LoginMethodSelectionPage extends StatelessWidget {
|
|
||||||
String userToken;
|
|
||||||
|
|
||||||
LoginMethodSelectionPage(this.userToken);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: appBar(context, title: LocaleKeys.log_in.tr()),
|
|
||||||
body: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
LocaleKeys.loginSelection.tr().toText20(),
|
|
||||||
30.height,
|
|
||||||
LocaleKeys.welcomeBack.tr().toText20(),
|
|
||||||
40.height,
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
performBasicOtp(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.fingerPrint.tr(),
|
|
||||||
icon: icons + "ic_fingerprint.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
20.width,
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
performBasicOtp(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.faceRecognition.tr(),
|
|
||||||
icon: icons + "ic_face.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
40.height,
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
performBasicOtp(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.SMS.tr(),
|
|
||||||
icon: icons + "ic_sms.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
20.width,
|
|
||||||
Expanded(
|
|
||||||
child: ShowImageButton(
|
|
||||||
onClick: () {
|
|
||||||
// navigateWithName(context, AppRoutes.dashboard);
|
|
||||||
performBasicOtp(context);
|
|
||||||
},
|
|
||||||
title: LocaleKeys.whatsapp.tr(),
|
|
||||||
icon: icons + "ic_whatsapp.svg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> performBasicOtp(BuildContext context) async {
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response response = await UserApiClent().login_V2_OTP(userToken, "1");
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
LoginPassword user = LoginPassword.fromJson(jsonDecode(response.body));
|
|
||||||
if (user.messageStatus == 1) {
|
|
||||||
showMDialog(context, child: OtpDialog(
|
|
||||||
onClick: (String code) async {
|
|
||||||
pop(context);
|
|
||||||
Utils.showLoading(context);
|
|
||||||
Response response2 = await UserApiClent().login_V2_OTPVerify(user.data!.userToken??"", code);
|
|
||||||
Utils.hideLoading(context);
|
|
||||||
RegisterUser verifiedUser = RegisterUser.fromJson(jsonDecode(response2.body));
|
|
||||||
if (verifiedUser.messageStatus == 1) {
|
|
||||||
User user = User.fromJson(jsonDecode(response2.body));
|
|
||||||
if(user.data!.userInfo!.roleId==4){
|
|
||||||
|
|
||||||
|
|
||||||
AppState().setUser = user;
|
|
||||||
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
||||||
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
||||||
SharedPrefManager.setRefreshToken(user.data!.refreshToken??"");
|
|
||||||
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
|
||||||
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
||||||
}else{
|
|
||||||
Utils.showToast(LocaleKeys.onlyCustomerApp.tr());
|
|
||||||
//("Sorry, Only Customer's can log in this app");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Utils.showToast(verifiedUser.message??"");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
Utils.showToast(user.message ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:car_customer_app/api/api_client.dart';
|
||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/classes/consts.dart';
|
||||||
|
import 'package:car_customer_app/config/dependencies.dart';
|
||||||
|
import 'package:car_customer_app/models/m_response.dart';
|
||||||
|
import 'package:car_customer_app/models/profile/branch.dart';
|
||||||
|
import 'package:car_customer_app/models/profile/categroy.dart';
|
||||||
|
import 'package:car_customer_app/models/profile/document.dart';
|
||||||
|
import 'package:car_customer_app/models/profile/services.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
abstract class BranchRepo {
|
||||||
|
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude);
|
||||||
|
|
||||||
|
Future<Branch> fetchAllBranches();
|
||||||
|
|
||||||
|
Future<Category> fetchBranchCategory();
|
||||||
|
|
||||||
|
Future<Services> fetchServicesByCategoryId(String serviceCategoryId);
|
||||||
|
|
||||||
|
Future<MResponse> createNewService(List<Map<String, dynamic>> map);
|
||||||
|
|
||||||
|
Future<Document> getServiceProviderDocument(dynamic userId);
|
||||||
|
|
||||||
|
Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents);
|
||||||
|
}
|
||||||
|
|
||||||
|
class BranchRepoImp implements BranchRepo {
|
||||||
|
@override
|
||||||
|
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
||||||
|
var postParams = {
|
||||||
|
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
||||||
|
"branchName": branchName,
|
||||||
|
"branchDescription": branchDescription,
|
||||||
|
"cityID": cityId,
|
||||||
|
"address": address,
|
||||||
|
"latitude": latitude,
|
||||||
|
"longitude": longitude,
|
||||||
|
"isActive": true
|
||||||
|
};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Branch> fetchAllBranches() async {
|
||||||
|
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Category> fetchBranchCategory() async {
|
||||||
|
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Services> fetchServicesByCategoryId(String serviceCategoryId) async {
|
||||||
|
var postParams = {"ServiceCategoryID": serviceCategoryId};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.Services_Get, queryParameters: postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> createNewService(List<Map<String, dynamic>> map) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Document> getServiceProviderDocument(dynamic userId) async {
|
||||||
|
var queryParameters = {
|
||||||
|
"ServiceProviderID": userId.toString(),
|
||||||
|
};
|
||||||
|
String? token = AppState().getUser.data?.accessToken;
|
||||||
|
debugPrint(token);
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Document.fromJson(json), ApiConsts.GetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents) async {
|
||||||
|
List<Map<String, dynamic>> map = [];
|
||||||
|
for (int i = 0; i < documents!.length; i++) {
|
||||||
|
if (documents[i].document != null) {
|
||||||
|
var postParams = {
|
||||||
|
"id": documents[i].id,
|
||||||
|
"serviceProviderID": documents[i].serviceProviderId,
|
||||||
|
"documentID": documents[i].documentId,
|
||||||
|
"documentExt": documents[i].fileExt,
|
||||||
|
"documentImage": documents[i].document,
|
||||||
|
"isActive": true
|
||||||
|
};
|
||||||
|
map.add(postParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderDocument_Update, map, token: t);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
|
||||||
@ -0,0 +1,291 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:car_customer_app/api/api_client.dart';
|
||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/classes/consts.dart';
|
||||||
|
import 'package:car_customer_app/config/dependencies.dart';
|
||||||
|
import 'package:car_customer_app/models/m_response.dart';
|
||||||
|
import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_email.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_mobile.dart';
|
||||||
|
import 'package:car_customer_app/models/user/cities.dart';
|
||||||
|
import 'package:car_customer_app/models/user/confirm_email.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/models/user/country.dart';
|
||||||
|
import 'package:car_customer_app/models/user/forget_password_otp_compare.dart';
|
||||||
|
import 'package:car_customer_app/models/user/image_response.dart';
|
||||||
|
import 'package:car_customer_app/models/user/login_password.dart';
|
||||||
|
import 'package:car_customer_app/models/user/refresh_token.dart';
|
||||||
|
import 'package:car_customer_app/models/user/register_user.dart';
|
||||||
|
import 'package:car_customer_app/models/user/role.dart';
|
||||||
|
import 'package:car_customer_app/models/user/user.dart';
|
||||||
|
import 'package:car_customer_app/models/user/verify_email.dart';
|
||||||
|
import 'package:car_customer_app/utils/shared_prefrence.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
abstract class UserRepo {
|
||||||
|
Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1});
|
||||||
|
|
||||||
|
Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken);
|
||||||
|
|
||||||
|
Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password);
|
||||||
|
|
||||||
|
Future<Response> loginV1(String phoneNo, String password);
|
||||||
|
|
||||||
|
Future<LoginPasswordRespModel> loginV2OTP(String userToken, String loginType);
|
||||||
|
|
||||||
|
Future<Response> loginV2OTPVerify(String userToken, String otp);
|
||||||
|
|
||||||
|
Future<RefreshToken> refreshTokenAPI(String token, String refreshToken);
|
||||||
|
|
||||||
|
Future<Country> getAllCountries();
|
||||||
|
|
||||||
|
Future<Cities> getAllCites(String countryId);
|
||||||
|
|
||||||
|
Future<Role> getRoles();
|
||||||
|
|
||||||
|
Future<Response> forgetPasswordOTPRequest(String userName, int otpType);
|
||||||
|
|
||||||
|
Future<PasswordOTPCompareResModel> forgetPasswordOTPCompare(String userToken, String userOTP);
|
||||||
|
|
||||||
|
Future<ConfirmPasswordRespModel> forgetPassword(String userToken, String newPassword);
|
||||||
|
|
||||||
|
Future<MResponse> changePassword(String currentPassword, String newPassword);
|
||||||
|
|
||||||
|
Future<ChangeMobileRespModel> changeMobileNoOTPRequest(countryID, String mobileNo, String password);
|
||||||
|
|
||||||
|
Future<ConfirmMobileRespModel> changeMobileNo(String userToken, String userOTP);
|
||||||
|
|
||||||
|
Future<ChanEmailRespModel> changeEmailOTPRequest(String email, String password);
|
||||||
|
|
||||||
|
Future<ConfirmEmailRespModel> changeEmail(String userToken, String userOTP);
|
||||||
|
|
||||||
|
Future<VerifyEmailRespModel> emailVerify(String email, String userID);
|
||||||
|
|
||||||
|
Future<MResponse> emailVerifyOTPVerify(String userToken, String userOTP);
|
||||||
|
|
||||||
|
Future<ImageResponse> updateUserImage(String image);
|
||||||
|
|
||||||
|
Future<ImageResponse> getUserImage(String image);
|
||||||
|
|
||||||
|
Future<String> updateUserToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserRepoImp implements UserRepo {
|
||||||
|
@override
|
||||||
|
Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}) async {
|
||||||
|
var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId};
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken) async {
|
||||||
|
var postParams = {
|
||||||
|
"userMobileNo": phoneNo,
|
||||||
|
"userOTP": otp,
|
||||||
|
"userToken": userToken,
|
||||||
|
};
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
|
||||||
|
Map<String, Object> postParams;
|
||||||
|
if (email.isEmpty) {
|
||||||
|
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password};
|
||||||
|
} else {
|
||||||
|
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password};
|
||||||
|
}
|
||||||
|
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Response> loginV1(String phoneNo, String password) async {
|
||||||
|
var postParams = {
|
||||||
|
"mobileorEmail": phoneNo,
|
||||||
|
"password": password,
|
||||||
|
};
|
||||||
|
return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V1, postParams);
|
||||||
|
//return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtp.fromJson(json), ApiConsts.Login_V1, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<LoginPasswordRespModel> loginV2OTP(String userToken, String loginType) async {
|
||||||
|
var postParams = {
|
||||||
|
"userToken": userToken,
|
||||||
|
"loginType": loginType,
|
||||||
|
};
|
||||||
|
|
||||||
|
Response response = await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTP, postParams);
|
||||||
|
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Response> loginV2OTPVerify(String userToken, String otp) async {
|
||||||
|
var postParams = {"userToken": userToken, "userOTP": otp};
|
||||||
|
return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTPVerify, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RefreshToken> refreshTokenAPI(String token, String refreshToken) async {
|
||||||
|
var postParams = {"token": token, "refreshToken": refreshToken};
|
||||||
|
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => RefreshToken.fromJson(json), ApiConsts.RefreshToken, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Country> getAllCountries() async {
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Cities> getAllCites(String countryId) async {
|
||||||
|
var postParams = {
|
||||||
|
"CountryID": countryId,
|
||||||
|
};
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Role> getRoles() async {
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Response> forgetPasswordOTPRequest(String userName, int otpType) async {
|
||||||
|
var postParams = {
|
||||||
|
"userName": userName,
|
||||||
|
"otpType": 1,
|
||||||
|
};
|
||||||
|
return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||||
|
//return await injector.get<ApiClient>().postJsonForObject((json) => PasswordOTPRequest.fromJson(json), ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PasswordOTPCompareResModel> forgetPasswordOTPCompare(String userToken, String userOTP) async {
|
||||||
|
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
|
Response response = await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPasswordOTPCompare, postParams);
|
||||||
|
|
||||||
|
PasswordOTPCompareResModel otpCompare = PasswordOTPCompareResModel.fromJson(jsonDecode(response.body));
|
||||||
|
return otpCompare;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ConfirmPasswordRespModel> forgetPassword(String userToken, String newPassword) async {
|
||||||
|
var postParams = {
|
||||||
|
"userToken": userToken,
|
||||||
|
"newPassword": newPassword,
|
||||||
|
};
|
||||||
|
|
||||||
|
Response response = await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPassword, postParams);
|
||||||
|
ConfirmPasswordRespModel data = ConfirmPasswordRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
|
||||||
|
return data ;
|
||||||
|
//return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> changePassword(String currentPassword, String newPassword) async {
|
||||||
|
var postParams = {
|
||||||
|
"currentPassword": currentPassword,
|
||||||
|
"newPassword": newPassword,
|
||||||
|
};
|
||||||
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
|
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ChangeMobileRespModel> changeMobileNoOTPRequest(countryID, String mobileNo, String password) async {
|
||||||
|
var postParams = {"countryID": 1, "mobileNo": mobileNo, "password": password};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ChangeMobileRespModel.fromJson(json), ApiConsts.ChangeMobileNoOTPRequest, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ConfirmMobileRespModel> changeMobileNo(String userToken, String userOTP) async {
|
||||||
|
var postParams = {
|
||||||
|
"userToken": userToken,
|
||||||
|
"userOTP": userOTP,
|
||||||
|
};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmMobileRespModel.fromJson(json), ApiConsts.ChangeMobileNo, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ChanEmailRespModel> changeEmailOTPRequest(String email, String password) async {
|
||||||
|
var postParams = {"email": email, "password": password};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ChanEmailRespModel.fromJson(json), ApiConsts.ChangeEmailOTPRequest, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ConfirmEmailRespModel> changeEmail(String userToken, String userOTP) async {
|
||||||
|
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmEmailRespModel.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<VerifyEmailRespModel> emailVerify(String email, String userID) async {
|
||||||
|
var postParams = {
|
||||||
|
// "email": email,
|
||||||
|
// "userID": userID,
|
||||||
|
"email": AppState().getUser.data!.userInfo!.email ?? "",
|
||||||
|
"userID": AppState().getUser.data!.userInfo!.userId ?? "",
|
||||||
|
};
|
||||||
|
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => VerifyEmailRespModel.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> emailVerifyOTPVerify(String userToken, String userOTP) async {
|
||||||
|
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||||
|
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ImageResponse> updateUserImage(String image) async {
|
||||||
|
var postParams = {"userID": AppState().getUser.data!.userInfo!.userId, "userImage": image};
|
||||||
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
|
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ImageResponse> getUserImage(String image) async {
|
||||||
|
var postParams = {};
|
||||||
|
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||||
|
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
debugPrint("token " + t);
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> updateUserToken() async {
|
||||||
|
String token = await SharedPrefManager.getUserToken();
|
||||||
|
String refreshToken = await SharedPrefManager.getRefreshToken();
|
||||||
|
RefreshToken refresh = await refreshTokenAPI(token, refreshToken);
|
||||||
|
SharedPrefManager.setUserToken(refresh.data!.accessToken ?? "");
|
||||||
|
SharedPrefManager.setRefreshToken(refresh.data!.refreshToken ?? "");
|
||||||
|
String mdata = await SharedPrefManager.getData();
|
||||||
|
UserInfo info = UserInfo.fromJson(jsonDecode(mdata));
|
||||||
|
User user = User();
|
||||||
|
user.data = UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info);
|
||||||
|
AppState().setUser = user;
|
||||||
|
return refresh.data!.accessToken ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
|
abstract class CommonServices {
|
||||||
|
Future<File?> pickImageFromPhone(int sourceFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CommonServicesImp implements CommonServices {
|
||||||
|
@override
|
||||||
|
Future<File?> pickImageFromPhone(int sourceFlag) async {
|
||||||
|
final picker = ImagePicker();
|
||||||
|
final pickedImage = await picker.pickImage(
|
||||||
|
source: sourceFlag == 0 ? ImageSource.camera : ImageSource.gallery,
|
||||||
|
);
|
||||||
|
final pickedImageFile = File(pickedImage!.path);
|
||||||
|
return pickedImageFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,73 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MyColors {
|
||||||
|
static const Color darkPrimaryColor = Color(0xffF47F20);
|
||||||
|
static const Color primaryColor = Color(0xffF69521);
|
||||||
|
static const Color accentColor = Colors.blue;
|
||||||
|
static const Color lightTextColor = Color(0xff969696);
|
||||||
|
static const Color textColor = Color(0xff777777);
|
||||||
|
static const Color textFieldColor = Color(0xffF3F5F7);
|
||||||
|
static const Color darkIconColor = Color(0xff28323A);
|
||||||
|
static const Color darkTextColor = Color(0xff2B353E);
|
||||||
|
static const Color normalTextColor = Color(0xff5A5A5A);
|
||||||
|
static const Color gradiantStartColor = Color(0xff33c0a5);
|
||||||
|
static const Color gradiantEndColor = Color(0xff259db7);
|
||||||
|
static const Color textMixColor = Color(0xff2BB8A6);
|
||||||
|
static const Color backgroundColor = Color(0xffF8F8F8);
|
||||||
|
static const Color grey57Color = Color(0xff575757);
|
||||||
|
static const Color grey77Color = Color(0xff777777);
|
||||||
|
static const Color grey70Color = Color(0xff707070);
|
||||||
|
static const Color greyACColor = Color(0xffACACAC);
|
||||||
|
static const Color grey98Color = Color(0xff989898);
|
||||||
|
static const Color lightGreyEFColor = Color(0xffEFEFEF);
|
||||||
|
static const Color lightGreyEDColor = Color(0xffEDEDED);
|
||||||
|
static const Color lightGreyEAColor = Color(0xffEAEAEA);
|
||||||
|
static const Color darkWhiteColor = Color(0xffE0E0E0);
|
||||||
|
static const Color redColor = Color(0xffD02127);
|
||||||
|
static const Color yellowColor = Color(0xffF4E31C);
|
||||||
|
static const Color backgroundBlackColor = Color(0xff202529);
|
||||||
|
static const Color black = Color(0xff000000);
|
||||||
|
static const Color white = Color(0xffffffff);
|
||||||
|
static const Color green = Color(0xffffffff);
|
||||||
|
static const Color borderColor = Color(0xffE8E8E8);
|
||||||
|
|
||||||
|
static Decoration gradient = BoxDecoration(
|
||||||
|
gradient: const LinearGradient(colors: [
|
||||||
|
darkPrimaryColor,
|
||||||
|
primaryColor,
|
||||||
|
]),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: primaryColor.withOpacity(0.5),
|
||||||
|
blurRadius: 20.0,
|
||||||
|
spreadRadius: 1.0,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
static Decoration gradientButton = BoxDecoration(
|
||||||
|
gradient: const LinearGradient(colors: [
|
||||||
|
darkPrimaryColor,
|
||||||
|
primaryColor,
|
||||||
|
]),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: primaryColor.withOpacity(0.2),
|
||||||
|
blurRadius: 4.0,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const Color primaryColor = Colors.white;
|
const Color primaryColor = Colors.white;
|
||||||
const Color accentColor = Colors.blue;
|
const Color accentColor = Colors.blue;
|
||||||
const Color appBackgroundColor = Colors.white;
|
const Color appBackgroundColor = Colors.white;
|
||||||
Color? accentColorDark = Colors.green[800];
|
Color? accentColorDark = Colors.green[800];
|
||||||
const Color borderColor = Colors.blueGrey;
|
const Color borderColor = Colors.blueGrey;
|
||||||
Color? borderLightColor = Colors.blueGrey[50];
|
Color? borderLightColor = Colors.blueGrey[50];
|
||||||
Color backgroudColor =
|
|
||||||
Colors.blueGrey[50]!.withOpacity(0.5) ;
|
|
||||||
const Color iconColor = Colors.blueGrey;
|
const Color iconColor = Colors.blueGrey;
|
||||||
Color? headingColor = Colors.blueGrey[800];
|
Color? headingColor = Colors.blueGrey[800];
|
||||||
Color? txtColor = Colors.blueGrey[500];
|
Color? txtColor = Colors.blueGrey[500];
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
// enum APPSTATUS {
|
||||||
|
// loading,
|
||||||
|
// unAuthenticated,
|
||||||
|
// authenticated,
|
||||||
|
// unverified,
|
||||||
|
// }
|
||||||
|
|
||||||
|
enum AuthMethodTypes {
|
||||||
|
sms,
|
||||||
|
whatsApp,
|
||||||
|
fingerPrint,
|
||||||
|
faceID,
|
||||||
|
moreOptions,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ViewState {
|
||||||
|
hide,
|
||||||
|
idle,
|
||||||
|
busy,
|
||||||
|
error,
|
||||||
|
busyLocal,
|
||||||
|
errorLocal,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum LoginType {
|
||||||
|
FROM_LOGIN,
|
||||||
|
SILENT_LOGIN,
|
||||||
|
SILENT_WITH_OTP,
|
||||||
|
}
|
||||||
@ -1,320 +1,306 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:car_customer_app/config/constants.dart';
|
|
||||||
import 'package:car_customer_app/theme/colors.dart';
|
import 'package:car_customer_app/theme/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
|
|
||||||
import 'package:sizer/sizer.dart';
|
import 'package:car_customer_app/exceptions/api_exception.dart';
|
||||||
|
import 'package:car_customer_app/widgets/loading_dialog.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
Color getColorFromHex(String hexColor) {
|
class Utils {
|
||||||
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
static bool _isLoadingVisible = false;
|
||||||
|
|
||||||
if (hexColor.length == 6) {
|
static bool get isLoading => _isLoadingVisible;
|
||||||
hexColor = 'FF' + hexColor;
|
|
||||||
|
static void showToast(String message) {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 2, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Color(int.parse(hexColor, radix: 16));
|
static dynamic getNotNullValue(List<dynamic> list, int index) {
|
||||||
}
|
try {
|
||||||
|
return list[index];
|
||||||
|
} catch (ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget spacerVertical(double v) {
|
static int stringToHex(String colorCode) {
|
||||||
return Container(
|
try {
|
||||||
height: v,
|
return int.parse(colorCode.replaceAll("#", "0xff"));
|
||||||
width: double.infinity,
|
} catch (ex) {
|
||||||
);
|
return (0xff000000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String convertFileToBase64(File file) {
|
static void showLoading(BuildContext context) {
|
||||||
List<int> imageBytes = file.readAsBytesSync();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
return base64Encode(imageBytes);
|
_isLoadingVisible = true;
|
||||||
}
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierColor: Colors.black.withOpacity(0.5),
|
||||||
|
builder: (BuildContext context) => LoadingDialog(),
|
||||||
|
).then((value) {
|
||||||
|
_isLoadingVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// String checkFileExt(String path) {
|
static void hideLoading(BuildContext context) {
|
||||||
// String ex = p.extension(path);
|
if (_isLoadingVisible) {
|
||||||
// var parts = ex.split('.');
|
_isLoadingVisible = false;
|
||||||
// return parts[1] ?? "png"; // '.dart'
|
Navigator.of(context).pop();
|
||||||
// }
|
}
|
||||||
|
_isLoadingVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
Future delay(int millis) async {
|
static void handleException(dynamic exception, Function(String)? onErrorMessage) {
|
||||||
return await Future.delayed(Duration(milliseconds: millis));
|
String errorMessage;
|
||||||
}
|
if (exception is APIException) {
|
||||||
|
if (exception.message == APIException.UNAUTHORIZED) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
errorMessage = exception.error?.errorMessage ?? exception.message;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorMessage = APIException.UNKNOWN;
|
||||||
|
}
|
||||||
|
if (onErrorMessage != null) {
|
||||||
|
onErrorMessage(errorMessage);
|
||||||
|
} else {
|
||||||
|
showToast(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inkWellCorner({double? r}) {
|
static Color getColorFromHex(String hexColor) {
|
||||||
return RoundedRectangleBorder(
|
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
||||||
borderRadius: BorderRadius.circular(r ?? 4),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget spacerHorizontal(double v) {
|
if (hexColor.length == 6) {
|
||||||
return Container(
|
hexColor = 'FF' + hexColor;
|
||||||
height: v,
|
}
|
||||||
width: v,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Widget mHeight(double f) {
|
return Color(int.parse(hexColor, radix: 16));
|
||||||
// return Container(
|
}
|
||||||
// width: f,
|
|
||||||
// height: f,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
Widget mDivider(Color color, {double? h}) {
|
|
||||||
return Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: h ?? 1,
|
|
||||||
color: color,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget mDivider3({double? h}) {
|
static Widget spacerVertical(double v) {
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: double.infinity,
|
height: v,
|
||||||
height: h ?? 1,
|
width: double.infinity,
|
||||||
color: borderLightColor!.withOpacity(0.7),
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Widget mDivider2(Color color, double w) {
|
static String convertFileToBase64(File file) {
|
||||||
return Container(
|
List<int> imageBytes = file.readAsBytesSync();
|
||||||
width: w,
|
return base64Encode(imageBytes);
|
||||||
height: 1,
|
}
|
||||||
color: color,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputDecoration txtField(String label) {
|
static Future delay(int millis) async {
|
||||||
return new InputDecoration(
|
return await Future.delayed(Duration(milliseconds: millis));
|
||||||
border: InputBorder.none,
|
}
|
||||||
focusedBorder: InputBorder.none,
|
|
||||||
enabledBorder: InputBorder.none,
|
static inkWellCorner({double? r}) {
|
||||||
errorBorder: InputBorder.none,
|
return RoundedRectangleBorder(
|
||||||
hintText: label,
|
borderRadius: BorderRadius.circular(r ?? 4),
|
||||||
hintStyle: TextStyle(color: Colors.grey),
|
);
|
||||||
disabledBorder: InputBorder.none,
|
}
|
||||||
isDense: false,
|
|
||||||
contentPadding: EdgeInsets.only(left: 15, right: 15),
|
static Widget spacerHorizontal(double v) {
|
||||||
);
|
return SizedBox(
|
||||||
}
|
height: v,
|
||||||
|
width: v,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Widget mWidth(double f) {
|
static Widget mDivider(Color color, {double? h}) {
|
||||||
// return Container(
|
return Container(
|
||||||
// width: f,
|
|
||||||
// height: f,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
Widget mFlex(int f) {
|
|
||||||
return Flexible(
|
|
||||||
flex: f,
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: h ?? 1,
|
||||||
),
|
color: color,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget mExp(int f) {
|
static Widget mDivider3({double? h}) {
|
||||||
return Expanded(
|
return Container(
|
||||||
flex: f,
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
),
|
height: h ?? 1,
|
||||||
);
|
color: borderLightColor!.withOpacity(0.7),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
spacer() {
|
static Widget mDivider2(Color color, double w) {
|
||||||
return SizedBox(
|
return Container(
|
||||||
height: 8,
|
width: w,
|
||||||
);
|
height: 1,
|
||||||
}
|
color: color,
|
||||||
//
|
);
|
||||||
// Widget floatButton(String icon, {Color? color, required Function onClick, String? title}) {
|
}
|
||||||
// return Padding(
|
|
||||||
// padding: const EdgeInsets.only(top: 12, bottom: 12),
|
|
||||||
// child: Column(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// children: [
|
|
||||||
// FloatingActionButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// onClick();
|
|
||||||
// },
|
|
||||||
// heroTag: icon,
|
|
||||||
// backgroundColor: accentColor,
|
|
||||||
// elevation: 4,
|
|
||||||
// child: Container(
|
|
||||||
// child: SvgPicture.asset(
|
|
||||||
// categorySvgIcons + icon,
|
|
||||||
// color: color,
|
|
||||||
// ),
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
// decoration: containerRadius(Colors.white, 200),
|
|
||||||
// clipBehavior: Clip.antiAlias,
|
|
||||||
// padding: EdgeInsets.all(15),
|
|
||||||
// margin: EdgeInsets.all(1),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// if (title != null) mHeight(2.w),
|
|
||||||
// if (title != null)
|
|
||||||
// Txt(
|
|
||||||
// title,
|
|
||||||
// fontSize: 12.sp,
|
|
||||||
// bold: true,
|
|
||||||
// color: headingColor,
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
navigateTo(context, page) {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => page));
|
|
||||||
}
|
|
||||||
|
|
||||||
circularImage(String im, double width, double height) {
|
static InputDecoration txtField(String label) {
|
||||||
return new Container(width: 190.0, height: 190.0, decoration: new BoxDecoration(shape: BoxShape.circle, image: new DecorationImage(fit: BoxFit.fill, image: new AssetImage(im))));
|
return InputDecoration(
|
||||||
}
|
border: InputBorder.none,
|
||||||
|
focusedBorder: InputBorder.none,
|
||||||
|
enabledBorder: InputBorder.none,
|
||||||
|
errorBorder: InputBorder.none,
|
||||||
|
hintText: label,
|
||||||
|
hintStyle: const TextStyle(color: Colors.grey),
|
||||||
|
disabledBorder: InputBorder.none,
|
||||||
|
isDense: false,
|
||||||
|
contentPadding: const EdgeInsets.only(left: 15, right: 15),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
circularImage2(String im, double width, double height) {
|
static Widget mFlex(int f) {
|
||||||
return new Container(width: width, height: height, decoration: new BoxDecoration(shape: BoxShape.circle, image: new DecorationImage(fit: BoxFit.fill, image: new AssetImage(im))));
|
return Flexible(
|
||||||
}
|
flex: f,
|
||||||
|
child: const SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
cardRadius(double radius) {
|
static Widget mExp(int f) {
|
||||||
return RoundedRectangleBorder(
|
return Expanded(
|
||||||
side: BorderSide(color: Colors.transparent, width: 1),
|
flex: f,
|
||||||
borderRadius: BorderRadius.circular(radius),
|
child: Container(
|
||||||
);
|
width: double.infinity,
|
||||||
}
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
cardRadiusWithoutBorder(double radius) {
|
static spacer() {
|
||||||
return RoundedRectangleBorder(
|
return const SizedBox(
|
||||||
side: BorderSide(color: Colors.transparent, width: 1),
|
height: 8,
|
||||||
borderRadius: BorderRadius.circular(radius),
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Image imageFromBase64String(String base64String) {
|
static cardRadius(double radius) {
|
||||||
return Image.memory(base64Decode(base64String));
|
return RoundedRectangleBorder(
|
||||||
}
|
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||||
|
borderRadius: BorderRadius.circular(radius),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Uint8List dataFromBase64String(String base64String) {
|
static cardRadiusWithoutBorder(double radius) {
|
||||||
return base64Decode(base64String);
|
return RoundedRectangleBorder(
|
||||||
}
|
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||||
|
borderRadius: BorderRadius.circular(radius),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String base64String(Uint8List data) {
|
static Image imageFromBase64String(String base64String) {
|
||||||
return base64Encode(data);
|
return Image.memory(base64Decode(base64String));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Uint8List dataFromBase64String(String base64String) {
|
||||||
|
return base64Decode(base64String);
|
||||||
|
}
|
||||||
|
|
||||||
Widget overLayWidget({double? width, double? height, List<Color>? color}) {
|
static String base64String(Uint8List data) {
|
||||||
return Container(
|
return base64Encode(data);
|
||||||
width: width ?? double.infinity,
|
}
|
||||||
height: height ?? 60,
|
|
||||||
decoration: BoxDecoration(
|
static Widget overLayWidget({double? width, double? height, List<Color>? color}) {
|
||||||
gradient: LinearGradient(
|
return Container(
|
||||||
colors: color != null
|
width: width ?? double.infinity,
|
||||||
? color
|
height: height ?? 60,
|
||||||
: [
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: color ??
|
||||||
|
[
|
||||||
Colors.black.withOpacity(0.2),
|
Colors.black.withOpacity(0.2),
|
||||||
Colors.black.withOpacity(0.1),
|
Colors.black.withOpacity(0.1),
|
||||||
Colors.black.withOpacity(0.004),
|
Colors.black.withOpacity(0.004),
|
||||||
],
|
],
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
tileMode: TileMode.clamp,
|
tileMode: TileMode.clamp,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Decoration containerRadius(Color color, double r) {
|
static Decoration containerRadius(Color color, double r) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: color,
|
color: color,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoration containerRadiusTop({Color? color, double? r}) {
|
static Decoration containerRadiusTop({Color? color, double? r}) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: color ?? Colors.white,
|
color: color ?? Colors.white,
|
||||||
borderRadius: BorderRadius.only(topRight: Radius.circular(r ?? 12), topLeft: Radius.circular(r ?? 12)),
|
borderRadius: BorderRadius.only(topRight: Radius.circular(r ?? 12), topLeft: Radius.circular(r ?? 12)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoration containerRadiusBorder(Color color, double r) {
|
static Decoration containerRadiusBorder(Color color, double r) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
border: Border.all(color: color, width: 1),
|
border: Border.all(color: color, width: 1),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoration containerRadiusBottom(Color color, double r) {
|
static Decoration containerRadiusBottom(Color color, double r) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: color,
|
color: color,
|
||||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(r), bottomRight: Radius.circular(r)),
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(r), bottomRight: Radius.circular(r)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder cardRadiusTop(double radius) {
|
static ShapeBorder cardRadiusTop(double radius) {
|
||||||
return RoundedRectangleBorder(
|
return RoundedRectangleBorder(
|
||||||
side: BorderSide(color: Colors.transparent, width: 0),
|
side: const BorderSide(color: Colors.transparent, width: 0),
|
||||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) {
|
static Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: background,
|
color: background,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
width: w, //
|
width: w, //
|
||||||
color: color // <--- border width here
|
color: color // <--- border width here
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(radius),
|
borderRadius: BorderRadius.circular(radius),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder cardRadiusTop2(double radius) {
|
static ShapeBorder cardRadiusTop2(double radius) {
|
||||||
return RoundedRectangleBorder(
|
return RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder cardRadiusBottom(double radius) {
|
static ShapeBorder cardRadiusBottom(double radius) {
|
||||||
return RoundedRectangleBorder(
|
return RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Decoration containerColorRadiusBorder(Color background, double radius, Color color) {
|
static Decoration containerColorRadiusBorder(Color background, double radius, Color color) {
|
||||||
return BoxDecoration(
|
return BoxDecoration(
|
||||||
color: background,
|
color: background,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
width: 1, //
|
width: 1, //
|
||||||
color: color // <--- border width here
|
color: color // <--- border width here
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(radius),
|
borderRadius: BorderRadius.circular(radius),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Decoration appGradient = BoxDecoration(
|
static bool passwordValidateStructure(String value) {
|
||||||
// gradient: LinearGradient(
|
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
||||||
// colors: [
|
RegExp regExp = RegExp(pattern);
|
||||||
// Colors.green[200],
|
return regExp.hasMatch(value);
|
||||||
// Colors.green,
|
}
|
||||||
// ],
|
|
||||||
// begin: Alignment.topCenter,
|
static bool isEmailValid(String email) {
|
||||||
// end: Alignment.bottomCenter,
|
String p = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
||||||
// ),
|
RegExp regExp = RegExp(p);
|
||||||
//);
|
return regExp.hasMatch(email);
|
||||||
// launchURL(String url) async {
|
}
|
||||||
// if (await canLaunch(url)) {
|
}
|
||||||
// await launch(url);
|
|
||||||
// } else {
|
|
||||||
// throw 'Could not launch $url';
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
import 'package:car_customer_app/utils/enums.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
class BaseVM extends ChangeNotifier {
|
||||||
|
ViewState _state = ViewState.idle;
|
||||||
|
bool isInternetConnection = true;
|
||||||
|
|
||||||
|
ViewState get state => _state;
|
||||||
|
|
||||||
|
String error = "";
|
||||||
|
|
||||||
|
void setOnlyState(ViewState viewState) {
|
||||||
|
_state = viewState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setState(ViewState viewState) {
|
||||||
|
_state = viewState;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/models/user/image_response.dart';
|
||||||
|
import 'package:car_customer_app/repositories/user_repo.dart';
|
||||||
|
import 'package:car_customer_app/services/services.dart';
|
||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/view_models/base_view_model.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
class DashboardVM extends BaseVM {
|
||||||
|
final CommonServices commonServices;
|
||||||
|
final UserRepo userRepo;
|
||||||
|
|
||||||
|
DashboardVM({required this.commonServices, required this.userRepo});
|
||||||
|
|
||||||
|
String pickedImage = "";
|
||||||
|
|
||||||
|
void pickImageFromPhone(BuildContext context, int sourceFlag) async {
|
||||||
|
final File? pickedImageFile = await commonServices.pickImageFromPhone(sourceFlag);
|
||||||
|
if (pickedImageFile == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int sizeInBytes = pickedImageFile.lengthSync();
|
||||||
|
if (sizeInBytes > 1000) {
|
||||||
|
Utils.showToast(LocaleKeys.fileLarger.tr());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
String image64 = Utils.convertFileToBase64(pickedImageFile);
|
||||||
|
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ImageResponse response = await userRepo.updateUserImage(image64);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
if (response.messageStatus == 1) {
|
||||||
|
Utils.showToast(LocaleKeys.imageUploaded.tr());
|
||||||
|
AppState().getUser.data!.userInfo!.userImageUrl = response.data;
|
||||||
|
} else {
|
||||||
|
Utils.showToast(response.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ImageResponse> updateUserImage(String image) async {
|
||||||
|
return await userRepo.updateUserImage(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,477 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/classes/consts.dart';
|
||||||
|
import 'package:car_customer_app/config/routes.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/models/m_response.dart';
|
||||||
|
import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_email.dart';
|
||||||
|
import 'package:car_customer_app/models/user/change_mobile.dart';
|
||||||
|
import 'package:car_customer_app/models/user/confirm_email.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/models/user/country.dart';
|
||||||
|
import 'package:car_customer_app/models/user/forget_password_otp_compare.dart';
|
||||||
|
import 'package:car_customer_app/models/user/forget_password_otp_request.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/models/user/verify_email.dart';
|
||||||
|
import 'package:car_customer_app/repositories/user_repo.dart';
|
||||||
|
import 'package:car_customer_app/utils/navigator.dart';
|
||||||
|
import 'package:car_customer_app/utils/shared_prefrence.dart';
|
||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/view_models/base_view_model.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/tab/login_email_tab.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
class UserVM extends BaseVM {
|
||||||
|
final UserRepo userRepo;
|
||||||
|
|
||||||
|
UserVM({required this.userRepo});
|
||||||
|
|
||||||
|
bool completeProfilePageCheckbox = false;
|
||||||
|
|
||||||
|
void updateCompleteProfilePageCheckbox(bool newValue) {
|
||||||
|
completeProfilePageCheckbox = newValue;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
String displayStrengthText = '';
|
||||||
|
|
||||||
|
void updateStrengthText(String newValue) {
|
||||||
|
displayStrengthText = newValue;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
double strengthThreshold = 0.0;
|
||||||
|
|
||||||
|
void updateStrengthThreshold(double newValue) {
|
||||||
|
strengthThreshold = newValue;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeUserEmail(BuildContext context, String email, String password) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ChanEmailRespModel otpRequest = await userRepo.changeEmailOTPRequest(email, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ConfirmEmailRespModel otpCompare = await userRepo.changeEmail(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
showMDialog(
|
||||||
|
context,
|
||||||
|
child: MessageDialog(
|
||||||
|
title: LocaleKeys.emailChangedSuccessfully.tr(),
|
||||||
|
//"Email is Changed Successfully",
|
||||||
|
onClick: () {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeUserMobile(BuildContext context, int countryId, String mobileNo, String password) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ChangeMobileRespModel otpRequest = await userRepo.changeMobileNoOTPRequest(countryId, mobileNo, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ConfirmMobileRespModel otpCompare = await userRepo.changeMobileNo(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
showMDialog(
|
||||||
|
context,
|
||||||
|
child: MessageDialog(
|
||||||
|
title: LocaleKeys.phoneNumberVerified.tr(),
|
||||||
|
//"Phone Number Verified",
|
||||||
|
onClick: () {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeUserPassword(BuildContext context, String newPassword, String currentPassword) async {
|
||||||
|
if (Utils.passwordValidateStructure(newPassword)) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
MResponse res = await userRepo.changePassword(currentPassword, newPassword);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (res.messageStatus == 1) {
|
||||||
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
||||||
|
//("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(LocaleKeys.passwordShouldContains.tr());
|
||||||
|
//("Password Should contains Character, Number, Capital and small letters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performCompleteProfile(
|
||||||
|
BuildContext context, {
|
||||||
|
required String password,
|
||||||
|
required String confirmPassword,
|
||||||
|
required String firstName,
|
||||||
|
required String lastName,
|
||||||
|
required String email,
|
||||||
|
required String? userId,
|
||||||
|
}) async {
|
||||||
|
if (Utils.passwordValidateStructure(password)) {
|
||||||
|
if (password == confirmPassword) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
Utils.showToast(LocaleKeys.successfullyRegistered.tr());
|
||||||
|
pop(context);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
||||||
|
//("Please enter same password");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
||||||
|
//("Password Should contains Character, Number, Capital and small letters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dataValidation({
|
||||||
|
required String password,
|
||||||
|
required String? firstName,
|
||||||
|
required String? lastName,
|
||||||
|
required String? email,
|
||||||
|
}) {
|
||||||
|
bool isValid = true;
|
||||||
|
if (firstName!.isEmpty) {
|
||||||
|
Utils.showToast(LocaleKeys.firstNameMandatory.tr());
|
||||||
|
//("First name is mandatory");
|
||||||
|
isValid = false;
|
||||||
|
} else if (lastName!.isEmpty) {
|
||||||
|
Utils.showToast(LocaleKeys.surnameNameMandatory.tr());
|
||||||
|
//("Surname is mandatory");
|
||||||
|
isValid = false;
|
||||||
|
} else if (email!.isNotEmpty) {
|
||||||
|
if (!Utils.isEmailValid(email)) {
|
||||||
|
Utils.showToast(LocaleKeys.enterValidEmail.tr());
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
} else if (password.isEmpty) {
|
||||||
|
Utils.showToast(LocaleKeys.passwordNameMandatory.tr());
|
||||||
|
//("Password is mandatory");
|
||||||
|
isValid = false;
|
||||||
|
} else if (!completeProfilePageCheckbox) {
|
||||||
|
Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr());
|
||||||
|
//("Please accept terms");
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkPassword(String password) {
|
||||||
|
if (password.length <= 6) {
|
||||||
|
updateStrengthThreshold(1 / 4);
|
||||||
|
updateStrengthText('Your password is too short');
|
||||||
|
} else if (password.length < 8) {
|
||||||
|
updateStrengthThreshold(2 / 4);
|
||||||
|
updateStrengthText('Your password is acceptable but not strong');
|
||||||
|
} else {
|
||||||
|
if (!letterReg.hasMatch(password) || !numReg.hasMatch(password)) {
|
||||||
|
updateStrengthThreshold(3 / 4);
|
||||||
|
updateStrengthText('Your password is strong');
|
||||||
|
} else {
|
||||||
|
updateStrengthThreshold(1);
|
||||||
|
updateStrengthText('Your password is very strong');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> confirmPasswordOTP(BuildContext context, {required String userToken, required String newPassword}) async {
|
||||||
|
if (Utils.passwordValidateStructure(newPassword)) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ConfirmPasswordRespModel data = await userRepo.forgetPassword(userToken, newPassword);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (data.messageStatus == 1) {
|
||||||
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
||||||
|
navigateWithName(context, AppRoutes.loginWithPassword);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(data.message ?? "");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> verifyEmail(BuildContext context, {required String email, required String userID}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
VerifyEmailRespModel otpRequest = await userRepo.emailVerify(email, userID);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
MResponse otpCompare = await userRepo.emailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
AppState().getUser.data!.userInfo!.isEmailVerified = true;
|
||||||
|
Utils.showToast(LocaleKeys.emailVerified.tr());
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> forgetPasswordOTPMethod(BuildContext context, {required String userToken}) async {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
PasswordOTPCompareResModel otpCompare = await userRepo.forgetPasswordOTPCompare(userToken, code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
var userToken = otpCompare.data!.userToken;
|
||||||
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> forgetPasswordPhoneOTP(BuildContext context, {required String countryCode, required String userName, required int otpType}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response = await userRepo.forgetPasswordOTPRequest(countryCode + userName, otpType);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
PasswordOTPRequestRespModel otpRequest = PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
var userToken = otpRequest.data!.userToken;
|
||||||
|
navigateReplaceWithName(context, AppRoutes.forgetPasswordMethodPage, arguments: userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> forgetPasswordEmailOTP(BuildContext context, {required String countryCode, required String userName, required int otpType}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response = await userRepo.forgetPasswordOTPRequest(userName, otpType);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
PasswordOTPRequestRespModel otpRequest = PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
if (otpRequest.messageStatus == 1) {
|
||||||
|
Utils.showToast(LocaleKeys.codeSentToEmail.tr());
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
PasswordOTPCompareResModel otpCompare = await userRepo.forgetPasswordOTPCompare(otpRequest.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (otpCompare.messageStatus == 1) {
|
||||||
|
var userToken = otpCompare.data!.userToken;
|
||||||
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpCompare.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(otpRequest.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performBasicOtpLoginSelectionPage(BuildContext context, {required String userToken}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
LoginPasswordRespModel user = await userRepo.loginV2OTP(userToken, "1");
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response2 = await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
||||||
|
if (verifiedUser.messageStatus == 1) {
|
||||||
|
User user = User.fromJson(jsonDecode(response2.body));
|
||||||
|
if (user.data!.userInfo!.roleId == 4) {
|
||||||
|
AppState().setUser = user;
|
||||||
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
||||||
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
||||||
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
||||||
|
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
||||||
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(LocaleKeys.onlyCustomerApp.tr());
|
||||||
|
//("Sorry, Only Customer's can log in this app");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showToast(verifiedUser.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> performApiCallLoginVerificationPage(BuildContext context) async {
|
||||||
|
String userToken = "";
|
||||||
|
String userName = await SharedPrefManager.getPhoneOrEmail();
|
||||||
|
String password = await SharedPrefManager.getUserPassword();
|
||||||
|
if (userName.isNotEmpty && userName.isNotEmpty) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response = await userRepo.loginV1(userName, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
userToken = user.data!.userToken ?? "";
|
||||||
|
// navigateWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performBasicOtpLoginVerificationPage(BuildContext context, {required String userToken}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
LoginPasswordRespModel user = await userRepo.loginV2OTP(userToken, "1");
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response2 = await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", code);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
||||||
|
if (verifiedUser.messageStatus == 1) {
|
||||||
|
User user = User.fromJson(jsonDecode(response2.body));
|
||||||
|
AppState().setUser = user;
|
||||||
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(verifiedUser.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performBasicOtpLoginVerifyAccountPage(BuildContext context, {required String phoneNum, required int otpType}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
BasicOtpRespModel basicOtp = await userRepo.basicOtp(phoneNum, otpType: otpType);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (basicOtp.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
RegisterUserRespModel user = await userRepo.basicVerify(phoneNum, code, basicOtp.data!.userToken ?? "");
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
showMDialog(
|
||||||
|
context,
|
||||||
|
child: MessageDialog(
|
||||||
|
title: LocaleKeys.phoneNumberVerified.tr(),
|
||||||
|
//"Phone Number Verified",
|
||||||
|
onClick: () {
|
||||||
|
pop(context);
|
||||||
|
navigateWithName(context, AppRoutes.profile1, arguments: user);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(basicOtp.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performBasicOtpLoginWithPasswordPage(BuildContext context, {required ClassType type, required String countryCode, required String phoneNum, required String password}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Response response = await userRepo.loginV1(type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum, password);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
SharedPrefManager.setPhoneOrEmail(type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum);
|
||||||
|
SharedPrefManager.setUserPassword(password);
|
||||||
|
navigateReplaceWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Country> getAllCountries() async {
|
||||||
|
return await userRepo.getAllCountries();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> performBasicOtpRegisterPage(BuildContext context, {required String countryCode, required String phoneNum, required int role}) async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (basicOtp.messageStatus == 1) {
|
||||||
|
showMDialog(context, child: OtpDialog(
|
||||||
|
onClick: (String code) async {
|
||||||
|
pop(context);
|
||||||
|
Utils.showLoading(context);
|
||||||
|
RegisterUserRespModel user = await userRepo.basicVerify(countryCode + phoneNum, code, basicOtp.data!.userToken ?? "");
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
if (user.messageStatus == 1) {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user);
|
||||||
|
} else {
|
||||||
|
Utils.showToast(user.message ?? "");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Utils.showToast(basicOtp.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,219 @@
|
|||||||
|
import 'package:car_customer_app/classes/app_state.dart';
|
||||||
|
import 'package:car_customer_app/classes/consts.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/extensions/widget_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/models/user/image_response.dart';
|
||||||
|
import 'package:car_customer_app/theme/colors.dart';
|
||||||
|
import 'package:car_customer_app/utils/navigator.dart';
|
||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/view_models/dashboard_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DashboardPage extends StatefulWidget {
|
||||||
|
const DashboardPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DashboardPage> createState() => _DashboardPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DashboardPageState extends State<DashboardPage> {
|
||||||
|
late DashboardVM dashboardVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
dashboardVM = Provider.of<DashboardVM>(context, listen: false);
|
||||||
|
fetchUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchUsername() async {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: "Logo/Brand", isRemoveBackButton: true),
|
||||||
|
drawer: showDrawer(context),
|
||||||
|
body: Center(
|
||||||
|
child: LocaleKeys.dashboard.tr().toText(
|
||||||
|
height: 23 / 24,
|
||||||
|
fontSize: 24,
|
||||||
|
letterSpacing: -1.44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget showDrawer(BuildContext context) {
|
||||||
|
return Drawer(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 200,
|
||||||
|
color: MyColors.darkPrimaryColor.withOpacity(0.01),
|
||||||
|
child: Image.network(
|
||||||
|
ApiConsts.baseUrlServices + AppState().getUser.data!.userInfo!.userImageUrl.toString(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
).onPress(() {
|
||||||
|
_openImagePicker();
|
||||||
|
// _handleURLButtonPress(context, ImageSourceType.camera);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.delete,
|
||||||
|
color: Colors.red,
|
||||||
|
).onPress(() async {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
ImageResponse response = await dashboardVM.updateUserImage("");
|
||||||
|
if (response.messageStatus == 1) {
|
||||||
|
Utils.showToast("Image is Deleted");
|
||||||
|
setState(() {
|
||||||
|
AppState().getUser.data!.userInfo!.userImageUrl = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: MyColors.darkPrimaryColor.withOpacity(0.1),
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"userName".toText(
|
||||||
|
isBold: true,
|
||||||
|
fontSize: 20,
|
||||||
|
letterSpacing: -1.44,
|
||||||
|
),
|
||||||
|
AppState().getUser.data!.userInfo!.roleName!.toText(fontSize: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.edit.tr(),
|
||||||
|
fontSize: 12,
|
||||||
|
maxHeight: 35,
|
||||||
|
maxWidth: 70,
|
||||||
|
onPressed: () {
|
||||||
|
navigateWithName(context, AppRoutes.editAccountPage);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.notifications,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
title: LocaleKeys.notifications.tr().toText(fontSize: 12),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.settings,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
title: LocaleKeys.general.tr().toText(fontSize: 12),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.person,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
title: LocaleKeys.account.tr().toText(fontSize: 12),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Image.asset(
|
||||||
|
"assets/images/ic_world.png",
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
title: LocaleKeys.english.tr().toText(fontSize: 12),
|
||||||
|
onTap: () {
|
||||||
|
if (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA") {
|
||||||
|
context.setLocale(const Locale("en", "US"));
|
||||||
|
} else {
|
||||||
|
context.setLocale(const Locale('ar', 'SA'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.logout,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
title: LocaleKeys.signOut.tr().toText(fontSize: 12),
|
||||||
|
onTap: () {
|
||||||
|
pop(context);
|
||||||
|
navigateReplaceWithName(context, AppRoutes.registerSelection);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _openImagePicker() {
|
||||||
|
showDialog<ImageSource>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
content: const Text("Choose image source"),
|
||||||
|
actions: [
|
||||||
|
TextButton(child: const Text("Camera"), onPressed: () => dashboardVM.pickImageFromPhone(context, 0)),
|
||||||
|
TextButton(child: const Text("Gallery"), onPressed: () => dashboardVM.pickImageFromPhone(context, 1)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ChangeEmailPage extends StatefulWidget {
|
||||||
|
const ChangeEmailPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChangeEmailPage> createState() => _ChangeEmailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangeEmailPageState extends State<ChangeEmailPage> {
|
||||||
|
String password = "";
|
||||||
|
String email = '';
|
||||||
|
|
||||||
|
late UserVM userVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
userVM = Provider.of<UserVM>(context, listen: false);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.changeEmail.tr()),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.enterEmail.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterNewEmail.tr(),
|
||||||
|
onChanged: (v) => email = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterCurrentPassword.tr(),
|
||||||
|
onChanged: (v) => password = v,
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.confirm.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () async {
|
||||||
|
await userVM.changeUserEmail(context, email, password);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ChangeMobilePage extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<ChangeMobilePage> createState() => _ChangeMobilePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangeMobilePageState extends State<ChangeMobilePage> {
|
||||||
|
int countryID = 1;
|
||||||
|
|
||||||
|
String mobileNo = '';
|
||||||
|
String password = '';
|
||||||
|
|
||||||
|
late UserVM userVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
userVM = Provider.of<UserVM>(context, listen: false);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.changeMobile.tr()),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.enterNewPhoneNumber.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterNewPhoneNumber.tr(),
|
||||||
|
onChanged: (v) => mobileNo = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterCurrentPassword.tr(),
|
||||||
|
onChanged: (v) => password = v,
|
||||||
|
),
|
||||||
|
20.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.confirm.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () async {
|
||||||
|
await userVM.changeUserMobile(context, countryID, mobileNo, password);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ChangePasswordPage extends StatefulWidget {
|
||||||
|
const ChangePasswordPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
||||||
|
String newPassword = "";
|
||||||
|
String currentPassword = '';
|
||||||
|
|
||||||
|
late UserVM userVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
userVM = Provider.of<UserVM>(context, listen: false);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.changePassword.tr()),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.enterNewPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterOldPassword.tr(),
|
||||||
|
onChanged: (v) => currentPassword = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.enterNewPassword.tr(),
|
||||||
|
onChanged: (v) => newPassword = v,
|
||||||
|
),
|
||||||
|
20.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.confirm.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () async {
|
||||||
|
await userVM.changeUserPassword(context, newPassword, currentPassword);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,164 @@
|
|||||||
|
import 'package:car_customer_app/theme/colors.dart';
|
||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/models/user/register_user.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CompleteProfilePage extends StatefulWidget {
|
||||||
|
final RegisterUserRespModel user;
|
||||||
|
|
||||||
|
const CompleteProfilePage(this.user, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CompleteProfilePage> createState() => _CompleteProfilePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
||||||
|
String? firstName = "", lastName = "", email = "", confirmPassword = "";
|
||||||
|
late String password = "";
|
||||||
|
bool isChecked = false;
|
||||||
|
late UserVM userVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
userVM = Provider.of<UserVM>(context, listen: false);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(
|
||||||
|
context,
|
||||||
|
title: LocaleKeys.signUp.tr(),
|
||||||
|
),
|
||||||
|
body: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
6.height,
|
||||||
|
LocaleKeys.completeProfile.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: LocaleKeys.profileMsg.tr().toText(
|
||||||
|
color: MyColors.lightTextColor,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
fontSize: 14,
|
||||||
|
height: 23 / 24,
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.firstName.tr(),
|
||||||
|
value: firstName,
|
||||||
|
onChanged: (v) {
|
||||||
|
firstName = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.surname.tr(),
|
||||||
|
value: lastName,
|
||||||
|
onChanged: (v) {
|
||||||
|
lastName = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.email.tr(),
|
||||||
|
value: email,
|
||||||
|
// isButtonEnable: email!.length > 0 ? true : false,
|
||||||
|
buttonTitle: LocaleKeys.verify.tr(),
|
||||||
|
onChanged: (v) {
|
||||||
|
email = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.createPass.tr(),
|
||||||
|
isPasswordEnabled: true,
|
||||||
|
maxLines: 1,
|
||||||
|
value: password,
|
||||||
|
onChanged: (v) {
|
||||||
|
password = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TxtField(
|
||||||
|
hint: LocaleKeys.confirmPass.tr(),
|
||||||
|
isPasswordEnabled: true,
|
||||||
|
maxLines: 1,
|
||||||
|
value: confirmPassword,
|
||||||
|
onChanged: (v) {
|
||||||
|
confirmPassword = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
50.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Consumer(builder: (BuildContext context, UserVM userVM, Widget? child) {
|
||||||
|
return Checkbox(
|
||||||
|
value: userVM.completeProfilePageCheckbox,
|
||||||
|
activeColor: Colors.blue,
|
||||||
|
onChanged: (value) {
|
||||||
|
userVM.updateCompleteProfilePageCheckbox(value!);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.termsOfService.tr().toText(fontSize: 12),
|
||||||
|
LocaleKeys.terms.tr().toText(fontSize: 12, color: MyColors.darkPrimaryColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Theme(
|
||||||
|
data: ThemeData(unselectedWidgetColor: Colors.transparent),
|
||||||
|
child: Checkbox(
|
||||||
|
value: false,
|
||||||
|
onChanged: (_) {},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.save.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () {
|
||||||
|
bool validateStatus = userVM.dataValidation(password: password, firstName: firstName, lastName: lastName, email: email);
|
||||||
|
if (validateStatus) {
|
||||||
|
userVM.performCompleteProfile(
|
||||||
|
context,
|
||||||
|
password: password,
|
||||||
|
confirmPassword: confirmPassword!,
|
||||||
|
firstName: firstName!,
|
||||||
|
lastName: lastName!,
|
||||||
|
email: email!,
|
||||||
|
userId: widget.user.data!.userId ?? "",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
16.height,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ConfirmNewPasswordPage extends StatefulWidget {
|
||||||
|
final String userToken;
|
||||||
|
|
||||||
|
const ConfirmNewPasswordPage(this.userToken, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ConfirmNewPasswordPage> createState() => _ConfirmNewPasswordPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
|
||||||
|
String newPassword = "";
|
||||||
|
String confirmPassword = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
UserVM userVM = context.read<UserVM>();
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.forgetPassword.tr()),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.newPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
// hintText: "Enter New Password",
|
||||||
|
hintText: LocaleKeys.enterNewPassword.tr(),
|
||||||
|
hintStyle: const TextStyle(color: Colors.grey),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => newPassword = v,
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
TextFormField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
// hintText: "Confirm Password",
|
||||||
|
hintText: LocaleKeys.confirmPassword.tr(),
|
||||||
|
hintStyle: const TextStyle(color: Colors.grey),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
obscureText: true,
|
||||||
|
onChanged: (v) => confirmPassword = v,
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.confirm.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () {
|
||||||
|
if (validation()) userVM.confirmPasswordOTP(context, newPassword: newPassword, userToken: widget.userToken);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validation() {
|
||||||
|
bool isValid = true;
|
||||||
|
if (newPassword != confirmPassword) {
|
||||||
|
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
import 'package:car_customer_app/classes/consts.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/button/show_image_button.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ForgetPasswordMethodPage extends StatefulWidget {
|
||||||
|
final String userToken;
|
||||||
|
|
||||||
|
const ForgetPasswordMethodPage(this.userToken, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ForgetPasswordMethodPage> createState() => _ForgetPasswordMethodPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ForgetPasswordMethodPageState extends State<ForgetPasswordMethodPage> {
|
||||||
|
int otpType = 1;
|
||||||
|
String userOTP = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
UserVM userVM = context.read<UserVM>();
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.forgetPassword.tr()),
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(40),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.selectMethod.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||||
|
12.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () async {
|
||||||
|
otpType = 1;
|
||||||
|
await userVM.forgetPasswordOTPMethod(context, userToken: widget.userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.SMS.tr(),
|
||||||
|
icon: icons + "ic_sms.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.width,
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () async {
|
||||||
|
otpType = 1;
|
||||||
|
await userVM.forgetPasswordOTPMethod(context, userToken: widget.userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.whatsapp.tr(),
|
||||||
|
icon: icons + "ic_whatsapp.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Utils.mFlex(10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,153 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:car_customer_app/models/user/country.dart';
|
||||||
|
import 'package:car_customer_app/theme/colors.dart';
|
||||||
|
import 'package:car_customer_app/utils/utils.dart';
|
||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/dropdown/dropdow_field.dart';
|
||||||
|
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||||
|
import 'package:car_customer_app/widgets/tab/login_email_tab.dart';
|
||||||
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ForgetPasswordPage extends StatefulWidget {
|
||||||
|
const ForgetPasswordPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ForgetPasswordPage> createState() => _ForgetPasswordPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ForgetPasswordPageState extends State<ForgetPasswordPage> {
|
||||||
|
int otpType = 1;
|
||||||
|
|
||||||
|
String userName = "";
|
||||||
|
ClassType type = ClassType.EMAIL;
|
||||||
|
Country? _country;
|
||||||
|
String countryCode = "";
|
||||||
|
|
||||||
|
late UserVM userVM;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
scheduleMicrotask(() {
|
||||||
|
userVM = Provider.of(context, listen: false);
|
||||||
|
getCountryList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getCountryList() async {
|
||||||
|
_country = await userVM.getAllCountries();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.changePassword.tr()),
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
12.height,
|
||||||
|
LocaleKeys.forgetPassword.tr().toText(
|
||||||
|
fontSize: 20,
|
||||||
|
letterSpacing: -1.44,
|
||||||
|
),
|
||||||
|
20.height,
|
||||||
|
LocaleKeys.retrievePassword.tr().toText(
|
||||||
|
color: MyColors.lightTextColor,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
fontSize: 14,
|
||||||
|
height: 23 / 24,
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
),
|
||||||
|
30.height,
|
||||||
|
LoginEmailTab(
|
||||||
|
onSelection: (ClassType type) {
|
||||||
|
setState(() {
|
||||||
|
this.type = type;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
type == ClassType.NUMBER
|
||||||
|
? Column(
|
||||||
|
children: [
|
||||||
|
getCountry(),
|
||||||
|
6.height,
|
||||||
|
TxtField(
|
||||||
|
hint: "5********",
|
||||||
|
value: userName,
|
||||||
|
onChanged: (v) {
|
||||||
|
userName = v;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: TxtField(
|
||||||
|
hint: LocaleKeys.emailAddress.tr(),
|
||||||
|
value: userName,
|
||||||
|
onChanged: (v) {
|
||||||
|
userName = v;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
20.height,
|
||||||
|
(type == ClassType.NUMBER ? LocaleKeys.retriveOnPhone.tr() : LocaleKeys.retriveOnEmail.tr()).toText(
|
||||||
|
color: MyColors.lightTextColor,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
fontSize: 14,
|
||||||
|
height: 23 / 24,
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
),
|
||||||
|
30.height,
|
||||||
|
ShowFillButton(
|
||||||
|
title: LocaleKeys.send.tr(),
|
||||||
|
maxWidth: double.infinity,
|
||||||
|
onPressed: () {
|
||||||
|
if (userName.isNum() && type == ClassType.NUMBER) {
|
||||||
|
userVM.forgetPasswordPhoneOTP(context, countryCode: countryCode, userName: userName, otpType: otpType);
|
||||||
|
} else if (!userName.isNum() && type == ClassType.EMAIL) {
|
||||||
|
userVM.forgetPasswordEmailOTP(context, countryCode: countryCode, userName: userName, otpType: otpType);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Utils.mFlex(10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getCountry() {
|
||||||
|
if (_country != null) {
|
||||||
|
List<DropValue> dropList = [];
|
||||||
|
_country!.data?.forEach((element) {
|
||||||
|
dropList.add(DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? ""));
|
||||||
|
});
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(2.0),
|
||||||
|
child: DropdownField((DropValue value) {
|
||||||
|
countryCode = value.subValue;
|
||||||
|
}, list: dropList, hint: LocaleKeys.selectCountryCode.tr()),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
import 'package:car_customer_app/classes/consts.dart';
|
||||||
|
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||||
|
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:car_customer_app/widgets/button/show_image_button.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class LoginMethodSelectionPage extends StatelessWidget {
|
||||||
|
final String userToken;
|
||||||
|
|
||||||
|
const LoginMethodSelectionPage(this.userToken, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
UserVM userVM = context.read<UserVM>();
|
||||||
|
return Scaffold(
|
||||||
|
appBar: appBar(context, title: LocaleKeys.log_in.tr()),
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.loginSelection.tr().toText(fontSize: 20, letterSpacing: -1.44,),
|
||||||
|
30.height,
|
||||||
|
LocaleKeys.welcomeBack.tr().toText(fontSize: 20, letterSpacing: -1.44,),
|
||||||
|
40.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
userVM.performBasicOtpLoginSelectionPage(context, userToken: userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.fingerPrint.tr(),
|
||||||
|
icon: icons + "ic_fingerprint.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.width,
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
userVM.performBasicOtpLoginSelectionPage(context, userToken: userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.faceRecognition.tr(),
|
||||||
|
icon: icons + "ic_face.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
40.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
userVM.performBasicOtpLoginSelectionPage(context, userToken: userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.SMS.tr(),
|
||||||
|
icon: icons + "ic_sms.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.width,
|
||||||
|
Expanded(
|
||||||
|
child: ShowImageButton(
|
||||||
|
onClick: () {
|
||||||
|
// navigateWithName(context, AppRoutes.dashboard);
|
||||||
|
userVM.performBasicOtpLoginSelectionPage(context, userToken: userToken);
|
||||||
|
},
|
||||||
|
title: LocaleKeys.whatsapp.tr(),
|
||||||
|
icon: icons + "ic_whatsapp.svg",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue