|
|
|
|
@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
@ -55,6 +56,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
int selectedButtonIndex = 0;
|
|
|
|
|
int selectedNextDayButtonIndex = -1;
|
|
|
|
|
dynamic freeSlotsResponse;
|
|
|
|
|
|
|
|
|
|
// String nextDayAppointmentDate ="";
|
|
|
|
|
late ScrollController _scrollController;
|
|
|
|
|
|
|
|
|
|
@ -120,7 +122,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
_calendarController.selectedDate = day;
|
|
|
|
|
openTimeSlotsPickerForDate(day, docFreeSlots);
|
|
|
|
|
DocAvailableAppointments.selectedDate = formatter.format(day);
|
|
|
|
|
selectedNextDayButtonIndex =-1;
|
|
|
|
|
selectedNextDayButtonIndex = -1;
|
|
|
|
|
print(_calendarController.selectedDate);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -143,45 +145,51 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
),
|
|
|
|
|
DocAvailableAppointments.areSlotsAvailable
|
|
|
|
|
? Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [ Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
child:
|
|
|
|
|
ListView.builder(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: dayEvents.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5),
|
|
|
|
|
child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 20,),
|
|
|
|
|
nextDayEvents.isNotEmpty ? Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 20, right: 20, bottom:20),
|
|
|
|
|
child: Text(selectedNextDate, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black))) :SizedBox(),
|
|
|
|
|
Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 0, right: 0),
|
|
|
|
|
child:
|
|
|
|
|
ListView.builder(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: nextDayEvents.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: EdgeInsets.only(right: (index == nextDayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5),
|
|
|
|
|
child: index == selectedNextDayButtonIndex ? getSelectedNextDayButton(index) : getNormalNextDayButton(index),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: dayEvents.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5),
|
|
|
|
|
child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
nextDayEvents.isNotEmpty && projectViewModel.havePrivilege(110)
|
|
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 20, right: 20, bottom: 20),
|
|
|
|
|
child: Text(
|
|
|
|
|
selectedNextDate,
|
|
|
|
|
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: SizedBox(),
|
|
|
|
|
Container(
|
|
|
|
|
height: 40,
|
|
|
|
|
padding: EdgeInsets.only(left: 0, right: 0),
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: nextDayEvents.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: EdgeInsets.only(right: (index == nextDayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5),
|
|
|
|
|
child: index == selectedNextDayButtonIndex ? getSelectedNextDayButton(index) : getNormalNextDayButton(index),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
|
|
|
|
|
@ -261,20 +269,24 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
} else
|
|
|
|
|
DocAvailableAppointments.areSlotsAvailable = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
filterNextDayAppo(List<TimeSlot> freeSlots, Map<String, dynamic> listList){
|
|
|
|
|
DateTime dateStart = DateTime.parse(listList['end']).add(Duration(days: 1));
|
|
|
|
|
|
|
|
|
|
filterNextDayAppo(List<TimeSlot> freeSlots, Map<String, dynamic> listList) {
|
|
|
|
|
DateTime dateStart = DateTime.parse(listList['end']).add(Duration(days: 1));
|
|
|
|
|
|
|
|
|
|
DateTime dateStartObj = new DateTime(dateStart.year, dateStart.month, dateStart.day, 0, 0, 0, 0, 0);
|
|
|
|
|
nextDayEvents = [];
|
|
|
|
|
DateTime beforeHour = new DateTime(dateStart.year, dateStart.month, dateStart.day, 6, 0, 0, 0, 0);
|
|
|
|
|
nextDayEvents = [];
|
|
|
|
|
DateTime beforeHour = new DateTime(dateStart.year, dateStart.month, dateStart.day, 6, 0, 0, 0, 0);
|
|
|
|
|
if (projectViewModel.havePrivilege(110)) {
|
|
|
|
|
freeSlots.forEach((v) {
|
|
|
|
|
if (v.start == dateStartObj && v.end!.isBefore(beforeHour) ) nextDayEvents.add(v);
|
|
|
|
|
if (v.start == dateStartObj && v.end!.isBefore(beforeHour)) nextDayEvents.add(v);
|
|
|
|
|
});
|
|
|
|
|
// print(nextDayEvents);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
nextDayEvents = [];
|
|
|
|
|
}
|
|
|
|
|
// print(nextDayEvents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<Map<DateTime, List>> _getJSONSlots() async {
|
|
|
|
|
Map<DateTime, List> _eventsParsed;
|
|
|
|
|
List<FreeSlot> slotsList = [];
|
|
|
|
|
@ -299,7 +311,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DocAvailableAppointments.selectedAppoDateTime = (isLiveCareSchedule != null && isLiveCareSchedule)
|
|
|
|
|
? DateUtil.convertStringToDate(freeSlotsResponse[0])
|
|
|
|
|
: DateUtil.convertStringToDateSaudiTimezone(
|
|
|
|
|
@ -318,15 +330,15 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
language);
|
|
|
|
|
selectedNextDate = DateUtil.getWeekDayMonthDayYearDateFormatted(
|
|
|
|
|
selectedNextDate = DateUtil.getWeekDayMonthDayYearDateFormatted(
|
|
|
|
|
(isLiveCareSchedule != null && isLiveCareSchedule)
|
|
|
|
|
? DateUtil.convertStringToDate(freeSlotsResponse[0]).add(Duration(days:1))
|
|
|
|
|
? DateUtil.convertStringToDate(freeSlotsResponse[0]).add(Duration(days: 1))
|
|
|
|
|
: DateUtil.convertStringToDateSaudiTimezone(
|
|
|
|
|
freeSlotsResponse[0],
|
|
|
|
|
int.parse(
|
|
|
|
|
widget.doctor.projectID.toString(),
|
|
|
|
|
),
|
|
|
|
|
).add(Duration(days:1)),
|
|
|
|
|
freeSlotsResponse[0],
|
|
|
|
|
int.parse(
|
|
|
|
|
widget.doctor.projectID.toString(),
|
|
|
|
|
),
|
|
|
|
|
).add(Duration(days: 1)),
|
|
|
|
|
language);
|
|
|
|
|
selectedDateJSON = freeSlotsResponse[0];
|
|
|
|
|
});
|
|
|
|
|
@ -370,13 +382,11 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
DocAvailableAppointments.selectedAppoDateTime = timeslot.end;
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
selectedButtonIndex = index;
|
|
|
|
|
selectedNextDayButtonIndex =-1;
|
|
|
|
|
selectedNextDayButtonIndex = -1;
|
|
|
|
|
DocAvailableAppointments.selectedTime = dayEvents[index].isoTime;
|
|
|
|
|
print(DocAvailableAppointments.selectedTime);
|
|
|
|
|
DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
projectViewModel.analytics.appointment.book_appointment_time_selection(appointment_type: 'regular', dateTime: timeslot.end, doctor: widget.doctor);
|
|
|
|
|
},
|
|
|
|
|
@ -404,6 +414,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
child: Text(dayEvents[index].isoTime!, style: TextStyle(fontSize: 12.0, color: Colors.white)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget getNormalNextDayButton(int index) {
|
|
|
|
|
return CustomTextButton(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
@ -412,16 +423,16 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
color: Colors.black, //Color of the border
|
|
|
|
|
style: BorderStyle.solid, //Style of the border
|
|
|
|
|
width: 1.5 //width of the border
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
final timeslot = nextDayEvents[index];
|
|
|
|
|
DocAvailableAppointments.selectedAppoDateTime = timeslot.end;
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
selectedButtonIndex = -1;
|
|
|
|
|
selectedNextDayButtonIndex =index;
|
|
|
|
|
selectedNextDayButtonIndex = index;
|
|
|
|
|
DocAvailableAppointments.selectedTime = nextDayEvents[index].isoTime;
|
|
|
|
|
DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days:1)));
|
|
|
|
|
DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days: 1)));
|
|
|
|
|
print(DocAvailableAppointments.selectedTime);
|
|
|
|
|
});
|
|
|
|
|
projectViewModel.analytics.appointment.book_appointment_time_selection(appointment_type: 'regular', dateTime: timeslot.end, doctor: widget.doctor);
|
|
|
|
|
@ -438,13 +449,13 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
|
|
|
|
|
color: nextDayEvents[index].isoTime == TranslationBase.of(context).waitingAppointment ? CustomColors.darkOrange : CustomColors.green, //Color of the border
|
|
|
|
|
style: BorderStyle.solid, //Style of the border
|
|
|
|
|
width: 1.5 //width of the border
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
selectedButtonIndex =-1;
|
|
|
|
|
selectedButtonIndex = -1;
|
|
|
|
|
selectedNextDayButtonIndex = index;
|
|
|
|
|
DocAvailableAppointments.selectedTime = nextDayEvents[index].isoTime;
|
|
|
|
|
DocAvailableAppointments.selectedDate =dateFormatter.format(_calendarController.selectedDate!.add(Duration(days:1)));
|
|
|
|
|
DocAvailableAppointments.selectedDate = dateFormatter.format(_calendarController.selectedDate!.add(Duration(days: 1)));
|
|
|
|
|
print(DocAvailableAppointments.selectedTime);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|