build context handled

merge-update-with-lab-changes
taha.alam 2 years ago
parent 936682ff95
commit fe9d259cbd

@ -1,6 +1,7 @@
import 'dart:collection';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:flutter/material.dart';
@ -56,6 +57,8 @@ class _SearchByHospitalState extends State<SearchByHospital> {
@override
Widget build(BuildContext context) {
AppGlobal.context = context;
return Column(
children: [
Padding(
@ -66,14 +69,17 @@ class _SearchByHospitalState extends State<SearchByHospital> {
activeColor: CustomColors.accentColor,
value: nearestAppo,
onChanged: (bool? value) {
nearestAppo = value?? false;
nearestAppo = value ?? false;
setState(() {
});
},
),
AutoSizeText(
TranslationBase.of(context).nearestAppo.trim(),
TranslationBase
.of(context)
.nearestAppo
.trim(),
maxLines: 1,
minFontSize: 10,
style: TextStyle(
@ -102,7 +108,9 @@ class _SearchByHospitalState extends State<SearchByHospital> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).selectHospital,
TranslationBase
.of(context)
.selectHospital,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
@ -115,7 +123,9 @@ class _SearchByHospitalState extends State<SearchByHospital> {
child: DropdownButtonHideUnderline(
child: DropdownButton<HospitalsModel>(
hint: Text(
TranslationBase.of(context).selectHospital),
TranslationBase
.of(context)
.selectHospital),
value: selectedHospital,
iconSize: 0,
isExpanded: true,
@ -141,11 +151,11 @@ class _SearchByHospitalState extends State<SearchByHospital> {
// Text('${item.name!}'),
);
}).toList(),
onChanged: (HospitalsModel? newValue) async {
onChanged: (HospitalsModel? newValue){
getClinicWrtHospital(newValue);
// setState(() {
// selectedHospital = newValue;
// });
setState(() {
selectedHospital = newValue;
});
},
),
),
@ -172,7 +182,8 @@ class _SearchByHospitalState extends State<SearchByHospital> {
"-" +
clincs.liveCareClinicID.toString() +
"-" +
clincs.liveCareServiceID.toString();
clincs.liveCareServiceID.toString(
);
});
getDoctorsList(context);
@ -197,7 +208,9 @@ class _SearchByHospitalState extends State<SearchByHospital> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).selectClinic,
TranslationBase
.of(context)
.selectClinic,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
@ -251,7 +264,9 @@ class _SearchByHospitalState extends State<SearchByHospital> {
getProjectsList() {
GifLoaderDialogUtils.showMyDialog(context);
int languageID = context.read<ProjectViewModel>().isArabic ? 1 : 2;
int languageID = context
.read<ProjectViewModel>()
.isArabic ? 1 : 2;
ClinicListService service = new ClinicListService();
List<HospitalsModel> projectsListLocal = [];
service.getProjectsList(languageID, context).then((res) {
@ -275,8 +290,7 @@ class _SearchByHospitalState extends State<SearchByHospital> {
}
void getClinicWrtHospital(HospitalsModel? newValue) {
void getClinicWrtHospital(HospitalsModel? newValue) async {
GifLoaderDialogUtils.showMyDialog(context);
ClinicListService service = new ClinicListService();
List<HospitalsModel> projectsListLocal = [];
@ -284,23 +298,25 @@ class _SearchByHospitalState extends State<SearchByHospital> {
clinicIds = List.empty();
});
List<ListClinicCentralized> clinicId = [];
service
.getClinicByHospital(
projectID: newValue?.mainProjectID.toString() ?? "")
.then((res) {
print("the result is obtained");
try {
Map res = await service
.getClinicB
yHospital(
projectID: newValue?.mainProjectID.toString() ?? "");
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
List list = res['ListClinic'];
if(list.isEmpty){
if (list.isEmpty) {
AppToast.showErrorToast(message:
TranslationBase.of(context).NoClinicFound,
TranslationBase
.of(context)
.NoClinicFound,
);
}
res['ListClinic'].forEach((v) {
clinicId?.add(ListClinicCentralized.fromJson(v));
clinicId.add(ListClinicCentralized.fromJson(v));
});
clinicIds = clinicId;
setState(() {
@ -308,27 +324,67 @@ class _SearchByHospitalState extends State<SearchByHospital> {
});
} else {
AppToast.showErrorToast(message:
TranslationBase.of(context).NoClinicFound,
TranslationBase
.of(context)
.NoClinicFound,
);
}
}).catchError((err) {
print('the error is $err');
AppToast.showErrorToast(message:
TranslationBase.of(context).NoClinicFound,
);
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
} catch (e) {
print("the error is $e");
AppToast.showErrorToast(message:
TranslationBase.of(context).NoClinicFound,
);
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
Future navigateToDentalComplaints(
BuildContext context, SearchInfo searchInfo) async {
// .then((res) {
// print("the result is obtained");
// GifLoaderDialogUtils.hideDialog(context);
// if (res['MessageStatus'] == 1) {
// List list = res['ListClinic'];
//
// if(list.isEmpty){
// AppToast.showErrorToast(message:
// TranslationBase.of(context).NoClinicFound,
// );
//
// }
// res['ListClinic'].forEach((v) {
// clinicId?.add(ListClinicCentralized.fromJson(v));
// });
// clinicIds = clinicId;
// setState(() {
//
// });
// } else {
// AppToast.showErrorToast(message:
// TranslationBase.of(context).NoClinicFound,
// );
// }
// }).catchError((err) {
// print('the error is $err');
// AppToast.showErrorToast(message:
// TranslationBase.of(context).NoClinicFound,
// );
// GifLoaderDialogUtils.hideDialog(context);
// }).catchError((err) {
// AppToast.showErrorToast(message:
// TranslationBase.of(context).NoClinicFound,
// );
// GifLoaderDialogUtils.hideDialog(context);
//
// print(err);
// });
}
@override
void dispose() {
super.dispose();
}
Future navigateToDentalComplaints(BuildContext context,
SearchInfo searchInfo) async {
Navigator.push(
context,
FadePage(
@ -344,7 +400,9 @@ class _SearchByHospitalState extends State<SearchByHospital> {
}
callDoctorsSearchAPI(int clinicID) {
int languageID = context.read<ProjectViewModel>().isArabic ? 1 : 2;
int languageID = context
.read<ProjectViewModel>()
.isArabic ? 1 : 2;
GifLoaderDialogUtils.showMyDialog(context);
List<DoctorList> doctorsList = [];
List<String> arr = [];
@ -371,7 +429,7 @@ class _SearchByHospitalState extends State<SearchByHospital> {
if (res['DoctorList'].length != 0) {
doctorsList.clear();
res['DoctorList'].forEach((v) {
doctorsList.add(new DoctorList.fromJson(v));
doctorsList.add( DoctorList.fromJson(v));
});
doctorsList.forEach((element) {
List<PatientDoctorAppointmentList> doctorByHospital =
@ -414,8 +472,7 @@ class _SearchByHospitalState extends State<SearchByHospital> {
});
}
Future navigateToSearchResults(
context,
Future navigateToSearchResults(context,
List<DoctorList> docList,
List<PatientDoctorAppointmentList>
patientDoctorAppointmentListHospital) async {
@ -428,7 +485,6 @@ class _SearchByHospitalState extends State<SearchByHospital> {
patientDoctorAppointmentListHospital:
patientDoctorAppointmentListHospital)))
.then((value) {
print("navigation return ");
dropdownValue = null;
dropdownTitle = "";
@ -466,8 +522,13 @@ class _SearchByHospitalState extends State<SearchByHospital> {
searchInfo.clinic = selectedClinic;
searchInfo.date = DateTime.now();
if (context.read<ProjectViewModel>().isLogin) {
if (context.read<ProjectViewModel>().user.age! > 12) {
if (context
.read<ProjectViewModel>()
.isLogin) {
if (context
.read<ProjectViewModel>()
.user
.age! > 12) {
navigateToDentalComplaints(context, searchInfo);
} else {
callDoctorsSearchAPI(17);

Loading…
Cancel
Save