@ -8,11 +8,13 @@ import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidTestProceduresRe
import ' package:diplomaticquarterapp/pages/Covid-DriveThru/covid-payment-alert.dart ' ;
import ' package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart ' ;
import ' package:diplomaticquarterapp/services/covid-drivethru/covid-drivethru.dart ' ;
import ' package:diplomaticquarterapp/theme/colors.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_shared_preferences.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/date_uitl.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/widgets/dialogs/confirm_dialog.dart ' ;
import ' package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart ' ;
import ' package:diplomaticquarterapp/widgets/transitions/fade_page.dart ' ;
@ -43,8 +45,7 @@ class CovidTimeSlots extends StatefulWidget {
_CovidTimeSlotsState createState ( ) = > _CovidTimeSlotsState ( ) ;
}
class _CovidTimeSlotsState extends State < CovidTimeSlots >
with TickerProviderStateMixin {
class _CovidTimeSlotsState extends State < CovidTimeSlots > with TickerProviderStateMixin {
Map < DateTime , List > _events ;
AnimationController _animationController ;
CalendarController _calendarController ;
@ -76,8 +77,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
_selectedDay: [ ' Event A0 ' ]
} ;
WidgetsBinding . instance . addPostFrameCallback (
( _ ) = > getCovidFreeSlots ( context , widget . projectID ) ) ;
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) = > getCovidFreeSlots ( context , widget . projectID ) ) ;
_calendarController = CalendarController ( ) ;
_animationController = AnimationController (
@ -96,25 +96,21 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
super . dispose ( ) ;
}
void _onDaySelected (
DateTime day , List events , ProjectViewModel projectViewModel ) {
void _onDaySelected ( DateTime day , List events , ProjectViewModel projectViewModel ) {
final DateFormat formatter = DateFormat ( ' yyyy-MM-dd ' ) ;
setState ( ( ) {
this . selectedDate = DateUtil . getWeekDayMonthDayYearDateFormatted (
day , projectViewModel . isArabic ? " ar " : " en " ) ;
this . selectedDate = DateUtil . getWeekDayMonthDayYearDateFormatted ( day , projectViewModel . isArabic ? " ar " : " en " ) ;
openTimeSlotsPickerForDate ( day , docFreeSlots ) ;
CovidTimeSlots . selectedDate = formatter . format ( day ) ;
print ( CovidTimeSlots . selectedDate ) ;
} ) ;
}
void _onVisibleDaysChanged (
DateTime first , DateTime last , CalendarFormat format ) {
void _onVisibleDaysChanged ( DateTime first , DateTime last , CalendarFormat format ) {
print ( ' CALLBACK: _onVisibleDaysChanged ' ) ;
}
void _onCalendarCreated (
DateTime first , DateTime last , CalendarFormat format ) {
void _onCalendarCreated ( DateTime first , DateTime last , CalendarFormat format ) {
print ( ' CALLBACK: _onCalendarCreated ' ) ;
}
@ -124,154 +120,114 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
return AppScaffold (
appBarTitle: TranslationBase . of ( context ) . covidTest ,
isShowAppBar: true ,
body: SingleChildScrollView (
child: Container (
margin: EdgeInsets . fromLTRB ( 15.0 , 15.0 , 15.0 , 0.0 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
Container (
height: 150.0 ,
decoration: BoxDecoration (
image: DecorationImage (
image: AssetImage (
" assets/images/new-design/covid-19-big-banner-bg.png " ) ,
fit: BoxFit . fill ,
) ,
color: Colors . white . withOpacity ( 0.3 ) ,
borderRadius: BorderRadius . all ( Radius . circular ( 10 ) ) ) ,
child: Row (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
Container (
margin:
EdgeInsets . only ( left: 15.0 , right: 15.0 , top: 30.0 ) ,
child: SvgPicture . asset (
' assets/images/new-design/covid-19-car.svg ' ,
width: 90.0 ,
height: 90.0 ) ,
) ,
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
Container (
margin: EdgeInsets . only (
left: 20.0 , right: 20.0 , top: 20.0 ) ,
child: Text ( TranslationBase . of ( context ) . covidTest ,
style: TextStyle (
color: Colors . white ,
fontWeight: FontWeight . bold ,
fontSize: 24.0 ) ) ,
) ,
Container (
margin: EdgeInsets . only (
left: 20.0 , right: 20.0 , top: 10.0 ) ,
child: Text ( TranslationBase . of ( context ) . driveThru ,
style: TextStyle (
color: Colors . white , fontSize: 24.0 ) ) ,
) ,
] ,
) ,
] ,
) ,
) ,
Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 10.0 ) ,
color: Colors . white ) ,
margin: EdgeInsets . fromLTRB ( 0.0 , 20.0 , 0.0 , 5.0 ) ,
padding: EdgeInsets . fromLTRB ( 10.0 , 0.0 , 10.0 , 20.0 ) ,
width: MediaQuery . of ( context ) . size . width ,
/ / height: MediaQuery . of ( context ) . size . height * 0.65 ,
showNewAppBar: true ,
showNewAppBarTitle: true ,
backgroundColor: CustomColors . appBackgroudGrey2Color ,
body: Column (
children: [
Expanded (
child: SingleChildScrollView (
child: Container (
margin: EdgeInsets . fromLTRB ( 15.0 , 15.0 , 15.0 , 0.0 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . max ,
children: < Widget > [
Container (
margin: EdgeInsets . all ( 10.0 ) ,
child: Text ( TranslationBase . of ( context ) . selectAppo ,
style:
TextStyle ( color: Colors . black , fontSize: 16.0 ) ) ,
) ,
Container (
margin: EdgeInsets . only ( top: 10.0 ) ,
alignment: Alignment . center ,
child: Text ( selectedDate ,
style: TextStyle (
fontSize: 18.0 , fontWeight: FontWeight . bold ) ) ,
) ,
Container (
height: 50 ,
margin: EdgeInsets . all ( 20.0 ) ,
child: ListView . builder (
controller: _scrollController ,
scrollDirection: Axis . horizontal ,
itemCount: dayEvents . length ,
itemBuilder: ( context , index ) {
return Container (
margin: EdgeInsets . only ( right: 10.0 ) ,
child: ButtonTheme (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 5.0 ) ,
side: BorderSide (
color: Colors . blue [ 400 ] ,
/ / Color 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 ) ) ,
) ;
} ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . max ,
children: < Widget > [
Text (
TranslationBase . of ( context ) . selectAppo ,
style: TextStyle (
color: Colors . black ,
fontSize: 16.0 ,
letterSpacing: - 0.64 ,
fontWeight: FontWeight . w600 ,
) ,
) ,
Card (
shape: cardRadius ( 12 ) ,
child: _buildTableCalendarWithBuilders ( projectViewModel ) ,
) ,
mHeight ( 12 ) ,
Text (
selectedDate ,
style: TextStyle (
fontSize: 16.0 ,
fontWeight: FontWeight . bold ,
letterSpacing: - 0.64 ,
) ,
) ,
mHeight ( 8 ) ,
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 ) ? 0 : 5.0 , left: index = = 0 ? 0 : 5 ) ,
child: ButtonTheme (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 5.0 ) ,
side: BorderSide (
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
) ,
) ,
minWidth: MediaQuery . of ( context ) . size . width * 0.2 ,
child: index = = selectedButtonIndex ? getSelectedButton ( index ) : getNormalButton ( index ) ) ,
) ;
} ,
) ,
) ,
] ,
) ,
) ,
_buildTableCalendarWithBuilders ( projectViewModel ) ,
SizedBox (
height: 100.0 ,
) ,
] ,
) ,
) ,
SizedBox (
height: 100.0 ,
) ,
] ,
) ,
) ,
) ,
) ,
bottomSheet: Container (
margin: EdgeInsets . all ( 10. 0) ,
child: Flex (
direction: Axis . horizontal ,
children: < Widget > [
Expanded (
flex: 1 ,
child: Container (
margin: EdgeInsets . fromLTRB ( 10.0 , 0.0 , 5.0 , 0.0 ) ,
child: ButtonTheme (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 10.0 ) ,
) ,
minWidth: MediaQuery . of ( context ) . size . width * 0.7 ,
height: 45.0 ,
child: RaisedButton (
color: new Color ( 0xFF60686b ) ,
textColor: Colors . white ,
disabledTextColor: Colors . white ,
disabledColor: Colors . grey [ 500 ] ,
onPressed: ( ) {
bookCovidTestAppointment ( ) ;
} ,
child: Text ( TranslationBase . of ( context ) . bookNow ,
style: TextStyle ( fontSize: 18.0 ) ) ,
Card (
elevation: 20 ,
margin: EdgeInsets . zero ,
shape: cardRadius ( 0) ,
child: Container (
width: double . infinity ,
padding: EdgeInsets . all ( 12 ) ,
child: ButtonTheme (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 10.0 ) ,
) ,
minWidth: MediaQuery . of ( context ) . size . width * 0.7 ,
height: 45.0 ,
child: RaisedButton (
color: CustomColors . green ,
textColor: Colors . white ,
disabledTextColor: Colors . white ,
disabledColor: Colors . grey [ 500 ] ,
onPressed: ( ) {
bookCovidTestAppointment ( ) ;
} ,
child: Text (
TranslationBase . of ( context ) . bookAppo ,
style: TextStyle (
fontSize: 16.0 ,
letterSpacing: - 0.64 ,
) ,
) ,
) ,
) ,
) ,
],
) ,
)
] ,
) ,
) ;
}
@ -297,12 +253,10 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
holidayStyle: TextStyle ( ) . copyWith ( color: Colors . blue [ 800 ] ) ,
) ,
daysOfWeekStyle: DaysOfWeekStyle (
weekendStyle: TextStyle ( ) . copyWith ( color: Colors . blue [ 600 ] ) ,
) ,
headerStyle: HeaderStyle (
centerHeaderTitle: true ,
formatButtonVisible: false ,
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 (
@ -315,7 +269,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
height: 0 ,
child: Text (
' ${ date . day } ' ,
style: TextStyle ( ) . copyWith ( fontSize: 1 6 .0) ,
style: TextStyle ( ) . copyWith ( fontSize: 1 4 .0) ,
) ,
) ,
) ;
@ -327,8 +281,8 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
color: _calendarController . isSelected ( date )
? Colors . green [ 400 ]
: _calendarController . isToday ( date )
? Colors . brown[ 300 ]
: Color s. blue [ 400 ] ,
? Colors . transparent
: Color ( 0xff76cfb7 ) ,
) ,
width: 40.0 ,
height: 40.0 ,
@ -370,8 +324,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
openTimeSlotsPickerForDate ( DateTime dateStart , List < TimeSlot > freeSlots ) {
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 ) ;
freeSlots . forEach ( ( v ) {
if ( v . start = = dateStartObj ) dayEvents . add ( v ) ;
@ -396,48 +349,49 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
final DateFormat formatter = DateFormat ( ' HH:mm ' ) ;
final DateFormat dateFormatter = DateFormat ( ' yyyy-MM-dd ' ) ;
for ( var i = 0 ; i < freeSlotsResponse . length ; i + + ) {
date =
DateUtil . convertStringToDate ( freeSlotsResponse [ i ] [ ' FreeTimeSlots ' ] ) ;
date = DateUtil . convertStringToDate ( freeSlotsResponse [ i ] [ ' FreeTimeSlots ' ] ) ;
slotsList . add ( FreeSlot ( date , [ ' slot ' ] ) ) ;
docFreeSlots . add ( TimeSlot (
isoTime: formatter . format ( date ) ,
start: new DateTime ( date . year , date . month , date . day , 0 , 0 , 0 , 0 ) ,
end: date ) ) ;
docFreeSlots . add ( TimeSlot ( isoTime: formatter . format ( date ) , start: new DateTime ( date . year , date . month , date . day , 0 , 0 , 0 , 0 ) , end: date ) ) ;
}
_eventsParsed =
Map . fromIterable ( slotsList , key: ( e ) = > e . slot , value: ( e ) = > e . event ) ;
_eventsParsed = Map . fromIterable ( slotsList , key: ( e ) = > e . slot , value: ( e ) = > e . event ) ;
setState ( ( ) {
CovidTimeSlots . selectedDate = dateFormatter . format (
DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
selectedDate = DateUtil . getMonthDayYearDateFormatted (
DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
CovidTimeSlots . selectedDate = dateFormatter . format ( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
selectedDate = DateUtil . getMonthDayYearDateFormatted ( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
selectedDateJSON = freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ;
} ) ;
openTimeSlotsPickerForDate (
DateUtil . convertStringToDate ( selectedDateJSON ) , docFreeSlots ) ;
_calendarController
. setFocusedDay ( DateUtil . convertStringToDate ( selectedDateJSON ) ) ;
openTimeSlotsPickerForDate ( DateUtil . convertStringToDate ( selectedDateJSON ) , docFreeSlots ) ;
_calendarController . setFocusedDay ( DateUtil . convertStringToDate ( selectedDateJSON ) ) ;
return _eventsParsed ;
}
Widget _buildEventsMarker ( DateTime date , List events ) {
return Container (
decoration: BoxDecoration (
shape: BoxShape . circle ,
color: _calendarController . isSelected ( date )
? Colors . green [ 400 ]
: _calendarController . isToday ( date )
? Colors . brown [ 300 ]
: Colors . blue [ 400 ] ,
) ,
/ / decoration: BoxDecoration (
/ / shape: BoxShape . circle ,
/ / color: _calendarController . isSelected ( date )
/ / ? Colors . green [ 400 ]
/ / : _calendarController . isToday ( date )
/ / ? Colors . brown [ 300 ]
/ / : Colors . blue [ 400 ] ,
/ / ) ,
decoration: containerColorRadiusBorderWidth (
_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: Colors . white ,
fontSize: 14.0 ,
color: _calendarController. isSelected ( date ) ? Colors. white : Colors . black ,
fontSize: 1 3 .0,
) ,
) ,
) ,
@ -447,6 +401,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
Widget getNormalButton ( int index ) {
return RaisedButton (
color: Colors . white ,
elevation: 0 ,
textColor: new Color ( 0xFF60686b ) ,
onPressed: ( ) {
setState ( ( ) {
@ -455,14 +410,13 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
print ( CovidTimeSlots . selectedTime ) ;
} ) ;
} ,
child: Text ( dayEvents [ index ] . isoTime ,
style: TextStyle ( fontSize: 16.0 , fontWeight: FontWeight . bold ) ) ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 , fontWeight: FontWeight . bold ) ) ,
) ;
}
Widget getSelectedButton ( int index ) {
return RaisedButton (
color: C olors. blue [ 400 ] ,
color: C ustomColors. green , / / Color of the border
textColor: Colors . white ,
onPressed: ( ) {
setState ( ( ) {
@ -471,8 +425,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
print ( CovidTimeSlots . selectedTime ) ;
} ) ;
} ,
child: Text ( dayEvents [ index ] . isoTime ,
style: TextStyle ( fontSize: 16.0 , fontWeight: FontWeight . bold ) ) ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 , fontWeight: FontWeight . bold ) ) ,
) ;
}
@ -489,19 +442,11 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
DoctorsListService service = new DoctorsListService ( ) ;
AppoitmentAllHistoryResultList appo ;
service
. insertAppointment (
docObject . doctorID ,
docObject . clinicID ,
docObject . projectID ,
CovidTimeSlots . selectedTime ,
CovidTimeSlots . selectedDate ,
context ,
widget . selectedProcedure . procedureID )
. insertAppointment ( docObject . doctorID , docObject . clinicID , docObject . projectID , CovidTimeSlots . selectedTime , CovidTimeSlots . selectedDate , context , widget . selectedProcedure . procedureID )
. then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
AppToast . showSuccessToast ( message: " Appointment Booked Successfully " ) ;
getPatientShare ( context , res [ ' AppointmentNo ' ] , docObject . clinicID ,
docObject . projectID , docObject ) ;
getPatientShare ( context , res [ ' AppointmentNo ' ] , docObject . clinicID , docObject . projectID , docObject ) ;
} else {
GifLoaderDialogUtils . hideDialog ( context ) ;
appo = new AppoitmentAllHistoryResultList ( ) ;
@ -532,8 +477,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
} ) ;
}
cancelAppointment ( DoctorList docObject , AppoitmentAllHistoryResultList appo ,
BuildContext context ) {
cancelAppointment ( DoctorList docObject , AppoitmentAllHistoryResultList appo , BuildContext context ) {
ConfirmDialog . closeAlertDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorsListService service = new DoctorsListService ( ) ;
@ -551,12 +495,9 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
} ) ;
}
getPatientShare ( context , String appointmentNo , int clinicID , int projectID ,
DoctorList docObject ) {
getPatientShare ( context , String appointmentNo , int clinicID , int projectID , DoctorList docObject ) {
DoctorsListService service = new DoctorsListService ( ) ;
service
. getPatientShare ( appointmentNo , clinicID , projectID , context )
. then ( ( res ) {
service . getPatientShare ( appointmentNo , clinicID , projectID , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( res ) ;
widget . patientShareResponse = new PatientShareResponse . fromJson ( res ) ;
@ -571,8 +512,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
Navigator . push (
context ,
FadePage (
page: CovidPaymentAlert (
patientShareResponse: widget . patientShareResponse ) ,
page: CovidPaymentAlert ( patientShareResponse: widget . patientShareResponse ) ,
) ,
) ;
}
@ -586,14 +526,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots>
if ( res [ ' COVID19_FreeTimeSlots ' ] . length ! = 0 ) {
freeSlotsResponse = res [ ' COVID19_FreeTimeSlots ' ] ;
_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 {