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 d60f0c0..71a2e60 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -2,12 +2,12 @@ buildscript { repositories { google() mavenCentral() - maven { url = uri("https://developer.huawei.com/repo/") } +// 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") +// classpath("com.huawei.agconnect:agcp:1.9.3.302") } } @@ -15,7 +15,7 @@ allprojects { repositories { google() mavenCentral() - maven { url = uri("https://developer.huawei.com/repo/") } +// 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..bac2157 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -435,7 +435,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; @@ -564,7 +564,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 +615,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; diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 4e08cd1..ef15c95 100644 --- a/lib/core/api/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/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 '../app_state.dart'; -import '../consts.dart'; -import '../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/exceptions/api_exception.dart b/lib/core/exceptions/api_exception.dart index 7d94212..5076cc3 100644 --- a/lib/core/exceptions/api_exception.dart +++ b/lib/core/exceptions/api_exception.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:equatable/equatable.dart'; import 'package:hmg_patient_app_new/core/api/api_client.dart'; class APIException implements Exception { @@ -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 get props => [message]; +} + +class ConnectivityFailure extends Failure { + const ConnectivityFailure(super.message); + + @override + List get props => [message]; +} + +class LocalStorageFailure extends Failure { + const LocalStorageFailure(super.message); + + @override + List get props => [message]; +} + +class DuplicateUsername extends Failure { + const DuplicateUsername({String? message}) : super(message ?? ''); + + @override + List get props => [message]; +} + +class InvalidCredentials extends Failure { + const InvalidCredentials({String? message}) : super(message ?? ''); + + @override + List get props => [message]; +} diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 1755fba..64bc2ca 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -1,4 +1,59 @@ -class AuthenticationRepo { + +import 'package:dartz/dartz.dart'; +import 'package:hmg_patient_app_new/core/api/api_client.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_exception.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; +import 'package:hmg_patient_app_new/services/logger_service.dart'; + +abstract class AuthenticationRepo { + Future> signIn({required String phone, required String password}); +} + +class AuthenticationRepoImp implements AuthenticationRepo { + final ApiClient apiClient; + final LoggerService loggerService; + + AuthenticationRepoImp({required this.loggerService, required this.apiClient}); + + @override + Future> signIn({required String phone, required String password}) async { + try { + // Mock API call with delayed response + final result = await Future.delayed( + const Duration(seconds: 2), + () => { + 'success': true, + 'data': [ + { + 'id': '1', + 'name': 'Dr. Ahmed Hassan', + 'specialty': 'Cardiology', + 'experience': '10 years', + 'rating': 4.8, + 'image': 'https://example.com/doctor1.jpg' + }, + ] + } + ); + + if (result != null && result is Map && result['success'] != null && result['success'] != null && result['success'] != false) { + return Right(result); + } else { + loggerService.errorLogs(result.toString()); + return Left(ServerFailure(result.toString())); + } + } on APIException catch (e) { + APIError? apiError; + if (e.error is APIError) { + apiError = e.error as APIError; + } + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(apiError?.errorMessage ?? e.message)); + } catch (e) { + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(e.toString())); + } + } } \ No newline at end of file diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index af542ac..434df16 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -1,5 +1,46 @@ import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart'; class AuthenticationViewModel extends ChangeNotifier { - // Add properties and methods related to authentication here -} \ No newline at end of file + AuthenticationRepo authenticationRepo; + + AuthenticationViewModel({required this.authenticationRepo}); + + Future signUp({ + required String phone, + required String password, + Function(dynamic)? onSuccess, + Function(String)? onError, + }) async { + Utils.showLoading(); + final resultEither = await authenticationRepo.signIn( + phone: phone, + password: password, + ); + + if (resultEither.isLeft()) { + + + } + + if (resultEither.isRight()) { + + + } + + + resultEither.fold( + (failure) { + Utils.hideLoading(); + notifyListeners(); + if (onError != null) onError(failure.message); + }, + (data) { + Utils.hideLoading(); + notifyListeners(); + if (onSuccess != null) onSuccess(data); + }, + ); + } +} diff --git a/lib/features/book_appointments/book_appointments_repo.dart b/lib/features/book_appointments/book_appointments_repo.dart index e69de29..b994b35 100644 --- a/lib/features/book_appointments/book_appointments_repo.dart +++ b/lib/features/book_appointments/book_appointments_repo.dart @@ -0,0 +1,56 @@ +import 'package:dartz/dartz.dart'; +import 'package:hmg_patient_app_new/core/api/api_client.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_exception.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; +import 'package:hmg_patient_app_new/services/logger_service.dart'; + +abstract class BookAppointmentsRepo { + Future> getDoctors(); +} + +class BookAppointmentsRepoImp implements BookAppointmentsRepo { + final ApiClient apiClient; + final LoggerService loggerService; + + BookAppointmentsRepoImp({required this.loggerService, required this.apiClient}); + + @override + Future> getDoctors() async { + try { + // Mock API call with delayed response + final result = await Future.delayed( + const Duration(seconds: 2), + () => { + 'success': true, + 'data': [ + { + 'id': '1', + 'name': 'Dr. Ahmed Hassan', + 'specialty': 'Cardiology', + 'experience': '10 years', + 'rating': 4.8, + 'image': 'https://example.com/doctor1.jpg' + }, + ] + } + ); + + if (result != null && result is Map && result['success'] != null && result['success'] != false) { + return Right(result); + } else { + loggerService.errorLogs(result.toString()); + return Left(ServerFailure(result.toString())); + } + } on APIException catch (e) { + APIError? apiError; + if (e.error is APIError) { + apiError = e.error as APIError; + } + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(apiError?.errorMessage ?? e.message)); + } catch (e) { + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(e.toString())); + } + } +} diff --git a/lib/features/common/common_repo.dart b/lib/features/common/common_repo.dart index e69de29..1d7301c 100644 --- a/lib/features/common/common_repo.dart +++ b/lib/features/common/common_repo.dart @@ -0,0 +1,13 @@ +import 'package:hmg_patient_app_new/services/logger_service.dart'; + +abstract class CommonRepo { + +} + + +class CommonRepoImp implements CommonRepo { + LoggerService loggerService; + + CommonRepoImp({required this.loggerService}); + +} \ No newline at end of file diff --git a/lib/features/my_appointments/my_appointments_repo.dart b/lib/features/my_appointments/my_appointments_repo.dart index e69de29..7ac0c47 100644 --- a/lib/features/my_appointments/my_appointments_repo.dart +++ b/lib/features/my_appointments/my_appointments_repo.dart @@ -0,0 +1,78 @@ +import 'package:dartz/dartz.dart'; +import 'package:hmg_patient_app_new/core/api/api_client.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_exception.dart'; +import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; +import 'package:hmg_patient_app_new/services/logger_service.dart'; + +abstract class MyAppointmentsRepo { + Future> getMyAppointments(); +} + +class MyAppointmentsRepoImp implements MyAppointmentsRepo { + final ApiClient apiClient; + final LoggerService loggerService; + + MyAppointmentsRepoImp({required this.loggerService, required this.apiClient}); + + @override + Future> getMyAppointments() async { + try { + // Mock API call with delayed response + final result = await Future.delayed( + const Duration(seconds: 2), + () => { + 'success': true, + 'data': [ + { + 'id': '1', + 'doctorName': 'Dr. Ahmed Hassan', + 'specialty': 'Cardiology', + 'appointmentDate': '2025-09-05', + 'appointmentTime': '10:00 AM', + 'status': 'confirmed', + 'clinicName': 'HMG Hospital', + 'patientName': 'John Doe' + }, + { + 'id': '2', + 'doctorName': 'Dr. Sarah Johnson', + 'specialty': 'Dermatology', + 'appointmentDate': '2025-09-08', + 'appointmentTime': '2:30 PM', + 'status': 'pending', + 'clinicName': 'HMG Medical Center', + 'patientName': 'John Doe' + }, + { + 'id': '3', + 'doctorName': 'Dr. Mohamed Ali', + 'specialty': 'Pediatrics', + 'appointmentDate': '2025-08-25', + 'appointmentTime': '11:15 AM', + 'status': 'completed', + 'clinicName': 'HMG Children\'s Clinic', + 'patientName': 'John Doe' + } + ] + } + ); + + if (result != null && result is Map && result['success'] != null && result['success'] != false) { + return Right(result); + } else { + loggerService.errorLogs(result.toString()); + return Left(ServerFailure(result.toString())); + } + } on APIException catch (e) { + APIError? apiError; + if (e.error is APIError) { + apiError = e.error as APIError; + } + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(apiError?.errorMessage ?? e.message)); + } catch (e) { + loggerService.errorLogs(e.toString()); + return Left(ServerFailure(e.toString())); + } + } +} diff --git a/lib/main.dart b/lib/main.dart index ce601a2..8adfc4a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,8 +6,10 @@ import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; +import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/routes/app_routes.dart'; +import 'package:hmg_patient_app_new/services/logger_service.dart'; import 'package:hmg_patient_app_new/theme/app_theme.dart'; import 'package:logger/logger.dart'; import 'package:provider/provider.dart'; @@ -19,23 +21,11 @@ import 'firebase_options.dart'; var globalMessengerKey = GlobalKey(); final navigatorKey = GlobalKey(); -Logger logger = Logger( - printer: PrettyPrinter( - lineLength: 0, - ), -); - -late AppState appState; @pragma('vm:entry-point') Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - print("Firebase backgroundMessageHandler Main!!!"); - // debugPrint('backgroundMessage: message => ${message.notification!.title.toString()}'); - // messagesOpended = message.notification!.title.toString(); - var payload = message.data; - // showCallkitIncoming(payload); - // await backgroundCallHandler(payload); + getIt.get().logInfo("Firebase backgroundMessageHandler Main!!!"); } class MyHttpOverrides extends HttpOverrides { @@ -45,12 +35,17 @@ class MyHttpOverrides extends HttpOverrides { } } -void main() async { +Future callInitializations() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + AppDependencies.addDependencies(); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); HttpOverrides.global = MyHttpOverrides(); +} + +void main() async { + callInitializations(); runApp( EasyLocalization( supportedLocales: const [ @@ -61,7 +56,7 @@ void main() async { fallbackLocale: Locale('en', 'US'), child: MultiProvider(providers: [ ChangeNotifierProvider( - create: (_) => AuthenticationViewModel(), + create: (_) => AuthenticationViewModel(authenticationRepo: getIt()), ), ], child: MyApp()), ), @@ -71,7 +66,6 @@ void main() async { class MyApp extends StatelessWidget { const MyApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { return SafeArea( diff --git a/lib/services/cache_service.dart b/lib/services/cache_service.dart new file mode 100644 index 0000000..f25409e --- /dev/null +++ b/lib/services/cache_service.dart @@ -0,0 +1,14 @@ + +import 'package:shared_preferences/shared_preferences.dart'; + +abstract class CacheService { + +} + +class CacheServiceImp implements CacheService { + SharedPreferences sharedPreferences; + + CacheServiceImp({required this.sharedPreferences}); + + +} diff --git a/lib/services/logger_service.dart b/lib/services/logger_service.dart index 833a7d2..0b33c52 100644 --- a/lib/services/logger_service.dart +++ b/lib/services/logger_service.dart @@ -3,7 +3,7 @@ import 'package:logger/logger.dart'; abstract class LoggerService { - void logError(String message); + void errorLogs(String message); void logInfo(String message); } @@ -16,7 +16,7 @@ class LoggerServiceImp implements LoggerService { @override - void logError(String message) { + void errorLogs(String message) { logger.e(message); } diff --git a/pubspec.yaml b/pubspec.yaml index db3d25e..27ba216 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,8 +30,8 @@ dependencies: # firebase_core: ^3.13.1 permission_handler: ^12.0.1 flutter_local_notifications: ^19.4.1 - injector: ^4.0.0 provider: ^6.1.5+1 + get_it: ^8.2.0 just_audio: ^0.10.4 flutter_callkit_incoming: git: @@ -60,6 +60,8 @@ dependencies: dropdown_search: ^6.0.2 google_maps_flutter: ^2.12.3 flutter_zoom_videosdk: ^2.1.10 + dartz: ^0.10.1 + equatable: ^2.0.7 web: any