Upgraded the code structure 2.0
parent
88ad86146b
commit
c3555cb38c
@ -1,69 +1,57 @@
|
||||
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/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:car_customer_app/models/user/country.dart';
|
||||
import 'package:car_customer_app/models/user/role.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 'package:car_customer_app/models/member_model.dart';
|
||||
import 'package:car_customer_app/models/surah_model.dart';
|
||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||
import 'package:car_customer_app/models/user/register_user.dart';
|
||||
|
||||
import '../api_client.dart';
|
||||
|
||||
class BranchApiClent {
|
||||
static final BranchApiClent _instance = BranchApiClent._internal();
|
||||
|
||||
BranchApiClent._internal();
|
||||
|
||||
factory BranchApiClent() => _instance;
|
||||
|
||||
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
||||
var postParams = {
|
||||
// "id": 0,
|
||||
"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 ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<Branch> fetchAllBranches() async {
|
||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
||||
}
|
||||
|
||||
Future<Category> fetchBranchCategory() async {
|
||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, 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);
|
||||
}
|
||||
}
|
||||
// import 'dart:async';
|
||||
//
|
||||
// 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/services.dart';
|
||||
//
|
||||
// import '../api_client.dart';
|
||||
//
|
||||
// class BranchApiClient {
|
||||
//
|
||||
// Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
||||
// var postParams = {
|
||||
// // "id": 0,
|
||||
// "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 ?? "";
|
||||
// print("tokeen " + t);
|
||||
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
||||
// }
|
||||
//
|
||||
// Future<Branch> fetchAllBranches() async {
|
||||
// var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||
// print("tokeen " + t);
|
||||
// return await injector.get<ApiClient>().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
||||
// }
|
||||
//
|
||||
// Future<Category> fetchBranchCategory() async {
|
||||
// var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
// 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<Services> fetchServices(String serviceCategoryId) async {
|
||||
// var postParams = {"ServiceCategoryID": serviceCategoryId};
|
||||
// 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<MResponse> createService(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);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,52 +1,47 @@
|
||||
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/models/profile/document.dart';
|
||||
import 'package:car_customer_app/models/user/country.dart';
|
||||
import 'package:car_customer_app/models/user/role.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 'package:car_customer_app/models/member_model.dart';
|
||||
import 'package:car_customer_app/models/surah_model.dart';
|
||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||
import 'package:car_customer_app/models/user/register_user.dart';
|
||||
|
||||
import '../api_client.dart';
|
||||
|
||||
class ProfileApiClent {
|
||||
static final ProfileApiClent _instance = ProfileApiClent._internal();
|
||||
|
||||
ProfileApiClent._internal();
|
||||
|
||||
factory ProfileApiClent() => _instance;
|
||||
|
||||
Future<Document> getServiceProviderDocument(dynamic userId) async {
|
||||
var queryParameters = {
|
||||
"ServiceProviderID": userId.toString(),
|
||||
};
|
||||
String? token = AppState().getUser.data?.accessToken;
|
||||
print(token);
|
||||
return await ApiClient().getJsonForObject((json) => Document.fromJson(json), ApiConsts.GetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
||||
}
|
||||
|
||||
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 ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderDocument_Update, map, token: t);
|
||||
}
|
||||
}
|
||||
// import 'dart:async';
|
||||
//
|
||||
// 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/document.dart';
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
//
|
||||
// import '../api_client.dart';
|
||||
//
|
||||
// class ProfileApiClient {
|
||||
// static final ProfileApiClient _instance = ProfileApiClient._internal();
|
||||
//
|
||||
// ProfileApiClient._internal();
|
||||
//
|
||||
// factory ProfileApiClient() => _instance;
|
||||
//
|
||||
// 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 ?? "");
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,226 +1,214 @@
|
||||
import 'dart:async';
|
||||
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/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/country.dart';
|
||||
import 'package:car_customer_app/models/user/image_response.dart';
|
||||
import 'package:car_customer_app/models/user/refresh_token.dart';
|
||||
import 'package:car_customer_app/models/user/refresh_token.dart';
|
||||
import 'package:car_customer_app/models/user/role.dart';
|
||||
import 'package:car_customer_app/models/user/confirm_password.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/verify_email.dart';
|
||||
import 'package:car_customer_app/models/user/verify_email_otp.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 'package:car_customer_app/models/member_model.dart';
|
||||
import 'package:car_customer_app/models/surah_model.dart';
|
||||
import 'package:car_customer_app/models/user/basic_otp.dart';
|
||||
import 'package:car_customer_app/models/user/register_user.dart';
|
||||
|
||||
import '../../classes/app_state.dart';
|
||||
import '../../models/m_response.dart';
|
||||
|
||||
import '../../models/user/user.dart';
|
||||
import '../api_client.dart';
|
||||
import '../shared_prefrence.dart';
|
||||
|
||||
class UserApiClent {
|
||||
static final UserApiClent _instance = UserApiClent._internal();
|
||||
|
||||
UserApiClent._internal();
|
||||
|
||||
factory UserApiClent() => _instance;
|
||||
|
||||
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<RegisterUser> basicVerify(String phoneNo, String otp, String userToken) async {
|
||||
var postParams = {
|
||||
"userMobileNo": phoneNo,
|
||||
"userOTP": otp,
|
||||
"userToken": userToken,
|
||||
};
|
||||
return await ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicVerify, postParams);
|
||||
}
|
||||
|
||||
Future<RegisterUser> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
|
||||
var 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 ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicComplete, postParams);
|
||||
}
|
||||
|
||||
Future<Response> login_V1(String phoneNo, String password) async {
|
||||
var postParams = {
|
||||
"mobileorEmail": phoneNo,
|
||||
"password": password,
|
||||
};
|
||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V1, postParams);
|
||||
//return await ApiClient().postJsonForObject((json) => BasicOtp.fromJson(json), ApiConsts.Login_V1, postParams);
|
||||
}
|
||||
|
||||
Future<Response> login_V2_OTP(String userToken, String loginType) async {
|
||||
var postParams = {
|
||||
"userToken": userToken,
|
||||
"loginType": loginType,
|
||||
};
|
||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V2_OTP, postParams);
|
||||
}
|
||||
|
||||
Future<Response> login_V2_OTPVerify(String userToken, String otp) async {
|
||||
var postParams = {"userToken": userToken, "userOTP": otp};
|
||||
return await ApiClient().postJsonForResponse(ApiConsts.Login_V2_OTPVerify, postParams);
|
||||
}
|
||||
|
||||
Future<RefreshToken> RefreshTokenAPI(String token, String refreshToken) async {
|
||||
var postParams = {"token": token, "refreshToken": refreshToken};
|
||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => RefreshToken.fromJson(json), ApiConsts.RefreshToken, postParams);
|
||||
}
|
||||
|
||||
Future<Country> getAllCountries() async {
|
||||
var postParams = {};
|
||||
return await ApiClient().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
||||
}
|
||||
|
||||
Future<Cities> getAllCites(String countryId) async {
|
||||
var postParams = {
|
||||
"CountryID": countryId,
|
||||
};
|
||||
return await ApiClient().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
||||
}
|
||||
|
||||
Future<Role> getRoles() async {
|
||||
return await ApiClient().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
||||
}
|
||||
|
||||
Future<Response> ForgetPasswordOTPRequest(String userName, int otpType) async {
|
||||
var postParams = {
|
||||
"userName": userName,
|
||||
"otpType": 1,
|
||||
};
|
||||
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||
//return await ApiClient().postJsonForObject((json) => PasswordOTPRequest.fromJson(json), ApiConsts.ForgetPasswordOTPRequest, postParams);
|
||||
}
|
||||
|
||||
Future<Response> ForgetPasswordOTPCompare(String userToken, String userOTP) async {
|
||||
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<Response> ForgetPassword(String userToken, String newPassword) async {
|
||||
var postParams = {
|
||||
"userToken": userToken,
|
||||
"newPassword": newPassword,
|
||||
};
|
||||
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPassword, postParams);
|
||||
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
|
||||
}
|
||||
|
||||
Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
|
||||
var postParams = {
|
||||
"currentPassword": currentPasswor,
|
||||
"newPassword": newPassword,
|
||||
};
|
||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<ChangeMobile> ChangeMobileNoOTPRequest(
|
||||
countryID,
|
||||
String mobileNo,
|
||||
String password,
|
||||
) async {
|
||||
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<ConfirmMobile> ChangeMobileNo(String userToken, String userOTP) async {
|
||||
var postParams = {
|
||||
"userToken": userToken,
|
||||
"userOTP": userOTP,
|
||||
};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => ConfirmMobile.fromJson(json), ApiConsts.ChangeMobileNo, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<ChanEmail> ChangeEmailOTPRequest(String email, String password) async {
|
||||
var postParams = {"email": email, "password": password};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => ChanEmail.fromJson(json), ApiConsts.ChangeEmailOTPRequest, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<ConfirmEmail> ChangeEmail(String userToken, String userOTP) async {
|
||||
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => ConfirmEmail.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<VerifyEmail> 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 ApiClient().postJsonForObject((json) => VerifyEmail.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<MResponse> EmailVerifyOTPVerify(String userToken, String userOTP) async {
|
||||
var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<ImageResponse> UpdateUserImage(String image) async {
|
||||
var postParams = {"userID": AppState().getUser.data!.userInfo!.userId, "userImage": image};
|
||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<ImageResponse> GetUserImage(String image) async {
|
||||
var postParams = {};
|
||||
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||
|
||||
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();
|
||||
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??"";
|
||||
}
|
||||
}
|
||||
// import 'dart:async';
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:car_customer_app/classes/consts.dart';
|
||||
// import 'package:car_customer_app/config/dependencies.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/country.dart';
|
||||
// import 'package:car_customer_app/models/user/image_response.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/verify_email.dart';
|
||||
// import 'package:http/http.dart';
|
||||
//
|
||||
// import '../../classes/app_state.dart';
|
||||
// import '../../models/m_response.dart';
|
||||
// import '../../models/user/user.dart';
|
||||
// import '../api_client.dart';
|
||||
// import '../../utils/shared_prefrence.dart';
|
||||
//
|
||||
// class UserApiClient {
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
|
||||
// var 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);
|
||||
// }
|
||||
//
|
||||
// Future<Response> login_V1(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);
|
||||
// }
|
||||
//
|
||||
// Future<Response> login_V2_OTP(String userToken, String loginType) async {
|
||||
// var postParams = {
|
||||
// "userToken": userToken,
|
||||
// "loginType": loginType,
|
||||
// };
|
||||
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTP, postParams);
|
||||
// }
|
||||
//
|
||||
// Future<Response> login_V2_OTPVerify(String userToken, String otp) async {
|
||||
// var postParams = {"userToken": userToken, "userOTP": otp};
|
||||
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.Login_V2_OTPVerify, postParams);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// Future<Country> getAllCountries() async {
|
||||
// var postParams = {};
|
||||
// return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
||||
// }
|
||||
//
|
||||
// Future<Cities> getAllCites(String countryId) async {
|
||||
// var postParams = {
|
||||
// "CountryID": countryId,
|
||||
// };
|
||||
// return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
||||
// }
|
||||
//
|
||||
// Future<Role> getRoles() async {
|
||||
// return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// Future<Response> ForgetPasswordOTPCompare(String userToken, String userOTP) async {
|
||||
// var postParams = {"userToken": userToken, "userOTP": userOTP};
|
||||
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPasswordOTPCompare, postParams);
|
||||
// // return await injector.get<ApiClient>().postJsonForObject((json) => PasswordOTPCompare.fromJson(json), ApiConsts.ForgetPasswordOTPCompare, postParams);
|
||||
// }
|
||||
//
|
||||
// Future<Response> ForgetPassword(String userToken, String newPassword) async {
|
||||
// var postParams = {
|
||||
// "userToken": userToken,
|
||||
// "newPassword": newPassword,
|
||||
// };
|
||||
// return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ForgetPassword, postParams);
|
||||
// //return await injector.get<ApiClient>().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
|
||||
// }
|
||||
//
|
||||
// Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
|
||||
// var postParams = {
|
||||
// "currentPassword": currentPasswor,
|
||||
// "newPassword": newPassword,
|
||||
// };
|
||||
// // return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||
//
|
||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||
// print("tokeen " + t);
|
||||
// return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// 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 ?? "";
|
||||
// print("tokeen " + t);
|
||||
// return await injector.get<ApiClient>().postJsonForObject((json) => ImageResponse.fromJson(json), ApiConsts.UpdateUserImage, postParams, token: t);
|
||||
// }
|
||||
//
|
||||
// Future<ImageResponse> GetUserImage(String image) async {
|
||||
// var postParams = {};
|
||||
// // return await injector.get<ApiClient>().postJsonForResponse(ApiConsts.ChangePassword, postParams);
|
||||
//
|
||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||
// print("tokeen " + t);
|
||||
// return await injector.get<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();
|
||||
// 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/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/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/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:flutter/material.dart';
|
||||
import 'package:sizer/sizer.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:provider/single_child_widget.dart';
|
||||
|
||||
import 'config/routes.dart';
|
||||
import 'generated/codegen_loader.g.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
AppDependencies.addDependencies();
|
||||
await EasyLocalization.ensureInitialized();
|
||||
runApp(
|
||||
EasyLocalization(
|
||||
supportedLocales: [
|
||||
Locale('ar', 'SA'),
|
||||
Locale('en', 'US')
|
||||
|
||||
],
|
||||
fallbackLocale: Locale('en', 'US'),
|
||||
// startLocale: Locale('ar', 'SA'),
|
||||
startLocale: Locale('en', 'US'),
|
||||
path: 'resources/langs',
|
||||
child: MyApp(),
|
||||
supportedLocales: const [Locale('ar', 'SA'), Locale('en', 'US')],
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
startLocale: const Locale('en', 'US'),
|
||||
assetLoader: const CodegenLoader(),
|
||||
path: "assetsl/langs",
|
||||
child: MultiProvider(
|
||||
providers: <SingleChildWidget>[
|
||||
ChangeNotifierProvider<BaseVM>(
|
||||
create: (_) => BaseVM(),
|
||||
),
|
||||
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
|
||||
// flutter pub run easy_localization:generate --source-dir ./resources/langs
|
||||
// todo terminal command to genertate translation keys
|
||||
// flutter pub run easy_localization:generate --source-dir ./resources/langs -f keys -o locale_keys.g.dart
|
||||
// todo terminal command to generate translation files
|
||||
// flutter pub run easy_localization:generate --source-dir ./assets/langs
|
||||
// todo terminal command to generate translation keys
|
||||
// flutter pub run easy_localization:generate --source-dir ./assets/langs -f keys -o locale_keys.g.dart
|
||||
// command to generate languages data from json
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppProvider(
|
||||
child: Sizer(
|
||||
builder: (context, orientation, deviceType) {
|
||||
AppState().setPostParamsModel(
|
||||
PostParamsModel(languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,),
|
||||
);
|
||||
return MaterialApp(
|
||||
theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"),
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: context.locale,
|
||||
initialRoute: AppRoutes.initialRoute,
|
||||
routes: AppRoutes.routes,
|
||||
);
|
||||
},
|
||||
),
|
||||
return Sizer(
|
||||
builder: (context, orientation, deviceType) {
|
||||
AppState().setPostParamsModel(
|
||||
PostParamsModel(
|
||||
languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,
|
||||
),
|
||||
);
|
||||
return MaterialApp(
|
||||
theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"),
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: context.locale,
|
||||
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';
|
||||
|
||||
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 accentColor = Colors.blue;
|
||||
const Color appBackgroundColor = Colors.white;
|
||||
Color? accentColorDark = Colors.green[800];
|
||||
const Color borderColor = Colors.blueGrey;
|
||||
Color? borderLightColor = Colors.blueGrey[50];
|
||||
Color backgroudColor =
|
||||
Colors.blueGrey[50]!.withOpacity(0.5) ;
|
||||
const Color iconColor = Colors.blueGrey;
|
||||
Color? headingColor = Colors.blueGrey[800];
|
||||
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:io';
|
||||
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: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) {
|
||||
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
||||
class Utils {
|
||||
static bool _isLoadingVisible = false;
|
||||
|
||||
if (hexColor.length == 6) {
|
||||
hexColor = 'FF' + hexColor;
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
return Container(
|
||||
height: v,
|
||||
width: double.infinity,
|
||||
);
|
||||
}
|
||||
static int stringToHex(String colorCode) {
|
||||
try {
|
||||
return int.parse(colorCode.replaceAll("#", "0xff"));
|
||||
} catch (ex) {
|
||||
return (0xff000000);
|
||||
}
|
||||
}
|
||||
|
||||
String convertFileToBase64(File file) {
|
||||
List<int> imageBytes = file.readAsBytesSync();
|
||||
return base64Encode(imageBytes);
|
||||
}
|
||||
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;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// String checkFileExt(String path) {
|
||||
// String ex = p.extension(path);
|
||||
// var parts = ex.split('.');
|
||||
// return parts[1] ?? "png"; // '.dart'
|
||||
// }
|
||||
static void hideLoading(BuildContext context) {
|
||||
if (_isLoadingVisible) {
|
||||
_isLoadingVisible = false;
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
_isLoadingVisible = false;
|
||||
}
|
||||
|
||||
Future delay(int millis) async {
|
||||
return await Future.delayed(Duration(milliseconds: millis));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
inkWellCorner({double? r}) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(r ?? 4),
|
||||
);
|
||||
}
|
||||
static Color getColorFromHex(String hexColor) {
|
||||
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
||||
|
||||
Widget spacerHorizontal(double v) {
|
||||
return Container(
|
||||
height: v,
|
||||
width: v,
|
||||
);
|
||||
}
|
||||
if (hexColor.length == 6) {
|
||||
hexColor = 'FF' + hexColor;
|
||||
}
|
||||
|
||||
// Widget mHeight(double f) {
|
||||
// return Container(
|
||||
// width: f,
|
||||
// height: f,
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget mDivider(Color color, {double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: h ?? 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
return Color(int.parse(hexColor, radix: 16));
|
||||
}
|
||||
|
||||
Widget mDivider3({double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: h ?? 1,
|
||||
color: borderLightColor!.withOpacity(0.7),
|
||||
);
|
||||
}
|
||||
static Widget spacerVertical(double v) {
|
||||
return SizedBox(
|
||||
height: v,
|
||||
width: double.infinity,
|
||||
);
|
||||
}
|
||||
|
||||
Widget mDivider2(Color color, double w) {
|
||||
return Container(
|
||||
width: w,
|
||||
height: 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
static String convertFileToBase64(File file) {
|
||||
List<int> imageBytes = file.readAsBytesSync();
|
||||
return base64Encode(imageBytes);
|
||||
}
|
||||
|
||||
InputDecoration txtField(String label) {
|
||||
return new InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
errorBorder: InputBorder.none,
|
||||
hintText: label,
|
||||
hintStyle: TextStyle(color: Colors.grey),
|
||||
disabledBorder: InputBorder.none,
|
||||
isDense: false,
|
||||
contentPadding: EdgeInsets.only(left: 15, right: 15),
|
||||
);
|
||||
}
|
||||
static Future delay(int millis) async {
|
||||
return await Future.delayed(Duration(milliseconds: millis));
|
||||
}
|
||||
|
||||
static inkWellCorner({double? r}) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(r ?? 4),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget spacerHorizontal(double v) {
|
||||
return SizedBox(
|
||||
height: v,
|
||||
width: v,
|
||||
);
|
||||
}
|
||||
|
||||
// Widget mWidth(double f) {
|
||||
// return Container(
|
||||
// width: f,
|
||||
// height: f,
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget mFlex(int f) {
|
||||
return Flexible(
|
||||
flex: f,
|
||||
child: Container(
|
||||
static Widget mDivider(Color color, {double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
height: h ?? 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
|
||||
Widget mExp(int f) {
|
||||
return Expanded(
|
||||
flex: f,
|
||||
child: Container(
|
||||
static Widget mDivider3({double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
height: h ?? 1,
|
||||
color: borderLightColor!.withOpacity(0.7),
|
||||
);
|
||||
}
|
||||
|
||||
spacer() {
|
||||
return SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
}
|
||||
//
|
||||
// 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));
|
||||
}
|
||||
static Widget mDivider2(Color color, double w) {
|
||||
return Container(
|
||||
width: w,
|
||||
height: 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
|
||||
circularImage(String im, double width, double height) {
|
||||
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))));
|
||||
}
|
||||
static InputDecoration txtField(String label) {
|
||||
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) {
|
||||
return new Container(width: width, height: height, decoration: new BoxDecoration(shape: BoxShape.circle, image: new DecorationImage(fit: BoxFit.fill, image: new AssetImage(im))));
|
||||
}
|
||||
static Widget mFlex(int f) {
|
||||
return Flexible(
|
||||
flex: f,
|
||||
child: const SizedBox(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
cardRadius(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
static Widget mExp(int f) {
|
||||
return Expanded(
|
||||
flex: f,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
cardRadiusWithoutBorder(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
static spacer() {
|
||||
return const SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
}
|
||||
|
||||
Image imageFromBase64String(String base64String) {
|
||||
return Image.memory(base64Decode(base64String));
|
||||
}
|
||||
static cardRadius(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
Uint8List dataFromBase64String(String base64String) {
|
||||
return base64Decode(base64String);
|
||||
}
|
||||
static cardRadiusWithoutBorder(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
String base64String(Uint8List data) {
|
||||
return base64Encode(data);
|
||||
}
|
||||
static Image imageFromBase64String(String base64String) {
|
||||
return Image.memory(base64Decode(base64String));
|
||||
}
|
||||
|
||||
static Uint8List dataFromBase64String(String base64String) {
|
||||
return base64Decode(base64String);
|
||||
}
|
||||
|
||||
Widget overLayWidget({double? width, double? height, List<Color>? color}) {
|
||||
return Container(
|
||||
width: width ?? double.infinity,
|
||||
height: height ?? 60,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: color != null
|
||||
? color
|
||||
: [
|
||||
static String base64String(Uint8List data) {
|
||||
return base64Encode(data);
|
||||
}
|
||||
|
||||
static Widget overLayWidget({double? width, double? height, List<Color>? color}) {
|
||||
return Container(
|
||||
width: width ?? double.infinity,
|
||||
height: height ?? 60,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: color ??
|
||||
[
|
||||
Colors.black.withOpacity(0.2),
|
||||
Colors.black.withOpacity(0.1),
|
||||
Colors.black.withOpacity(0.004),
|
||||
],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
tileMode: TileMode.clamp,
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
tileMode: TileMode.clamp,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerRadius(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
static Decoration containerRadius(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerRadiusTop({Color? color, double? r}) {
|
||||
return BoxDecoration(
|
||||
color: color ?? Colors.white,
|
||||
borderRadius: BorderRadius.only(topRight: Radius.circular(r ?? 12), topLeft: Radius.circular(r ?? 12)),
|
||||
);
|
||||
}
|
||||
static Decoration containerRadiusTop({Color? color, double? r}) {
|
||||
return BoxDecoration(
|
||||
color: color ?? Colors.white,
|
||||
borderRadius: BorderRadius.only(topRight: Radius.circular(r ?? 12), topLeft: Radius.circular(r ?? 12)),
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerRadiusBorder(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
border: Border.all(color: color, width: 1),
|
||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
static Decoration containerRadiusBorder(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
border: Border.all(color: color, width: 1),
|
||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerRadiusBottom(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(r), bottomRight: Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
static Decoration containerRadiusBottom(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(r), bottomRight: Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
|
||||
ShapeBorder cardRadiusTop(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: BorderSide(color: Colors.transparent, width: 0),
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
static ShapeBorder cardRadiusTop(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: const BorderSide(color: Colors.transparent, width: 0),
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) {
|
||||
return BoxDecoration(
|
||||
color: background,
|
||||
border: Border.all(
|
||||
width: w, //
|
||||
color: color // <--- border width here
|
||||
),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
static Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) {
|
||||
return BoxDecoration(
|
||||
color: background,
|
||||
border: Border.all(
|
||||
width: w, //
|
||||
color: color // <--- border width here
|
||||
),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
ShapeBorder cardRadiusTop2(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
static ShapeBorder cardRadiusTop2(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
|
||||
ShapeBorder cardRadiusBottom(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
static ShapeBorder cardRadiusBottom(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
|
||||
Decoration containerColorRadiusBorder(Color background, double radius, Color color) {
|
||||
return BoxDecoration(
|
||||
color: background,
|
||||
border: Border.all(
|
||||
width: 1, //
|
||||
color: color // <--- border width here
|
||||
),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
static Decoration containerColorRadiusBorder(Color background, double radius, Color color) {
|
||||
return BoxDecoration(
|
||||
color: background,
|
||||
border: Border.all(
|
||||
width: 1, //
|
||||
color: color // <--- border width here
|
||||
),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
//Decoration appGradient = BoxDecoration(
|
||||
// gradient: LinearGradient(
|
||||
// colors: [
|
||||
// Colors.green[200],
|
||||
// Colors.green,
|
||||
// ],
|
||||
// begin: Alignment.topCenter,
|
||||
// end: Alignment.bottomCenter,
|
||||
// ),
|
||||
//);
|
||||
// launchURL(String url) async {
|
||||
// if (await canLaunch(url)) {
|
||||
// await launch(url);
|
||||
// } else {
|
||||
// throw 'Could not launch $url';
|
||||
// }
|
||||
// }
|
||||
static bool passwordValidateStructure(String value) {
|
||||
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
||||
RegExp regExp = RegExp(pattern);
|
||||
return regExp.hasMatch(value);
|
||||
}
|
||||
|
||||
static bool isEmailValid(String email) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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