Calendar plugin changed

merge-requests/429/head
haroon amjad 3 years ago
parent 7264d03818
commit 01ccd484f4

@ -1484,4 +1484,7 @@ const Map localizedValues = {
"rateAppointment": {"en": "Rate Appointment", "ar": "سعر التعيين"}, "rateAppointment": {"en": "Rate Appointment", "ar": "سعر التعيين"},
"noInsuranceCardAttached": {"en": "Please attach your insurance card image to continue", "ar": "يرجى إرفاق صورة بطاقة التأمين الخاصة بك للمتابعة"}, "noInsuranceCardAttached": {"en": "Please attach your insurance card image to continue", "ar": "يرجى إرفاق صورة بطاقة التأمين الخاصة بك للمتابعة"},
"bodyMassIndex": {"en": "Body Mass Index is: ", "ar": "مؤشر كتلة الجسم هو:"}, "bodyMassIndex": {"en": "Body Mass Index is: ", "ar": "مؤشر كتلة الجسم هو:"},
"noSlotsError": {"en": "No appointments available for selected date", "ar": "لا توجد مواعيد متاحة للتاريخ المحدد"},
"selectSlot": {"en": "Please select Time Slot to continue", "ar": "الرجاء تحديد فترة زمنية للمتابعة"},
}; };

@ -35,3 +35,4 @@ const H2O_REMINDER = 'H2O_REMINDER';
const LIVECARE_CLINIC_DATA = 'LIVECARE_CLINIC_DATA'; const LIVECARE_CLINIC_DATA = 'LIVECARE_CLINIC_DATA';
const DOCTOR_SCHEDULE_DATE_SEL = 'DOCTOR_SCHEDULE_DATE_SEL'; const DOCTOR_SCHEDULE_DATE_SEL = 'DOCTOR_SCHEDULE_DATE_SEL';
const APPOINTMENT_HISTORY_MEDICAL = 'APPOINTMENT_HISTORY_MEDICAL'; const APPOINTMENT_HISTORY_MEDICAL = 'APPOINTMENT_HISTORY_MEDICAL';
const CLINICS_LIST = 'CLINICS_LIST';

@ -500,7 +500,7 @@ class _DoctorProfileState extends State<DoctorProfile> with TickerProviderStateM
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
} }
} else } else
AppToast.showErrorToast(message: "Please select Time Slot to continue"); AppToast.showErrorToast(message: TranslationBase.of(context).selectSlot);
} }
navigateToLogin() { navigateToLogin() {

@ -7,11 +7,13 @@ import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:table_calendar/table_calendar.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
import '../../../uitl/date_uitl.dart'; import '../../../uitl/date_uitl.dart';
@ -24,6 +26,7 @@ class DocAvailableAppointments extends StatefulWidget {
static String selectedTime; static String selectedTime;
bool isLiveCareAppointment; bool isLiveCareAppointment;
final dynamic doctorSchedule; final dynamic doctorSchedule;
DocAvailableAppointments({@required this.doctor, this.doctorSchedule, @required this.isLiveCareAppointment}); DocAvailableAppointments({@required this.doctor, this.doctorSchedule, @required this.isLiveCareAppointment});
@override @override
@ -55,8 +58,8 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
@override @override
void didUpdateWidget(covariant DocAvailableAppointments oldWidget) { void didUpdateWidget(covariant DocAvailableAppointments oldWidget) {
if (oldWidget.doctorSchedule != widget.doctorSchedule) { if (oldWidget.doctorSchedule != widget.doctorSchedule) {
_calendarController.setSelectedDay(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), isProgrammatic: true); _onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date']));
_onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), List()); _calendarController.selectedDate = DateUtil.convertStringToDate(widget.doctorSchedule['Date']);
} }
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
} }
@ -99,28 +102,17 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
super.dispose(); super.dispose();
} }
void _onDaySelected(DateTime day, List events) { void _onDaySelected(DateTime day) {
final DateFormat formatter = DateFormat('yyyy-MM-dd'); final DateFormat formatter = DateFormat('yyyy-MM-dd');
setState(() { setState(() {
this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, language); this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, language);
openTimeSlotsPickerForDate(day, docFreeSlots); openTimeSlotsPickerForDate(day, docFreeSlots);
DocAvailableAppointments.selectedDate = formatter.format(day); DocAvailableAppointments.selectedDate = formatter.format(day);
print(DocAvailableAppointments.selectedDate); _calendarController.selectedDate = day;
print(_calendarController.selectedDate);
}); });
} }
void _onVisibleDaysChanged(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onVisibleDaysChanged');
print(first);
print(last);
}
void _onCalendarCreated(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onCalendarCreated');
print(first);
print(last);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return SingleChildScrollView(
@ -134,30 +126,36 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
child: Text(selectedDate, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600, letterSpacing: -0.64)), child: Text(selectedDate, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600, letterSpacing: -0.64)),
), ),
Container( DocAvailableAppointments.areSlotsAvailable
height: 40, ? Container(
child: ListView.builder( height: 40,
controller: _scrollController, child: ListView.builder(
scrollDirection: Axis.horizontal, controller: _scrollController,
itemCount: dayEvents.length, scrollDirection: Axis.horizontal,
itemBuilder: (context, index) { itemCount: dayEvents.length,
return Container( itemBuilder: (context, index) {
margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), return Container(
child: ButtonTheme( margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5),
shape: RoundedRectangleBorder( child: ButtonTheme(
borderRadius: BorderRadius.circular(5.0), shape: RoundedRectangleBorder(
side: BorderSide( borderRadius: BorderRadius.circular(5.0),
color: index == selectedButtonIndex ? CustomColors.green : Colors.black, //Color of the border side: BorderSide(
style: BorderStyle.solid, //Style of the border color: index == selectedButtonIndex ? CustomColors.green : Colors.black, //Color of the border
width: 1.5, //width of the border style: BorderStyle.solid, //Style of the border
), width: 1.5, //width of the border
), ),
minWidth: MediaQuery.of(context).size.width * 0.18, ),
child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index)), minWidth: MediaQuery.of(context).size.width * 0.18,
); child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index)),
}, );
), },
), ),
)
: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Text(TranslationBase.of(context).noSlotsError, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.grey)),
)),
], ],
), ),
), ),
@ -166,99 +164,42 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
Widget _buildTableCalendarWithBuilders() { Widget _buildTableCalendarWithBuilders() {
return Card( return Card(
shape: cardRadius(12), shape: cardRadius(12),
margin: EdgeInsets.all(16), margin: EdgeInsets.all(16),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 12), padding: const EdgeInsets.only(bottom: 12),
child: TableCalendar( child: Container(
locale: language == "en" ? 'en_US' : 'ar_SA', child: SfCalendar(
calendarController: _calendarController, controller: _calendarController,
events: _events, minDate: DateTime.now(),
initialCalendarFormat: CalendarFormat.month, showNavigationArrow: true,
startDay: DateTime.now(), headerStyle: CalendarHeaderStyle(textAlign: TextAlign.center, textStyle: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46)),
formatAnimation: FormatAnimation.slide, viewHeaderStyle: ViewHeaderStyle(dayTextStyle: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black)),
startingDayOfWeek: StartingDayOfWeek.sunday, view: CalendarView.month,
weekendDays: [DateTime.friday, DateTime.saturday], todayHighlightColor: CustomColors.green,
availableGestures: AvailableGestures.horizontalSwipe, selectionDecoration: containerColorRadiusBorderWidth(Colors.transparent, 4, CustomColors.green, 2.5),
availableCalendarFormats: const { cellBorderColor: Colors.white,
CalendarFormat.month: '', dataSource: MeetingDataSource(_getDataSource()),
CalendarFormat.week: '', monthViewSettings: const MonthViewSettings(appointmentDisplayMode: MonthAppointmentDisplayMode.indicator, showTrailingAndLeadingDates: false, appointmentDisplayCount: 1),
}, onTap: (CalendarTapDetails details) {
calendarStyle: CalendarStyle( _calendarController.selectedDate = details.date;
outsideDaysVisible: false, _onDaySelected(details.date);
weekendStyle: TextStyle().copyWith(color: Colors.blue[800]), },
holidayStyle: TextStyle().copyWith(color: Colors.blue[800]), ),
),
daysOfWeekStyle: DaysOfWeekStyle(
weekendStyle: TextStyle().copyWith(color: Colors.black, fontSize: 11.0, fontWeight: FontWeight.w600),
weekdayStyle: TextStyle().copyWith(color: Colors.black, fontSize: 11.0, fontWeight: FontWeight.w600),
),
headerStyle: HeaderStyle(centerHeaderTitle: true, formatButtonVisible: false, titleTextStyle: TextStyle(fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600)),
builders: CalendarBuilders(
selectedDayBuilder: (context, date, _) {
return FadeTransition(
opacity: Tween(begin: 0.0, end: 1.0).animate(_animationController),
child: Container(
margin: const EdgeInsets.all(4.0),
padding: const EdgeInsets.only(top: 5.0, left: 5.0),
color: Colors.transparent,
width: 0,
height: 0,
child: Text(
'${date.day}',
style: TextStyle().copyWith(fontSize: 14.0),
),
),
);
},
todayDayBuilder: (context, date, _) {
return Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _calendarController.isSelected(date)
? Colors.green[400]
: _calendarController.isToday(date)
? Colors.transparent
: Color(0xff76cfb7),
),
width: 40.0,
height: 40.0,
child: Center(
child: Text(
'${date.day}',
style: TextStyle().copyWith(
color: Colors.white,
fontSize: 14.0,
),
),
),
);
},
markersBuilder: (context, date, events, _) {
final children = <Widget>[];
if (events.isNotEmpty) {
children.add(
Positioned(
right: 4,
bottom: 4,
child: _buildEventsMarker(date, events),
),
);
}
return children;
},
), ),
onDaySelected: (date, event, _) { ));
_onDaySelected(date, event); }
_animationController.forward(from: 0.0);
}, List<Meeting> _getDataSource() {
onVisibleDaysChanged: _onVisibleDaysChanged, final List<Meeting> meetings = <Meeting>[];
onCalendarCreated: _onCalendarCreated,
), _events.forEach((key, value) {
), final DateTime startTime = DateTime(key.year, key.month, key.day, 9, 0, 0);
); final DateTime endTime = startTime.add(const Duration(hours: 2));
meetings.add(Meeting("", startTime, endTime, CustomColors.green, false));
});
return meetings;
} }
openTimeSlotsPickerForDate(DateTime dateStart, List<TimeSlot> freeSlots) { openTimeSlotsPickerForDate(DateTime dateStart, List<TimeSlot> freeSlots) {
@ -270,14 +211,12 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
}); });
setState(() { setState(() {
if (dayEvents.length != 0) if (dayEvents.length != 0) {
DocAvailableAppointments.areSlotsAvailable = true; DocAvailableAppointments.areSlotsAvailable = true;
else selectedButtonIndex = 0;
DocAvailableAppointments.selectedTime = dayEvents[selectedButtonIndex].isoTime;
} else
DocAvailableAppointments.areSlotsAvailable = false; DocAvailableAppointments.areSlotsAvailable = false;
selectedButtonIndex = 0;
DocAvailableAppointments.selectedTime = dayEvents[selectedButtonIndex].isoTime;
}); });
} }
@ -299,7 +238,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
selectedDateJSON = freeSlotsResponse[0]; selectedDateJSON = freeSlotsResponse[0];
}); });
openTimeSlotsPickerForDate(DateUtil.convertStringToDate(selectedDateJSON), docFreeSlots); openTimeSlotsPickerForDate(DateUtil.convertStringToDate(selectedDateJSON), docFreeSlots);
_calendarController.setFocusedDay(DateUtil.convertStringToDate(selectedDateJSON)); _calendarController.selectedDate = DateUtil.convertStringToDate(selectedDateJSON);
return _eventsParsed; return _eventsParsed;
} }
@ -321,7 +260,8 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
Widget getSelectedButton(int index) { Widget getSelectedButton(int index) {
return RaisedButton( return RaisedButton(
color: CustomColors.green, //Color of the border color: CustomColors.green,
//Color of the border
textColor: Colors.white, textColor: Colors.white,
elevation: 0, elevation: 0,
onPressed: () { onPressed: () {
@ -352,10 +292,7 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
_events.clear(), _events.clear(),
_events = value, _events = value,
if (widget.doctorSchedule != null) if (widget.doctorSchedule != null)
{ {_onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date'])), _calendarController.selectedDate = DateUtil.convertStringToDate(widget.doctorSchedule['Date'])}
_calendarController.setSelectedDay(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), isProgrammatic: true),
_onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), List())
}
}); });
}); });
} else { } else {
@ -403,29 +340,49 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
this.language = languageID; this.language = languageID;
}); });
} }
}
Widget _buildEventsMarker(DateTime date, List events) { class MeetingDataSource extends CalendarDataSource {
return Container( MeetingDataSource(List<Meeting> source) {
decoration: containerColorRadiusBorderWidth( appointments = source;
_calendarController.isSelected(date)
? CustomColors.green
: _calendarController.isToday(date)
? CustomColors.green.withOpacity(0.5)
: Colors.white,
200,
_calendarController.isSelected(date) ? CustomColors.green : Colors.black,
2),
width: 40.0,
height: 40.0,
child: Center(
child: Text(
'${date.day}',
style: TextStyle().copyWith(
color: _calendarController.isSelected(date) ? Colors.white : Colors.black,
fontSize: 14.0,
),
),
),
);
} }
@override
DateTime getStartTime(int index) {
return _getMeetingData(index).from;
}
@override
DateTime getEndTime(int index) {
return _getMeetingData(index).to;
}
@override
String getSubject(int index) {
return _getMeetingData(index).eventName;
}
@override
Color getColor(int index) {
return _getMeetingData(index).background;
}
@override
bool isAllDay(int index) {
return _getMeetingData(index).isAllDay;
}
Meeting _getMeetingData(int index) {
final dynamic meeting = appointments[index];
Meeting meetingData;
if (meeting is Meeting) {
meetingData = meeting;
}
return meetingData;
}
}
class Meeting {
Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay);
String eventName;
DateTime from;
DateTime to;
Color background;
bool isAllDay;
} }

@ -1,5 +1,6 @@
import "dart:collection"; import "dart:collection";
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
@ -429,24 +430,36 @@ class _SearchByClinicState extends State<SearchByClinic> {
return false; return false;
} }
getClinicsList() { getClinicsList() async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
ClinicListService service = new ClinicListService(); if (await sharedPref.getObject(CLINICS_LIST) != null) {
service.getClinicsList(context).then((res) { dynamic res = await sharedPref.getObject(CLINICS_LIST);
if (res['MessageStatus'] == 1) { setState(() {
setState(() { isMobileAppDentalAllow = res['ISMobileAppDentalAllow'];
isMobileAppDentalAllow = res['ISMobileAppDentalAllow']; res['ListClinicCentralized'].forEach((v) {
res['ListClinicCentralized'].forEach((v) { clinicsList.add(new ListClinicCentralized.fromJson(v));
clinicsList.add(new ListClinicCentralized.fromJson(v));
});
}); });
getProjectsList(); });
GifLoaderDialogUtils.hideDialog(context); getProjectsList();
} else {}
}).catchError((err) {
print(err);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}); } else {
ClinicListService service = new ClinicListService();
service.getClinicsList(context).then((res) {
if (res['MessageStatus'] == 1) {
setState(() {
isMobileAppDentalAllow = res['ISMobileAppDentalAllow'];
res['ListClinicCentralized'].forEach((v) {
clinicsList.add(new ListClinicCentralized.fromJson(v));
});
});
getProjectsList();
GifLoaderDialogUtils.hideDialog(context);
} else {}
}).catchError((err) {
print(err);
GifLoaderDialogUtils.hideDialog(context);
});
}
} }
getProjectsList() { getProjectsList() {

@ -21,10 +21,11 @@ import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:table_calendar/table_calendar.dart'; // import 'package:table_calendar/table_calendar.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
class CovidTimeSlots extends StatefulWidget { class CovidTimeSlots extends StatefulWidget {
int projectID; int projectID;
@ -100,24 +101,17 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
super.dispose(); super.dispose();
} }
void _onDaySelected(DateTime day, List events, ProjectViewModel projectViewModel) { void _onDaySelected(DateTime day, ProjectViewModel projectViewModel) {
final DateFormat formatter = DateFormat('yyyy-MM-dd'); final DateFormat formatter = DateFormat('yyyy-MM-dd');
setState(() { setState(() {
this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, projectViewModel.isArabic ? "ar" : "en"); this.selectedDate = DateUtil.getWeekDayMonthDayYearDateFormatted(day, projectViewModel.isArabic ? "ar" : "en");
openTimeSlotsPickerForDate(day, docFreeSlots); openTimeSlotsPickerForDate(day, docFreeSlots);
CovidTimeSlots.selectedDate = formatter.format(day); CovidTimeSlots.selectedDate = formatter.format(day);
_calendarController.selectedDate = day;
print(CovidTimeSlots.selectedDate); print(CovidTimeSlots.selectedDate);
}); });
} }
void _onVisibleDaysChanged(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onVisibleDaysChanged');
}
void _onCalendarCreated(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onCalendarCreated');
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -151,6 +145,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
mHeight(12),
Card( Card(
shape: cardRadius(12), shape: cardRadius(12),
child: _buildTableCalendarWithBuilders(projectViewModel), child: _buildTableCalendarWithBuilders(projectViewModel),
@ -165,30 +160,36 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
), ),
), ),
mHeight(8), mHeight(8),
Container( CovidTimeSlots.areSlotsAvailable
height: 40, ? Container(
child: ListView.builder( height: 40,
controller: _scrollController, child: ListView.builder(
scrollDirection: Axis.horizontal, controller: _scrollController,
itemCount: dayEvents.length, scrollDirection: Axis.horizontal,
itemBuilder: (context, index) { itemCount: dayEvents.length,
return Container( itemBuilder: (context, index) {
margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 0 : 5.0, left: index == 0 ? 0 : 5), return Container(
child: ButtonTheme( margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 0 : 5.0, left: index == 0 ? 0 : 5),
shape: RoundedRectangleBorder( child: ButtonTheme(
borderRadius: BorderRadius.circular(5.0), shape: RoundedRectangleBorder(
side: BorderSide( borderRadius: BorderRadius.circular(5.0),
color: index == selectedButtonIndex ? CustomColors.green : Colors.black, //Color of the border side: BorderSide(
style: BorderStyle.solid, //Style of the border color: index == selectedButtonIndex ? CustomColors.green : Colors.black, //Color of the border
width: 1.5, //width of the border style: BorderStyle.solid, //Style of the border
), width: 1.5, //width of the border
), ),
minWidth: MediaQuery.of(context).size.width * 0.2, ),
child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index)), minWidth: MediaQuery.of(context).size.width * 0.2,
); child: index == selectedButtonIndex ? getSelectedButton(index) : getNormalButton(index)),
}, );
), },
), ),
)
: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Text(TranslationBase.of(context).noSlotsError, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.grey)),
)),
], ],
), ),
), ),
@ -239,95 +240,35 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
} }
Widget _buildTableCalendarWithBuilders(ProjectViewModel projectViewModel) { Widget _buildTableCalendarWithBuilders(ProjectViewModel projectViewModel) {
return TableCalendar( return SfCalendar(
locale: projectViewModel.isArabic ? 'ar_SA' : 'en_US', controller: _calendarController,
calendarController: _calendarController, minDate: DateTime.now(),
events: _events, showNavigationArrow: true,
initialCalendarFormat: CalendarFormat.month, headerStyle: CalendarHeaderStyle(textAlign: TextAlign.center, textStyle: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46)),
startDay: DateTime.now(), viewHeaderStyle: ViewHeaderStyle(dayTextStyle: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.black)),
formatAnimation: FormatAnimation.slide, view: CalendarView.month,
startingDayOfWeek: StartingDayOfWeek.sunday, todayHighlightColor: CustomColors.green,
weekendDays: [DateTime.friday, DateTime.saturday], selectionDecoration: containerColorRadiusBorderWidth(Colors.transparent, 4, CustomColors.green, 2.5),
availableGestures: AvailableGestures.horizontalSwipe, cellBorderColor: Colors.white,
availableCalendarFormats: const { dataSource: MeetingDataSource(_getDataSource()),
CalendarFormat.month: '', monthViewSettings: const MonthViewSettings(appointmentDisplayMode: MonthAppointmentDisplayMode.indicator, showTrailingAndLeadingDates: false, appointmentDisplayCount: 1),
CalendarFormat.week: '', onTap: (CalendarTapDetails details) {
}, _calendarController.selectedDate = details.date;
calendarStyle: CalendarStyle( _onDaySelected(details.date, projectViewModel);
outsideDaysVisible: false,
weekendStyle: TextStyle().copyWith(color: Colors.blue[800]),
holidayStyle: TextStyle().copyWith(color: Colors.blue[800]),
),
daysOfWeekStyle: DaysOfWeekStyle(
weekendStyle: TextStyle().copyWith(color: Colors.black, fontSize: 11.0, fontWeight: FontWeight.w600),
weekdayStyle: TextStyle().copyWith(color: Colors.black, fontSize: 11.0, fontWeight: FontWeight.w600),
),
headerStyle: HeaderStyle(centerHeaderTitle: true, formatButtonVisible: false, titleTextStyle: TextStyle(fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600)),
builders: CalendarBuilders(
selectedDayBuilder: (context, date, _) {
return FadeTransition(
opacity: Tween(begin: 0.0, end: 1.0).animate(_animationController),
child: Container(
margin: const EdgeInsets.all(4.0),
padding: const EdgeInsets.only(top: 5.0, left: 6.0),
color: Colors.transparent,
width: 0,
height: 0,
child: Text(
'${date.day}',
style: TextStyle().copyWith(fontSize: 14.0),
),
),
);
},
todayDayBuilder: (context, date, _) {
return Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _calendarController.isSelected(date)
? Colors.green[400]
: _calendarController.isToday(date)
? Colors.transparent
: Color(0xff76cfb7),
),
width: 40.0,
height: 40.0,
child: Center(
child: Text(
'${date.day}',
style: TextStyle().copyWith(
color: Colors.white,
fontSize: 14.0,
),
),
),
);
},
markersBuilder: (context, date, events, holidays) {
final children = <Widget>[];
if (events.isNotEmpty) {
children.add(
Positioned(
right: 4,
bottom: 4,
child: _buildEventsMarker(date, events),
),
);
}
return children;
},
),
onDaySelected: (date, event, _) {
_onDaySelected(date, event, projectViewModel);
_animationController.forward(from: 0.0);
}, },
onVisibleDaysChanged: _onVisibleDaysChanged,
onCalendarCreated: _onCalendarCreated,
); );
} }
List<Meeting> _getDataSource() {
final List<Meeting> meetings = <Meeting>[];
_events.forEach((key, value) {
final DateTime startTime = DateTime(key.year, key.month, key.day, 9, 0, 0);
final DateTime endTime = startTime.add(const Duration(hours: 2));
meetings.add(Meeting("", startTime, endTime, CustomColors.green, false));
});
return meetings;
}
openTimeSlotsPickerForDate(DateTime dateStart, List<TimeSlot> freeSlots) { openTimeSlotsPickerForDate(DateTime dateStart, List<TimeSlot> freeSlots) {
dayEvents.clear(); dayEvents.clear();
DateTime dateStartObj = new DateTime(dateStart.year, dateStart.month, dateStart.day, 0, 0, 0, 0, 0); DateTime dateStartObj = new DateTime(dateStart.year, dateStart.month, dateStart.day, 0, 0, 0, 0, 0);
@ -337,14 +278,12 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
}); });
setState(() { setState(() {
if (dayEvents.length != 0) if (dayEvents.length != 0) {
CovidTimeSlots.areSlotsAvailable = true; CovidTimeSlots.areSlotsAvailable = true;
else selectedButtonIndex = 0;
CovidTimeSlots.selectedTime = dayEvents[selectedButtonIndex].isoTime;
} else
CovidTimeSlots.areSlotsAvailable = false; CovidTimeSlots.areSlotsAvailable = false;
selectedButtonIndex = 0;
CovidTimeSlots.selectedTime = dayEvents[selectedButtonIndex].isoTime;
}); });
} }
@ -366,43 +305,43 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
selectedDateJSON = freeSlotsResponse[0]['FreeTimeSlots']; selectedDateJSON = freeSlotsResponse[0]['FreeTimeSlots'];
}); });
openTimeSlotsPickerForDate(DateUtil.convertStringToDate(selectedDateJSON), docFreeSlots); openTimeSlotsPickerForDate(DateUtil.convertStringToDate(selectedDateJSON), docFreeSlots);
_calendarController.setFocusedDay(DateUtil.convertStringToDate(selectedDateJSON)); _calendarController.selectedDate = DateUtil.convertStringToDate(selectedDateJSON);
return _eventsParsed; return _eventsParsed;
} }
Widget _buildEventsMarker(DateTime date, List events) { // Widget _buildEventsMarker(DateTime date, List events) {
return Container( // return Container(
// decoration: BoxDecoration( // // decoration: BoxDecoration(
// shape: BoxShape.circle, // // shape: BoxShape.circle,
// color: _calendarController.isSelected(date) // // color: _calendarController.isSelected(date)
// ? Colors.green[400] // // ? Colors.green[400]
// : _calendarController.isToday(date) // // : _calendarController.isToday(date)
// ? Colors.brown[300] // // ? Colors.brown[300]
// : Colors.blue[400], // // : Colors.blue[400],
// ), // // ),
//
decoration: containerColorRadiusBorderWidth( // decoration: containerColorRadiusBorderWidth(
_calendarController.isSelected(date) // _calendarController.isSelected(date)
? CustomColors.green // ? CustomColors.green
: _calendarController.isToday(date) // : _calendarController.isToday(date)
? CustomColors.green.withOpacity(0.5) // ? CustomColors.green.withOpacity(0.5)
: Colors.white, // : Colors.white,
200, // 200,
_calendarController.isSelected(date) ? CustomColors.green : Colors.black, // _calendarController.isSelected(date) ? CustomColors.green : Colors.black,
2), // 2),
width: 40.0, // width: 40.0,
height: 40.0, // height: 40.0,
child: Center( // child: Center(
child: Text( // child: Text(
'${date.day}', // '${date.day}',
style: TextStyle().copyWith( // style: TextStyle().copyWith(
color: _calendarController.isSelected(date) ? Colors.white : Colors.black, // color: _calendarController.isSelected(date) ? Colors.white : Colors.black,
fontSize: 13.0, // fontSize: 13.0,
), // ),
), // ),
), // ),
); // );
} // }
Widget getNormalButton(int index) { Widget getNormalButton(int index) {
return RaisedButton( return RaisedButton(
@ -436,12 +375,16 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
} }
bookCovidTestAppointment() { bookCovidTestAppointment() {
GifLoaderDialogUtils.showMyDialog(context); if(CovidTimeSlots.areSlotsAvailable) {
DoctorList docObject = new DoctorList(); GifLoaderDialogUtils.showMyDialog(context);
docObject.doctorID = widget.selectedDoctorID; DoctorList docObject = new DoctorList();
docObject.clinicID = widget.selectedClinicID; docObject.doctorID = widget.selectedDoctorID;
docObject.projectID = widget.projectID; docObject.clinicID = widget.selectedClinicID;
insertAppointmentCovidTest(context, docObject); docObject.projectID = widget.projectID;
insertAppointmentCovidTest(context, docObject);
} else {
AppToast.showErrorToast(message: TranslationBase.of(context).selectSlot);
}
} }
insertAppointmentCovidTest(context, DoctorList docObject) { insertAppointmentCovidTest(context, DoctorList docObject) {
@ -546,8 +489,8 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
if (res['COVID19_FreeTimeSlots'].length != 0) { if (res['COVID19_FreeTimeSlots'].length != 0) {
freeSlotsResponse = res['COVID19_FreeTimeSlots']; freeSlotsResponse = res['COVID19_FreeTimeSlots'];
_getJSONSlots().then((value) => { _getJSONSlots().then((value) => {
setState(() => {widget.selectedClinicID = freeSlotsResponse[0]['ClinicID'], widget.selectedDoctorID = freeSlotsResponse[0]['DoctorID'], _events.clear(), _events = value}) setState(() => {widget.selectedClinicID = freeSlotsResponse[0]['ClinicID'], widget.selectedDoctorID = freeSlotsResponse[0]['DoctorID'], _events.clear(), _events = value})
}); });
} else {} } else {}
} else { } else {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
@ -560,3 +503,53 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
}); });
} }
} }
class MeetingDataSource extends CalendarDataSource {
MeetingDataSource(List<Meeting> source) {
appointments = source;
}
@override
DateTime getStartTime(int index) {
return _getMeetingData(index).from;
}
@override
DateTime getEndTime(int index) {
return _getMeetingData(index).to;
}
@override
String getSubject(int index) {
return _getMeetingData(index).eventName;
}
@override
Color getColor(int index) {
return _getMeetingData(index).background;
}
@override
bool isAllDay(int index) {
return _getMeetingData(index).isAllDay;
}
Meeting _getMeetingData(int index) {
final dynamic meeting = appointments[index];
Meeting meetingData;
if (meeting is Meeting) {
meetingData = meeting;
}
return meetingData;
}
}
class Meeting {
Meeting(this.eventName, this.from, this.to, this.background, this.isAllDay);
String eventName;
DateTime from;
DateTime to;
Color background;
bool isAllDay;
}

@ -145,7 +145,6 @@ class CovidDirveThruQuestionsState extends State<CovidDirveThruQuestions> {
itemBuilder: (ctx, idx) { itemBuilder: (ctx, idx) {
var obj = qa[idx]; var obj = qa[idx];
var qtext = isArabic ? obj["questionAR"] : obj["questionEN"]; var qtext = isArabic ? obj["questionAR"] : obj["questionEN"];
print("dddddddddddddd " + obj["ans"].toString());
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),

@ -40,6 +40,7 @@ class ClinicListService extends BaseService {
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: request); }, body: request);
sharedPref.setObject(CLINICS_LIST, localRes);
return Future.value(localRes); return Future.value(localRes);
} }

@ -2343,6 +2343,9 @@ class TranslationBase {
String get respirationBPM => localizedValues["respirationBPM"][locale.languageCode]; String get respirationBPM => localizedValues["respirationBPM"][locale.languageCode];
String get noSlotsError => localizedValues["noSlotsError"][locale.languageCode];
String get selectSlot => localizedValues["selectSlot"][locale.languageCode];
} }

@ -102,7 +102,8 @@ dependencies:
rating_bar: ^0.2.0 rating_bar: ^0.2.0
# Calendar # Calendar
table_calendar: ^2.3.0 # table_calendar: ^2.3.0
syncfusion_flutter_calendar: ^18.4.49
# SVG Images # SVG Images
flutter_svg: ^0.18.0 flutter_svg: ^0.18.0

Loading…
Cancel
Save