From 233a273316d01f4987faa62713435485237e13d6 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 1 Sep 2021 17:06:40 +0300 Subject: [PATCH] shcedule page --- lib/pages/BookAppointment/DoctorProfile.dart | 14 +++++++-- .../components/DocAvailableAppointments.dart | 30 +++++++++---------- .../MyAppointments/AppointmentDetails.dart | 18 ++++++++--- lib/pages/MyAppointments/SchedulePage.dart | 23 +++++++------- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index e6aea879..a2510b6a 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -44,7 +44,7 @@ class _DoctorProfileState extends State with TickerProviderStateM TabController _tabController; bool showFooterButton = false; var event = RobotProvider(); - + dynamic doctorSchedule; AppSharedPreferences sharedPref = AppSharedPreferences(); List doctorDetailsList = List(); @@ -122,7 +122,11 @@ class _DoctorProfileState extends State with TickerProviderStateM FadePage( page: SchedulePage(doctorList: widget.doctor), ), - ); + ).then((value) { + setState(() { + this.doctorSchedule = value; + }); + }); }, onRatingAndReviewTap: () { getDoctorRatingsDetails(); @@ -170,7 +174,11 @@ class _DoctorProfileState extends State with TickerProviderStateM physics: NeverScrollableScrollPhysics(), children: [ DoctorInformation(docProfileList: widget.docProfileList), - DocAvailableAppointments(doctor: widget.doctor, isLiveCareAppointment: widget.isLiveCareAppointment), + DocAvailableAppointments( + doctor: widget.doctor, + isLiveCareAppointment: widget.isLiveCareAppointment, + doctorSchedule: doctorSchedule, + ), ], controller: _tabController, ), diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index afcbd646..ff407053 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -24,10 +24,7 @@ class DocAvailableAppointments extends StatefulWidget { static String selectedTime; bool isLiveCareAppointment; final dynamic doctorSchedule; - DocAvailableAppointments( - {@required this.doctor, - this.doctorSchedule, - @required this.isLiveCareAppointment}); + DocAvailableAppointments({@required this.doctor, this.doctorSchedule, @required this.isLiveCareAppointment}); @override _DocAvailableAppointmentsState createState() => _DocAvailableAppointmentsState(); @@ -55,6 +52,15 @@ class _DocAvailableAppointmentsState extends State wit var language; + @override + void didUpdateWidget(covariant DocAvailableAppointments oldWidget) { + if (oldWidget.doctorSchedule != widget.doctorSchedule) { + _calendarController.setSelectedDay(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), isProgrammatic: true); + _onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), List()); + } + super.didUpdateWidget(oldWidget); + } + @override void initState() { // TODO: implement initState @@ -121,7 +127,7 @@ class _DocAvailableAppointmentsState extends State wit children: [ _buildTableCalendarWithBuilders(), Padding( - 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)), ), Container( @@ -132,12 +138,12 @@ class _DocAvailableAppointmentsState extends State wit itemCount: dayEvents.length, itemBuilder: (context, index) { return Container( - margin: EdgeInsets.only(right: (index==dayEvents.length-1)?16:5.0,left: index==0?16:5), + margin: EdgeInsets.only(right: (index == dayEvents.length - 1) ? 16 : 5.0, left: index == 0 ? 16 : 5), child: ButtonTheme( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0), side: BorderSide( - color:index == selectedButtonIndex ? CustomColors.green:Colors.black, //Color of the border + color: index == selectedButtonIndex ? CustomColors.green : Colors.black, //Color of the border style: BorderStyle.solid, //Style of the border width: 1.5, //width of the border ), @@ -345,14 +351,8 @@ class _DocAvailableAppointmentsState extends State wit _events = value, if (widget.doctorSchedule != null) { - _calendarController.setSelectedDay( - DateUtil.convertStringToDate( - widget.doctorSchedule['Date']), - isProgrammatic: true), - _onDaySelected( - DateUtil.convertStringToDate( - widget.doctorSchedule['Date']), - List()) + _calendarController.setSelectedDay(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), isProgrammatic: true), + _onDaySelected(DateUtil.convertStringToDate(widget.doctorSchedule['Date']), List()) } }); }); diff --git a/lib/pages/MyAppointments/AppointmentDetails.dart b/lib/pages/MyAppointments/AppointmentDetails.dart index 6045d771..46b1fb40 100644 --- a/lib/pages/MyAppointments/AppointmentDetails.dart +++ b/lib/pages/MyAppointments/AppointmentDetails.dart @@ -28,7 +28,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; class AppointmentDetails extends StatefulWidget { AppoitmentAllHistoryResultList appo; static bool isLoading = false; - final dynamic doctorSchedule; + dynamic doctorSchedule; static bool showFooterButton = false; final int parentIndex; @@ -182,9 +182,13 @@ class _AppointmentDetailsState extends State with SingleTick Navigator.push( context, FadePage( - page: SchedulePage(doctorList: doctorList), + page: SchedulePage(doctorList: doctorList, appo: widget.appo), ), - ); + ).then((value) { + setState(() { + widget.doctorSchedule = value; + }); + }); }, ), SizedBox(height: 10), @@ -586,7 +590,13 @@ class _AppointmentDetailsState extends State with SingleTick } void openSchedule() { - Navigator.push(context, FadePage(page: SchedulePage(doctorList: getDoctorObject()))); + Navigator.push( + context, + FadePage( + page: SchedulePage( + doctorList: getDoctorObject(), + appo: widget.appo, + ))); } setTab() async { diff --git a/lib/pages/MyAppointments/SchedulePage.dart b/lib/pages/MyAppointments/SchedulePage.dart index 4283432f..ef53ab04 100644 --- a/lib/pages/MyAppointments/SchedulePage.dart +++ b/lib/pages/MyAppointments/SchedulePage.dart @@ -17,8 +17,8 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; class SchedulePage extends StatefulWidget { - final DoctorList doctorList; - final AppoitmentAllHistoryResultList appo; + DoctorList doctorList; + AppoitmentAllHistoryResultList appo; SchedulePage({ this.appo, this.doctorList, @@ -202,14 +202,15 @@ class _SchedulePageState extends State { openBookAppointment(selectedDate) { //sharedPref.setObject(DOCTOR_SCHEDULE_DATE_SEL, selectedDate); - Navigator.push( - context, - FadePage( - page: AppointmentDetails( - appo: widget.appo, - doctorSchedule: selectedDate, - ), - ), - ); + Navigator.of(context).pop(selectedDate); + // Navigator.push( + // context, + // FadePage( + // page: AppointmentDetails( + // appo: widget.appo, + // doctorSchedule: selectedDate, + // ), + // ), + // ); } }