diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index f531524..432ad2a 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -1,10 +1,9 @@
plugins {
id("com.android.application")
id("kotlin-android")
- // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
id("com.google.gms.google-services")
- id("com.huawei.agconnect")
+// id("com.huawei.agconnect")
}
android {
diff --git a/android/build.gradle.kts b/android/build.gradle.kts
index 89176ef..71a2e60 100644
--- a/android/build.gradle.kts
+++ b/android/build.gradle.kts
@@ -1,7 +1,21 @@
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+// maven { url = uri("https://developer.huawei.com/repo/") }
+ }
+ dependencies {
+ classpath("com.android.tools.build:gradle:7.4.2")
+ classpath("com.google.gms:google-services:4.4.1")
+// classpath("com.huawei.agconnect:agcp:1.9.3.302")
+ }
+}
+
allprojects {
repositories {
google()
mavenCentral()
+// maven { url = uri("https://developer.huawei.com/repo/") }
}
}
diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist
index 7c56964..1dc6cf7 100644
--- a/ios/Flutter/AppFrameworkInfo.plist
+++ b/ios/Flutter/AppFrameworkInfo.plist
@@ -21,6 +21,6 @@
CFBundleVersion
1.0
MinimumOSVersion
- 12.0
+ 13.0
diff --git a/ios/Podfile b/ios/Podfile
index 6010472..9249e54 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -99,4 +99,4 @@ post_integrate do |installer|
end
end
project.save()
-end
\ No newline at end of file
+end
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 3f36518..dae81f2 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -279,10 +279,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
+ inputPaths = (
+ );
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
+ outputPaths = (
+ );
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
@@ -296,10 +300,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
+ inputPaths = (
+ );
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
+ outputPaths = (
+ );
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
@@ -435,7 +443,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -451,7 +459,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = ZB3P5B74MA;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
@@ -564,7 +572,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -615,7 +623,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -633,7 +641,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = ZB3P5B74MA;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
@@ -658,7 +666,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = ZB3P5B74MA;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
diff --git a/lib/services/api_client.dart b/lib/core/api/api_client.dart
similarity index 86%
rename from lib/services/api_client.dart
rename to lib/core/api/api_client.dart
index 42ffc58..ef15c95 100644
--- a/lib/services/api_client.dart
+++ b/lib/core/api/api_client.dart
@@ -3,14 +3,15 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter/foundation.dart';
-import 'package:hmg_patient_app_new/services/api_exception.dart';
+import 'package:hmg_patient_app_new/core/app_state.dart';
+import 'package:hmg_patient_app_new/core/consts.dart';
+import 'package:hmg_patient_app_new/core/dependencies.dart';
+import 'package:hmg_patient_app_new/core/exceptions/api_exception.dart';
+import 'package:hmg_patient_app_new/core/utils/utils.dart';
+import 'package:hmg_patient_app_new/services/logger_service.dart';
import 'package:http/http.dart';
import 'package:http/io_client.dart';
-import '../core/app_state.dart';
-import '../core/consts.dart';
-import '../core/utils/utils.dart';
-import '../main.dart';
// ignore_for_file: avoid_annotating_with_dynamic
@@ -31,12 +32,16 @@ class APIError {
}
APIException _throwAPIException(Response response, Function retryCallBack) {
+
+
+LoggerService loggerService = getIt.get();
+
switch (response.statusCode) {
case 200:
APIError? apiError;
if (response.body != null && response.body.isNotEmpty) {
var jsonError = jsonDecode(response.body);
- print(jsonError);
+ loggerService.logInfo(jsonError.toString());
apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage']);
}
return APIException(APIException.BAD_REQUEST, error: apiError);
@@ -75,11 +80,9 @@ abstract class IApiClient {
}
class ApiClient implements IApiClient {
- // static final ApiClient _instance = ApiClient._internal();
-
- // ApiClient._internal();
+ LoggerService loggerService;
- // factory ApiClient() => _instance;
+ ApiClient({required this.loggerService});
@override
Future postJsonForObject(FactoryConstructor factoryConstructor, String url, T jsonObject,
@@ -89,18 +92,18 @@ class ApiClient implements IApiClient {
_headers.addAll(headers);
}
if (!kReleaseMode) {
- print("Url:$url");
+ loggerService.logInfo("Url:$url");
var bodyJson = json.encode(jsonObject);
- print("body:$bodyJson");
+ loggerService.logInfo("body:$bodyJson");
}
var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes);
// try {
if (!kReleaseMode) {
- logger.i("res: " + response.body);
+ loggerService.logInfo("res: ${response.body}");
}
var jsonData = jsonDecode(response.body);
if (jsonData["IsAuthenticated"] != null) {
- AppState().setIsAuthenticated = jsonData["IsAuthenticated"];
+ getIt.get().setIsAuthenticated = jsonData["IsAuthenticated"];
}
if (jsonData["ErrorMessage"] == null) {
return factoryConstructor(jsonData);
@@ -146,16 +149,16 @@ class ApiClient implements IApiClient {
}
if (queryParameters != null) {
// var queryString = new Uri(queryParameters: queryParameters).query;
- var queryString = Uri(queryParameters: queryParameters.map((key, value) => MapEntry(key, value == null ? null : value.toString()))).query;
- url = url + '?' + queryString;
+ var queryString = Uri(queryParameters: queryParameters.map((key, value) => MapEntry(key, value?.toString()))).query;
+ url = '$url?$queryString';
}
// if (!kReleaseMode && url.contains("saned")) {
if (!kReleaseMode) {
- print("Url: $url");
- print("Headers: $_headers");
+ loggerService.logInfo("Url: $url");
+ loggerService.logInfo("Headers: $_headers");
// var bodyJson = json.encode(requestBody);
- print("body: $requestBody");
+ loggerService.logInfo("body: $requestBody");
}
var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 120));
@@ -170,7 +173,7 @@ class ApiClient implements IApiClient {
}
} on SocketException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -178,7 +181,7 @@ class ApiClient implements IApiClient {
}
} on HttpException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -188,7 +191,7 @@ class ApiClient implements IApiClient {
throw APIException(APIException.TIMEOUT, arguments: e);
} on ClientException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -199,7 +202,7 @@ class ApiClient implements IApiClient {
@override
Future getJsonForResponse(String url, {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isAuthAPI = false}) async {
- logger.i("Url:$url");
+ loggerService.logInfo("Url:$url");
if (headers == null) {
headers = {'Content-Type': 'application/json'};
} else {
@@ -225,8 +228,8 @@ class ApiClient implements IApiClient {
}
if (queryParameters != null) {
- var queryString = new Uri(queryParameters: queryParameters).query;
- url = url + '?' + queryString;
+ var queryString = Uri(queryParameters: queryParameters).query;
+ url = '$url?$queryString';
}
var response = await _get(Uri.parse(url), headers: _headers).timeout(Duration(seconds: 60));
@@ -239,7 +242,7 @@ class ApiClient implements IApiClient {
}
} on SocketException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -247,7 +250,7 @@ class ApiClient implements IApiClient {
}
} on HttpException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -257,7 +260,7 @@ class ApiClient implements IApiClient {
throw APIException(APIException.TIMEOUT, arguments: e);
} on ClientException catch (e) {
if (retryTimes > 0) {
- print('will retry after 3 seconds...');
+ loggerService.logInfo('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else {
@@ -282,7 +285,6 @@ class ApiClient implements IApiClient {
Future _post(url, {Map? headers, body, Encoding? encoding}) => _withClient((client) => client.post(url, headers: headers, body: body, encoding: encoding));
- Future _put(url, {Map? headers, body, Encoding? encoding}) => _withClient((client) => client.put(url, headers: headers, body: body, encoding: encoding));
@override
void setHomeUrl(String url) {
diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart
index 4bed676..684c600 100644
--- a/lib/core/app_state.dart
+++ b/lib/core/app_state.dart
@@ -5,14 +5,10 @@ import 'package:hmg_patient_app_new/main.dart';
import 'consts.dart';
class AppState {
- static final AppState _instance = AppState._internal();
-
- AppState._internal();
-
- factory AppState() => _instance;
+ // Simple constructor - let get_it handle the singleton behavior
+ AppState();
//Tokens
-
bool isAuthenticated = false;
set setIsAuthenticated(v) => isAuthenticated = v;
diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart
index 4b3b0d6..82e3fe7 100644
--- a/lib/core/dependencies.dart
+++ b/lib/core/dependencies.dart
@@ -1,9 +1,31 @@
+import 'package:get_it/get_it.dart';
+import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
-import 'package:injector/injector.dart';
+import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
+import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_repo.dart';
+import 'package:hmg_patient_app_new/features/common/common_repo.dart';
+import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart';
+import 'package:hmg_patient_app_new/services/cache_service.dart';
+import 'package:hmg_patient_app_new/services/logger_service.dart';
+import 'package:logger/web.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+GetIt getIt = GetIt.instance;
class AppDependencies {
- static void addDependencies() {
- Injector injector = Injector.appInstance;
- injector.registerSingleton(() => AppState());
+ static Future addDependencies() async {
+ // Services
+ getIt.registerLazySingleton(() => LoggerServiceImp(logger: Logger(printer: PrettyPrinter(lineLength: 0))));
+ final sharedPreferences = await SharedPreferences.getInstance();
+ getIt.registerLazySingleton(() => CacheServiceImp(sharedPreferences: sharedPreferences));
+ getIt.registerSingleton(AppState());
+ getIt.registerLazySingleton(() => ApiClient(loggerService: getIt()));
+
+ // Repositories
+ getIt.registerLazySingleton(() => CommonRepoImp(loggerService: getIt()));
+ getIt.registerLazySingleton(() => AuthenticationRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => BookAppointmentsRepoImp(loggerService: getIt(), apiClient: getIt()));
+ getIt.registerLazySingleton(() => MyAppointmentsRepoImp(loggerService: getIt(), apiClient: getIt()));
+
}
}
diff --git a/lib/core/enums.dart b/lib/core/enums.dart
index 95efb6c..db758f3 100644
--- a/lib/core/enums.dart
+++ b/lib/core/enums.dart
@@ -23,9 +23,9 @@ enum ViewState {
}
enum LoginType {
- FROM_LOGIN,
- SILENT_LOGIN,
- SILENT_WITH_OTP,
+ fromLogin,
+ silentLogin,
+ silentWithOTP,
}
enum OTPType { sms, whatsapp }
diff --git a/lib/services/api_exception.dart b/lib/core/exceptions/api_exception.dart
similarity index 90%
rename from lib/services/api_exception.dart
rename to lib/core/exceptions/api_exception.dart
index f0f1ff9..5076cc3 100644
--- a/lib/services/api_exception.dart
+++ b/lib/core/exceptions/api_exception.dart
@@ -1,6 +1,7 @@
import 'dart:convert';
-import 'package:hmg_patient_app_new/services/api_client.dart';
+import 'package:equatable/equatable.dart';
+import 'package:hmg_patient_app_new/core/api/api_client.dart';
class APIException implements Exception {
static const String BAD_REQUEST = 'api_common_bad_request';
@@ -27,3 +28,4 @@ class APIException implements Exception {
return jsonEncode(this);
}
}
+
diff --git a/lib/core/exceptions/api_failure.dart b/lib/core/exceptions/api_failure.dart
new file mode 100644
index 0000000..eaa434e
--- /dev/null
+++ b/lib/core/exceptions/api_failure.dart
@@ -0,0 +1,42 @@
+
+import 'package:equatable/equatable.dart';
+
+abstract class Failure extends Equatable implements Exception {
+ final String message;
+ const Failure(this.message);
+}
+
+class ServerFailure extends Failure {
+ const ServerFailure(super.message);
+
+ @override
+ List