diff --git a/lib/features/contact_us/contact_us_repo.dart b/lib/features/contact_us/contact_us_repo.dart index 9834150..f2b1169 100644 --- a/lib/features/contact_us/contact_us_repo.dart +++ b/lib/features/contact_us/contact_us_repo.dart @@ -4,10 +4,13 @@ import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_hmg_locations.dart'; +import 'package:hmg_patient_app_new/features/contact_us/models/resp_models/get_patient_ic_projects.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart'; abstract class ContactUsRepo { Future>>> getHMGLocations(); + + Future>>> getLiveChatProjectsList(); } class ContactUsRepoImp implements ContactUsRepo { @@ -52,4 +55,41 @@ class ContactUsRepoImp implements ContactUsRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future>>> getLiveChatProjectsList() async { + Map mapDevice = {}; + + try { + GenericApiModel>? apiResponse; + Failure? failure; + await apiClient.post( + GET_LIVECHAT_REQUEST, + body: mapDevice, + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (response, statusCode, {messageStatus, errorMessage}) { + try { + final list = response['List_PatientICProjects']; + final hmgLocations = list.map((item) => GetPatientICProjectsModel.fromJson(item as Map)).toList().cast(); + + apiResponse = GenericApiModel>( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: hmgLocations, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, + ); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } } diff --git a/lib/features/contact_us/models/resp_models/get_patientI_cprojects.dart b/lib/features/contact_us/models/resp_models/get_patient_ic_projects.dart similarity index 100% rename from lib/features/contact_us/models/resp_models/get_patientI_cprojects.dart rename to lib/features/contact_us/models/resp_models/get_patient_ic_projects.dart diff --git a/lib/presentation/contact_us/contact_us.dart b/lib/presentation/contact_us/contact_us.dart index 970e7eb..6890fb4 100644 --- a/lib/presentation/contact_us/contact_us.dart +++ b/lib/presentation/contact_us/contact_us.dart @@ -11,6 +11,7 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/contact_us/contact_us_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/contact_us/find_us_page.dart'; +import 'package:hmg_patient_app_new/presentation/contact_us/live_chat_page.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:provider/provider.dart'; @@ -26,7 +27,7 @@ class ContactUs extends StatelessWidget { Widget build(BuildContext context) { appState = getIt.get(); locationUtils = getIt.get(); - locationUtils!.isShowConfirmDialog = true; + locationUtils.isShowConfirmDialog = true; contactUsViewModel = Provider.of(context); return Column( children: [ @@ -56,7 +57,16 @@ class ContactUs extends StatelessWidget { AppAssets.checkin_location_icon, LocaleKeys.liveChat.tr(), "Live chat option with HMG".needTranslation, - ), + ).onPress(() { + locationUtils.getCurrentLocation(onSuccess: (value) { + Navigator.pop(context); + Navigator.of(context).push( + CustomPageRoute( + page: LiveChatPage(), + ), + ); + }); + }), ], ); } diff --git a/lib/presentation/contact_us/live_chat_page.dart b/lib/presentation/contact_us/live_chat_page.dart new file mode 100644 index 0000000..aced678 --- /dev/null +++ b/lib/presentation/contact_us/live_chat_page.dart @@ -0,0 +1,27 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/theme/colors.dart'; +import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; + +class LiveChatPage extends StatelessWidget { + const LiveChatPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.bgScaffoldColor, + body: Column( + children: [ + Expanded( + child: CollapsingListView( + title: LocaleKeys.liveChat.tr(), + child: SingleChildScrollView(), + ), + ), + Container() + ], + ), + ); + } +}