schedule page fix

merge-requests/390/head
Sultan Khan 5 years ago
parent 3abd7227ec
commit abcd207554

@ -19,12 +19,10 @@ class MedicalService extends BaseService {
body['isDentalAllowedBackend'] = false; body['isDentalAllowedBackend'] = false;
} }
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async {
onSuccess: (response, statusCode) async {
appoitmentAllHistoryResultList.clear(); appoitmentAllHistoryResultList.clear();
response['AppoimentAllHistoryResultList'].forEach((appoitment) { response['AppoimentAllHistoryResultList'].forEach((appoitment) {
appoitmentAllHistoryResultList appoitmentAllHistoryResultList.add(AppoitmentAllHistoryResultList.fromJson(appoitment));
.add(AppoitmentAllHistoryResultList.fromJson(appoitment));
}); });
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
@ -39,9 +37,7 @@ class MedicalService extends BaseService {
body['RequesterFileNo'] = user.patientID; body['RequesterFileNo'] = user.patientID;
body['RequesterMobileNo'] = user.mobileNumber; body['RequesterMobileNo'] = user.mobileNumber;
body['RequesterIsOutSA'] = user.outSA; body['RequesterIsOutSA'] = user.outSA;
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async {}, onFailure: (String error, int statusCode) {
onSuccess: (response, statusCode) async {},
onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: body); }, body: body);
@ -49,35 +45,22 @@ class MedicalService extends BaseService {
getSchedule(DoctorList doctorRequest) async { getSchedule(DoctorList doctorRequest) async {
Map<String, dynamic> request; Map<String, dynamic> request;
request = { request = {'DoctorID': doctorRequest.doctorID, 'ProjectID': doctorRequest.projectID, 'ClinicID': doctorRequest.clinicID, 'DoctorWorkingHoursDays': 7};
'DoctorID': doctorRequest.doctorID,
'ProjectID': doctorRequest.projectID,
'ClinicID': doctorRequest.clinicID,
'DoctorWorkingHoursDays': 7
};
dynamic localRes; dynamic localRes;
await baseAppClient.post(DOCTOR_SCHEDULE_URL, await baseAppClient.post(DOCTOR_SCHEDULE_URL, onSuccess: (response, statusCode) async {
onSuccess: (response, statusCode) async {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: request); }, body: request);
doctorScheduleResponse.clear(); doctorScheduleResponse.clear();
localRes['List_DoctorWorkingHoursTable'].forEach((item) => localRes['List_DoctorWorkingHoursTable'].forEach((item) => {doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item))});
{doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item))});
} }
getFreeSlot(DoctorList doctorRequest) async { getFreeSlot(DoctorList doctorRequest) async {
Map<String, dynamic> request; Map<String, dynamic> request;
request = { request = {'DoctorID': doctorRequest.doctorID, 'ProjectID': doctorRequest.projectID, 'ClinicID': doctorRequest.clinicID, 'DoctorWorkingHoursDays': 7};
'DoctorID': doctorRequest.doctorID,
'ProjectID': doctorRequest.projectID,
'ClinicID': doctorRequest.clinicID,
'DoctorWorkingHoursDays': 7
};
dynamic localRes; dynamic localRes;
await baseAppClient.post(GET_DOCTOR_FREE_SLOTS, await baseAppClient.post(GET_DOCTOR_FREE_SLOTS, onSuccess: (response, statusCode) async {
onSuccess: (response, statusCode) async {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;

@ -10,10 +10,8 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleR
class MedicalViewModel extends BaseViewModel { class MedicalViewModel extends BaseViewModel {
MedicalService _medicalService = locator<MedicalService>(); MedicalService _medicalService = locator<MedicalService>();
List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList => List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList => _medicalService.appoitmentAllHistoryResultList;
_medicalService.appoitmentAllHistoryResultList; List<DoctorScheduleResponse> get getDoctorScheduleList => _medicalService.doctorScheduleResponse;
List<DoctorScheduleResponse> get getDoctorScheduleList =>
_medicalService.doctorScheduleResponse;
List<String> get freeSlots => _medicalService.freeSlots; List<String> get freeSlots => _medicalService.freeSlots;
getAppointmentHistory() async { getAppointmentHistory() async {
if (authenticatedUserObject.isLogin) { if (authenticatedUserObject.isLogin) {
@ -28,7 +26,7 @@ class MedicalViewModel extends BaseViewModel {
} }
getDoctorSchedule(DoctorList doctorRequest) async { getDoctorSchedule(DoctorList doctorRequest) async {
if (authenticatedUserObject.isLogin) { //if (authenticatedUserObject.isLogin) {
setState(ViewState.Busy); setState(ViewState.Busy);
await _medicalService.getSchedule(doctorRequest); await _medicalService.getSchedule(doctorRequest);
if (_medicalService.hasError) { if (_medicalService.hasError) {
@ -36,11 +34,11 @@ class MedicalViewModel extends BaseViewModel {
setState(ViewState.Error); setState(ViewState.Error);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} //}
} }
getFreeSlots(DoctorList doctorRequest) async { getFreeSlots(DoctorList doctorRequest) async {
if (authenticatedUserObject.isLogin) { //if (authenticatedUserObject.isLogin) {
setState(ViewState.Busy); setState(ViewState.Busy);
await _medicalService.getFreeSlot(doctorRequest); await _medicalService.getFreeSlot(doctorRequest);
if (_medicalService.hasError) { if (_medicalService.hasError) {
@ -49,5 +47,5 @@ class MedicalViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} //}
} }

@ -51,8 +51,10 @@ class _SchedulePageState extends State<SchedulePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<MedicalViewModel>( return BaseView<MedicalViewModel>(
onModelReady: (model) => model.getDoctorSchedule(doctorList), onModelReady: (model) => model.getDoctorSchedule(doctorList),
allowAny: true,
builder: (_, model, widget) => BaseView<MedicalViewModel>( builder: (_, model, widget) => BaseView<MedicalViewModel>(
onModelReady: (model2) => model2.getFreeSlots(doctorList), onModelReady: (model2) => model2.getFreeSlots(doctorList),
allowAny: true,
builder: (_, model2, widget2) { builder: (_, model2, widget2) {
if (model.freeSlots.length > 0 && isPageChange == false) { if (model.freeSlots.length > 0 && isPageChange == false) {
this.freeSlots = model.freeSlots; this.freeSlots = model.freeSlots;
@ -84,42 +86,31 @@ class _SchedulePageState extends State<SchedulePage> {
return Container( return Container(
child: ListView.builder( child: ListView.builder(
itemCount: weeks[index].length, itemCount: weeks[index].length,
itemBuilder: (context, index2) => itemBuilder: (context, index2) => InkWell(
InkWell(
onTap: () { onTap: () {
openBookAppointment( openBookAppointment(weeks[index][index2]);
weeks[index][index2]);
}, },
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
flex: 1, flex: 1,
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(left: 20),
EdgeInsets.only( child: Row(children: [
left: 20),
child: Row(
children: [
Column( Column(
children: [ children: [
Texts( Texts(
weeks[index][index2] weeks[index][index2]['DayName'],
[ fontSize: 13,
'DayName'],
fontSize:
13,
), ),
Texts( Texts(
getDayMonths( getDayMonths(
DateUtil DateUtil.convertStringToDate(
.convertStringToDate(
weeks[index][index2]['Date'], weeks[index][index2]['Date'],
), ),
), ),
fontWeight: fontWeight: FontWeight.bold,
FontWeight.bold, fontSize: 18,
fontSize:
18,
) )
], ],
) )
@ -128,50 +119,19 @@ class _SchedulePageState extends State<SchedulePage> {
Expanded( Expanded(
flex: 3, flex: 3,
child: ClipRRect( child: ClipRRect(
borderRadius: borderRadius: const BorderRadius.all(Radius.circular(20.0)),
const BorderRadius
.all(
Radius.circular(
20.0)),
child: Container( child: Container(
padding: padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 20),
EdgeInsets.only( margin: EdgeInsets.only(left: 20, right: 20, top: 7, bottom: 7),
left: decoration: BoxDecoration(boxShadow: [
10, weeks[index][index2]['fullDay'] == false ? BoxShadow(color: Colors.green, offset: Offset(-5, 0)) : BoxShadow(),
right: ], borderRadius: const BorderRadius.all(Radius.circular(10.0)), color: Colors.white),
10,
top: 20,
bottom:
20),
margin: EdgeInsets.only(
left: 20,
right: 20,
top: 7,
bottom: 7),
decoration: BoxDecoration(
boxShadow: [
weeks[index][index2]['fullDay'] ==
false
? BoxShadow(
color: Colors.green,
offset: Offset(-5, 0))
: BoxShadow(),
],
borderRadius:
const BorderRadius.all(Radius.circular(
10.0)),
color: Colors
.white),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: child: Texts(
Texts( weeks[index][index2]['WorkingHours'],
weeks[index][index2] fontWeight: FontWeight.w400,
[
'WorkingHours'],
fontWeight:
FontWeight.w400,
), ),
) )
], ],
@ -213,9 +173,7 @@ class _SchedulePageState extends State<SchedulePage> {
var newWeekSchedule = []; var newWeekSchedule = [];
for (var workDay in this.doctorScheduleResponse) { for (var workDay in this.doctorScheduleResponse) {
Map<String, dynamic> newWorkDay = Map(); Map<String, dynamic> newWorkDay = Map();
newWorkDay['Date'] = DateUtil.convertDateMSToJsonDate( newWorkDay['Date'] = DateUtil.convertDateMSToJsonDate(DateUtil.convertStringToDate(workDay.date).millisecondsSinceEpoch + weekMSOffset);
DateUtil.convertStringToDate(workDay.date).millisecondsSinceEpoch +
weekMSOffset);
newWorkDay['DayName'] = workDay.dayName; newWorkDay['DayName'] = workDay.dayName;
newWorkDay['WorkingHours'] = workDay.workingHours; newWorkDay['WorkingHours'] = workDay.workingHours;
newWeekSchedule.add(newWorkDay); newWeekSchedule.add(newWorkDay);
@ -238,8 +196,7 @@ class _SchedulePageState extends State<SchedulePage> {
} }
String getDayMonths(DateTime dateTime) { String getDayMonths(DateTime dateTime) {
String dateFormat = String dateFormat = '${dateTime.day} ${DateUtil.getMonth(dateTime.month).toString().substring(0, 3)}';
'${dateTime.day} ${DateUtil.getMonth(dateTime.month).toString().substring(0, 3)}';
return dateFormat; return dateFormat;
} }

Loading…
Cancel
Save