livechat implementation contd.

pull/93/head
haroon amjad 2 months ago
parent 2a6c7fc0a1
commit 096b2b7cbf

@ -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<Either<Failure, GenericApiModel<List<GetHMGLocationsModel>>>> getHMGLocations();
Future<Either<Failure, GenericApiModel<List<GetPatientICProjectsModel>>>> getLiveChatProjectsList();
}
class ContactUsRepoImp implements ContactUsRepo {
@ -52,4 +55,41 @@ class ContactUsRepoImp implements ContactUsRepo {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel<List<GetPatientICProjectsModel>>>> getLiveChatProjectsList() async {
Map<String, dynamic> mapDevice = {};
try {
GenericApiModel<List<GetPatientICProjectsModel>>? 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<String, dynamic>)).toList().cast<GetPatientICProjectsModel>();
apiResponse = GenericApiModel<List<GetPatientICProjectsModel>>(
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()));
}
}
}

@ -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<AppState>();
locationUtils = getIt.get<LocationUtils>();
locationUtils!.isShowConfirmDialog = true;
locationUtils.isShowConfirmDialog = true;
contactUsViewModel = Provider.of<ContactUsViewModel>(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(),
),
);
});
}),
],
);
}

@ -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()
],
),
);
}
}
Loading…
Cancel
Save