Comprehensive checkup Completed
parent
721bf95c1b
commit
3331edc10d
@ -0,0 +1,380 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/app_assets.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/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/route_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/models/resq_models/get_cmc_services_resp_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/presentation/comprehensive_checkup/widgets/cmc_hospital_selection_helper.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||||
|
import 'package:maps_launcher/maps_launcher.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CmcSelectionReviewPage extends StatefulWidget {
|
||||||
|
final GetCMCServicesResponseModel selectedService;
|
||||||
|
final HospitalsModel? preSelectedHospital;
|
||||||
|
|
||||||
|
const CmcSelectionReviewPage({
|
||||||
|
super.key,
|
||||||
|
required this.selectedService,
|
||||||
|
this.preSelectedHospital,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CmcSelectionReviewPage> createState() => _CmcSelectionReviewPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CmcSelectionReviewPageState extends State<CmcSelectionReviewPage> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// Initialize ViewModel state with preselected hospital if provided
|
||||||
|
if (widget.preSelectedHospital != null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||||
|
hmgServicesViewModel.setSelectedHospitalForOrder(widget.preSelectedHospital);
|
||||||
|
hmgServicesViewModel.setSelectedServiceForOrder(widget.selectedService);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appState = getIt.get<AppState>();
|
||||||
|
final isArabic = appState.isArabic();
|
||||||
|
|
||||||
|
return CollapsingListView(
|
||||||
|
title: "Summary".needTranslation,
|
||||||
|
bottomChild: _buildBottomButton(),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.all(16.w),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildOrderSummaryCard(isArabic),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
_buildSelectedServiceCard(isArabic),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOrderSummaryCard(bool isArabic) {
|
||||||
|
return Consumer<HmgServicesViewModel>(
|
||||||
|
builder: (context, hmgServicesViewModel, child) {
|
||||||
|
final selectedHospital = hmgServicesViewModel.selectedHospitalForOrder;
|
||||||
|
final isLocationSelected = selectedHospital != null;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 16.r,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(16.w),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Select Hospital".needTranslation,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.f,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: AppColors.blackColor,
|
||||||
|
letterSpacing: -0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
_buildHospitalSelector(isArabic, selectedHospital, isLocationSelected),
|
||||||
|
if (isLocationSelected && selectedHospital != null) ...[
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
_buildHospitalMap(selectedHospital),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHospitalSelector(bool isArabic, HospitalsModel? selectedHospital, bool isLocationSelected) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: _showHospitalSelectionBottomSheet,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.bgScaffoldColor,
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
border: Border.all(
|
||||||
|
color: AppColors.greyColor.withAlpha(51),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
isLocationSelected && selectedHospital != null
|
||||||
|
? (isArabic ? (selectedHospital.nameN ?? selectedHospital.name ?? '') : (selectedHospital.name ?? ''))
|
||||||
|
: "Select Hospital".needTranslation,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.f,
|
||||||
|
fontWeight: isLocationSelected ? FontWeight.w600 : FontWeight.w400,
|
||||||
|
color: isLocationSelected ? AppColors.blackColor : AppColors.greyTextColor,
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.keyboard_arrow_down,
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
size: 24.h,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHospitalMap(HospitalsModel selectedHospital) {
|
||||||
|
final String lat = selectedHospital.latitude ?? "0.0";
|
||||||
|
final String lng = selectedHospital.longitude ?? "0.0";
|
||||||
|
|
||||||
|
if (lat == "0.0" || lng == "0.0") return SizedBox.shrink();
|
||||||
|
|
||||||
|
// final String staticMapUrl =
|
||||||
|
// "https://maps.googleapis.com/maps/api/staticmap?center=$lat,$lng&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C$lat,$lng&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8";
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
child: Image.network(
|
||||||
|
"staticMapUrl",
|
||||||
|
height: 200.h,
|
||||||
|
width: double.infinity,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
loadingBuilder: (context, child, loadingProgress) {
|
||||||
|
if (loadingProgress == null) return child;
|
||||||
|
return Container(
|
||||||
|
height: 200.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.bgScaffoldColor,
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: AppColors.primaryRedColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return Container(
|
||||||
|
height: 200.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.bgScaffoldColor,
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.error_outline,
|
||||||
|
size: 48.h,
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 12.h,
|
||||||
|
right: 12.w,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => _launchDirections(selectedHospital),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: BorderRadius.circular(1000.r),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color.fromARGB(26, 0, 0, 0),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Utils.buildSvgWithAssets(
|
||||||
|
icon: AppAssets.directions_icon,
|
||||||
|
width: 16.w,
|
||||||
|
height: 16.h,
|
||||||
|
),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
|
Text(
|
||||||
|
"Get Directions".needTranslation,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.f,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.blackColor,
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSelectedServiceCard(bool isArabic) {
|
||||||
|
final serviceName = isArabic ? (widget.selectedService.textN ?? widget.selectedService.text ?? '') : (widget.selectedService.text ?? '');
|
||||||
|
final price = widget.selectedService.priceTotal ?? 0.0;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 16.r,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(16.w),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Selected Service".needTranslation.toText14(
|
||||||
|
weight: FontWeight.w600,
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: serviceName.toText16(weight: FontWeight.w700, color: AppColors.blackColor, letterSpacing: -0.5)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
"${"Price".needTranslation}: ".toText14(weight: FontWeight.w500, color: AppColors.greyTextColor, letterSpacing: -0.4),
|
||||||
|
Utils.getPaymentAmountWithSymbol(
|
||||||
|
isExpanded: false,
|
||||||
|
price.toString().toText14(weight: FontWeight.w700),
|
||||||
|
AppColors.primaryRedColor,
|
||||||
|
16,
|
||||||
|
isSaudiCurrency: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomButton() {
|
||||||
|
return Consumer<HmgServicesViewModel>(
|
||||||
|
builder: (context, hmgServicesViewModel, child) {
|
||||||
|
final isLocationSelected = hmgServicesViewModel.selectedHospitalForOrder != null;
|
||||||
|
|
||||||
|
return SafeArea(
|
||||||
|
top: false,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color.fromARGB(13, 0, 0, 0),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: Offset(0, -2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: CustomButton(
|
||||||
|
text: "Confirm".needTranslation,
|
||||||
|
onPressed: () {
|
||||||
|
isLocationSelected ? _handleConfirm : null;
|
||||||
|
},
|
||||||
|
textColor: AppColors.whiteColor,
|
||||||
|
backgroundColor: isLocationSelected ? AppColors.successColor : AppColors.greyColor,
|
||||||
|
borderRadius: 12.r,
|
||||||
|
borderColor: Colors.transparent,
|
||||||
|
borderWidth: 0,
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 14.h),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showHospitalSelectionBottomSheet() {
|
||||||
|
CmcHospitalSelectionHelper.showHospitalSelectionBottomSheet(context: context, onHospitalSelected: (hospital) => context.pop());
|
||||||
|
}
|
||||||
|
|
||||||
|
void _launchDirections(HospitalsModel selectedHospital) {
|
||||||
|
final double lat = double.parse(selectedHospital.latitude ?? "0.0");
|
||||||
|
final double lng = double.parse(selectedHospital.longitude ?? "0.0");
|
||||||
|
|
||||||
|
if (lat != 0.0 && lng != 0.0) {
|
||||||
|
MapsLauncher.launchCoordinates(
|
||||||
|
lat,
|
||||||
|
lng,
|
||||||
|
selectedHospital.name ?? "Hospital",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleConfirm() {
|
||||||
|
final hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||||
|
final selectedHospital = hmgServicesViewModel.selectedHospitalForOrder;
|
||||||
|
|
||||||
|
if (selectedHospital == null) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text("Please select a hospital to continue".needTranslation),
|
||||||
|
backgroundColor: AppColors.errorColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement order creation API call
|
||||||
|
// Create CMC order with:
|
||||||
|
// - hmgServicesViewModel.selectedServiceForOrder (the medical checkup service)
|
||||||
|
// - hmgServicesViewModel.selectedHospitalForOrder (the chosen hospital)
|
||||||
|
// - Call hmgServicesViewModel.createCmcOrder() or similar method
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
"Order confirmed! Service: ${widget.selectedService.text}, Hospital: ${selectedHospital.name}",
|
||||||
|
),
|
||||||
|
backgroundColor: AppColors.successColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Navigate back after confirmation
|
||||||
|
Future.delayed(Duration(seconds: 2), () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
// Clear order selection after successful confirmation
|
||||||
|
hmgServicesViewModel.clearOrderSelection();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,195 +1,427 @@
|
|||||||
|
// import 'dart:async';
|
||||||
|
//
|
||||||
// import 'package:hmg_patient_app/core/enum/viewstate.dart';
|
// import 'package:hmg_patient_app/core/enum/viewstate.dart';
|
||||||
// import 'package:hmg_patient_app/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart';
|
// import 'package:hmg_patient_app/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart';
|
||||||
|
// import 'package:hmg_patient_app/core/model/ImagesInfo.dart';
|
||||||
|
// import 'package:hmg_patient_app/core/model/hospitals/hospitals_model.dart';
|
||||||
// import 'package:hmg_patient_app/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
|
// import 'package:hmg_patient_app/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
|
||||||
// import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
|
// import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
|
||||||
// import 'package:hmg_patient_app/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart';
|
// import 'package:hmg_patient_app/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/Dialog/confirm_dialog.dart';
|
||||||
|
// import 'package:hmg_patient_app/services/clinic_services/get_clinic_service.dart';
|
||||||
|
// import 'package:hmg_patient_app/theme/colors.dart';
|
||||||
|
// import 'package:hmg_patient_app/uitl/app_toast.dart';
|
||||||
|
// import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
|
||||||
// import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
|
// import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
|
||||||
// import 'package:hmg_patient_app/uitl/utils.dart';
|
// import 'package:hmg_patient_app/uitl/utils.dart';
|
||||||
// import 'package:hmg_patient_app/uitl/utils_new.dart';
|
// import 'package:hmg_patient_app/uitl/utils_new.dart';
|
||||||
// import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
|
// import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
|
||||||
// import 'package:hmg_patient_app/widgets/dragable_sheet.dart';
|
|
||||||
// import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
|
// import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
|
||||||
// import 'package:hmg_patient_app/widgets/photo_view_page.dart';
|
|
||||||
// import 'package:flutter/cupertino.dart';
|
// import 'package:flutter/cupertino.dart';
|
||||||
// import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
// import 'package:flutter_svg/svg.dart';
|
// import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
// import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
// import 'package:maps_launcher/maps_launcher.dart';
|
||||||
// import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
//
|
//
|
||||||
// import 'new_cmc_step_tow_page.dart';
|
// class NewCMCStepThreePage extends StatefulWidget {
|
||||||
//
|
// final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel;
|
||||||
// class NewCMCStepOnePage extends StatefulWidget {
|
|
||||||
// final CMCInsertPresOrderRequestModel cMCInsertPresOrderRequestModel;
|
|
||||||
// final Function changePageViewIndex;
|
|
||||||
// final CMCViewModel model;
|
// final CMCViewModel model;
|
||||||
//
|
//
|
||||||
// final double latitude;
|
// NewCMCStepThreePage(
|
||||||
// final double longitude;
|
// {Key? key,
|
||||||
//
|
// required this.model,
|
||||||
// const NewCMCStepOnePage({Key? key, required this.cMCInsertPresOrderRequestModel, required this.model, required this.changePageViewIndex, required this.latitude, required this.longitude})
|
// required this.cmcInsertPresOrderRequestModel});
|
||||||
// : super(key: key);
|
|
||||||
//
|
//
|
||||||
// @override
|
// @override
|
||||||
// _NewCMCStepOnePageState createState() => _NewCMCStepOnePageState();
|
// _NewCMCStepThreePageState createState() => _NewCMCStepThreePageState();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
|
// class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
|
||||||
// int selectedItem = 0;
|
// Completer<GoogleMapController> _controller = Completer();
|
||||||
|
//
|
||||||
|
// String? projectDropdownValue;
|
||||||
|
// late List<HospitalsModel> projectsList = [];
|
||||||
|
// HospitalsModel? selectedHospital;
|
||||||
|
// final GlobalKey projectDropdownKey = GlobalKey();
|
||||||
|
// bool isLocationSelected = false;
|
||||||
|
// ProjectViewModel? projectViewModel;
|
||||||
|
//
|
||||||
|
// static CameraPosition _kGooglePlex = CameraPosition(
|
||||||
|
// target: LatLng(37.42796133580664, -122.085749655962),
|
||||||
|
// zoom: 14.4746,
|
||||||
|
// );
|
||||||
|
// final Set<Marker> markers = new Set();
|
||||||
//
|
//
|
||||||
// @override
|
// @override
|
||||||
// void initState() {
|
// void initState() {
|
||||||
|
// if (widget.cmcInsertPresOrderRequestModel.latitude != null) {
|
||||||
|
// markers.clear();
|
||||||
|
// markers.add(
|
||||||
|
// Marker(
|
||||||
|
// markerId: MarkerId(
|
||||||
|
// widget.cmcInsertPresOrderRequestModel.latitude.hashCode
|
||||||
|
// .toString(),
|
||||||
|
// ),
|
||||||
|
// position: LatLng(widget.cmcInsertPresOrderRequestModel.latitude!,
|
||||||
|
// widget.cmcInsertPresOrderRequestModel.longitude!)),
|
||||||
|
// );
|
||||||
|
// _kGooglePlex = CameraPosition(
|
||||||
|
// target: LatLng(widget.cmcInsertPresOrderRequestModel.latitude!,
|
||||||
|
// widget.cmcInsertPresOrderRequestModel.longitude!),
|
||||||
|
// zoom: 14.4746,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
// // if (projectViewModel.isLogin) {
|
||||||
|
// getProjectsList();
|
||||||
|
// // }
|
||||||
|
// });
|
||||||
// super.initState();
|
// super.initState();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @override
|
// @override
|
||||||
// Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
// ProjectViewModel projectViewModel = Provider.of(context);
|
// projectViewModel = Provider.of(context);
|
||||||
//
|
|
||||||
// return AppScaffold(
|
// return AppScaffold(
|
||||||
// isShowAppBar: false,
|
// isShowAppBar: true,
|
||||||
|
// description: TranslationBase.of(context).infoCMC,
|
||||||
|
// imagesInfo: [
|
||||||
|
// ImagesInfo(
|
||||||
|
// imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png',
|
||||||
|
// imageEn:
|
||||||
|
// 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
|
||||||
|
// ],
|
||||||
|
// appBarTitle: TranslationBase.of(context).comprehensiveMedicalCheckup,
|
||||||
|
// showNewAppBar: true,
|
||||||
|
// showNewAppBarTitle: true,
|
||||||
|
// backgroundColor: CustomColors.appBackgroudGreyColor,
|
||||||
// baseViewModel: widget.model,
|
// baseViewModel: widget.model,
|
||||||
// body: Column(
|
// body: SingleChildScrollView(
|
||||||
// children: [
|
|
||||||
// Expanded(
|
|
||||||
// child: SingleChildScrollView(
|
|
||||||
// physics: BouncingScrollPhysics(),
|
// physics: BouncingScrollPhysics(),
|
||||||
// padding: EdgeInsets.all(21),
|
// child: Container(
|
||||||
|
// height: 500,
|
||||||
|
// width: double.maxFinite,
|
||||||
|
// margin: EdgeInsets.only(left: 12, right: 12),
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// SizedBox(
|
||||||
|
// height: 12,
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// TranslationBase.of(context).orderSummary,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 16,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// letterSpacing: -0.46,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// height: 12,
|
||||||
|
// ),
|
||||||
|
// Container(
|
||||||
|
// decoration: cardRadius(12),
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(8),
|
||||||
// child: Column(
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// decoration: containerRadius(Colors.white, 12),
|
||||||
|
// margin: EdgeInsets.only(top: 12),
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// left: 0, right: 0, top: 0, bottom: 12),
|
||||||
|
// child: Row(
|
||||||
// children: [
|
// children: [
|
||||||
// ListView.separated(
|
// Flexible(
|
||||||
// physics: NeverScrollableScrollPhysics(),
|
// child: Column(
|
||||||
// shrinkWrap: true,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// itemBuilder: (context, index) {
|
|
||||||
// return Row(
|
|
||||||
// children: [
|
// children: [
|
||||||
// Radio(
|
// Text(
|
||||||
// value: num.tryParse(widget.model.cmcAllServicesList[index].serviceID!),
|
// TranslationBase.of(context).selectLocation,
|
||||||
// activeColor: Colors.red[800],
|
// style: TextStyle(
|
||||||
// onChanged: (newValue) async {
|
// fontSize: 11,
|
||||||
// selectedItem = index;
|
// letterSpacing: -0.44,
|
||||||
// PatientERCMCInsertServicesList patientERCMCInsertServicesList = PatientERCMCInsertServicesList(
|
// fontWeight: FontWeight.w600,
|
||||||
// price: widget.model.cmcAllServicesList[index].price,
|
// ),
|
||||||
// serviceID: widget.model.cmcAllServicesList[index].serviceID,
|
// ),
|
||||||
// selectedServiceName: widget.model.cmcAllServicesList[index].text,
|
// Container(
|
||||||
// selectedServiceNameAR: widget.model.cmcAllServicesList[index].textN,
|
// height: 18,
|
||||||
// recordID: 1,
|
// child: DropdownButtonHideUnderline(
|
||||||
// totalPrice: widget.model.cmcAllServicesList[index].priceTotal,
|
// child: DropdownButton<HospitalsModel>(
|
||||||
// vAT: widget.model.cmcAllServicesList[index].priceVAT);
|
// key: projectDropdownKey,
|
||||||
|
// hint: new Text(
|
||||||
|
// TranslationBase.of(context)
|
||||||
|
// .selectHospital),
|
||||||
|
// value: selectedHospital,
|
||||||
|
// iconSize: 0,
|
||||||
|
// isExpanded: true,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 14,
|
||||||
|
// letterSpacing: -0.56,
|
||||||
|
// color: Colors.black),
|
||||||
|
// items: projectsList.map((item) {
|
||||||
|
// return new DropdownMenuItem<
|
||||||
|
// HospitalsModel>(
|
||||||
|
// value: item,
|
||||||
|
// child: new Text(item.name!),
|
||||||
|
// );
|
||||||
|
// }).toList(),
|
||||||
|
// onChanged:
|
||||||
|
// (HospitalsModel? newValue) async {
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
|
// selectedHospital = newValue!;
|
||||||
|
// projectDropdownValue = newValue
|
||||||
|
// .mainProjectID
|
||||||
|
// .toString();
|
||||||
|
// isLocationSelected = true;
|
||||||
|
// widget.cmcInsertPresOrderRequestModel
|
||||||
|
// .projectID =
|
||||||
|
// newValue.mainProjectID;
|
||||||
|
// // getDoctorsList(context);
|
||||||
// });
|
// });
|
||||||
// // CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: newValue);
|
|
||||||
// // await widget.model.getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel);
|
|
||||||
// },
|
// },
|
||||||
// groupValue: widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList!.length > 0
|
// ),
|
||||||
// ? int.parse(widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList![0].serviceID!)
|
// ),
|
||||||
// : 1),
|
// ),
|
||||||
// Expanded(
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Icon(Icons.keyboard_arrow_down),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// height: 6,
|
||||||
|
// ),
|
||||||
|
// isLocationSelected
|
||||||
|
// ? Padding(
|
||||||
|
// padding: const EdgeInsets.all(8.0),
|
||||||
|
// child: Stack(
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// height: 200,
|
||||||
|
// decoration: containerColorRadiusBorder(
|
||||||
|
// Colors.white, 12, Colors.grey),
|
||||||
|
// clipBehavior: Clip.antiAlias,
|
||||||
|
// child: Container(
|
||||||
|
// decoration: cardRadius(12),
|
||||||
|
// clipBehavior: Clip.antiAlias,
|
||||||
|
// margin: const EdgeInsets.all(0),
|
||||||
|
// child: Image.network(
|
||||||
|
// "https://maps.googleapis.com/maps/api/staticmap?center=" +
|
||||||
|
// selectedHospital!.latitude
|
||||||
|
// .toString() +
|
||||||
|
// "," +
|
||||||
|
// selectedHospital!.longitude
|
||||||
|
// .toString() +
|
||||||
|
// "&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C" +
|
||||||
|
// selectedHospital!.latitude
|
||||||
|
// .toString() +
|
||||||
|
// "," +
|
||||||
|
// selectedHospital!.longitude
|
||||||
|
// .toString() +
|
||||||
|
// "&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8",
|
||||||
|
// width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
// fit: BoxFit.cover,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// InkWell(
|
||||||
|
// onTap: () {
|
||||||
|
// getDirections();
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// decoration: cardRadius(1000),
|
||||||
|
// margin: EdgeInsets.all(12),
|
||||||
// child: Padding(
|
// child: Padding(
|
||||||
// padding: const EdgeInsets.only(
|
// padding: const EdgeInsets.only(
|
||||||
// left: 10,
|
// left: 12,
|
||||||
// right: 10,
|
// right: 12,
|
||||||
// top: 20,
|
// top: 6,
|
||||||
// bottom: 20,
|
// bottom: 6),
|
||||||
|
// child: Row(
|
||||||
|
// children: [
|
||||||
|
// Padding(
|
||||||
|
// padding:
|
||||||
|
// const EdgeInsets.all(3.0),
|
||||||
|
// child: SvgPicture.asset(
|
||||||
|
// "assets/images/new/direction.svg",
|
||||||
|
// width: 13,
|
||||||
|
// height: 13,
|
||||||
// ),
|
// ),
|
||||||
// child: Text(
|
// ),
|
||||||
// projectViewModel.isArabic ? widget.model.cmcAllServicesList[index].textN! : widget.model.cmcAllServicesList[index].text!,
|
// mWidth(6),
|
||||||
|
// Text(
|
||||||
|
// TranslationBase.of(context)
|
||||||
|
// .getDirections,
|
||||||
// style: TextStyle(
|
// style: TextStyle(
|
||||||
// fontSize: 14,
|
// color: Colors.black,
|
||||||
|
// fontSize: 11,
|
||||||
|
// letterSpacing: -0.44,
|
||||||
// fontWeight: FontWeight.w600,
|
// fontWeight: FontWeight.w600,
|
||||||
// letterSpacing: -0.45,
|
// ),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ],
|
// ],
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// separatorBuilder: (context, index) {
|
|
||||||
// return mDivider(Colors.grey);
|
|
||||||
// },
|
|
||||||
// itemCount: widget.model.cmcAllServicesList.length),
|
|
||||||
// Stack(
|
|
||||||
// children: [
|
|
||||||
// Image.asset(
|
|
||||||
// projectViewModel.isArabic ? "assets/images/cc_ar.png" : "assets/images/cc_en.png",
|
|
||||||
// width: double.infinity,
|
|
||||||
// ),
|
// ),
|
||||||
// Align(
|
// ],
|
||||||
// alignment: Alignment.topRight,
|
|
||||||
// child: Container(
|
|
||||||
// decoration: containerColorRadiusBorder(
|
|
||||||
// Colors.black.withOpacity(0.2),
|
|
||||||
// 1000,
|
|
||||||
// Colors.white,
|
|
||||||
// ),
|
// ),
|
||||||
// margin: EdgeInsets.all(12),
|
// )
|
||||||
// child: IconButton(
|
// : Container(),
|
||||||
// icon: SvgPicture.asset(
|
// SizedBox(
|
||||||
// "assets/images/new/ic_zoom.svg",
|
// height: 12,
|
||||||
// color: Colors.white,
|
|
||||||
// ),
|
// ),
|
||||||
// padding: EdgeInsets.all(12),
|
// Text(
|
||||||
// onPressed: () {
|
// TranslationBase.of(context).selectedService,
|
||||||
// showDraggableDialog(context, PhotoViewPage(projectViewModel.isArabic ? "assets/images/cc_ar.png" : "assets/images/cc_en.png"));
|
// style: TextStyle(
|
||||||
// },
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// letterSpacing: -0.46,
|
||||||
|
// color: CustomColors.grey,
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
// ...List.generate(
|
||||||
|
// widget.cmcInsertPresOrderRequestModel
|
||||||
|
// .patientERCMCInsertServicesList!.length,
|
||||||
|
// (index) => Container(
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// projectViewModel!.isArabic
|
||||||
|
// ? widget
|
||||||
|
// .cmcInsertPresOrderRequestModel
|
||||||
|
// .patientERCMCInsertServicesList![index]
|
||||||
|
// .selectedServiceNameAR!
|
||||||
|
// : widget
|
||||||
|
// .cmcInsertPresOrderRequestModel
|
||||||
|
// .patientERCMCInsertServicesList![index]
|
||||||
|
// .selectedServiceName!,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 12,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// letterSpacing: -0.46,
|
||||||
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// Container(
|
// ),
|
||||||
|
// ),
|
||||||
|
// bottomSheet: Container(
|
||||||
|
// height: MediaQuery.of(context).size.height * 0.10,
|
||||||
|
// width: double.infinity,
|
||||||
// color: Colors.white,
|
// color: Colors.white,
|
||||||
// padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21),
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: <Widget>[
|
||||||
|
// Container(
|
||||||
|
// width: MediaQuery.of(context).size.width * 0.9,
|
||||||
// child: DefaultButton(
|
// child: DefaultButton(
|
||||||
// TranslationBase.of(context).next,
|
// TranslationBase.of(context).confirm,
|
||||||
// () async {
|
// !isLocationSelected
|
||||||
// if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList!.length != 0 || widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList == null) {
|
// ? null
|
||||||
// // int index = widget.model.cmcAllServicesList.length;
|
// : () async {
|
||||||
// PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
|
// GifLoaderDialogUtils.showMyDialog(context);
|
||||||
// price: widget.model.cmcAllServicesList[selectedItem].price,
|
// String requestId = await widget.model.insertCMCOrderRC(
|
||||||
// serviceID: widget.model.cmcAllServicesList[selectedItem].serviceID.toString(),
|
// order: widget.cmcInsertPresOrderRequestModel);
|
||||||
// selectedServiceName: widget.model.cmcAllServicesList[selectedItem].text,
|
// GifLoaderDialogUtils.hideDialog(context);
|
||||||
// selectedServiceNameAR: widget.model.cmcAllServicesList[selectedItem].textN,
|
// if (widget.model.state != ViewState.ErrorLocal) {
|
||||||
// recordID: 1,
|
// showCMCConfirmDialog(
|
||||||
// totalPrice: widget.model.cmcAllServicesList[selectedItem].priceTotal,
|
|
||||||
// vAT: widget.model.cmcAllServicesList[selectedItem].priceVAT,
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// widget.cMCInsertPresOrderRequestModel.patientID = projectViewModel.user!.patientID;
|
|
||||||
// widget.cMCInsertPresOrderRequestModel.patientOutSA = projectViewModel.user!.outSA;
|
|
||||||
//
|
|
||||||
// widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
|
|
||||||
// navigateTo(
|
|
||||||
// context,
|
// context,
|
||||||
// NewCMCStepThreePage(
|
// requestId,
|
||||||
// cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel,
|
// onClick: () {
|
||||||
// model: widget.model,
|
// Navigator.pop(context);
|
||||||
// ),
|
// Navigator.pop(context);
|
||||||
|
// },
|
||||||
// );
|
// );
|
||||||
// // await widget.model.getCustomerInfo();
|
|
||||||
// if (widget.model.state == ViewState.ErrorLocal) {
|
|
||||||
// Utils.showErrorToast();
|
|
||||||
// } else {
|
// } else {
|
||||||
// // navigateTo(
|
// AppToast.showErrorToast(message: widget.model.error);
|
||||||
// // context,
|
|
||||||
// // NewCMCStepTowPage(
|
|
||||||
// // longitude: widget.longitude,
|
|
||||||
// // latitude: widget.latitude,
|
|
||||||
// // cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel,
|
|
||||||
// // model: widget.model,
|
|
||||||
// // ),
|
|
||||||
// // );
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
|
// color: CustomColors.green,
|
||||||
|
// disabledColor: CustomColors.grey,
|
||||||
// ),
|
// ),
|
||||||
|
// // SecondaryButton(
|
||||||
|
// // label: TranslationBase.of(context).confirm,
|
||||||
|
// // color: CustomColors.green,
|
||||||
|
// // onTap: () async {
|
||||||
|
// // if(isLocationSelected) {
|
||||||
|
// // GifLoaderDialogUtils.showMyDialog(context);
|
||||||
|
// // String requestId = await widget.model.insertCMCOrderRC(order: widget.cmcInsertPresOrderRequestModel);
|
||||||
|
// // GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
// // if (widget.model.state != ViewState.ErrorLocal) {
|
||||||
|
// // showCMCConfirmDialog(
|
||||||
|
// // context,
|
||||||
|
// // requestId,
|
||||||
|
// // onClick: () {
|
||||||
|
// // Navigator.pop(context);
|
||||||
|
// // Navigator.pop(context);
|
||||||
|
// // },
|
||||||
|
// // );
|
||||||
|
// // } else {
|
||||||
|
// // AppToast.showErrorToast(message: widget.model.error);
|
||||||
|
// // }
|
||||||
|
// // } else {
|
||||||
|
// // Utils.showErrorToast("Please select hospital from the dropdown menu to continue");
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // textColor: Theme.of(context).backgroundColor),
|
||||||
// ),
|
// ),
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
|
// ),
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// getDirections() {
|
||||||
|
// if (isLocationSelected) {
|
||||||
|
// MapsLauncher.launchCoordinates(double.parse(selectedHospital!.latitude!),
|
||||||
|
// double.parse(selectedHospital!.longitude!), selectedHospital!.name);
|
||||||
|
// } else {
|
||||||
|
// Utils.showErrorToast(
|
||||||
|
// "Please select address from the dropdown menu to get directions");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// getProjectsList() {
|
||||||
|
// int languageID = projectViewModel!.isArabic ? 1 : 2;
|
||||||
|
// ClinicListService service = new ClinicListService();
|
||||||
|
// GifLoaderDialogUtils.showMyDialog(context);
|
||||||
|
// List<HospitalsModel> projectsListLocal = [];
|
||||||
|
// service.getProjectsList(languageID, context).then((res) {
|
||||||
|
// if (res['MessageStatus'] == 1) {
|
||||||
|
// setState(() {
|
||||||
|
// res['ListProject'].forEach((v) {
|
||||||
|
// projectsListLocal.add(new HospitalsModel.fromJson(v));
|
||||||
|
// });
|
||||||
|
// projectsList = projectsListLocal;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
// }).catchError((err) {
|
||||||
|
// GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
// }).catchError((err) {
|
||||||
|
// GifLoaderDialogUtils.hideDialog(context);
|
||||||
|
// print(err);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -0,0 +1,111 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.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/core/enums.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||||
|
import 'package:hmg_patient_app_new/presentation/comprehensive_checkup/widgets/cmc_hospital_list_item.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:shimmer/shimmer.dart';
|
||||||
|
|
||||||
|
class CmcHospitalBottomSheetBody extends StatelessWidget {
|
||||||
|
final Function(HospitalsModel) onHospitalSelected;
|
||||||
|
|
||||||
|
const CmcHospitalBottomSheetBody({super.key, required this.onHospitalSelected});
|
||||||
|
|
||||||
|
Widget _buildLoadingShimmer() {
|
||||||
|
return ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemCount: 4,
|
||||||
|
separatorBuilder: (_, __) => SizedBox(height: 12.h),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Shimmer.fromColors(
|
||||||
|
baseColor: Colors.grey[300]!,
|
||||||
|
highlightColor: Colors.grey[100]!,
|
||||||
|
child: Container(
|
||||||
|
height: 80.h,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appState = getIt.get<AppState>();
|
||||||
|
final bool isArabic = appState.isArabic();
|
||||||
|
final bool isLocationEnabled = (appState.userLat != 0) && (appState.userLong != 0);
|
||||||
|
|
||||||
|
return Consumer(
|
||||||
|
builder: (BuildContext context, HmgServicesViewModel hmgServicesViewModel, Widget? child) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Choose your preferred hospital for the service".needTranslation.toText14(
|
||||||
|
weight: FontWeight.w400,
|
||||||
|
color: AppColors.greyTextColor,
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
TextInputWidget(
|
||||||
|
labelText: LocaleKeys.search.tr(),
|
||||||
|
hintText: LocaleKeys.searchHospital.tr(),
|
||||||
|
onChange: (value) {
|
||||||
|
hmgServicesViewModel.filterHospitalsByString(value ?? '', isArabic);
|
||||||
|
},
|
||||||
|
isEnable: true,
|
||||||
|
prefix: null,
|
||||||
|
autoFocus: false,
|
||||||
|
isBorderAllowed: false,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
isAllowLeadingIcon: true,
|
||||||
|
selectionType: SelectionTypeEnum.search,
|
||||||
|
padding: EdgeInsets.symmetric(vertical: ResponsiveExtension(10).h, horizontal: ResponsiveExtension(15).h),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.4,
|
||||||
|
child: hmgServicesViewModel.isHospitalListLoading
|
||||||
|
? _buildLoadingShimmer()
|
||||||
|
: hmgServicesViewModel.filteredHospitalsList.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: "No hospitals Found".needTranslation.toText16(weight: FontWeight.w500, color: AppColors.greyTextColor),
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
itemCount: hmgServicesViewModel.filteredHospitalsList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 12.h),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final hospital = hmgServicesViewModel.filteredHospitalsList[index];
|
||||||
|
return CmcHospitalListItem(
|
||||||
|
hospital: hospital,
|
||||||
|
isLocationEnabled: isLocationEnabled,
|
||||||
|
onPress: () {
|
||||||
|
hmgServicesViewModel.setSelectedHospital(hospital);
|
||||||
|
onHospitalSelected(hospital);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/app_assets.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/core/utils/size_utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
||||||
|
|
||||||
|
class CmcHospitalListItem extends StatelessWidget {
|
||||||
|
final HospitalsModel hospital;
|
||||||
|
final VoidCallback onPress;
|
||||||
|
final bool isLocationEnabled;
|
||||||
|
|
||||||
|
const CmcHospitalListItem({
|
||||||
|
super.key,
|
||||||
|
required this.hospital,
|
||||||
|
required this.onPress,
|
||||||
|
this.isLocationEnabled = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appState = getIt.get<AppState>();
|
||||||
|
final bool isArabic = appState.isArabic();
|
||||||
|
final String hospitalName = isArabic ? (hospital.nameN ?? hospital.name ?? '') : (hospital.name ?? '');
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
onTap: onPress,
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||||
|
color: AppColors.whiteColor,
|
||||||
|
borderRadius: 20.h,
|
||||||
|
hasShadow: false,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 8.h,
|
||||||
|
children: [
|
||||||
|
_buildHospitalName(hospitalName),
|
||||||
|
_buildDistanceInfo(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Transform.flip(
|
||||||
|
flipX: isArabic,
|
||||||
|
child: Utils.buildSvgWithAssets(
|
||||||
|
icon: AppAssets.forward_arrow_icon_small,
|
||||||
|
iconColor: AppColors.blackColor,
|
||||||
|
width: 18.h,
|
||||||
|
height: 13.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingSymmetrical(16.h, 16.h),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHospitalName(String hospitalName) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Utils.buildSvgWithAssets(
|
||||||
|
icon: (hospital.isHMC == true) ? AppAssets.hmc : AppAssets.hmg,
|
||||||
|
).paddingOnly(right: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
hospitalName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 16,
|
||||||
|
color: AppColors.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDistanceInfo() {
|
||||||
|
final distanceText = hospital.distanceInKilometers != null ? hospital.distanceInKilometers!.toStringAsFixed(1) : "0";
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
spacing: 4.w,
|
||||||
|
children: [
|
||||||
|
Visibility(
|
||||||
|
visible: (hospital.distanceInKilometers != null && hospital.distanceInKilometers! > 0),
|
||||||
|
child: AppCustomChipWidget(
|
||||||
|
labelText: "$distanceText km".needTranslation,
|
||||||
|
deleteIcon: AppAssets.location_red,
|
||||||
|
deleteIconSize: Size(9, 12),
|
||||||
|
backgroundColor: AppColors.secondaryLightRedColor,
|
||||||
|
textColor: AppColors.errorColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: (hospital.distanceInKilometers == null || hospital.distanceInKilometers == 0),
|
||||||
|
child: AppCustomChipWidget(
|
||||||
|
labelText: " Distance not available".needTranslation,
|
||||||
|
textColor: AppColors.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Visibility(
|
||||||
|
// visible: !isLocationEnabled,
|
||||||
|
// child: AppCustomChipWidget(
|
||||||
|
// labelText: "Location turned off".needTranslation,
|
||||||
|
// deleteIcon: AppAssets.location_unavailable,
|
||||||
|
// deleteIconSize: Size(9.w, 12.h),
|
||||||
|
// textColor: AppColors.blackColor,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
|
import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart';
|
||||||
|
import 'package:hmg_patient_app_new/presentation/comprehensive_checkup/widgets/cmc_hospital_bottom_sheet_body.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CmcHospitalSelectionHelper {
|
||||||
|
static void showHospitalSelectionBottomSheet({
|
||||||
|
required BuildContext context,
|
||||||
|
required Function(dynamic) onHospitalSelected,
|
||||||
|
}) {
|
||||||
|
final hmgServicesViewModel = context.read<HmgServicesViewModel>();
|
||||||
|
|
||||||
|
showCommonBottomSheetWithoutHeight(
|
||||||
|
context,
|
||||||
|
title: "Select Hospital".needTranslation,
|
||||||
|
child: CmcHospitalBottomSheetBody(
|
||||||
|
onHospitalSelected: (hospital) {
|
||||||
|
hmgServicesViewModel.setSelectedHospitalForOrder(hospital);
|
||||||
|
onHospitalSelected(hospital);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue