my appointment sorting implemented

merge-update-with-lab-changes
haroon amjad 6 years ago
parent ce9903fd13
commit 3e5ef26b29

@ -272,3 +272,13 @@ class AppoitmentAllHistoryResultList {
return data; return data;
} }
} }
class PatientAppointmentList {
String filterName = "";
List<AppoitmentAllHistoryResultList> patientDoctorAppointmentList = List();
PatientAppointmentList(
{this.filterName, AppoitmentAllHistoryResultList patientDoctorAppointment}) {
patientDoctorAppointmentList.add(patientDoctorAppointment);
}
}

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/AppointmentCar
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:smart_progress_bar/smart_progress_bar.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart';
@ -15,6 +16,13 @@ class MyAppointments extends StatefulWidget {
List<AppoitmentAllHistoryResultList> confirmedAppoList = []; List<AppoitmentAllHistoryResultList> confirmedAppoList = [];
List<AppoitmentAllHistoryResultList> arrivedAppoList = []; List<AppoitmentAllHistoryResultList> arrivedAppoList = [];
List<PatientAppointmentList> _patientBookedAppointmentListHospital = List();
List<PatientAppointmentList> _patientConfirmedAppointmentListHospital =
List();
List<PatientAppointmentList> _patientArrivedAppointmentListHospital = List();
@override @override
_MyAppointmentsState createState() => _MyAppointmentsState(); _MyAppointmentsState createState() => _MyAppointmentsState();
} }
@ -40,7 +48,6 @@ class _MyAppointmentsState extends State<MyAppointments>
isShowAppBar: true, isShowAppBar: true,
body: Container( body: Container(
child: Column(children: [ child: Column(children: [
/// this is will not colored with theme data
TabBar( TabBar(
tabs: [ tabs: [
Tab(text: TranslationBase.of(context).booked), Tab(text: TranslationBase.of(context).booked),
@ -94,7 +101,8 @@ class _MyAppointmentsState extends State<MyAppointments>
} }
}).catchError((err) { }).catchError((err) {
print(err); print(err);
}).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); }).showProgressBar(
text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6));
} }
bool isConfirmed(AppoitmentAllHistoryResultList appo) { bool isConfirmed(AppoitmentAllHistoryResultList appo) {
@ -123,64 +131,176 @@ class _MyAppointmentsState extends State<MyAppointments>
widget.arrivedAppoList.add(v); widget.arrivedAppoList.add(v);
} }
}); });
widget.bookedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByHospital =
widget._patientBookedAppointmentListHospital
.where(
(elementClinic) =>
elementClinic.filterName == element.clinicName,
)
.toList();
if (doctorByHospital.length != 0) {
widget
._patientBookedAppointmentListHospital[widget
._patientBookedAppointmentListHospital
.indexOf(doctorByHospital[0])]
.patientDoctorAppointmentList
.add(element);
} else {
widget._patientBookedAppointmentListHospital.add(PatientAppointmentList(
filterName: element.clinicName, patientDoctorAppointment: element));
}
});
widget.confirmedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByHospital =
widget._patientConfirmedAppointmentListHospital
.where(
(elementClinic) =>
elementClinic.filterName == element.clinicName,
)
.toList();
if (doctorByHospital.length != 0) {
widget
._patientConfirmedAppointmentListHospital[widget
._patientConfirmedAppointmentListHospital
.indexOf(doctorByHospital[0])]
.patientDoctorAppointmentList
.add(element);
} else {
widget._patientConfirmedAppointmentListHospital.add(
PatientAppointmentList(
filterName: element.clinicName,
patientDoctorAppointment: element));
}
});
widget.arrivedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByHospital =
widget._patientArrivedAppointmentListHospital
.where(
(elementClinic) =>
elementClinic.filterName == element.clinicName,
)
.toList();
if (doctorByHospital.length != 0) {
widget
._patientArrivedAppointmentListHospital[widget
._patientArrivedAppointmentListHospital
.indexOf(doctorByHospital[0])]
.patientDoctorAppointmentList
.add(element);
} else {
widget._patientArrivedAppointmentListHospital.add(
PatientAppointmentList(
filterName: element.clinicName,
patientDoctorAppointment: element));
}
});
} }
openAppointmentsTab() { openAppointmentsTab() {
if (widget.bookedAppoList.length != 0) { if (widget.bookedAppoList.length != 0) {
_tabController.animateTo((_tabController.index + 1) % 1); _tabController.index = 0;
} else if (widget.confirmedAppoList.length != 0) { } else if (widget.confirmedAppoList.length != 0) {
_tabController.animateTo((_tabController.index + 1) % 2); _tabController.index = 1;
} else if (widget.arrivedAppoList.length != 0) { } else if (widget.arrivedAppoList.length != 0) {
_tabController.animateTo((_tabController.index + 1) % 3); _tabController.index = 2;
return; return;
} }
} }
Widget getBookedAppointments() { Widget getBookedAppointments() {
return Container( return Container(
child: widget.bookedAppoList.length != 0 margin: EdgeInsets.only(top: 10.0),
? new ListView.builder( child: Container(
itemCount: widget.bookedAppoList.length, child: widget.bookedAppoList.length != 0
itemBuilder: (context, i) { ? SingleChildScrollView(
return AppointmentCard( physics: BouncingScrollPhysics(),
appo: widget.bookedAppoList[i],
onReloadAppointmentHistory: getPatientAppointmentHistory,
);
},
)
: Container(
child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Image.asset( ...List.generate(
"assets/images/new-design/noAppointmentIcon.png"), widget._patientBookedAppointmentListHospital.length,
Container( (index) => AppExpandableNotifier(
margin: EdgeInsets.only(top: 10.0), title: widget
child: Text("No Booked Appointments", ._patientBookedAppointmentListHospital[index]
style: TextStyle( .filterName,
fontSize: 16.0, bodyWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: widget
._patientBookedAppointmentListHospital[index]
.patientDoctorAppointmentList
.map((doctor) {
return AppointmentCard(
appo: doctor,
onReloadAppointmentHistory:
getPatientAppointmentHistory,
);
}).toList(),
)), )),
), )
], ],
), ),
)
: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/images/new-design/noAppointmentIcon.png"),
Container(
margin: EdgeInsets.only(top: 10.0),
child: Text("No Booked Appointments",
style: TextStyle(
fontSize: 16.0,
)),
),
],
),
),
), ),
), ),
); );
} }
Widget getConfirmedAppointments() { Widget getConfirmedAppointments() {
return widget.confirmedAppoList.length != 0 return widget.confirmedAppoList.length != 0
? Container( ? Container(
child: new ListView.builder( margin: EdgeInsets.only(top: 10.0),
itemCount: widget.confirmedAppoList.length, child: SingleChildScrollView(
itemBuilder: (context, i) { physics: BouncingScrollPhysics(),
return AppointmentCard( child: Column(
appo: widget.confirmedAppoList[i], children: <Widget>[
onReloadAppointmentHistory: getPatientAppointmentHistory, ...List.generate(
); widget._patientConfirmedAppointmentListHospital.length,
}, (index) => AppExpandableNotifier(
title: widget
._patientConfirmedAppointmentListHospital[index]
.filterName,
bodyWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: widget
._patientConfirmedAppointmentListHospital[index]
.patientDoctorAppointmentList
.map((doctor) {
return AppointmentCard(
appo: doctor,
onReloadAppointmentHistory:
getPatientAppointmentHistory,
);
}).toList(),
)),
)
],
),
), ),
) )
: Container( : Container(
@ -206,16 +326,47 @@ class _MyAppointmentsState extends State<MyAppointments>
Widget getArrivedAppointments() { Widget getArrivedAppointments() {
return widget.arrivedAppoList.length != 0 return widget.arrivedAppoList.length != 0
? Container( ? Container(
child: new ListView.builder( margin: EdgeInsets.only(top: 10.0),
itemCount: widget.arrivedAppoList.length, child: SingleChildScrollView(
itemBuilder: (context, i) { physics: BouncingScrollPhysics(),
return AppointmentCard( child: Column(
appo: widget.arrivedAppoList[i], children: <Widget>[
onReloadAppointmentHistory: getPatientAppointmentHistory, ...List.generate(
); widget._patientArrivedAppointmentListHospital.length,
}, (index) => AppExpandableNotifier(
title: widget
._patientArrivedAppointmentListHospital[index]
.filterName,
bodyWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: widget
._patientArrivedAppointmentListHospital[index]
.patientDoctorAppointmentList
.map((doctor) {
return AppointmentCard(
appo: doctor,
onReloadAppointmentHistory:
getPatientAppointmentHistory,
);
}).toList(),
)),
)
],
),
), ),
) )
// Container(
// child: new ListView.builder(
// itemCount: widget.arrivedAppoList.length,
// itemBuilder: (context, i) {
// return AppointmentCard(
// appo: widget.arrivedAppoList[i],
// onReloadAppointmentHistory: getPatientAppointmentHistory,
// );
// },
// ),
// )
: Container( : Container(
child: Center( child: Center(
child: Column( child: Column(

@ -42,7 +42,7 @@ class _ApointmentCardState extends State<AppointmentCard> {
fit: BoxFit.fill, height: 60.0, width: 60.0), fit: BoxFit.fill, height: 60.0, width: 60.0),
), ),
Container( Container(
width: MediaQuery.of(context).size.width * 0.6, width: MediaQuery.of(context).size.width * 0.57,
margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -95,7 +95,7 @@ class _ApointmentCardState extends State<AppointmentCard> {
emptyIcon: Icons.star, emptyIcon: Icons.star,
), ),
Container( Container(
transform: Matrix4.translationValues(0.0, -40.0, 0.0), transform: Matrix4.translationValues(15.0, -40.0, 0.0),
child: Image.asset( child: Image.asset(
"assets/images/new-design/arrow.png", "assets/images/new-design/arrow.png",
width: 25.0, width: 25.0,

Loading…
Cancel
Save