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

Loading…
Cancel
Save