Common Setup
parent
dc7548fea4
commit
c3f4c66342
@ -1,317 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:car_customer_app/classes/app_state.dart';
|
||||
import 'package:car_customer_app/classes/consts.dart';
|
||||
import 'package:car_customer_app/exceptions/api_exception.dart';
|
||||
import 'package:car_customer_app/models/user/refresh_token.dart';
|
||||
import 'package:car_customer_app/models/user/user.dart';
|
||||
import 'package:car_customer_app/utils/shared_prefrence.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/io_client.dart';
|
||||
|
||||
typedef FactoryConstructor<U> = U Function(dynamic);
|
||||
|
||||
class APIError {
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
|
||||
APIError(this.errorCode, this.errorMessage);
|
||||
|
||||
Map<String, dynamic> toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
|
||||
|
||||
static APIException throwAPIException(Response response) {
|
||||
switch (response.statusCode) {
|
||||
case 400:
|
||||
APIError? apiError;
|
||||
if (response.body != null && response.body.isNotEmpty) {
|
||||
var jsonError = jsonDecode(response.body);
|
||||
apiError = APIError(jsonError['errorCode'], jsonError['errorMessage']);
|
||||
}
|
||||
return APIException(APIException.BAD_REQUEST, error: apiError);
|
||||
case 401:
|
||||
return const APIException(APIException.UNAUTHORIZED);
|
||||
case 403:
|
||||
return const APIException(APIException.FORBIDDEN);
|
||||
case 404:
|
||||
return const APIException(APIException.NOT_FOUND);
|
||||
case 500:
|
||||
return const APIException(APIException.INTERNAL_SERVER_ERROR);
|
||||
case 444:
|
||||
var downloadUrl = response.headers["location"];
|
||||
return APIException(APIException.UPGRADE_REQUIRED, arguments: downloadUrl);
|
||||
default:
|
||||
return const APIException(APIException.OTHER);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class ApiClient {
|
||||
Future<U> postJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, T jsonObject,
|
||||
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0});
|
||||
|
||||
Future<Response> postJsonForResponse<T>(String url, T jsonObject, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0});
|
||||
|
||||
Future<U> getJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0});
|
||||
|
||||
Future<Response> getJsonForResponse<T>(String url, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0});
|
||||
}
|
||||
|
||||
class ApiClientImp implements ApiClient {
|
||||
@override
|
||||
Future<U> postJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, T jsonObject,
|
||||
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
|
||||
var _headers = {'Accept': 'application/json'};
|
||||
if (headers != null && headers.isNotEmpty) {
|
||||
_headers.addAll(headers);
|
||||
}
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("Url:$url");
|
||||
debugPrint("body:$jsonObject");
|
||||
}
|
||||
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
|
||||
try {
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("res121:" + response.body);
|
||||
debugPrint("res121:" + response.statusCode.toString());
|
||||
}
|
||||
var jsonData = jsonDecode(response.body);
|
||||
return factoryConstructor(jsonData);
|
||||
} catch (ex) {
|
||||
debugPrint(ex.toString());
|
||||
debugPrint("exception:" + ex.toString());
|
||||
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> postJsonForResponse<T>(String url, T jsonObject, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
|
||||
String? requestBody;
|
||||
if (jsonObject != null) {
|
||||
requestBody = jsonEncode(jsonObject);
|
||||
if (headers == null) {
|
||||
headers = {'Content-Type': 'application/json'};
|
||||
} else {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
}
|
||||
|
||||
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
|
||||
}
|
||||
|
||||
Future<Response> _postForResponse(
|
||||
String url,
|
||||
requestBody, {
|
||||
String? token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
Map<String, String>? headers,
|
||||
int retryTimes = 0,
|
||||
}) async {
|
||||
try {
|
||||
var _headers = <String, String>{};
|
||||
if (token != null) {
|
||||
_headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
if (headers != null && headers.isNotEmpty) {
|
||||
_headers.addAll(headers);
|
||||
}
|
||||
|
||||
if (queryParameters != null) {
|
||||
var queryString = Uri(queryParameters: queryParameters).query;
|
||||
url = url + '?' + queryString;
|
||||
}
|
||||
|
||||
Response response;
|
||||
|
||||
response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(const Duration(seconds: 100));
|
||||
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("Url:$url");
|
||||
debugPrint("body:$requestBody");
|
||||
debugPrint("res: " + response.body);
|
||||
}
|
||||
if (response.statusCode >= 200 && response.statusCode < 500) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData["StatusMessage"] != null && jsonData["StatusMessage"] == "Unauthorized user attempt to access API") {
|
||||
String mToken = await updateUserToken();
|
||||
return await _postForResponse(url, requestBody, token: mToken, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
throw APIError.throwAPIException(response);
|
||||
}
|
||||
} on SocketException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
debugPrint('will retry after 3 seconds...');
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} on HttpException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
debugPrint('will retry after 3 seconds...');
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} on TimeoutException catch (e) {
|
||||
throw APIException(APIException.TIMEOUT, arguments: e);
|
||||
} on ClientException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
debugPrint('will retry after 3 seconds...');
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} catch (ex) {
|
||||
debugPrint("exception1:" + ex.toString());
|
||||
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
|
||||
}
|
||||
}
|
||||
|
||||
bool _certificateCheck(X509Certificate cert, String host, int port) => true;
|
||||
|
||||
Future<T> _withClient<T>(Future<T> Function(Client) fn) async {
|
||||
var httpClient = HttpClient()..badCertificateCallback = _certificateCheck;
|
||||
var client = IOClient(httpClient);
|
||||
try {
|
||||
return await fn(client);
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> _post(url, {Map<String, String>? headers, body, Encoding? encoding}) => _withClient((client) => client.post(url, headers: headers, body: body, encoding: encoding));
|
||||
|
||||
@override
|
||||
Future<U> getJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url,
|
||||
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
|
||||
var _headers = {'Accept': 'application/json'};
|
||||
if (headers != null && headers.isNotEmpty) {
|
||||
_headers.addAll(headers);
|
||||
}
|
||||
var response = await getJsonForResponse(url, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
|
||||
try {
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("res:" + response.body);
|
||||
}
|
||||
var jsonData = jsonDecode(response.body);
|
||||
return factoryConstructor(jsonData);
|
||||
} catch (ex) {
|
||||
debugPrint("exception:" + response.body);
|
||||
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> getJsonForResponse<T>(String url, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
|
||||
if (headers == null) {
|
||||
headers = {'Content-Type': 'application/json'};
|
||||
} else {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
|
||||
}
|
||||
|
||||
bool isFirstCall = true;
|
||||
|
||||
Future<Response> _getForResponse(String url, {String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0}) async {
|
||||
try {
|
||||
var _headers = <String, String>{};
|
||||
if (token != null) {
|
||||
_headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
if (headers != null && headers.isNotEmpty) {
|
||||
_headers.addAll(headers);
|
||||
}
|
||||
if (queryParameters != null) {
|
||||
String queryString = Uri(queryParameters: queryParameters).query;
|
||||
if (isFirstCall) url = url + '?' + queryString.toString();
|
||||
}
|
||||
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("Url:$url");
|
||||
debugPrint("queryParameters:$queryParameters");
|
||||
}
|
||||
var response = await _get(Uri.parse(url), headers: _headers).timeout(const Duration(seconds: 60));
|
||||
|
||||
if (!kReleaseMode) {
|
||||
debugPrint("res: " + response.body.toString());
|
||||
}
|
||||
if (response.statusCode >= 200 && response.statusCode < 500) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData["StatusMessage"] != null && jsonData["StatusMessage"] == "Unauthorized user attempt to access API") {
|
||||
String mToken = await updateUserToken();
|
||||
isFirstCall = false;
|
||||
return await _getForResponse(url, token: mToken, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes);
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
throw APIError.throwAPIException(response);
|
||||
}
|
||||
} on SocketException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
debugPrint('will retry after 3 seconds...');
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} on HttpException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
debugPrint('will retry after 3 seconds...');
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} on TimeoutException catch (e) {
|
||||
throw APIException(APIException.TIMEOUT, arguments: e);
|
||||
} on ClientException catch (e) {
|
||||
if (retryTimes > 0) {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
|
||||
} else {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
} catch (e) {
|
||||
throw APIException(APIException.OTHER, arguments: e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> _get(url, {Map<String, String>? headers}) => _withClient((client) => client.get(url, headers: headers));
|
||||
|
||||
Future<RefreshToken> refreshTokenAPI(String token, String refreshToken) async {
|
||||
var postParams = {"token": token, "refreshToken": refreshToken};
|
||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await postJsonForObject((json) => RefreshToken.fromJson(json), ApiConsts.RefreshToken, postParams);
|
||||
}
|
||||
|
||||
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??"";
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
// 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,47 +0,0 @@
|
||||
// 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,214 +0,0 @@
|
||||
// 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,33 +0,0 @@
|
||||
|
||||
|
||||
import 'package:car_customer_app/models/post_params_model.dart';
|
||||
import 'package:car_customer_app/models/user/user.dart';
|
||||
|
||||
class AppState {
|
||||
static final AppState _instance = AppState._internal();
|
||||
|
||||
AppState._internal();
|
||||
|
||||
factory AppState() => _instance;
|
||||
|
||||
bool isLogged = false;
|
||||
|
||||
set setLogged(v) => isLogged = v;
|
||||
|
||||
bool? get getIsLogged => isLogged;
|
||||
|
||||
User? _user = null;
|
||||
|
||||
set setUser(v) => _user = v;
|
||||
|
||||
User get getUser => _user??User();
|
||||
|
||||
PostParamsModel? _postParams;
|
||||
|
||||
PostParamsModel? get postParamsObject => _postParams;
|
||||
|
||||
Map<String, dynamic> get postParamsJson => _postParams?.toJson() ?? {};
|
||||
void setPostParamsModel(PostParamsModel _postParams) {
|
||||
this._postParams = _postParams;
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
class ApiConsts {
|
||||
// static String baseUrl = "http://10.200.204.20:2801/"; // Local server
|
||||
static String baseUrl = "https://ms.hmg.com/"; // production server
|
||||
static String baseUrlServices = baseUrl + ""; // production server
|
||||
static String BasicOTP = baseUrlServices + "api/Register/BasicOTP";
|
||||
static String BasicVerify = baseUrlServices + "api/Register/BasicVerify";
|
||||
static String BasicComplete = baseUrlServices + "api/Register/BasicComplete";
|
||||
static String RefreshToken = baseUrlServices + "api/Account/RefreshToken";
|
||||
|
||||
|
||||
//User
|
||||
static String Login_V1 = baseUrlServices + "api/Account/Login_V1";
|
||||
static String Login_V2_OTP = baseUrlServices + "api/Account/Login_V2_OTP";
|
||||
static String Login_V2_OTPVerify = baseUrlServices + "api/Account/Login_V2_OTPVerify";
|
||||
static String user = baseUrlServices + "api/User/";
|
||||
static String GetAllCountry = baseUrlServices + "api/Master/Country_Get";
|
||||
static String GetProviderRoles = baseUrlServices + "api/Master/RoleServiceProvider_Get";
|
||||
static String GetAllCities = baseUrlServices + "api/Master/City_Get";
|
||||
static String ForgetPasswordOTPRequest = baseUrlServices + "api/Account/ForgetPasswordOTPRequest";
|
||||
static String ForgetPasswordOTPCompare = baseUrlServices + "api/Account/ForgetPasswordOTPCompare";
|
||||
static String ForgetPassword = baseUrlServices + "api/Account/ForgetPassword";
|
||||
static String Login_Email_OTP = baseUrlServices + "api/Account/EmailVerify";
|
||||
static String Login_Email_OTPVerify = baseUrlServices + "api/Account/EmailVerifyOTPVerify";
|
||||
static String ChangePassword = baseUrlServices + "api/Account/ChangePassword";
|
||||
static String ChangeMobileNoOTPRequest = baseUrlServices + "api/Account/ChangeMobileNoOTPRequest";
|
||||
static String ChangeMobileNo = baseUrlServices + "api/Account/ChangeMobileNo";
|
||||
static String ChangeEmailOTPRequest = baseUrlServices + "api/Account/ChangeEmailOTPRequest";
|
||||
static String ChangeEmail = baseUrlServices + "api/Account/ChangeEmail";
|
||||
static String EmailVerify = baseUrlServices + "api/Account/EmailVerify";
|
||||
static String EmailVerifyOTPVerify = baseUrlServices + "api/Account/EmailVerifyOTPVerify";
|
||||
static String UpdateUserImage = baseUrlServices + "api/User_UpdateProfileImage";
|
||||
static String GetUserImage = baseUrlServices + "api/ProfileImage";
|
||||
|
||||
|
||||
//Profile
|
||||
static String GetProviderDocument = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Get";
|
||||
static String ServiceProviderDocument_Update = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Update";
|
||||
|
||||
//Branch
|
||||
static String createProviderBranch = baseUrlServices + "api/ServiceProviders/ServiceProviderBranch_Create";
|
||||
static String ServiceProviderBranchGet = baseUrlServices + "api/ServiceProviders/ServiceProviderBranch_Get";
|
||||
static String ServiceCategory_Get = baseUrlServices + "api/Master/ServiceCategory_Get";
|
||||
static String Services_Get = baseUrlServices + "api/ServiceProviders/Services_Get";
|
||||
static String ServiceProviderService_Create = baseUrlServices + "api/ServiceProviders/ServiceProviderService_Create";
|
||||
}
|
||||
|
||||
class GlobalConsts {
|
||||
static String isRememberMe = "remember_me";
|
||||
static String email = "email";
|
||||
static String password = "password";
|
||||
static String bookmark = "bookmark";
|
||||
static String fontZoomSize = "font_zoom_size";
|
||||
static String welcomeVideoUrl = "welcomeVideoUrl";
|
||||
static String doNotShowWelcomeVideo = "doNotShowWelcomeVideo";
|
||||
}
|
||||
|
||||
const String icons = "assets/icons/";
|
||||
const String categorySvgIcons = "assets/category/svg/";
|
||||
const String svgIcons = "assets/svg/";
|
||||
|
||||
RegExp numReg = RegExp(r".*[0-9].*");
|
||||
RegExp letterReg = RegExp(r".*[A-Za-z].*");
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
// 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,90 +0,0 @@
|
||||
import 'package:car_customer_app/models/user/register_user.dart';
|
||||
import 'package:car_customer_app/views/dashboard/dashboard_page.dart';
|
||||
// import 'package:car_customer_app/views/settings/create_services_page.dart';
|
||||
// import 'package:car_customer_app/views/settings/dealership_page.dart';
|
||||
// import 'package:car_customer_app/views/settings/define_branch_page.dart';
|
||||
// import 'package:car_customer_app/views/settings/define_license_page.dart';
|
||||
import 'package:car_customer_app/views/user/change_email_page.dart';
|
||||
import 'package:car_customer_app/views/user/change_mobile_page.dart';
|
||||
import 'package:car_customer_app/views/user/change_password_page.dart';
|
||||
import 'package:car_customer_app/views/user/complete_profile_page.dart';
|
||||
import 'package:car_customer_app/views/user/confirm_new_password_page.dart';
|
||||
import 'package:car_customer_app/views/user/edit_account_page.dart';
|
||||
import 'package:car_customer_app/views/user/forget_password_method_page.dart';
|
||||
import 'package:car_customer_app/views/user/forget_password_page.dart';
|
||||
import 'package:car_customer_app/views/user/login_method_selection_page.dart';
|
||||
import 'package:car_customer_app/views/user/login_verification_page.dart';
|
||||
import 'package:car_customer_app/views/user/login_verify_account_page.dart';
|
||||
import 'package:car_customer_app/views/user/login_with_password_page.dart';
|
||||
// import 'package:car_customer_app/views/user/profile/profile_1_page.dart';
|
||||
// import 'package:car_customer_app/views/user/profile/profile_2_page.dart';
|
||||
// import 'package:car_customer_app/views/user/profile/profile_3_page.dart';
|
||||
import 'package:car_customer_app/views/user/register_page.dart';
|
||||
import 'package:car_customer_app/views/user/register_selection_page.dart';
|
||||
import 'package:car_customer_app/views/splash/splash_page.dart';
|
||||
import 'package:car_customer_app/views/user/vertify_password_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppRoutes {
|
||||
//User
|
||||
static const String splash = "/splash";
|
||||
static const String registerSelection = "/registerSelection";
|
||||
static const String loginVerifyAccount = "/loginVerifyAccount";
|
||||
static const String register = "/register";
|
||||
static const String forgetPassword = "/forgetPassword";
|
||||
static const String loginVerification = "/loginVerification";
|
||||
static const String loginWithPassword = "/loginWithPassword";
|
||||
static const String loginMethodSelection = "/loginMethodSelection";
|
||||
static const String completeProfile = "/completeProfile";
|
||||
static const String profile1 = "/profile1";
|
||||
static const String profile2 = "/profile2";
|
||||
static const String profile3 = "/profile3";
|
||||
static const String verifyPassword = "/vertifyPassword";
|
||||
static const String confirmNewPasswordPage = "/confirmNewPasswordPage";
|
||||
static const String defineLicense = "/defineLicese";
|
||||
static const String changePassword = "/changePassword";
|
||||
static const String forgetPasswordMethodPage = "/forgetPasswordMethodPage";
|
||||
static const String changeMobilePage = "/changeMobilePage";
|
||||
static const String changeEmailPage = "/changeEmailPage";
|
||||
static const String editAccountPage = "/editAccoundPage";
|
||||
|
||||
static const String dashboard = "/dashboard";
|
||||
|
||||
//settings
|
||||
static const String dealershipSetting = "/dealershipSetting";
|
||||
static const String defineBranch = "/defineBranch";
|
||||
static const String createServices = "/createServices";
|
||||
|
||||
static const String initialRoute = splash;
|
||||
|
||||
static final Map<String, WidgetBuilder> routes = {
|
||||
//User
|
||||
splash: (context) => const SplashPage(),
|
||||
registerSelection: (context) => RegisterSelectionPage(),
|
||||
loginVerifyAccount: (context) => LoginVerifyAccountPage(),
|
||||
register: (context) => RegisterPage(),
|
||||
forgetPassword: (context) => ForgetPasswordPage(),
|
||||
loginVerification: (context) => const LoginVerificationPage(),
|
||||
loginWithPassword: (context) => LoginWithPassword(),
|
||||
loginMethodSelection: (context) => LoginMethodSelectionPage(ModalRoute.of(context)!.settings.arguments as String),
|
||||
completeProfile: (context) => CompleteProfilePage(ModalRoute.of(context)!.settings.arguments as RegisterUserRespModel),
|
||||
// profile1: (context) => Profile1Page(),
|
||||
// profile2: (context) => Profile2Page(),
|
||||
// profile3: (context) => Profile3Page(),
|
||||
// defineLicense: (context) => DefineLicensePage(),
|
||||
verifyPassword: (context) => VerifyPasswordPage(),
|
||||
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String),
|
||||
changePassword: (context) => ChangePasswordPage(),
|
||||
forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String),
|
||||
changeMobilePage: (context) => ChangeMobilePage(),
|
||||
changeEmailPage : (context) => const ChangeEmailPage(),
|
||||
editAccountPage : (context) => EditAccountPage(),
|
||||
//Home page
|
||||
dashboard: (context) => const DashboardPage(),
|
||||
|
||||
//setting
|
||||
// dealershipSetting: (context) => DealershipPage(),
|
||||
// defineBranch: (context) => DefineBranchPage(),
|
||||
// createServices: (context) => CreateServicesPage(),
|
||||
};
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:car_customer_app/api/api_client.dart';
|
||||
|
||||
class APIException implements Exception {
|
||||
static const String BAD_REQUEST = 'api_common_bad_request';
|
||||
static const String UNAUTHORIZED = 'api_common_unauthorized';
|
||||
static const String FORBIDDEN = 'api_common_forbidden';
|
||||
static const String NOT_FOUND = 'api_common_not_found';
|
||||
static const String INTERNAL_SERVER_ERROR = 'api_common_internal_server_error';
|
||||
static const String UPGRADE_REQUIRED = 'api_common_upgrade_required';
|
||||
static const String BAD_RESPONSE_FORMAT = 'api_common_bad_response_format';
|
||||
static const String OTHER = 'api_common_http_error';
|
||||
static const String TIMEOUT = 'api_common_http_timeout';
|
||||
static const String UNKNOWN = 'unexpected_error';
|
||||
|
||||
final String message;
|
||||
final APIError? error;
|
||||
final arguments;
|
||||
|
||||
const APIException(this.message, {this.arguments, this.error});
|
||||
|
||||
Map<String, dynamic> toJson() => {'message': message, 'error': error, 'arguments': '$arguments'};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return jsonEncode(this);
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
extension IntExtensions on int {
|
||||
Widget get height => SizedBox(height: toDouble());
|
||||
|
||||
Widget get width => SizedBox(width: toDouble());
|
||||
}
|
||||
@ -1,121 +0,0 @@
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
extension EmailValidator on String {
|
||||
Widget toText({Color? color, bool isBold = false, double? fontSize, bool isUnderLine = false, TextDecoration? textDecoration, double letterSpacing = -0.4, TextAlign? textAlign, double? height}) =>
|
||||
Text(
|
||||
this,
|
||||
textAlign: textAlign,
|
||||
style: TextStyle(
|
||||
height: height,
|
||||
decoration: textDecoration ?? TextDecoration.none,
|
||||
fontSize: fontSize ?? 10,
|
||||
fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
|
||||
color: color ?? MyColors.darkTextColor,
|
||||
letterSpacing: letterSpacing,
|
||||
),
|
||||
);
|
||||
|
||||
// Widget toText12({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => Text(
|
||||
// this,
|
||||
// textAlign: isCenter ? TextAlign.center : null,
|
||||
// maxLines: (maxLine > 0) ? maxLine : null,
|
||||
// style: TextStyle(
|
||||
// fontSize: 12,
|
||||
// fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
|
||||
// color: color ?? MyColors.darkTextColor,
|
||||
// letterSpacing: -0.72,
|
||||
// decoration: isUnderLine ? TextDecoration.underline : null),
|
||||
// );
|
||||
|
||||
// Widget toText13({Color? color, bool isUnderLine = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null),
|
||||
// );
|
||||
|
||||
// Widget toText14({
|
||||
// Color? color,
|
||||
// bool isBold = false,
|
||||
// TextAlign? textAlign,
|
||||
// }) =>
|
||||
// Text(
|
||||
// this,
|
||||
// textAlign: textAlign,
|
||||
// style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 14, letterSpacing: -0.48, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText16({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText17({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.68, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText20({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 20, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText22({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText24({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(height: 23 / 24, fontSize: 24, letterSpacing: -1.44, color: color ?? MyColors.darkTextColor, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
// Widget toText32({Color? color, bool isBold = false}) => Text(
|
||||
// this,
|
||||
// style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.92, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
|
||||
// );
|
||||
|
||||
bool isValidEmail() {
|
||||
return RegExp(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,}))$').hasMatch(this);
|
||||
}
|
||||
|
||||
bool isNum() {
|
||||
return RegExp(r'^[0-9]+$').hasMatch(this);
|
||||
}
|
||||
|
||||
String toFormattedDate() {
|
||||
String date = split("T")[0];
|
||||
String time = split("T")[1];
|
||||
var dates = date.split("-");
|
||||
return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a').format(DateFormat('hh:mm:ss').parse(time))}";
|
||||
}
|
||||
|
||||
getMonth(int month) {
|
||||
switch (month) {
|
||||
case 1:
|
||||
return "January";
|
||||
case 2:
|
||||
return "February";
|
||||
case 3:
|
||||
return "March";
|
||||
case 4:
|
||||
return "April";
|
||||
case 5:
|
||||
return "May";
|
||||
case 6:
|
||||
return "June";
|
||||
case 7:
|
||||
return "July";
|
||||
case 8:
|
||||
return "August";
|
||||
case 9:
|
||||
return "September";
|
||||
case 10:
|
||||
return "October";
|
||||
case 11:
|
||||
return "November";
|
||||
case 12:
|
||||
return "December";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension WidgetExtensions on Widget {
|
||||
Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this);
|
||||
|
||||
Widget paddingAll(double _value) => Padding(padding: EdgeInsets.all(_value), child: this);
|
||||
|
||||
Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) =>
|
||||
Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this);
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final account = accountFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:car_customer_app/models/parent_list.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
Account accountFromJson(String str) => Account.fromJson(json.decode(str));
|
||||
|
||||
String accountToJson(Account data) => json.encode(data.toJson());
|
||||
|
||||
class Account {
|
||||
Account({
|
||||
required this.parentList,
|
||||
required this.selectedItem,
|
||||
});
|
||||
|
||||
List<ParentList>? parentList;
|
||||
int selectedItem;
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) => Account(
|
||||
parentList: json["parentList"] == null
|
||||
? null
|
||||
: List<ParentList>.from(
|
||||
json["parentList"].map((x) => ParentList.fromJson(x))),
|
||||
selectedItem:
|
||||
json["selectedItem"] == null ? null : json["selectedItem"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"parentList": parentList == null
|
||||
? null
|
||||
: List<dynamic>.from(parentList!.map((x) => x.toJson())),
|
||||
"selectedItem": selectedItem == null ? null : selectedItem,
|
||||
};
|
||||
|
||||
Map<String, dynamic> toJsonData() => {
|
||||
"selectedItem": selectedItem == null ? null : selectedItem,
|
||||
};
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
class ConfigModel {
|
||||
ConfigModel(this.endpoint, this.organizationName);
|
||||
|
||||
String endpoint;
|
||||
|
||||
String organizationName;
|
||||
|
||||
factory ConfigModel.fromJson(Map<String, dynamic> json) =>
|
||||
ConfigModel("", "");
|
||||
|
||||
// Map<String, dynamic> toJson() => _$ConfigModelToJson(this);
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
class ContentInfoModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<ContentInfoDataModel>? data;
|
||||
|
||||
ContentInfoModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
ContentInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(new ContentInfoDataModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ContentInfoDataModel {
|
||||
int? contentInfoId;
|
||||
int? contentTypeId;
|
||||
String? content;
|
||||
String? contentTypeNameEn;
|
||||
String? contentTypeNameAr;
|
||||
String? fileName;
|
||||
String? exposeFilePath;
|
||||
|
||||
ContentInfoDataModel({this.contentInfoId, this.contentTypeId, this.content, this.contentTypeNameEn, this.contentTypeNameAr, this.fileName, this.exposeFilePath});
|
||||
|
||||
ContentInfoDataModel.fromJson(Map<String, dynamic> json) {
|
||||
contentInfoId = json['contentInfoId'];
|
||||
contentTypeId = json['contentTypeId'];
|
||||
content = json['content'];
|
||||
contentTypeNameEn = json['contentTypeNameEn'];
|
||||
contentTypeNameAr = json['contentTypeNameAr'];
|
||||
fileName = json['fileName'];
|
||||
exposeFilePath = json['exposeFilePath'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['contentInfoId'] = this.contentInfoId;
|
||||
data['contentTypeId'] = this.contentTypeId;
|
||||
data['content'] = this.content;
|
||||
data['contentTypeNameEn'] = this.contentTypeNameEn;
|
||||
data['contentTypeNameAr'] = this.contentTypeNameAr;
|
||||
data['fileName'] = this.fileName;
|
||||
data['exposeFilePath'] = this.exposeFilePath;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final mResponse = mResponseFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
MResponse mResponseFromJson(String str) => MResponse.fromJson(json.decode(str));
|
||||
|
||||
String mResponseToJson(MResponse data) => json.encode(data.toJson());
|
||||
|
||||
class MResponse {
|
||||
MResponse({
|
||||
this.totalItemsCount,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory MResponse.fromJson(Map<String, dynamic> json) => MResponse(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
messageStatus: json["messageStatus"],
|
||||
message: json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"messageStatus": messageStatus,
|
||||
"message": message,
|
||||
};
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
class MemberModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<MemberDataModel>? data;
|
||||
|
||||
MemberModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
MemberModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(new MemberDataModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MemberDataModel {
|
||||
int? committeeId;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? description;
|
||||
String? picture;
|
||||
int? orderNo;
|
||||
|
||||
MemberDataModel({this.committeeId, this.firstName, this.lastName, this.description, this.picture, this.orderNo});
|
||||
|
||||
MemberDataModel.fromJson(Map<String, dynamic> json) {
|
||||
committeeId = json['committeeId'];
|
||||
firstName = json['firstName'];
|
||||
lastName = json['lastName'];
|
||||
description = json['description'];
|
||||
picture = json['picture'];
|
||||
orderNo = json['orderNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['committeeId'] = this.committeeId;
|
||||
data['firstName'] = this.firstName;
|
||||
data['lastName'] = this.lastName;
|
||||
data['description'] = this.description;
|
||||
data['picture'] = this.picture;
|
||||
data['orderNo'] = this.orderNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
class ParentList {
|
||||
ParentList({
|
||||
required this.dbId,
|
||||
required this.text,
|
||||
required this.path,
|
||||
required this.isSelected,
|
||||
});
|
||||
|
||||
int dbId;
|
||||
String text;
|
||||
String path;
|
||||
bool isSelected;
|
||||
|
||||
factory ParentList.fromJson(Map<String, dynamic> json) => ParentList(
|
||||
dbId: json["dbId"] == null ? null : json["dbId"],
|
||||
text: json["text"] == null ? null : json["text"],
|
||||
path: json["path"] == null ? null : json["path"],
|
||||
isSelected: false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"dbId": dbId == null ? null : dbId,
|
||||
"text": text == null ? null : text,
|
||||
"path": path == null ? null : path,
|
||||
};
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
|
||||
class PostParamsModel {
|
||||
double? versionID;
|
||||
int? channel;
|
||||
int? languageID;
|
||||
String? mobileType;
|
||||
String? logInTokenID;
|
||||
String? tokenID;
|
||||
|
||||
PostParamsModel({this.versionID, this.channel, this.languageID, this.mobileType, this.logInTokenID, this.tokenID});
|
||||
|
||||
PostParamsModel.fromJson(Map<String, dynamic> json) {
|
||||
versionID = json['VersionID'];
|
||||
channel = json['Channel'];
|
||||
languageID = json['LanguageID'];
|
||||
mobileType = json['MobileType'];
|
||||
logInTokenID = json['LogInTokenID'];
|
||||
tokenID = json['TokenID'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['VersionID'] = this.versionID;
|
||||
data['Channel'] = this.channel;
|
||||
data['LanguageID'] = this.languageID;
|
||||
data['MobileType'] = this.mobileType;
|
||||
data['LogInTokenID'] = this.logInTokenID;
|
||||
data['TokenID'] = this.tokenID;
|
||||
return data;
|
||||
}
|
||||
|
||||
set setLogInTokenID(String? token) => logInTokenID = token;
|
||||
|
||||
set setTokenID(String? token) => tokenID = token;
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final branch = branchFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Branch branchFromJson(String str) => Branch.fromJson(json.decode(str));
|
||||
|
||||
String branchToJson(Branch data) => json.encode(data.toJson());
|
||||
|
||||
class Branch {
|
||||
Branch({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<BranchData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Branch.fromJson(Map<String, dynamic> json) => Branch(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<BranchData>.from(json["data"].map((x) => BranchData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class BranchData {
|
||||
BranchData({
|
||||
this.id,
|
||||
this.serviceProviderId,
|
||||
this.branchName,
|
||||
this.branchDescription,
|
||||
this.cityId,
|
||||
this.address,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.status,
|
||||
});
|
||||
|
||||
int? id;
|
||||
int? serviceProviderId;
|
||||
String? branchName;
|
||||
String? branchDescription;
|
||||
int? cityId;
|
||||
String? address;
|
||||
String? latitude;
|
||||
String? longitude;
|
||||
int? status;
|
||||
|
||||
factory BranchData.fromJson(Map<String, dynamic> json) => BranchData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"],
|
||||
branchName: json["branchName"] == null ? null : json["branchName"],
|
||||
branchDescription: json["branchDescription"] == null ? null : json["branchDescription"],
|
||||
cityId: json["cityID"] == null ? null : json["cityID"],
|
||||
address: json["address"] == null ? null : json["address"],
|
||||
latitude: json["latitude"] == null ? null : json["latitude"],
|
||||
longitude: json["longitude"] == null ? null : json["longitude"],
|
||||
status: json["status"] == null ? null : json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"serviceProviderID": serviceProviderId == null ? null : serviceProviderId,
|
||||
"branchName": branchName == null ? null : branchName,
|
||||
"branchDescription": branchDescription == null ? null : branchDescription,
|
||||
"cityID": cityId == null ? null : cityId,
|
||||
"address": address == null ? null : address,
|
||||
"latitude": latitude == null ? null : latitude,
|
||||
"longitude": longitude == null ? null : longitude,
|
||||
"status": status == null ? null : status,
|
||||
};
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final category = categoryFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Category categoryFromJson(String str) => Category.fromJson(json.decode(str));
|
||||
|
||||
String categoryToJson(Category data) => json.encode(data.toJson());
|
||||
|
||||
class Category {
|
||||
Category({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<CategoryData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) => Category(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<CategoryData>.from(json["data"].map((x) => CategoryData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class CategoryData {
|
||||
CategoryData({
|
||||
this.id,
|
||||
this.categoryName,
|
||||
this.categoryNameN,
|
||||
this.serviceCategoryIconUrl,
|
||||
this.serviceCategoryImageUrl,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? categoryName;
|
||||
String? categoryNameN;
|
||||
dynamic? serviceCategoryIconUrl;
|
||||
dynamic? serviceCategoryImageUrl;
|
||||
|
||||
factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
categoryName: json["categoryName"] == null ? null : json["categoryName"],
|
||||
categoryNameN: json["categoryNameN"] == null ? null : json["categoryNameN"],
|
||||
serviceCategoryIconUrl: json["serviceCategoryIconUrl"],
|
||||
serviceCategoryImageUrl: json["serviceCategoryImageUrl"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"categoryName": categoryName == null ? null : categoryName,
|
||||
"categoryNameN": categoryNameN == null ? null : categoryNameN,
|
||||
"serviceCategoryIconUrl": serviceCategoryIconUrl,
|
||||
"serviceCategoryImageUrl": serviceCategoryImageUrl,
|
||||
};
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final document = documentFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Document documentFromJson(String str) => Document.fromJson(json.decode(str));
|
||||
|
||||
String documentToJson(Document data) => json.encode(data.toJson());
|
||||
|
||||
class Document {
|
||||
Document({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<DocumentData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Document.fromJson(Map<String, dynamic> json) => Document(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<DocumentData>.from(json["data"].map((x) => DocumentData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class DocumentData {
|
||||
DocumentData({
|
||||
this.id,
|
||||
this.serviceProviderId,
|
||||
this.documentId,
|
||||
this.documentUrl,
|
||||
this.status,
|
||||
this.comment,
|
||||
this.isActive,
|
||||
this.document,
|
||||
this.fileExt,
|
||||
});
|
||||
|
||||
int? id;
|
||||
int? serviceProviderId;
|
||||
int? documentId;
|
||||
dynamic? documentUrl;
|
||||
int? status;
|
||||
dynamic? comment;
|
||||
bool? isActive;
|
||||
String? document;
|
||||
String? fileExt;
|
||||
|
||||
factory DocumentData.fromJson(Map<String, dynamic> json) => DocumentData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"],
|
||||
documentId: json["documentID"] == null ? null : json["documentID"],
|
||||
documentUrl: json["documentURL"],
|
||||
status: json["status"] == null ? null : json["status"],
|
||||
comment: json["comment"],
|
||||
isActive: json["isActive"] == null ? null : json["isActive"],
|
||||
document: null,
|
||||
fileExt: null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"serviceProviderID": serviceProviderId == null ? null : serviceProviderId,
|
||||
"documentID": documentId == null ? null : documentId,
|
||||
"documentURL": documentUrl,
|
||||
"status": status == null ? null : status,
|
||||
"comment": comment,
|
||||
"isActive": isActive == null ? null : isActive,
|
||||
};
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final services = servicesFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Services servicesFromJson(String str) => Services.fromJson(json.decode(str));
|
||||
|
||||
String servicesToJson(Services data) => json.encode(data.toJson());
|
||||
|
||||
class Services {
|
||||
Services({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<ServicesData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Services.fromJson(Map<String, dynamic> json) => Services(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<ServicesData>.from(json["data"].map((x) => ServicesData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class ServicesData {
|
||||
ServicesData({
|
||||
this.id,
|
||||
this.description,
|
||||
this.descriptionN,
|
||||
this.serviceIconUrl,
|
||||
this.serviceImageUrl,
|
||||
this.serviceCategoryId,
|
||||
this.categoryName,
|
||||
this.isSelected,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? description;
|
||||
String? descriptionN;
|
||||
dynamic? serviceIconUrl;
|
||||
dynamic? serviceImageUrl;
|
||||
int? serviceCategoryId;
|
||||
dynamic? categoryName;
|
||||
bool? isSelected;
|
||||
|
||||
factory ServicesData.fromJson(Map<String, dynamic> json) => ServicesData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
description: json["description"] == null ? null : json["description"],
|
||||
descriptionN: json["descriptionN"] == null ? null : json["descriptionN"],
|
||||
serviceIconUrl: json["serviceIconUrl"],
|
||||
serviceImageUrl: json["serviceImageUrl"],
|
||||
serviceCategoryId: json["serviceCategoryID"] == null ? null : json["serviceCategoryID"],
|
||||
categoryName: json["categoryName"],
|
||||
isSelected: false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"description": description == null ? null : description,
|
||||
"descriptionN": descriptionN == null ? null : descriptionN,
|
||||
"serviceIconUrl": serviceIconUrl,
|
||||
"serviceImageUrl": serviceImageUrl,
|
||||
"serviceCategoryID": serviceCategoryId == null ? null : serviceCategoryId,
|
||||
"categoryName": categoryName,
|
||||
};
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
///
|
||||
/// This example was taken from
|
||||
/// https://flutter.dev/docs/development/data-and-backend/json
|
||||
///
|
||||
|
||||
/// This allows the `User` class to access private members in
|
||||
/// the generated file. The value for this is *.g.dart, where
|
||||
/// the star denotes the source file name.
|
||||
|
||||
/// An annotation for the code generator to know that this class needs the
|
||||
/// JSON serialization logic to be generated.
|
||||
|
||||
class BackendResponse {
|
||||
BackendResponse({required this.id, required this.isOk, required this.result});
|
||||
|
||||
int id;
|
||||
bool isOk;
|
||||
dynamic result;
|
||||
|
||||
/// A necessary factory constructor for creating a new User instance
|
||||
/// from a map. Pass the map to the generated `_$UserFromJson()` constructor.
|
||||
/// The constructor is named after the source class, in this case, User.
|
||||
factory BackendResponse.fromJson(Map<String, dynamic> json) =>
|
||||
BackendResponse(
|
||||
id: 1,
|
||||
isOk: false,
|
||||
result: null,
|
||||
);
|
||||
//
|
||||
// /// `toJson` is the convention for a class to declare support for serialization
|
||||
// /// to JSON. The implementation simply calls the private, generated
|
||||
// /// helper method `_$UserToJson`.
|
||||
// Map<String, dynamic> toJson() => _$BackendResponseToJson(this);
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
class SurahModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<SurahModelData>? data;
|
||||
|
||||
SurahModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
SurahModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(SurahModelData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = totalItemsCount;
|
||||
data['statusCode'] = statusCode;
|
||||
data['message'] = message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class SurahModelData {
|
||||
int? id;
|
||||
int? surahID;
|
||||
String? nameAR;
|
||||
String? nameEN;
|
||||
int? numberOfAyahs;
|
||||
String? englishNameTranslation;
|
||||
int? revelationID;
|
||||
String? revelationType;
|
||||
int? startPageNo;
|
||||
int? endPageNo;
|
||||
|
||||
SurahModelData({this.id, this.surahID, this.nameAR, this.nameEN, this.numberOfAyahs, this.englishNameTranslation, this.revelationID, this.revelationType, this.startPageNo, this.endPageNo});
|
||||
|
||||
SurahModelData.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
surahID = json['surahID'];
|
||||
nameAR = json['nameAR'];
|
||||
nameEN = json['nameEN'];
|
||||
numberOfAyahs = json['numberOfAyahs'];
|
||||
englishNameTranslation = json['englishNameTranslation'];
|
||||
revelationID = json['revelation_ID'];
|
||||
revelationType = json['revelationType'];
|
||||
startPageNo = json['startPageNo'];
|
||||
endPageNo = json['endPageNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['surahID'] = this.surahID;
|
||||
data['nameAR'] = this.nameAR;
|
||||
data['nameEN'] = this.nameEN;
|
||||
data['numberOfAyahs'] = this.numberOfAyahs;
|
||||
data['englishNameTranslation'] = this.englishNameTranslation;
|
||||
data['revelation_ID'] = this.revelationID;
|
||||
data['revelationType'] = this.revelationType;
|
||||
data['startPageNo'] = this.startPageNo;
|
||||
data['endPageNo'] = this.endPageNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final basicOtp = basicOtpFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
BasicOtpRespModel basicOtpFromJson(String str) => BasicOtpRespModel.fromJson(json.decode(str));
|
||||
|
||||
String basicOtpToJson(BasicOtpRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class BasicOtpRespModel {
|
||||
BasicOtpRespModel({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
dynamic totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory BasicOtpRespModel.fromJson(Map<String, dynamic> json) => BasicOtpRespModel(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : Data.fromJson(json["data"]),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
this.userToken,
|
||||
});
|
||||
|
||||
String? userToken;
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
userToken: checkValue(json),
|
||||
);
|
||||
|
||||
static String checkValue(Map<String, dynamic> json) {
|
||||
try {
|
||||
return json["userToken"] == null ? null : json["userToken"];
|
||||
} catch (e) {
|
||||
return json["token"] == null ? null : json["token"];
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"userToken": userToken == null ? null : userToken,
|
||||
};
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ChanEmailRespModel changeEmailFromJson(String str) => ChanEmailRespModel.fromJson(json.decode(str));
|
||||
|
||||
String changeEmailToJson(ChanEmailRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class ChanEmailRespModel {
|
||||
int? messageStatus;
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
String? message;
|
||||
|
||||
ChanEmailRespModel(
|
||||
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||
|
||||
ChanEmailRespModel.fromJson(Map<String, dynamic> json) {
|
||||
messageStatus = json['messageStatus'];
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ChangeMobileRespModel changeMobileFromJson(String str) => ChangeMobileRespModel.fromJson(json.decode(str));
|
||||
|
||||
String changeMobileToJson(ChangeMobileRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class ChangeMobileRespModel {
|
||||
int? messageStatus;
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
String? message;
|
||||
|
||||
ChangeMobileRespModel(
|
||||
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||
|
||||
ChangeMobileRespModel.fromJson(Map<String, dynamic> json) {
|
||||
messageStatus = json['messageStatus'];
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ChangePassword changePasswordFromJson(String str) => ChangePassword.fromJson(json.decode(str));
|
||||
|
||||
String changePasswordToJson(ChangePassword data) => json.encode(data.toJson());
|
||||
|
||||
class ChangePassword {
|
||||
int? messageStatus;
|
||||
Null? totalItemsCount;
|
||||
bool? data;
|
||||
String? message;
|
||||
|
||||
ChangePassword(
|
||||
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||
|
||||
ChangePassword.fromJson(Map<String, dynamic> json) {
|
||||
messageStatus = json['messageStatus'];
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['data'] = this.data;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final cities = citiesFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Cities citiesFromJson(String str) => Cities.fromJson(json.decode(str));
|
||||
|
||||
String citiesToJson(Cities data) => json.encode(data.toJson());
|
||||
|
||||
class Cities {
|
||||
Cities({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<CityData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Cities.fromJson(Map<String, dynamic> json) => Cities(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<CityData>.from(json["data"].map((x) => CityData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class CityData {
|
||||
CityData({
|
||||
this.id,
|
||||
this.cityName,
|
||||
this.cityNameN,
|
||||
this.countryId,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? cityName;
|
||||
String? cityNameN;
|
||||
int? countryId;
|
||||
|
||||
factory CityData.fromJson(Map<String, dynamic> json) => CityData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
cityName: json["cityName"] == null ? null : json["cityName"],
|
||||
cityNameN: json["cityNameN"] == null ? null : json["cityNameN"],
|
||||
countryId: json["countryID"] == null ? null : json["countryID"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"cityName": cityName == null ? null : cityName,
|
||||
"cityNameN": cityNameN == null ? null : cityNameN,
|
||||
"countryID": countryId == null ? null : countryId,
|
||||
};
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ConfirmEmailRespModel confirmEmailFromJson(String str) => ConfirmEmailRespModel.fromJson(json.decode(str));
|
||||
|
||||
String confirmEmailToJson(ConfirmEmailRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class ConfirmEmailRespModel {
|
||||
int? messageStatus;
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
String? message;
|
||||
|
||||
ConfirmEmailRespModel(
|
||||
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||
|
||||
ConfirmEmailRespModel.fromJson(Map<String, dynamic> json) {
|
||||
messageStatus = json['messageStatus'];
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userID;
|
||||
|
||||
Data({this.userID});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ConfirmMobileRespModel confirmMobileFromJson(String str) => ConfirmMobileRespModel.fromJson(json.decode(str));
|
||||
|
||||
String confirmMobileToJson(ConfirmMobileRespModel data) => json.encode(data.toJson());
|
||||
|
||||
|
||||
class ConfirmMobileRespModel {
|
||||
int? messageStatus;
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
String? message;
|
||||
|
||||
ConfirmMobileRespModel(
|
||||
{this.messageStatus, this.totalItemsCount, this.data, this.message});
|
||||
|
||||
ConfirmMobileRespModel.fromJson(Map<String, dynamic> json) {
|
||||
messageStatus = json['messageStatus'];
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userID;
|
||||
|
||||
Data({this.userID});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userID = json['userID'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ConfirmPasswordRespModel confirmPasswordFromJson(String str) => ConfirmPasswordRespModel.fromJson(json.decode(str));
|
||||
|
||||
String confirmPasswordToJson(ConfirmPasswordRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class ConfirmPasswordRespModel {
|
||||
dynamic totalItemsCount;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
ConfirmPasswordRespModel(
|
||||
{this.totalItemsCount, this.messageStatus, this.message});
|
||||
|
||||
ConfirmPasswordRespModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final country = countryFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Country countryFromJson(String str) => Country.fromJson(json.decode(str));
|
||||
|
||||
String countryToJson(Country data) => json.encode(data.toJson());
|
||||
|
||||
class Country {
|
||||
Country({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<CountryData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<CountryData>.from(json["data"].map((x) => CountryData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class CountryData {
|
||||
CountryData({
|
||||
this.id,
|
||||
this.countryName,
|
||||
this.countryNameN,
|
||||
this.nationality,
|
||||
this.nationalityN,
|
||||
this.countryCode,
|
||||
this.alpha2Code,
|
||||
this.alpha3Code,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? countryName;
|
||||
String? countryNameN;
|
||||
String? nationality;
|
||||
String? nationalityN;
|
||||
String? countryCode;
|
||||
String? alpha2Code;
|
||||
String? alpha3Code;
|
||||
|
||||
factory CountryData.fromJson(Map<String, dynamic> json) => CountryData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
countryName: json["countryName"] == null ? null : json["countryName"],
|
||||
countryNameN: json["countryNameN"] == null ? null : json["countryNameN"],
|
||||
nationality: json["nationality"] == null ? null : json["nationality"],
|
||||
nationalityN: json["nationalityN"] == null ? null : json["nationalityN"],
|
||||
countryCode: json["countryCode"] == null ? null : json["countryCode"],
|
||||
alpha2Code: json["alpha2Code"] == null ? null : json["alpha2Code"],
|
||||
alpha3Code: json["alpha3Code"] == null ? null : json["alpha3Code"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"countryName": countryName == null ? null : countryName,
|
||||
"countryNameN": countryNameN == null ? null : countryNameN,
|
||||
"nationality": nationality == null ? null : nationality,
|
||||
"nationalityN": nationalityN == null ? null : nationalityN,
|
||||
"countryCode": countryCode == null ? null : countryCode,
|
||||
"alpha2Code": alpha2Code == null ? null : alpha2Code,
|
||||
"alpha3Code": alpha3Code == null ? null : alpha3Code,
|
||||
};
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmail verifyEmailFromJson(String str) => VerifyEmail.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailToJson(VerifyEmail data) => json.encode(data.toJson());
|
||||
|
||||
|
||||
class VerifyEmail {
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
VerifyEmail(
|
||||
{this.totalItemsCount, this.data, this.messageStatus, this.message});
|
||||
|
||||
VerifyEmail.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmailOTP verifyEmailOTPFromJson(String str) => VerifyEmailOTP.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailOTPToJson(VerifyEmailOTP data) => json.encode(data.toJson());
|
||||
|
||||
class VerifyEmailOTP {
|
||||
bool? success;
|
||||
Null? errors;
|
||||
|
||||
VerifyEmailOTP({this.success, this.errors});
|
||||
|
||||
VerifyEmailOTP.fromJson(Map<String, dynamic> json) {
|
||||
success = json['success'];
|
||||
errors = json['errors'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['success'] = this.success;
|
||||
data['errors'] = this.errors;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
PasswordOTPCompareResModel otpCompareFromJson(String str) => PasswordOTPCompareResModel.fromJson(json.decode(str));
|
||||
|
||||
String otpCompareToJson(PasswordOTPCompareResModel data) => json.encode(data.toJson());
|
||||
|
||||
class PasswordOTPCompareResModel {
|
||||
dynamic totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
PasswordOTPCompareResModel({this.totalItemsCount, this.data, this.messageStatus, this.message});
|
||||
|
||||
PasswordOTPCompareResModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
PasswordOTPRequestRespModel otpRequestFromJson(String str) => PasswordOTPRequestRespModel.fromJson(json.decode(str));
|
||||
|
||||
String otpRequestToJson(PasswordOTPRequestRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class PasswordOTPRequestRespModel {
|
||||
dynamic totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
PasswordOTPRequestRespModel(
|
||||
{this.totalItemsCount, this.data, this.messageStatus, this.message});
|
||||
|
||||
PasswordOTPRequestRespModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final imageResponse = imageResponseFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
ImageResponse imageResponseFromJson(String str) => ImageResponse.fromJson(json.decode(str));
|
||||
|
||||
String imageResponseToJson(ImageResponse data) => json.encode(data.toJson());
|
||||
|
||||
class ImageResponse {
|
||||
ImageResponse({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
dynamic? totalItemsCount;
|
||||
String? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory ImageResponse.fromJson(Map<String, dynamic> json) => ImageResponse(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : json["data"],
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data,
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final loginPassword = loginPasswordFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
LoginPasswordRespModel loginPasswordFromJson(String str) => LoginPasswordRespModel.fromJson(json.decode(str));
|
||||
|
||||
String loginPasswordToJson(LoginPasswordRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class LoginPasswordRespModel {
|
||||
LoginPasswordRespModel({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
dynamic totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory LoginPasswordRespModel.fromJson(Map<String, dynamic> json) => LoginPasswordRespModel(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : Data.fromJson(json["data"]),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
this.userToken,
|
||||
});
|
||||
|
||||
String? userToken;
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
userToken: json["userToken"] == null ? null : json["userToken"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"userToken": userToken == null ? null : userToken,
|
||||
};
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final refreshToken = refreshTokenFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
RefreshToken refreshTokenFromJson(String str) => RefreshToken.fromJson(json.decode(str));
|
||||
|
||||
String refreshTokenToJson(RefreshToken data) => json.encode(data.toJson());
|
||||
|
||||
class RefreshToken {
|
||||
RefreshToken({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
final dynamic? totalItemsCount;
|
||||
final RefreshData? data;
|
||||
final int? messageStatus;
|
||||
final String? message;
|
||||
|
||||
factory RefreshToken.fromJson(Map<String, dynamic> json) => RefreshToken(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : RefreshData.fromJson(json["data"]),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class RefreshData {
|
||||
RefreshData({
|
||||
this.accessToken,
|
||||
this.refreshToken,
|
||||
this.expiryDate,
|
||||
this.userInfo,
|
||||
});
|
||||
|
||||
final String? accessToken;
|
||||
final String? refreshToken;
|
||||
final DateTime? expiryDate;
|
||||
final dynamic? userInfo;
|
||||
|
||||
factory RefreshData.fromJson(Map<String, dynamic> json) => RefreshData(
|
||||
accessToken: json["accessToken"] == null ? null : json["accessToken"],
|
||||
refreshToken: json["refreshToken"] == null ? null : json["refreshToken"],
|
||||
expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
|
||||
userInfo: json["userInfo"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"accessToken": accessToken == null ? null : accessToken,
|
||||
"refreshToken": refreshToken == null ? null : refreshToken,
|
||||
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
|
||||
"userInfo": userInfo,
|
||||
};
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final registerUser = registerUserFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
RegisterUserRespModel registerUserFromJson(String str) => RegisterUserRespModel.fromJson(json.decode(str));
|
||||
|
||||
String registerUserToJson(RegisterUserRespModel data) => json.encode(data.toJson());
|
||||
|
||||
class RegisterUserRespModel {
|
||||
RegisterUserRespModel({
|
||||
this.messageStatus,
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.message,
|
||||
});
|
||||
|
||||
final int? messageStatus;
|
||||
final dynamic? totalItemsCount;
|
||||
final Data? data;
|
||||
final String? message;
|
||||
|
||||
factory RegisterUserRespModel.fromJson(Map<String, dynamic> json) => RegisterUserRespModel(
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : Data.fromJson(json["data"]),
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
this.id,
|
||||
this.userId,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.mobileNo,
|
||||
this.email,
|
||||
this.userImageUrl,
|
||||
this.roleId,
|
||||
this.roleName,
|
||||
this.isEmailVerified,
|
||||
this.serviceProviderBranch,
|
||||
this.isVerified,
|
||||
this.userRoles,
|
||||
this.isCustomer,
|
||||
this.isProviderDealership,
|
||||
this.isProviderIndividual,
|
||||
this.isDealershipUser,
|
||||
this.providerId,
|
||||
this.customerId,
|
||||
this.dealershipId,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? userId;
|
||||
final dynamic? firstName;
|
||||
final dynamic? lastName;
|
||||
final String? mobileNo;
|
||||
final String? email;
|
||||
final dynamic? userImageUrl;
|
||||
final int? roleId;
|
||||
final dynamic? roleName;
|
||||
final bool? isEmailVerified;
|
||||
final List<dynamic>? serviceProviderBranch;
|
||||
final bool? isVerified;
|
||||
final List<dynamic>? userRoles;
|
||||
final bool? isCustomer;
|
||||
final bool? isProviderDealership;
|
||||
final bool? isProviderIndividual;
|
||||
final bool? isDealershipUser;
|
||||
final dynamic? providerId;
|
||||
final dynamic? customerId;
|
||||
final dynamic? dealershipId;
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
userId: json["userID"] == null ? null : json["userID"],
|
||||
firstName: json["firstName"],
|
||||
lastName: json["lastName"],
|
||||
mobileNo: json["mobileNo"] == null ? null : json["mobileNo"],
|
||||
email: json["email"] == null ? null : json["email"],
|
||||
userImageUrl: json["userImageUrl"],
|
||||
roleId: json["roleID"] == null ? null : json["roleID"],
|
||||
roleName: json["roleName"],
|
||||
isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"],
|
||||
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
|
||||
isVerified: json["isVerified"] == null ? null : json["isVerified"],
|
||||
userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
|
||||
isCustomer: json["isCustomer"] == null ? null : json["isCustomer"],
|
||||
isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"],
|
||||
isProviderIndividual: json["isProviderIndividual"] == null ? null : json["isProviderIndividual"],
|
||||
isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"],
|
||||
providerId: json["providerID"],
|
||||
customerId: json["customerID"],
|
||||
dealershipId: json["dealershipID"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"userID": userId == null ? null : userId,
|
||||
"firstName": firstName,
|
||||
"lastName": lastName,
|
||||
"mobileNo": mobileNo == null ? null : mobileNo,
|
||||
"email": email == null ? null : email,
|
||||
"userImageUrl": userImageUrl,
|
||||
"roleID": roleId == null ? null : roleId,
|
||||
"roleName": roleName,
|
||||
"isEmailVerified": isEmailVerified == null ? null : isEmailVerified,
|
||||
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
|
||||
"isVerified": isVerified == null ? null : isVerified,
|
||||
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
|
||||
"isCustomer": isCustomer == null ? null : isCustomer,
|
||||
"isProviderDealership": isProviderDealership == null ? null : isProviderDealership,
|
||||
"isProviderIndividual": isProviderIndividual == null ? null : isProviderIndividual,
|
||||
"isDealershipUser": isDealershipUser == null ? null : isDealershipUser,
|
||||
"providerID": providerId,
|
||||
"customerID": customerId,
|
||||
"dealershipID": dealershipId,
|
||||
};
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final role = roleFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Role roleFromJson(String str) => Role.fromJson(json.decode(str));
|
||||
|
||||
String roleToJson(Role data) => json.encode(data.toJson());
|
||||
|
||||
class Role {
|
||||
Role({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<RoleData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Role.fromJson(Map<String, dynamic> json) => Role(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<RoleData>.from(json["data"].map((x) => RoleData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class RoleData {
|
||||
RoleData({
|
||||
this.id,
|
||||
this.roleName,
|
||||
this.roleNameN,
|
||||
this.isActive,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? roleName;
|
||||
String? roleNameN;
|
||||
bool? isActive;
|
||||
|
||||
factory RoleData.fromJson(Map<String, dynamic> json) => RoleData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
roleName: json["roleName"] == null ? null : json["roleName"],
|
||||
roleNameN: json["roleNameN"] == null ? null : json["roleNameN"],
|
||||
isActive: json["isActive"] == null ? null : json["isActive"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"roleName": roleName == null ? null : roleName,
|
||||
"roleNameN": roleNameN == null ? null : roleNameN,
|
||||
"isActive": isActive == null ? null : isActive,
|
||||
};
|
||||
}
|
||||
@ -1,153 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final user = userFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
User userFromJson(String str) => User.fromJson(json.decode(str));
|
||||
|
||||
String userToJson(User data) => json.encode(data.toJson());
|
||||
|
||||
class User {
|
||||
User({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
dynamic totalItemsCount;
|
||||
UserData? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : UserData.fromJson(json["data"]),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class UserData {
|
||||
UserData({
|
||||
this.accessToken,
|
||||
this.refreshToken,
|
||||
this.expiryDate,
|
||||
this.userInfo,
|
||||
});
|
||||
|
||||
String? accessToken;
|
||||
String? refreshToken;
|
||||
DateTime? expiryDate;
|
||||
UserInfo? userInfo;
|
||||
|
||||
factory UserData.fromJson(Map<String, dynamic> json) => UserData(
|
||||
accessToken: json["accessToken"] == null ? null : json["accessToken"],
|
||||
refreshToken: json["refreshToken"] == null ? null : json["refreshToken"],
|
||||
expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
|
||||
userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"accessToken": accessToken == null ? null : accessToken,
|
||||
"refreshToken": refreshToken == null ? null : refreshToken,
|
||||
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
|
||||
"userInfo": userInfo == null ? null : userInfo!.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class UserInfo {
|
||||
UserInfo({
|
||||
this.id,
|
||||
this.userId,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.mobileNo,
|
||||
this.email,
|
||||
this.userImageUrl,
|
||||
this.roleId,
|
||||
this.roleName,
|
||||
this.isEmailVerified,
|
||||
this.serviceProviderBranch,
|
||||
this.isVerified,
|
||||
this.userRoles,
|
||||
this.isCustomer,
|
||||
this.isProviderDealership,
|
||||
this.isDealershipUser,
|
||||
this.providerId,
|
||||
this.customerId,
|
||||
this.dealershipId,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? userId;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? mobileNo;
|
||||
String? email;
|
||||
dynamic userImageUrl;
|
||||
int? roleId;
|
||||
String? roleName;
|
||||
bool? isEmailVerified;
|
||||
List<dynamic>? serviceProviderBranch;
|
||||
bool? isVerified;
|
||||
List<dynamic>? userRoles;
|
||||
bool? isCustomer;
|
||||
bool? isProviderDealership;
|
||||
bool? isDealershipUser;
|
||||
dynamic providerId;
|
||||
int? customerId;
|
||||
dynamic dealershipId;
|
||||
|
||||
factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
userId: json["userID"] == null ? null : json["userID"],
|
||||
firstName: json["firstName"] == null ? null : json["firstName"],
|
||||
lastName: json["lastName"] == null ? null : json["lastName"],
|
||||
mobileNo: json["mobileNo"] == null ? null : json["mobileNo"],
|
||||
email: json["email"] == null ? null : json["email"],
|
||||
userImageUrl: json["userImageUrl"],
|
||||
roleId: json["roleID"] == null ? null : json["roleID"],
|
||||
roleName: json["roleName"] == null ? null : json["roleName"],
|
||||
isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"],
|
||||
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
|
||||
isVerified: json["isVerified"] == null ? null : json["isVerified"],
|
||||
userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
|
||||
isCustomer: json["isCustomer"] == null ? null : json["isCustomer"],
|
||||
isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"],
|
||||
isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"],
|
||||
providerId: json["providerID"],
|
||||
customerId: json["customerID"] == null ? null : json["customerID"],
|
||||
dealershipId: json["dealershipID"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"userID": userId == null ? null : userId,
|
||||
"firstName": firstName == null ? null : firstName,
|
||||
"lastName": lastName == null ? null : lastName,
|
||||
"mobileNo": mobileNo == null ? null : mobileNo,
|
||||
"email": email == null ? null : email,
|
||||
"userImageUrl": userImageUrl,
|
||||
"roleID": roleId == null ? null : roleId,
|
||||
"roleName": roleName == null ? null : roleName,
|
||||
"isEmailVerified": isEmailVerified == null ? null : isEmailVerified,
|
||||
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
|
||||
"isVerified": isVerified == null ? null : isVerified,
|
||||
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
|
||||
"isCustomer": isCustomer == null ? null : isCustomer,
|
||||
"isProviderDealership": isProviderDealership == null ? null : isProviderDealership,
|
||||
"isDealershipUser": isDealershipUser == null ? null : isDealershipUser,
|
||||
"providerID": providerId,
|
||||
"customerID": customerId == null ? null : customerId,
|
||||
"dealershipID": dealershipId,
|
||||
};
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmailRespModel verifyEmailFromJson(String str) => VerifyEmailRespModel.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailToJson(VerifyEmailRespModel data) => json.encode(data.toJson());
|
||||
|
||||
|
||||
class VerifyEmailRespModel {
|
||||
Null? totalItemsCount;
|
||||
Data? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
VerifyEmailRespModel(
|
||||
{this.totalItemsCount, this.data, this.messageStatus, this.message});
|
||||
|
||||
VerifyEmailRespModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
messageStatus = json['messageStatus'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.toJson();
|
||||
}
|
||||
data['messageStatus'] = this.messageStatus;
|
||||
data['message'] = this.message;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
String? userToken;
|
||||
|
||||
Data({this.userToken});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
userToken = json['userToken'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['userToken'] = this.userToken;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
VerifyEmailOTP verifyEmailOTPFromJson(String str) => VerifyEmailOTP.fromJson(json.decode(str));
|
||||
|
||||
String verifyEmailOTPToJson(VerifyEmailOTP data) => json.encode(data.toJson());
|
||||
|
||||
class VerifyEmailOTP {
|
||||
bool? success;
|
||||
Null? errors;
|
||||
|
||||
VerifyEmailOTP({this.success, this.errors});
|
||||
|
||||
VerifyEmailOTP.fromJson(Map<String, dynamic> json) {
|
||||
success = json['success'];
|
||||
errors = json['errors'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['success'] = this.success;
|
||||
data['errors'] = this.errors;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
|
||||
@ -1,291 +0,0 @@
|
||||
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 ?? "";
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
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,35 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'permission_handler.dart';
|
||||
|
||||
Future<ConfirmAction?> showConfirmDialogs(
|
||||
context, msg, positiveText, negativeText) async {
|
||||
return showDialog<ConfirmAction>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
title: Text(msg, style: TextStyle(fontSize: 16)),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
negativeText,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(ConfirmAction.CANCEL);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
positiveText,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(ConfirmAction.ACCEPT);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
// 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,14 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
navigateWithName(BuildContext context, String routeName, {Object? arguments}) {
|
||||
Navigator.pushNamed(context, routeName, arguments: arguments);
|
||||
}
|
||||
|
||||
|
||||
navigateReplaceWithName(BuildContext context, String routeName, {Object? arguments}) {
|
||||
Navigator.pushReplacementNamed(context, routeName, arguments: arguments);
|
||||
}
|
||||
|
||||
pop(BuildContext context) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import 'dialogs.dart';
|
||||
|
||||
enum ConfirmAction { CANCEL, ACCEPT }
|
||||
|
||||
Future<bool> requestPermissionGranted(
|
||||
context, Permission requestPermissions) async {
|
||||
var result = await requestPermissions.request();
|
||||
|
||||
switch (result) {
|
||||
case PermissionStatus.granted:
|
||||
// Application has been given permission to use the feature.
|
||||
return true;
|
||||
case PermissionStatus.denied:
|
||||
// Application has been denied permission to use the feature.
|
||||
return false;
|
||||
case PermissionStatus.permanentlyDenied:
|
||||
ConfirmAction? res = await showConfirmDialogs(
|
||||
context,
|
||||
'You was denied Permission. You have give manual permission from app setting. ',
|
||||
'Open App Setting',
|
||||
'Cancel');
|
||||
if (res == ConfirmAction.ACCEPT) {
|
||||
return false;
|
||||
} else if (res == ConfirmAction.CANCEL) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
case PermissionStatus.restricted:
|
||||
// iOS has restricted access to a specific feature.
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SharedPrefManager {
|
||||
static String USER_ID = "user.id";
|
||||
static String USER_TOKEN = "user.token";
|
||||
static String USER_NAME = "user.name";
|
||||
static String PASSWORD = "user.password";
|
||||
static String REFRESH_TOKEN = "user.refresh.token";
|
||||
static String DATA = "data";
|
||||
|
||||
static final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||
|
||||
static setUserId(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(USER_ID, cookie) ;
|
||||
}
|
||||
|
||||
static Future<String> getUserId() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(USER_ID) ?? "";
|
||||
}
|
||||
|
||||
static setUserToken(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(USER_TOKEN, cookie) ;
|
||||
}
|
||||
|
||||
static Future<String> getUserToken() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(USER_TOKEN) ?? "";
|
||||
}
|
||||
|
||||
static setPhoneOrEmail(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(USER_NAME, cookie) ;
|
||||
}
|
||||
|
||||
static Future<String> getPhoneOrEmail() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(USER_NAME) ?? "";
|
||||
}
|
||||
|
||||
static setUserPassword(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(PASSWORD, cookie) ;
|
||||
}
|
||||
|
||||
static Future<String> getUserPassword() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(PASSWORD) ?? "";
|
||||
}
|
||||
|
||||
static setRefreshToken(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(REFRESH_TOKEN, cookie) ;
|
||||
}
|
||||
|
||||
static Future<String> getRefreshToken() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(REFRESH_TOKEN) ?? "";
|
||||
}
|
||||
|
||||
static setData(String cookie) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString(DATA, cookie);
|
||||
}
|
||||
|
||||
static Future<String> getData() async {
|
||||
SharedPreferences prefs = await _prefs;
|
||||
return prefs.getString(DATA) ?? "";
|
||||
}
|
||||
}
|
||||
@ -1,306 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:car_customer_app/exceptions/api_exception.dart';
|
||||
import 'package:car_customer_app/widgets/loading_dialog.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);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getColorFromHex(String hexColor) {
|
||||
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
||||
|
||||
if (hexColor.length == 6) {
|
||||
hexColor = 'FF' + hexColor;
|
||||
}
|
||||
|
||||
return Color(int.parse(hexColor, radix: 16));
|
||||
}
|
||||
|
||||
static Widget spacerVertical(double v) {
|
||||
return SizedBox(
|
||||
height: v,
|
||||
width: double.infinity,
|
||||
);
|
||||
}
|
||||
|
||||
static String convertFileToBase64(File file) {
|
||||
List<int> imageBytes = file.readAsBytesSync();
|
||||
return base64Encode(imageBytes);
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
static Widget mDivider(Color color, {double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: h ?? 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
|
||||
static Widget mDivider3({double? h}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: h ?? 1,
|
||||
color: borderLightColor!.withOpacity(0.7),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget mDivider2(Color color, double w) {
|
||||
return Container(
|
||||
width: w,
|
||||
height: 1,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget mFlex(int f) {
|
||||
return Flexible(
|
||||
flex: f,
|
||||
child: const SizedBox(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget mExp(int f) {
|
||||
return Expanded(
|
||||
flex: f,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static spacer() {
|
||||
return const SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
}
|
||||
|
||||
static cardRadius(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
static cardRadiusWithoutBorder(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
side: const BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
);
|
||||
}
|
||||
|
||||
static Image imageFromBase64String(String base64String) {
|
||||
return Image.memory(base64Decode(base64String));
|
||||
}
|
||||
|
||||
static Uint8List dataFromBase64String(String base64String) {
|
||||
return base64Decode(base64String);
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Decoration containerRadius(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.all(Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
|
||||
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)),
|
||||
);
|
||||
}
|
||||
|
||||
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)),
|
||||
);
|
||||
}
|
||||
|
||||
static Decoration containerRadiusBottom(Color color, double r) {
|
||||
return BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(r), bottomRight: Radius.circular(r)),
|
||||
);
|
||||
}
|
||||
|
||||
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)),
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
static ShapeBorder cardRadiusTop2(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
||||
);
|
||||
}
|
||||
|
||||
static ShapeBorder cardRadiusBottom(double radius) {
|
||||
return RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.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),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -1,477 +0,0 @@
|
||||
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 ?? "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
import 'package:car_customer_app/config/routes.dart';
|
||||
import 'package:car_customer_app/utils/navigator.dart';
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SplashPage extends StatelessWidget {
|
||||
const SplashPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
performTimer(context);
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
color: Colors.black,
|
||||
child: Column(
|
||||
children: [
|
||||
Utils. mExp(1),
|
||||
Expanded(
|
||||
child: Image.asset(
|
||||
"assets/images/ic_logo_white.png",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 10,
|
||||
child: Image.asset(
|
||||
"assets/images/bn_car.jpeg",
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: 00,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Image.asset(
|
||||
"assets/images/ic_engine.png",
|
||||
),
|
||||
),
|
||||
Utils.mExp(1),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
performTimer(BuildContext context) {
|
||||
Utils.delay(3).whenComplete(() {
|
||||
navigateReplaceWithName(context, AppRoutes.registerSelection);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,164 +0,0 @@
|
||||
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,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
|
||||
import 'package:car_customer_app/extensions/string_extensions.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/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 ConfirmNewPasswordPage extends StatelessWidget {
|
||||
final String userToken;
|
||||
|
||||
ConfirmNewPasswordPage(this.userToken, {Key? key}) : super(key: key);
|
||||
|
||||
String newPassword = "";
|
||||
|
||||
@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.newPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||
12.height,
|
||||
TxtField(
|
||||
// hint: "Enter New Password",
|
||||
hint: LocaleKeys.enterNewPassword.tr(),
|
||||
value: newPassword,
|
||||
onChanged: (v) {
|
||||
newPassword = v;
|
||||
},
|
||||
),
|
||||
40.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.confirm.tr(),
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () async {
|
||||
await userVM.confirmPasswordOTP(
|
||||
context,
|
||||
newPassword: newPassword,
|
||||
userToken: userToken,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1,159 +0,0 @@
|
||||
import 'package:car_customer_app/classes/app_state.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/utils/navigator.dart';
|
||||
import 'package:car_customer_app/view_models/user_view_model.dart';
|
||||
import 'package:car_customer_app/widgets/app_bar.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
class EditAccountPage extends StatefulWidget {
|
||||
const EditAccountPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<EditAccountPage> createState() => _EditAccountPageState();
|
||||
}
|
||||
|
||||
class _EditAccountPageState extends State<EditAccountPage> {
|
||||
String userID = "";
|
||||
String email = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserVM userVM = context.read<UserVM>();
|
||||
return Scaffold(
|
||||
appBar: appBar(context, title: LocaleKeys.editAccount.tr()),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
20.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/ic_lock.svg",
|
||||
color: MyColors.darkPrimaryColor,
|
||||
width: 16,
|
||||
),
|
||||
20.width,
|
||||
Expanded(child: LocaleKeys.changePassword.tr().toText(isBold: true, fontSize: 12)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
backgroundColor: MyColors.darkPrimaryColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
),
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.changePassword);
|
||||
},
|
||||
child: Text(
|
||||
LocaleKeys.change.tr(),
|
||||
style: const TextStyle(
|
||||
fontSize: 14, letterSpacing: -0.48,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 23 / 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
15.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/ic_mobile.svg",
|
||||
color: MyColors.darkPrimaryColor,
|
||||
width: 16,
|
||||
),
|
||||
20.width,
|
||||
Expanded(child: LocaleKeys.changeMobile.tr().toText(isBold: true, fontSize: 12)),
|
||||
LocaleKeys.verify.tr().toText(color: Colors.green, fontSize: 12),
|
||||
20.width,
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
backgroundColor: MyColors.darkPrimaryColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
),
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.changeMobilePage);
|
||||
},
|
||||
child: Text(
|
||||
LocaleKeys.change.tr(),
|
||||
style: const TextStyle(fontSize: 14, height: 23 / 24,fontWeight: FontWeight.w600),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
20.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/ic_email.svg",
|
||||
color: MyColors.darkPrimaryColor,
|
||||
width: 16,
|
||||
),
|
||||
20.width,
|
||||
Expanded(child: LocaleKeys.changeEmail.tr().toText(isBold: true, fontSize: 12)),
|
||||
InkWell(
|
||||
child: ((AppState().getUser.data!.userInfo!.isEmailVerified ?? false) ? LocaleKeys.verified.tr() : LocaleKeys.verify.tr()).toText(
|
||||
color: Colors.green,
|
||||
fontSize: 12,
|
||||
),
|
||||
onTap: (AppState().getUser.data!.userInfo!.isEmailVerified ?? false)
|
||||
? null
|
||||
: () async {
|
||||
await userVM.verifyEmail(context, email: email, userID: userID);
|
||||
},
|
||||
),
|
||||
20.width,
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
backgroundColor: MyColors.darkPrimaryColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
),
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.changeEmailPage);
|
||||
},
|
||||
child: Text(
|
||||
LocaleKeys.change.tr(),
|
||||
style: const TextStyle(fontSize: 14, height: 23 / 24, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
// ListTile(
|
||||
// leading: SvgPicture.asset("assets/images/ic_mobile.svg"),
|
||||
// title: "Change Mobile".toText12(),
|
||||
// onTap: () {
|
||||
// navigateWithName(context, AppRoutes.changeMobilePage);
|
||||
// },
|
||||
// ),
|
||||
// ListTile(
|
||||
// leading: Icon(Icons.email_outlined, color: Colors.blue,),
|
||||
// title: "Change Email".toText12(),
|
||||
// onTap: () {
|
||||
// navigateWithName(context, AppRoutes.changeEmailPage);
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
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),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,153 +0,0 @@
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
|
||||
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",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,132 +0,0 @@
|
||||
import 'dart:async';
|
||||
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/utils/utils.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 LoginVerificationPage extends StatefulWidget {
|
||||
const LoginVerificationPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LoginVerificationPage> createState() => _LoginVerificationPageState();
|
||||
}
|
||||
|
||||
class _LoginVerificationPageState extends State<LoginVerificationPage> {
|
||||
String userToken = "";
|
||||
|
||||
late UserVM userVM;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
scheduleMicrotask(() async {
|
||||
userVM = Provider.of<UserVM>(context, listen: false);
|
||||
userToken = await userVM.performApiCallLoginVerificationPage(context);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: appBar(context, title: LocaleKeys.login.tr()),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
children: [
|
||||
LocaleKeys.verifyAccount.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||
Utils.mFlex(2),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
userVM.performBasicOtpLoginVerificationPage(context, userToken: userToken);
|
||||
},
|
||||
title: LocaleKeys.fingerPrint.tr(),
|
||||
icon: icons + "ic_fingerprint.png",
|
||||
),
|
||||
),
|
||||
20.width,
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
userVM.performBasicOtpLoginVerificationPage(context, userToken: userToken);
|
||||
},
|
||||
title: LocaleKeys.faceRecognition.tr(),
|
||||
icon: icons + "ic_face_id.png",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
40.height,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
userVM.performBasicOtpLoginVerificationPage(context, userToken: userToken);
|
||||
},
|
||||
title: LocaleKeys.SMS.tr(),
|
||||
icon: icons + "ic_sms.png",
|
||||
),
|
||||
),
|
||||
20.width,
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
userVM.performBasicOtpLoginVerificationPage(context, userToken: userToken);
|
||||
},
|
||||
title: LocaleKeys.whatsapp.tr(),
|
||||
icon: icons + "ic_whatsapp.png",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Utils.mFlex(10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> performBasicOtp(BuildContext context) async {
|
||||
// Utils.showLoading(context);
|
||||
// String userToken=await SharedPrefManager.getUserToken();
|
||||
// Response response = await UserApiClent().login_V2_OTP(userToken, "1");
|
||||
// Utils.hideLoading(context);
|
||||
// if (response.statusCode == 200) {
|
||||
// String userToken = jsonDecode(response.body)["token"];
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) async {
|
||||
// pop(context);
|
||||
// Utils.showLoading(context);
|
||||
// Response response2 = await UserApiClent().login_V2_OTPVerify(userToken, code);
|
||||
// Utils.hideLoading(context);
|
||||
// if (response2.statusCode == 200) {
|
||||
// User user = User.fromJson(jsonDecode(response2.body));
|
||||
// SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
||||
// SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
||||
// navigateWithName(context, AppRoutes.dashboard);
|
||||
// } else {
|
||||
// Utils.showToast("Something went wrong");
|
||||
// }
|
||||
// },
|
||||
// ));
|
||||
// } else {
|
||||
// String res = jsonDecode(response.body)["errors"][0] ?? "";
|
||||
// Utils.showToast(res);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
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/utils/utils.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: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 LoginVerifyAccountPage extends StatelessWidget {
|
||||
int otpType = 1;
|
||||
String phoneNum = "";
|
||||
|
||||
LoginVerifyAccountPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserVM userVM = context.read<UserVM>();
|
||||
return Scaffold(
|
||||
appBar: appBar(context,title: LocaleKeys.login.tr()),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
children: [
|
||||
LocaleKeys.verifyAccount.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||
Utils.mFlex(1),
|
||||
TxtField(
|
||||
hint: "966501234567",
|
||||
value: phoneNum,
|
||||
onChanged: (v) {
|
||||
phoneNum = v;
|
||||
},
|
||||
),
|
||||
Utils.mFlex(2),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
otpType = 1;
|
||||
userVM.performBasicOtpLoginVerifyAccountPage(context, phoneNum: phoneNum, otpType: otpType);
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) {
|
||||
// pop(context);
|
||||
// delay(300).then(
|
||||
// (value) => showMDialog(
|
||||
// context,
|
||||
// child: MessageDialog(
|
||||
// title: "Phone Number Verified",
|
||||
// onClick: () {
|
||||
// otpType=1;
|
||||
// performBasicOtp(context);
|
||||
// // navigateWithName(context, AppRoutes.completeProfile);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ));
|
||||
},
|
||||
title: LocaleKeys.SMS.tr(),
|
||||
icon: icons + "ic_sms.png",
|
||||
),
|
||||
),
|
||||
20.width,
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
otpType = 1;
|
||||
userVM.performBasicOtpLoginVerifyAccountPage(context, phoneNum: phoneNum, otpType: otpType);
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) {
|
||||
// pop(context);
|
||||
// delay(300).then(
|
||||
// (value) => showMDialog(
|
||||
// context,
|
||||
// child: MessageDialog(
|
||||
// title: "Phone Number Verified",
|
||||
// onClick: () {
|
||||
// otpType=2;
|
||||
// performBasicOtp(context);
|
||||
// // navigateWithName(context, AppRoutes.completeProfile);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ));
|
||||
},
|
||||
title: LocaleKeys.whatsapp.tr(),
|
||||
icon: icons + "ic_whatsapp.png",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Utils.mFlex(10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,154 +0,0 @@
|
||||
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/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/utils/navigator.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 LoginWithPassword extends StatefulWidget {
|
||||
const LoginWithPassword({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LoginWithPassword> createState() => _LoginWithPasswordState();
|
||||
}
|
||||
|
||||
class _LoginWithPasswordState extends State<LoginWithPassword> {
|
||||
int otpType = 1;
|
||||
|
||||
ClassType type = ClassType.EMAIL;
|
||||
String phoneNum = "", password = "";
|
||||
String email = "";
|
||||
String countryCode = "";
|
||||
Country? _country;
|
||||
|
||||
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: ""),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
12.height,
|
||||
LocaleKeys.login.tr().toText(fontSize: 20, letterSpacing: -1.44,),
|
||||
// 20.height,
|
||||
// (type == ClassType.NUMBER ? LocaleKeys.enterPhoneNumber.tr() : LocaleKeys.enterEmail.tr()).toText14(
|
||||
// color: MyColors.lightTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
30.height,
|
||||
LoginEmailTab(
|
||||
onSelection: (ClassType type) {
|
||||
setState(() {
|
||||
this.type = type;
|
||||
});
|
||||
},
|
||||
),
|
||||
10.height,
|
||||
Column(
|
||||
children: [
|
||||
if (type == ClassType.NUMBER) getCountry(context),
|
||||
10.height,
|
||||
TxtField(
|
||||
hint: type == ClassType.NUMBER ? LocaleKeys.enterPhoneNumber.tr() : LocaleKeys.enterEmail.tr(),
|
||||
value: phoneNum,
|
||||
isSidePaddingZero: true,
|
||||
onChanged: (v) {
|
||||
phoneNum = v;
|
||||
},
|
||||
),
|
||||
10.height,
|
||||
TxtField(
|
||||
hint: LocaleKeys.EnterPass.tr(),
|
||||
value: password,
|
||||
isPasswordEnabled: true,
|
||||
isSidePaddingZero: true,
|
||||
maxLines: 1,
|
||||
onChanged: (v) {
|
||||
password = v;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
20.height,
|
||||
LocaleKeys.forgetPasswordQ.tr().toText(
|
||||
color: MyColors.textColor,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.recover.tr(),
|
||||
isFlatButton: true,
|
||||
isBold: false,
|
||||
fontSize: 14,
|
||||
maxHeight: 24,
|
||||
txtColor: MyColors.darkPrimaryColor,
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.forgetPassword);
|
||||
},
|
||||
),
|
||||
30.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.continu.tr(),
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () {
|
||||
userVM.performBasicOtpLoginWithPasswordPage(context, type: type, countryCode: countryCode, phoneNum: phoneNum, password: password);
|
||||
},
|
||||
),
|
||||
20.height,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getCountry(BuildContext context) {
|
||||
if (_country != null) {
|
||||
List<DropValue> dropList = [];
|
||||
_country!.data?.forEach((element) {
|
||||
dropList.add(DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? ""));
|
||||
});
|
||||
return DropdownField((DropValue value) {
|
||||
countryCode = value.subValue;
|
||||
}, list: dropList, hint: LocaleKeys.selectCountryCode.tr());
|
||||
} else {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,185 +0,0 @@
|
||||
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/country.dart';
|
||||
import 'package:car_customer_app/utils/utils.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:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RegisterPage> createState() => _RegisterPageState();
|
||||
}
|
||||
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
String phoneNum = "", countryCode = "";
|
||||
|
||||
int role = 4, countryId = -1;
|
||||
|
||||
TextEditingController emailController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final UserVM userVM = context.read<UserVM>();
|
||||
return Scaffold(
|
||||
appBar: appBar(context, title: ""),
|
||||
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.signUp.tr().toText(fontSize: 20, letterSpacing: -1.44,),
|
||||
20.height,
|
||||
LocaleKeys.enterPhoneNumber.tr().toText(
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
30.height,
|
||||
FutureBuilder<Country>(
|
||||
future: userVM.getAllCountries(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
List<DropValue> dropList = [];
|
||||
snapshot.data?.data?.forEach((element) {
|
||||
dropList.add(DropValue(
|
||||
element.id ?? 0,
|
||||
EasyLocalization.of(context)?.currentLocale?.countryCode == "SA"
|
||||
? (element.countryNameN ?? "") + " " + (element.countryCode ?? "")
|
||||
: (element.countryName ?? "") + " " + (element.countryCode ?? ""),
|
||||
element.countryCode ?? ""));
|
||||
});
|
||||
return Column(
|
||||
children: [
|
||||
LocaleKeys.selectYourCountry.tr().toText(
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
10.height,
|
||||
DropdownField(
|
||||
(DropValue value) {
|
||||
setState(() {
|
||||
countryCode = value.subValue;
|
||||
countryId = value.id;
|
||||
});
|
||||
},
|
||||
list: dropList,
|
||||
hint: LocaleKeys.chooseCountry.tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
18.height,
|
||||
LocaleKeys.enterPhoneForVerfication.tr().toText(
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
10.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Utils.mExp(1),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
(countryCode.isEmpty ? "+00" : "+" + countryCode),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
" | ",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: TextField(
|
||||
controller: emailController,
|
||||
onChanged: (v) {
|
||||
phoneNum = v;
|
||||
},
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
hintStyle: TextStyle(color: MyColors.lightTextColor, fontSize: 20),
|
||||
hintText: "546758594",
|
||||
contentPadding: EdgeInsets.zero,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Utils.mExp(1),
|
||||
],
|
||||
),
|
||||
40.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.continu.tr(),
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () {
|
||||
if (validation()) userVM.performBasicOtpRegisterPage(context, countryCode: countryCode, phoneNum: phoneNum, role: role);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool validation() {
|
||||
bool isValid = true;
|
||||
if (role == -1) {
|
||||
Utils.showToast(LocaleKeys.selectProviderRole.tr());
|
||||
//("Please select Provider Role");
|
||||
isValid = false;
|
||||
} else if (countryCode.isEmpty) {
|
||||
Utils.showToast(LocaleKeys.selectCountryCode.tr());
|
||||
//("Please select Country Code");
|
||||
isValid = false;
|
||||
} else if (phoneNum.isEmpty) {
|
||||
Utils.showToast(LocaleKeys.addPhoneNo.tr());
|
||||
//("Please add Phone No");
|
||||
isValid = false;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
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/utils/navigator.dart';
|
||||
import 'package:car_customer_app/utils/utils.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:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
class RegisterSelectionPage extends StatelessWidget {
|
||||
const RegisterSelectionPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
// appBar: appBar(title: LocaleKeys.login.tr()),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/images/bn_Intro.png"),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Utils.mFlex(6),
|
||||
SvgPicture.asset("assets/images/logo.svg"),
|
||||
Utils.mFlex(4),
|
||||
LocaleKeys.welcomeMessage.tr().toText(
|
||||
fontSize: 20,
|
||||
letterSpacing: -1.44,
|
||||
),
|
||||
LocaleKeys.welcomeDes.tr().toText(
|
||||
color: MyColors.lightTextColor,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
Utils.mFlex(1),
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.login.tr(),
|
||||
maxWidth: double.infinity,
|
||||
horizontalMargin: 20,
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.loginWithPassword);
|
||||
},
|
||||
),
|
||||
20.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.signUp.tr(),
|
||||
maxWidth: double.infinity,
|
||||
isFlatButton: true,
|
||||
txtColor: Colors.black,
|
||||
onPressed: () {
|
||||
navigateWithName(context, AppRoutes.register);
|
||||
},
|
||||
),
|
||||
10.height,
|
||||
Utils.mFlex(3),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"Continue as Guest",
|
||||
style: TextStyle(
|
||||
color: MyColors.darkPrimaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
Utils.mFlex(3),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
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/generated/locale_keys.g.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/txt_field.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class VerifyPasswordPage extends StatelessWidget {
|
||||
int otpType = 1;
|
||||
String phoneNum = "";
|
||||
String userName = "";
|
||||
String userToken = "";
|
||||
String otp = "";
|
||||
|
||||
VerifyPasswordPage({Key? key}) : super(key: key);
|
||||
|
||||
@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(40),
|
||||
child: Column(
|
||||
children: [
|
||||
LocaleKeys.verifyNewPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||
Utils.mFlex(1),
|
||||
TxtField(
|
||||
hint: "966500000000",
|
||||
value: phoneNum,
|
||||
onChanged: (v) {
|
||||
phoneNum = v;
|
||||
},
|
||||
),
|
||||
Utils.mFlex(2),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
otpType = 1;
|
||||
// sendPasswordOTP(context);
|
||||
showMDialog(context, child: OtpDialog(
|
||||
onClick: (String code) {
|
||||
pop(context);
|
||||
Utils.delay(300).then(
|
||||
(value) => showMDialog(
|
||||
context,
|
||||
child: MessageDialog(
|
||||
title: LocaleKeys.phoneNumberVerified.tr(),
|
||||
onClick: () {
|
||||
otpType = 1;
|
||||
navigateWithName(context, AppRoutes.confirmNewPasswordPage);
|
||||
// ForgetPasswordOTP(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
title: LocaleKeys.SMS.tr(),
|
||||
icon: icons + "ic_sms.png",
|
||||
),
|
||||
),
|
||||
20.width,
|
||||
Expanded(
|
||||
child: ShowImageButton(
|
||||
onClick: () {
|
||||
otpType = 1;
|
||||
// sendPasswordOTP(context);
|
||||
showMDialog(context, child: OtpDialog(
|
||||
onClick: (String code) {
|
||||
pop(context);
|
||||
Utils.delay(300).then(
|
||||
(value) => showMDialog(
|
||||
context,
|
||||
child: MessageDialog(
|
||||
title: LocaleKeys.phoneNumberVerified.tr(),
|
||||
//"Phone Number Verified ",
|
||||
onClick: () {
|
||||
otpType = 2;
|
||||
navigateWithName(context, AppRoutes.confirmNewPasswordPage);
|
||||
// ForgetPasswordOTP(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
));
|
||||
},
|
||||
title: LocaleKeys.whatsapp.tr(),
|
||||
icon: icons + "ic_whatsapp.png",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Utils.mFlex(10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> sendPasswordOTP(BuildContext context) async {
|
||||
// Utils.showLoading(context);
|
||||
// PasswordOTPCompare otpCompare = await UserApiClent().ForgetPasswordOTPCompare(userToken, otp);
|
||||
// Utils.hideLoading(context);
|
||||
// if (otpCompare.messageStatus == 1) {
|
||||
// // navigateWithName(context, AppRoutes.confirmNewPasswordPage);
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) async {
|
||||
// pop(context);
|
||||
// Utils.showLoading(context);
|
||||
// // PasswordOTPCompare otpCompare = await UserApiClent().ForgetPasswordOTPCompare(userToken, otp);
|
||||
// Utils.hideLoading(context);
|
||||
// },
|
||||
// ));
|
||||
// } else {
|
||||
// Utils.showToast(otpCompare.message ?? "");
|
||||
// }
|
||||
// }
|
||||
|
||||
// User otpRequest = User.fromJson(jsonDecode(res.body));
|
||||
// SharedPrefManager.setUserToken(otpRequest.data!.accessToken ?? "");
|
||||
// SharedPrefManager.setUserId(otpRequest.data!.userInfo!.userId ?? "");
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) {
|
||||
// pop(context);
|
||||
// delay(300).then(
|
||||
// (value) => showMDialog(
|
||||
// context,
|
||||
// child: MessageDialog(
|
||||
// title: "Phone Number Verified",
|
||||
// onClick: () {
|
||||
// otpType=1;
|
||||
// navigateWithName(context, AppRoutes.confirmNewPasswordPage);
|
||||
// // ForgetPasswordOTP(context);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ));
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
AppBar appBar(
|
||||
BuildContext context, {
|
||||
Color? backgroundColor,
|
||||
double? elevation,
|
||||
String? title,
|
||||
Color? titleColor,
|
||||
bool? isTitleCenter,
|
||||
Color? backIconColor,
|
||||
List<Widget>? actions,
|
||||
bool isRemoveBackButton = false,
|
||||
}) {
|
||||
return AppBar(
|
||||
backgroundColor: backgroundColor ?? appBackgroundColor,
|
||||
elevation: elevation ?? 0,
|
||||
centerTitle: isTitleCenter ?? true,
|
||||
leading: isRemoveBackButton
|
||||
? null
|
||||
: IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios, color: Colors.black),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
color: backIconColor ?? Colors.black, //change your color here
|
||||
),
|
||||
actions: actions,
|
||||
title: (title ?? "").toText(fontSize: 20, isBold: true),
|
||||
);
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const kDemoText = Center(
|
||||
child: Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: Colors.white,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
const double kBlur = 1.0;
|
||||
const EdgeInsetsGeometry kDefaultPadding = EdgeInsets.all(16);
|
||||
const Color kDefaultColor = Colors.transparent;
|
||||
const BorderRadius kBorderRadius = BorderRadius.all(Radius.circular(20));
|
||||
const double kColorOpacity = 0.0;
|
||||
|
||||
class BlurryContainer extends StatelessWidget {
|
||||
final Widget child;
|
||||
final double blur;
|
||||
final double? height, width;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final Color bgColor;
|
||||
|
||||
final BorderRadius borderRadius;
|
||||
|
||||
//final double colorOpacity;
|
||||
|
||||
BlurryContainer({
|
||||
this.child = kDemoText,
|
||||
this.blur = 5,
|
||||
required this.height,
|
||||
required this.width,
|
||||
this.padding = kDefaultPadding,
|
||||
this.bgColor = kDefaultColor,
|
||||
this.borderRadius = kBorderRadius,
|
||||
//this.colorOpacity = kColorOpacity,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius: borderRadius,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
|
||||
child: Container(
|
||||
height: height!,
|
||||
width: width!,
|
||||
padding: padding,
|
||||
color: bgColor == Colors.transparent
|
||||
? bgColor
|
||||
: bgColor.withOpacity(0.5),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ShowCircularButton extends StatelessWidget {
|
||||
VoidCallback onPressed;
|
||||
IconData? iconData;
|
||||
ShowCircularButton({Key? key, this.iconData,required this.onPressed}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
shape: Utils.cardRadius(1000),
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
margin: const EdgeInsets.all(12),
|
||||
child: IconButton(
|
||||
onPressed: onPressed,
|
||||
icon: Icon(
|
||||
iconData?? Icons.amp_stories_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
class ShowImageButton extends StatelessWidget {
|
||||
String icon, title;
|
||||
VoidCallback onClick;
|
||||
|
||||
ShowImageButton({required this.icon, required this.title, required this.onClick});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onClick,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
child: Card(
|
||||
color: MyColors.darkPrimaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: Colors.transparent, width: 1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(26),
|
||||
child: SvgPicture.asset(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
6.height,
|
||||
title.toText(color: Colors.black, isBold: true, fontSize: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CountDownTimer extends StatefulWidget {
|
||||
const CountDownTimer({
|
||||
Key? key,
|
||||
int? secondsRemaining,
|
||||
this.countDownTimerStyle,
|
||||
this.whenTimeExpires,
|
||||
this.countDownFormatter,
|
||||
})
|
||||
: secondsRemaining = secondsRemaining,
|
||||
super(key: key);
|
||||
|
||||
final int? secondsRemaining;
|
||||
final Function? whenTimeExpires;
|
||||
final Function? countDownFormatter;
|
||||
final TextStyle ?countDownTimerStyle;
|
||||
|
||||
State createState() => new _CountDownTimerState();
|
||||
}
|
||||
|
||||
class _CountDownTimerState extends State<CountDownTimer>
|
||||
with TickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Duration duration;
|
||||
|
||||
String get timerDisplayString {
|
||||
Duration duration = _controller.duration! * _controller.value;
|
||||
return widget.countDownFormatter != null
|
||||
? widget.countDownFormatter!(duration.inSeconds)
|
||||
: formatHHMMSS(duration.inSeconds);
|
||||
// In case user doesn't provide formatter use the default one
|
||||
// for that create a method which will be called formatHHMMSS or whatever you like
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
duration = new Duration(seconds: widget.secondsRemaining ?? 0);
|
||||
_controller = new AnimationController(
|
||||
vsync: this,
|
||||
duration: duration,
|
||||
);
|
||||
_controller.reverse(from: widget.secondsRemaining!.toDouble());
|
||||
_controller.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) {
|
||||
widget.whenTimeExpires!();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(CountDownTimer oldWidget) {
|
||||
if (widget.secondsRemaining != oldWidget.secondsRemaining) {
|
||||
setState(() {
|
||||
duration = new Duration(seconds: widget.secondsRemaining ?? 0);
|
||||
_controller.dispose();
|
||||
_controller = new AnimationController(
|
||||
vsync: this,
|
||||
duration: duration,
|
||||
);
|
||||
_controller.reverse(from: widget.secondsRemaining?.toDouble());
|
||||
_controller.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
widget.whenTimeExpires!();
|
||||
} else if (status == AnimationStatus.dismissed) {
|
||||
print("Animation Complete");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (_, Widget? child) {
|
||||
return Text(
|
||||
timerDisplayString ??"",
|
||||
style: widget.countDownTimerStyle,
|
||||
);
|
||||
}),);
|
||||
}
|
||||
}
|
||||
|
||||
String formatHHMMSS(int seconds) {
|
||||
int hours = (seconds / 3600).truncate();
|
||||
seconds = (seconds % 3600).truncate();
|
||||
int minutes = (seconds / 60).truncate();
|
||||
|
||||
String hoursStr = (hours).toString().padLeft(2, '0');
|
||||
String minutesStr = (minutes).toString().padLeft(2, '0');
|
||||
String secondsStr = (seconds % 60).toString().padLeft(2, '0');
|
||||
|
||||
if (hours == 0) {
|
||||
return "$minutesStr:$secondsStr";
|
||||
}
|
||||
|
||||
return "$hoursStr:$minutesStr:$secondsStr";
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void showMDialog(
|
||||
context, {
|
||||
Widget? child,
|
||||
}) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MessageDialog extends StatelessWidget {
|
||||
String? title, buttonTitle;
|
||||
VoidCallback? onClick;
|
||||
|
||||
MessageDialog({this.title, this.buttonTitle, this.onClick});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.all(30),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(title ?? "message").toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
|
||||
40.height,
|
||||
ShowFillButton(
|
||||
title: buttonTitle ?? "Continue",
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () {
|
||||
onClick!();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
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/widgets/count_down_timer.dart';
|
||||
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../otp_widget.dart';
|
||||
|
||||
class OtpDialog extends StatefulWidget {
|
||||
String? userName;
|
||||
Function(String) onClick;
|
||||
|
||||
OtpDialog({Key? key, required this.onClick, this.userName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<OtpDialog> createState() => _OtpDialogState();
|
||||
}
|
||||
|
||||
class _OtpDialogState extends State<OtpDialog> {
|
||||
String code = "";
|
||||
bool hasTimerStopped = false;
|
||||
|
||||
final TextEditingController _pinPutController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.all(24),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
LocaleKeys.insert_otp_code.tr().toText(
|
||||
height: 23 / 24,
|
||||
fontSize: 24,
|
||||
letterSpacing: -1.44,
|
||||
),
|
||||
8.height,
|
||||
LocaleKeys.type_code.tr().toText(color: MyColors.textColor, fontSize: 12),
|
||||
if (widget.userName != null)
|
||||
(widget.userName ?? "").toText(
|
||||
color: MyColors.darkPrimaryColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
20.height,
|
||||
Center(
|
||||
child: OTPWidget(
|
||||
autoFocus: true,
|
||||
controller: _pinPutController,
|
||||
defaultBorderColor: const Color(0xffD8D8D8),
|
||||
maxLength: 4,
|
||||
onTextChanged: (text) {},
|
||||
pinBoxColor: Colors.white,
|
||||
onDone: (code) => _onOtpCallBack(code, null),
|
||||
textBorderColor: MyColors.darkPrimaryColor,
|
||||
pinBoxWidth: 48,
|
||||
pinBoxHeight: 48,
|
||||
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
|
||||
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
|
||||
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
|
||||
pinBoxRadius: 0,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
40.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.check_code.tr(),
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () {
|
||||
widget.onClick(code);
|
||||
},
|
||||
),
|
||||
if (!hasTimerStopped)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(LocaleKeys.time_will_expire.tr() + " "),
|
||||
CountDownTimer(
|
||||
secondsRemaining: 60,
|
||||
whenTimeExpires: () {
|
||||
setState(() {
|
||||
hasTimerStopped = true;
|
||||
});
|
||||
},
|
||||
countDownTimerStyle: const TextStyle(
|
||||
color: Colors.blue,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
Text(" " + LocaleKeys.sec.tr()),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (hasTimerStopped)
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
hasTimerStopped = false;
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Text(
|
||||
LocaleKeys.resend_code.tr(),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_onOtpCallBack(String otpCode, bool? isAutofill) {
|
||||
if (otpCode.length == 4) {
|
||||
// onSuccess(otpCode);
|
||||
code = otpCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
showDraggableDialog(BuildContext context, Widget child) {
|
||||
showGeneralDialog(
|
||||
barrierLabel: "Label",
|
||||
barrierDismissible: false,
|
||||
barrierColor: Colors.black.withOpacity(0.2),
|
||||
transitionDuration: Duration(milliseconds: 200),
|
||||
context: context,
|
||||
pageBuilder: (context, anim1, anim2) {
|
||||
return Dismissible(
|
||||
direction: DismissDirection.vertical,
|
||||
key: const Key('key'),
|
||||
onDismissed: (_) => Navigator.of(context).pop(),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
transitionBuilder: (context, anim1, anim2, child) {
|
||||
return SlideTransition(
|
||||
position: Tween(begin: Offset(0, 1), end: Offset(0, 0)).animate(anim1),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class DropValue {
|
||||
int id;
|
||||
String value;
|
||||
String subValue;
|
||||
|
||||
DropValue(this.id, this.value, this.subValue);
|
||||
|
||||
bool operator ==(o) => o is DropValue && o.value == value && o.id == id;
|
||||
}
|
||||
|
||||
class DropdownField extends StatefulWidget {
|
||||
String? hint;
|
||||
List<DropValue>? list;
|
||||
DropValue? dropdownValue;
|
||||
Function(DropValue) onSelect;
|
||||
|
||||
DropdownField(this.onSelect, {Key? key, this.hint, this.list,this.dropdownValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DropdownField> createState() => _DropdownFieldState();
|
||||
}
|
||||
|
||||
class _DropdownFieldState extends State<DropdownField> {
|
||||
DropValue? dropdownValue;
|
||||
List<DropValue> defaultV = [
|
||||
DropValue(1, "One", ""),
|
||||
DropValue(2, "Two", ""),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dropdownValue = widget.dropdownValue;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: Utils.containerColorRadiusBorderWidth(
|
||||
MyColors.white,
|
||||
0,
|
||||
MyColors.darkPrimaryColor,
|
||||
2,
|
||||
),
|
||||
margin: const EdgeInsets.all(0),
|
||||
padding: const EdgeInsets.only(left: 8, right: 8),
|
||||
child: DropdownButton<DropValue>(
|
||||
value: dropdownValue,
|
||||
icon: const Icon(Icons.keyboard_arrow_down_sharp),
|
||||
elevation: 16,
|
||||
iconSize: 16,
|
||||
iconEnabledColor: borderColor,
|
||||
iconDisabledColor: borderColor,
|
||||
isExpanded: true,
|
||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w600),
|
||||
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 12),
|
||||
underline: Container(
|
||||
height: 0,
|
||||
),
|
||||
onChanged: (DropValue? newValue) {
|
||||
setState(() {
|
||||
dropdownValue = newValue!;
|
||||
widget.onSelect(newValue);
|
||||
});
|
||||
},
|
||||
items: (widget.list ?? defaultV).map<DropdownMenuItem<DropValue>>(
|
||||
(DropValue value) {
|
||||
return DropdownMenuItem<DropValue>(
|
||||
value: value,
|
||||
child: value.value.toText(fontSize: 12),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
import 'package:car_customer_app/classes/consts.dart';
|
||||
import 'package:car_customer_app/config/constants.dart';
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class DropDownText extends StatelessWidget {
|
||||
String title;
|
||||
|
||||
DropDownText(this.title);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
title.toText(color: accentColor, fontSize: 16, letterSpacing: -0.64,),
|
||||
16.height,
|
||||
SvgPicture.asset(
|
||||
svgIcons + "ic_arrow_down.svg",
|
||||
width: 10,
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,233 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension ExtendedText on Widget {
|
||||
showOverlay({double? width, double? height}){
|
||||
return Container(
|
||||
width: width ?? double.infinity,
|
||||
height: height ?? 60,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(colors: [
|
||||
Colors.black.withOpacity(0.2),
|
||||
Colors.black.withOpacity(0.1),
|
||||
Colors.black.withOpacity(0.004),
|
||||
], begin: Alignment.topCenter, end: Alignment.bottomCenter, tileMode: TileMode.clamp),
|
||||
),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extension ImageExt on Image {
|
||||
Widget circular() {
|
||||
return ClipRRect(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension WidgetExt on Widget {
|
||||
Widget toWidget() {
|
||||
return this as Widget;
|
||||
}
|
||||
|
||||
Widget sized({double? width, double? height}) {
|
||||
return SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
Widget inkWell({required VoidCallback onTap,double radius=0}){
|
||||
return InkWell(
|
||||
child: Material(child: this,color: Colors.transparent,),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
Widget sizeSq(double size) {
|
||||
return SizedBox(
|
||||
width: size,
|
||||
height: size,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget fillParent({double hFactor = 1, double? vFactor}) {
|
||||
return FractionallySizedBox(
|
||||
heightFactor: null,
|
||||
widthFactor: hFactor,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget margin(
|
||||
{double top = 0, double bottom = 0, double left = 0, double right = 0}) {
|
||||
var pad =
|
||||
EdgeInsets.only(top: top, left: left, bottom: bottom, right: right);
|
||||
try {
|
||||
(this as dynamic).margin = pad;
|
||||
} catch (err) {
|
||||
return Padding(
|
||||
padding: pad,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Widget toClip({double r = 40}) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(r),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
// Widget scrollable({Axis? direction, bool fadingEdge = true}) {
|
||||
// var scrollview = SingleChildScrollView(
|
||||
// child: this,
|
||||
// controller: ScrollController(),
|
||||
// scrollDirection: direction ?? Axis.vertical,
|
||||
// );
|
||||
// return fadingEdge ? scrollview.fadingEdge() : scrollview;
|
||||
// }
|
||||
|
||||
Widget expand() {
|
||||
return Expanded(
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget align(Alignment alignment) {
|
||||
return Align(
|
||||
alignment: alignment,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget center() {
|
||||
return Center(
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget padding(EdgeInsets padding) {
|
||||
return Padding(
|
||||
padding: padding,
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
Widget paddingAll(double padding) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(padding),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
|
||||
// Widget onTap(VoidCallback onTap, {double corners = 0}) {
|
||||
// return Clickable.widget(child: this, corners: corners, onTap: onTap);
|
||||
// }
|
||||
|
||||
Widget ignoreInteraction() {
|
||||
return IgnorePointer(
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// extension xScrollView on ScrollView {
|
||||
// Widget fadingEdge() => FadingEdgeScrollView.fromScrollView(
|
||||
// child: this,
|
||||
// gradientFractionOnEnd: 0.08,
|
||||
// gradientFractionOnStart: 0.08,
|
||||
// shouldDisposeScrollController: true,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// extension x2ScrollView on SingleChildScrollView {
|
||||
// Widget fadingEdge() => FadingEdgeScrollView.fromSingleChildScrollView(
|
||||
// child: this,
|
||||
// gradientFractionOnEnd: 0.08,
|
||||
// gradientFractionOnStart: 0.08,
|
||||
// shouldDisposeScrollController: true,
|
||||
// );
|
||||
// }
|
||||
|
||||
class Position {
|
||||
final double x, y, w, h;
|
||||
|
||||
Position(this.x, this.y, this.w, this.h);
|
||||
}
|
||||
|
||||
extension KeyExt on GlobalKey {
|
||||
Position globalPosition() {
|
||||
RenderBox box = currentContext!.findRenderObject() as RenderBox;
|
||||
Offset xy = box.localToGlobal(Offset.zero);
|
||||
Size wh = box.size;
|
||||
return Position(xy.dx, xy.dy, wh.width, wh.height);
|
||||
}
|
||||
}
|
||||
|
||||
extension StateExt on State {
|
||||
reload({VoidCallback? b}) {
|
||||
setState(b ?? () {});
|
||||
}
|
||||
}
|
||||
|
||||
// extension LocatiionExt on Location {
|
||||
// LatLng toLatLng() {
|
||||
// return LatLng(lat!, lng!);
|
||||
// }
|
||||
// }
|
||||
|
||||
// extension xList<T> on List<T> {
|
||||
// T randomItem() {
|
||||
// final random = new Random();
|
||||
// var i = random.nextInt(this.length);
|
||||
// return this[i];
|
||||
// }
|
||||
//
|
||||
// List<T> append(List<T> items) {
|
||||
// this.addAll(items);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// bool isFirst(T item) => first == item;
|
||||
//
|
||||
// bool isLast(T item) => last == item;
|
||||
//
|
||||
// getOneByOne(
|
||||
// {required int delayMillis,
|
||||
// required Function(T) callback, VoidCallback? complete}) async {
|
||||
// for (var i in this) {
|
||||
// await delay(delayMillis);
|
||||
// callback(i);
|
||||
// }
|
||||
// complete!();
|
||||
// }
|
||||
// }
|
||||
|
||||
extension xFuture<T> on Future<T?> {
|
||||
thenWithDelay(int millis, Function(T) thenBlock) {
|
||||
then((value) {
|
||||
Future.delayed(Duration(milliseconds: millis))
|
||||
.then((value) => thenBlock(value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension xDouble on int {
|
||||
Duration durationMillis() => Duration(milliseconds: this);
|
||||
|
||||
Duration durationSec() => Duration(seconds: this);
|
||||
|
||||
Duration durationHour() => Duration(hours: this);
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientAppBar extends StatelessWidget {
|
||||
final String title;
|
||||
final double barHeight = 50.0;
|
||||
IconData? iconData;
|
||||
|
||||
GradientAppBar(this.title, {this.iconData});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double statusbarHeight = MediaQuery.of(context).padding.top;
|
||||
|
||||
return new Container(
|
||||
padding: EdgeInsets.only(top: statusbarHeight),
|
||||
height: statusbarHeight + barHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (iconData != null)
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: Icon(
|
||||
iconData,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.black.withOpacity(0.4),
|
||||
Colors.black.withOpacity(0.2),
|
||||
Colors.black.withOpacity(0.0001),
|
||||
],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
tileMode: TileMode.clamp,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
import 'package:car_customer_app/classes/consts.dart';
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CircularImage extends StatelessWidget {
|
||||
final double? w, h, padding;
|
||||
final String? image;
|
||||
|
||||
const CircularImage({Key? key, this.w, this.h, this.image, this.padding}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: w ?? 120,
|
||||
height: h ?? 120,
|
||||
child: Card(
|
||||
shape: Utils.cardRadius(2000),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
elevation: 4,
|
||||
child: Card(
|
||||
shape: Utils.cardRadius(2000),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.all(padding ?? 0),
|
||||
child: Image.asset(image ?? icons + "green.jpg"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingDialog extends StatefulWidget {
|
||||
LoadingDialog({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_LoadingDialogState createState() {
|
||||
return _LoadingDialogState();
|
||||
}
|
||||
}
|
||||
|
||||
class _LoadingDialogState extends State<LoadingDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,371 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
typedef OnDone = void Function(String text);
|
||||
|
||||
class ProvidedPinBoxTextAnimation {
|
||||
static AnimatedSwitcherTransitionBuilder scalingTransition = (child, animation) {
|
||||
return ScaleTransition(
|
||||
child: child,
|
||||
scale: animation,
|
||||
);
|
||||
};
|
||||
|
||||
static AnimatedSwitcherTransitionBuilder defaultNoTransition = (Widget child, Animation<double> animation) {
|
||||
return child;
|
||||
};
|
||||
}
|
||||
|
||||
class OTPWidget extends StatefulWidget {
|
||||
final int maxLength;
|
||||
final TextEditingController? controller;
|
||||
|
||||
final Color defaultBorderColor;
|
||||
final Color pinBoxColor;
|
||||
final double pinBoxBorderWidth;
|
||||
final double pinBoxRadius;
|
||||
final bool hideDefaultKeyboard;
|
||||
|
||||
final TextStyle? pinTextStyle;
|
||||
final double pinBoxHeight;
|
||||
final double pinBoxWidth;
|
||||
final OnDone? onDone;
|
||||
final bool hasError;
|
||||
final Color errorBorderColor;
|
||||
final Color textBorderColor;
|
||||
final Function(String)? onTextChanged;
|
||||
final bool autoFocus;
|
||||
final FocusNode? focusNode;
|
||||
final AnimatedSwitcherTransitionBuilder? pinTextAnimatedSwitcherTransition;
|
||||
final Duration pinTextAnimatedSwitcherDuration;
|
||||
final TextDirection textDirection;
|
||||
final TextInputType keyboardType;
|
||||
final EdgeInsets pinBoxOuterPadding;
|
||||
|
||||
const OTPWidget({
|
||||
Key? key,
|
||||
this.maxLength: 4,
|
||||
this.controller,
|
||||
this.pinBoxWidth: 70.0,
|
||||
this.pinBoxHeight: 70.0,
|
||||
this.pinTextStyle,
|
||||
this.onDone,
|
||||
this.defaultBorderColor: Colors.black,
|
||||
this.textBorderColor: Colors.black,
|
||||
this.pinTextAnimatedSwitcherTransition,
|
||||
this.pinTextAnimatedSwitcherDuration: const Duration(),
|
||||
this.hasError: false,
|
||||
this.errorBorderColor: Colors.red,
|
||||
this.onTextChanged,
|
||||
this.autoFocus: false,
|
||||
this.focusNode,
|
||||
this.textDirection: TextDirection.ltr,
|
||||
this.keyboardType: TextInputType.number,
|
||||
this.pinBoxOuterPadding = const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
this.pinBoxColor = Colors.white,
|
||||
this.pinBoxBorderWidth = 2.0,
|
||||
this.pinBoxRadius = 0,
|
||||
this.hideDefaultKeyboard = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return OTPWidgetState();
|
||||
}
|
||||
}
|
||||
|
||||
class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixin {
|
||||
AnimationController? _highlightAnimationController;
|
||||
FocusNode? focusNode;
|
||||
String text = "";
|
||||
int currentIndex = 0;
|
||||
List<String> strList = [];
|
||||
bool hasFocus = false;
|
||||
|
||||
@override
|
||||
void didUpdateWidget(OTPWidget oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
focusNode = widget.focusNode ?? focusNode;
|
||||
|
||||
if (oldWidget.maxLength < widget.maxLength) {
|
||||
setState(() {
|
||||
currentIndex = text.length;
|
||||
});
|
||||
widget.controller?.text = text;
|
||||
widget.controller?.selection = TextSelection.collapsed(offset: text.length);
|
||||
} else if (oldWidget.maxLength > widget.maxLength && widget.maxLength > 0 && text.length > 0 && text.length > widget.maxLength) {
|
||||
setState(() {
|
||||
text = text.substring(0, widget.maxLength);
|
||||
currentIndex = text.length;
|
||||
});
|
||||
widget.controller?.text = text;
|
||||
widget.controller?.selection = TextSelection.collapsed(offset: text.length);
|
||||
}
|
||||
}
|
||||
|
||||
_calculateStrList() {
|
||||
if (strList.length > widget.maxLength) {
|
||||
strList.length = widget.maxLength;
|
||||
}
|
||||
while (strList.length < widget.maxLength) {
|
||||
strList.add("");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
focusNode = widget.focusNode ?? FocusNode();
|
||||
|
||||
_initTextController();
|
||||
_calculateStrList();
|
||||
widget.controller?.addListener(_controllerListener);
|
||||
focusNode?.addListener(_focusListener);
|
||||
}
|
||||
|
||||
void _controllerListener() {
|
||||
if (mounted == true) {
|
||||
setState(() {
|
||||
_initTextController();
|
||||
});
|
||||
var onTextChanged = widget.onTextChanged;
|
||||
if (onTextChanged != null) {
|
||||
onTextChanged(widget.controller?.text ?? "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _focusListener() {
|
||||
if (mounted == true) {
|
||||
setState(() {
|
||||
hasFocus = focusNode?.hasFocus ?? false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _initTextController() {
|
||||
if (widget.controller == null) {
|
||||
return;
|
||||
}
|
||||
strList.clear();
|
||||
var text = widget.controller?.text ?? "";
|
||||
if (text.isNotEmpty) {
|
||||
if (text.length > widget.maxLength) {
|
||||
throw Exception("TextEditingController length exceeded maxLength!");
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
strList.add(text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
double get _width {
|
||||
var width = 0.0;
|
||||
for (var i = 0; i < widget.maxLength; i++) {
|
||||
width += widget.pinBoxWidth;
|
||||
if (i == 0) {
|
||||
width += widget.pinBoxOuterPadding.left;
|
||||
} else if (i + 1 == widget.maxLength) {
|
||||
width += widget.pinBoxOuterPadding.right;
|
||||
} else {
|
||||
width += widget.pinBoxOuterPadding.left;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (widget.focusNode == null) {
|
||||
focusNode?.dispose();
|
||||
} else {
|
||||
focusNode?.removeListener(_focusListener);
|
||||
}
|
||||
_highlightAnimationController?.dispose();
|
||||
widget.controller?.removeListener(_controllerListener);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
_otpTextInput(),
|
||||
_touchPinBoxRow(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _touchPinBoxRow() {
|
||||
return widget.hideDefaultKeyboard
|
||||
? _pinBoxRow(context)
|
||||
: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (hasFocus) {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
Future.delayed(Duration(milliseconds: 100), () {
|
||||
FocusScope.of(context).requestFocus(focusNode);
|
||||
});
|
||||
} else {
|
||||
FocusScope.of(context).requestFocus(focusNode);
|
||||
}
|
||||
},
|
||||
child: _pinBoxRow(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _otpTextInput() {
|
||||
var transparentBorder = OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.transparent,
|
||||
width: 0.0,
|
||||
),
|
||||
);
|
||||
return Container(
|
||||
width: _width,
|
||||
height: widget.pinBoxHeight,
|
||||
child: TextField(
|
||||
autofocus: !kIsWeb ? widget.autoFocus : false,
|
||||
enableInteractiveSelection: false,
|
||||
focusNode: focusNode,
|
||||
controller: widget.controller,
|
||||
keyboardType: widget.keyboardType,
|
||||
inputFormatters: widget.keyboardType == TextInputType.number ? <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly] : null,
|
||||
style: TextStyle(
|
||||
height: 0.1,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
focusedErrorBorder: transparentBorder,
|
||||
errorBorder: transparentBorder,
|
||||
disabledBorder: transparentBorder,
|
||||
enabledBorder: transparentBorder,
|
||||
focusedBorder: transparentBorder,
|
||||
counterText: null,
|
||||
counterStyle: null,
|
||||
helperStyle: TextStyle(
|
||||
height: 0.0,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
labelStyle: TextStyle(height: 0.1),
|
||||
fillColor: Colors.transparent,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
cursorColor: Colors.transparent,
|
||||
showCursor: false,
|
||||
maxLength: widget.maxLength,
|
||||
onChanged: _onTextChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onTextChanged(text) {
|
||||
var onTextChanged = widget.onTextChanged;
|
||||
if (onTextChanged != null) {
|
||||
onTextChanged(text);
|
||||
}
|
||||
setState(() {
|
||||
this.text = text;
|
||||
if (text.length >= currentIndex) {
|
||||
for (int i = currentIndex; i < text.length; i++) {
|
||||
strList[i] = text[i];
|
||||
}
|
||||
}
|
||||
currentIndex = text.length;
|
||||
});
|
||||
if (text.length == widget.maxLength) {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
var onDone = widget.onDone;
|
||||
if (onDone != null) {
|
||||
onDone(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _pinBoxRow(BuildContext context) {
|
||||
_calculateStrList();
|
||||
List<Widget> pinCodes = List.generate(widget.maxLength, (int i) {
|
||||
return _buildPinCode(i, context);
|
||||
});
|
||||
return Row(children: pinCodes, mainAxisSize: MainAxisSize.min);
|
||||
}
|
||||
|
||||
Widget _buildPinCode(int i, BuildContext context) {
|
||||
Color borderColor;
|
||||
Color pinBoxColor = widget.pinBoxColor;
|
||||
|
||||
if (widget.hasError) {
|
||||
borderColor = widget.errorBorderColor;
|
||||
} else if (i < text.length) {
|
||||
borderColor = widget.textBorderColor;
|
||||
} else {
|
||||
borderColor = widget.defaultBorderColor;
|
||||
pinBoxColor = widget.pinBoxColor;
|
||||
}
|
||||
|
||||
EdgeInsets insets;
|
||||
if (i == 0) {
|
||||
insets = EdgeInsets.only(
|
||||
left: 0,
|
||||
top: widget.pinBoxOuterPadding.top,
|
||||
right: widget.pinBoxOuterPadding.right,
|
||||
bottom: widget.pinBoxOuterPadding.bottom,
|
||||
);
|
||||
} else if (i == strList.length - 1) {
|
||||
insets = EdgeInsets.only(
|
||||
left: widget.pinBoxOuterPadding.left,
|
||||
top: widget.pinBoxOuterPadding.top,
|
||||
right: 0,
|
||||
bottom: widget.pinBoxOuterPadding.bottom,
|
||||
);
|
||||
} else {
|
||||
insets = widget.pinBoxOuterPadding;
|
||||
}
|
||||
return Container(
|
||||
key: ValueKey<String>("container$i"),
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 1.0),
|
||||
margin: insets,
|
||||
child: _animatedTextBox(strList[i], i),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: borderColor,
|
||||
width: widget.pinBoxBorderWidth,
|
||||
),
|
||||
color: pinBoxColor,
|
||||
borderRadius: BorderRadius.circular(widget.pinBoxRadius),
|
||||
),
|
||||
width: widget.pinBoxWidth,
|
||||
height: widget.pinBoxHeight,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _animatedTextBox(String text, int i) {
|
||||
if (widget.pinTextAnimatedSwitcherTransition != null) {
|
||||
return AnimatedSwitcher(
|
||||
duration: widget.pinTextAnimatedSwitcherDuration,
|
||||
transitionBuilder: widget.pinTextAnimatedSwitcherTransition ??
|
||||
(Widget child, Animation<double> animation) {
|
||||
return child;
|
||||
},
|
||||
child: Text(
|
||||
text,
|
||||
key: ValueKey<String>("$text$i"),
|
||||
style: widget.pinTextStyle,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
text,
|
||||
key: ValueKey<String>("${strList[i]}$i"),
|
||||
style: widget.pinTextStyle,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
import 'package:car_customer_app/widgets/show_fill_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ShowCardButton extends StatelessWidget {
|
||||
String title;
|
||||
VoidCallback onPressed;
|
||||
Color txtColor;
|
||||
|
||||
ShowCardButton({
|
||||
required this.title,
|
||||
required this.onPressed,
|
||||
this.txtColor = Colors.white,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
elevation: 20,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(12),
|
||||
child: ShowFillButton(
|
||||
title: title,
|
||||
onPressed: onPressed,
|
||||
txtColor: txtColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/colors.dart';
|
||||
|
||||
class ShowFillButton extends StatelessWidget {
|
||||
String title;
|
||||
VoidCallback onPressed;
|
||||
Color txtColor;
|
||||
double elevation, radius, maxWidth, maxHeight, fontSize, horizontalPadding, horizontalMargin, verticalMargin;
|
||||
bool isFlatButton, isBold;
|
||||
|
||||
ShowFillButton({
|
||||
required this.title,
|
||||
required this.onPressed,
|
||||
this.txtColor = Colors.white,
|
||||
this.elevation = 0,
|
||||
this.radius = 0,
|
||||
this.maxWidth = 88,
|
||||
this.maxHeight = 45,
|
||||
this.fontSize = 16,
|
||||
this.horizontalPadding = 16,
|
||||
this.isFlatButton = false,
|
||||
this.isBold = true,
|
||||
this.horizontalMargin = 0,
|
||||
this.verticalMargin = 0,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isFlatButton
|
||||
? Container(
|
||||
child: showButton(),
|
||||
height: maxHeight,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
)
|
||||
: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: maxHeight,
|
||||
minWidth: maxWidth,
|
||||
maxHeight: maxHeight,
|
||||
maxWidth: maxWidth,
|
||||
),
|
||||
child: showButton(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget showButton() {
|
||||
return Container(
|
||||
// decoration: isFlatButton ? null : MyColors.gradientButton,
|
||||
color:isFlatButton ? null : MyColors.darkPrimaryColor,
|
||||
margin: EdgeInsets.symmetric(horizontal: horizontalMargin, vertical: verticalMargin),
|
||||
child: MaterialButton(
|
||||
onPressed: onPressed,
|
||||
shape: new RoundedRectangleBorder(
|
||||
borderRadius: new BorderRadius.circular(radius),
|
||||
),
|
||||
child: title.toText(
|
||||
fontSize: fontSize,
|
||||
isBold: isBold,
|
||||
color: txtColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/generated/locale_keys.g.dart';
|
||||
import 'package:easy_localization/src/public_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
enum ClassType { EMAIL, NUMBER }
|
||||
|
||||
class LoginEmailTab extends StatefulWidget {
|
||||
Function(ClassType) onSelection;
|
||||
|
||||
LoginEmailTab({required this.onSelection});
|
||||
|
||||
@override
|
||||
State<LoginEmailTab> createState() => _LoginEmailTabState();
|
||||
}
|
||||
|
||||
class _LoginEmailTabState extends State<LoginEmailTab> {
|
||||
ClassType type = ClassType.EMAIL;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
type = ClassType.EMAIL;
|
||||
widget.onSelection(ClassType.EMAIL);
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: type == ClassType.EMAIL ? MyColors.darkPrimaryColor : Colors.grey[200],
|
||||
// border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
|
||||
borderRadius: BorderRadius.all(Radius.circular(0)),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
LocaleKeys.email.tr(),
|
||||
style: TextStyle(
|
||||
color: type == ClassType.EMAIL ? MyColors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
12.width,
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
type = ClassType.NUMBER;
|
||||
widget.onSelection(ClassType.NUMBER);
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.grey[200],
|
||||
// border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
|
||||
borderRadius: BorderRadius.all(Radius.circular(0)),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
LocaleKeys.phoneNumber.tr(),
|
||||
style: TextStyle(
|
||||
color: type == ClassType.NUMBER ? MyColors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,164 +0,0 @@
|
||||
import 'package:car_customer_app/extensions/int_extensions.dart';
|
||||
import 'package:car_customer_app/extensions/string_extensions.dart';
|
||||
import 'package:car_customer_app/theme/colors.dart';
|
||||
import 'package:car_customer_app/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sizer/sizer.dart';
|
||||
|
||||
class TxtField extends StatelessWidget {
|
||||
TextEditingController controller = TextEditingController();
|
||||
String? value;
|
||||
String? hint;
|
||||
String? lable;
|
||||
IconData? prefixData;
|
||||
IconData? postfixData;
|
||||
bool isNeedFilterButton;
|
||||
bool isNeedClickAll;
|
||||
bool isButtonEnable;
|
||||
double? elevation;
|
||||
VoidCallback? onTap;
|
||||
String? buttonTitle;
|
||||
int? maxLines;
|
||||
bool isSidePaddingZero;
|
||||
bool isNeedBorder;
|
||||
bool? isPasswordEnabled;
|
||||
Function(String)? onChanged;
|
||||
TextInputType? keyboardType;
|
||||
bool isBackgroundEnabled = false;
|
||||
|
||||
TxtField({
|
||||
Key? key,
|
||||
this.value,
|
||||
this.lable,
|
||||
this.hint,
|
||||
this.prefixData,
|
||||
this.postfixData,
|
||||
this.isNeedClickAll = false,
|
||||
this.isNeedFilterButton = false,
|
||||
this.elevation,
|
||||
this.onTap,
|
||||
this.isButtonEnable = false,
|
||||
this.buttonTitle,
|
||||
this.maxLines,
|
||||
this.isSidePaddingZero = false,
|
||||
this.isNeedBorder = true,
|
||||
this.onChanged,
|
||||
this.isPasswordEnabled,
|
||||
this.keyboardType,
|
||||
this.isBackgroundEnabled = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.text = value ?? "";
|
||||
controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
|
||||
return InkWell(
|
||||
onTap: isNeedClickAll == false
|
||||
? null
|
||||
: () {
|
||||
onTap!();
|
||||
},
|
||||
customBorder: Utils.inkWellCorner(),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: isBackgroundEnabled ? MyColors.textFieldColor : Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(0)),
|
||||
),
|
||||
child: TextField(
|
||||
keyboardType: keyboardType,
|
||||
autofocus: false,
|
||||
controller: controller,
|
||||
enabled: isNeedClickAll == true ? false : true,
|
||||
maxLines: maxLines,
|
||||
onTap: () {},
|
||||
obscureText: isPasswordEnabled ?? false,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: lable,
|
||||
alignLabelWithHint: true,
|
||||
fillColor: Colors.white,
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
|
||||
borderRadius: BorderRadius.circular(0.0),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
|
||||
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
|
||||
borderRadius: BorderRadius.circular(0.0),
|
||||
),
|
||||
disabledBorder: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: MyColors.textFieldColor, width: isNeedBorder ? 1.0 : 0),
|
||||
borderSide: BorderSide(color: MyColors.darkPrimaryColor, width: isNeedBorder ? 2.0 : 0),
|
||||
borderRadius: BorderRadius.circular(0.0),
|
||||
),
|
||||
prefixIcon: prefixData != null ? const Icon(Icons.search, color: borderColor) : null,
|
||||
labelStyle: TextStyle(color: borderColor, fontSize: 13.sp),
|
||||
hintStyle: TextStyle(color: borderColor, fontSize: 9.sp),
|
||||
hintText: hint ?? "",
|
||||
contentPadding: prefixData == null
|
||||
? EdgeInsets.only(
|
||||
left: 12,
|
||||
right: 12,
|
||||
top: maxLines != null ? 12 : 0,
|
||||
bottom: maxLines != null ? 12 : 0,
|
||||
)
|
||||
: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isNeedFilterButton) 8.width,
|
||||
if (isNeedFilterButton)
|
||||
InkWell(
|
||||
onTap: isNeedClickAll
|
||||
? null
|
||||
: () {
|
||||
controller.clear();
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 55,
|
||||
height: 55,
|
||||
child: Card(
|
||||
color: accentColor,
|
||||
// margin: EdgeInsets.all(4),
|
||||
// shape: cardRadius(0),
|
||||
child: Icon(
|
||||
postfixData ?? Icons.filter_alt,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isButtonEnable)
|
||||
Material(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
customBorder: Utils.inkWellCorner(),
|
||||
child: SizedBox(
|
||||
height: 55,
|
||||
child: Card(
|
||||
color: accentColor,
|
||||
// margin: EdgeInsets.all(4),
|
||||
// shape: cardRadius(0),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: (buttonTitle ?? "Search").toText(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
letterSpacing: -0.64,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue