@ -15,7 +15,6 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.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/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/uitl/utils_new.dart ' ;
import ' package:diplomaticquarterapp/uitl/utils_new.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/defaultButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart ' ;
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 ' ;
@ -66,8 +65,6 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
ScrollController _scrollController ;
ScrollController _scrollController ;
ProjectViewModel projectViewModel ;
@ override
@ override
void initState ( ) {
void initState ( ) {
final _selectedDay = DateTime . now ( ) ;
final _selectedDay = DateTime . now ( ) ;
@ -119,60 +116,50 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
projectViewModel = Provider . of ( context ) ;
ProjectViewModel projectViewModel = Provider . of ( context ) ;
return AppScaffold (
return AppScaffold (
appBarTitle: TranslationBase . of ( context ) . covidTest ,
appBarTitle: TranslationBase . of ( context ) . covidTest ,
isShowAppBar: true ,
isShowAppBar: true ,
showNewAppBar: true ,
showNewAppBar: true ,
showNewAppBarTitle: true ,
showNewAppBarTitle: true ,
body: SingleChildScrollView (
backgroundColor: CustomColors . appBackgroudGrey2Color ,
body: Column (
children: [
Expanded (
child: SingleChildScrollView (
child: Container (
child: Container (
margin: EdgeInsets . fromLTRB ( 15.0 , 15.0 , 15.0 , 0.0 ) ,
margin: EdgeInsets . fromLTRB ( 15.0 , 15.0 , 15.0 , 0.0 ) ,
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
children: < Widget > [
Container (
Container (
height: 150.0 ,
child: Column (
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 ,
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . max ,
children: < Widget > [
children: < Widget > [
Container (
Text (
margin: EdgeInsets . only ( left: 20.0 , right: 20.0 , top: 20.0 ) ,
TranslationBase . of ( context ) . selectAppo ,
child: Text ( TranslationBase . of ( context ) . covidTest , style: TextStyle ( color: Colors . white , fontWeight: FontWeight . bold , fontSize: 24.0 ) ) ,
style: TextStyle (
color: Colors . black ,
fontSize: 16.0 ,
letterSpacing: - 0.64 ,
fontWeight: FontWeight . w600 ,
) ,
) ,
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 ) ) ,
) ,
) ,
] ,
Card (
shape: cardRadius ( 12 ) ,
child: _buildTableCalendarWithBuilders ( projectViewModel ) ,
) ,
) ,
] ,
mHeight ( 12 ) ,
Text (
selectedDate ,
style: TextStyle (
fontSize: 16.0 ,
fontWeight: FontWeight . bold ,
letterSpacing: - 0.64 ,
) ,
) ,
) ,
) ,
Container (
mHeight ( 8 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . max ,
children: < Widget > [
_buildTableCalendarWithBuilders ( projectViewModel ) ,
Padding (
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 (
Container (
height: 40 ,
height: 40 ,
child: ListView . builder (
child: ListView . builder (
@ -181,7 +168,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
itemCount: dayEvents . length ,
itemCount: dayEvents . length ,
itemBuilder: ( context , index ) {
itemBuilder: ( context , index ) {
return Container (
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 ) ? 0 : 5.0 , left: index = = 0 ? 0 : 5 ) ,
child: ButtonTheme (
child: ButtonTheme (
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 5.0 ) ,
borderRadius: BorderRadius . circular ( 5.0 ) ,
@ -191,7 +178,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
width: 1.5 , / / width of the border
width: 1.5 , / / width of the border
) ,
) ,
) ,
) ,
minWidth: MediaQuery . of ( context ) . size . width * 0. 18 ,
minWidth: MediaQuery . of ( context ) . size . width * 0. 2 ,
child: index = = selectedButtonIndex ? getSelectedButton ( index ) : getNormalButton ( index ) ) ,
child: index = = selectedButtonIndex ? getSelectedButton ( index ) : getNormalButton ( index ) ) ,
) ;
) ;
} ,
} ,
@ -201,34 +188,53 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
) ,
) ,
) ,
) ,
SizedBox (
SizedBox (
height: 1 0.0,
height: 1 0 0.0,
) ,
) ,
if ( CovidTimeSlots . areSlotsAvailable )
] ,
Container (
) ,
color: Colors . grey [ 100 ] ,
) ,
margin: EdgeInsets . all ( 10.0 ) ,
) ,
child: DefaultButton (
) ,
TranslationBase . of ( context ) . bookNow ,
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 ,
elevation: 0 ,
disabledColor: Colors . grey [ 500 ] ,
onPressed: ( ) {
bookCovidTestAppointment ( ) ;
bookCovidTestAppointment ( ) ;
} ,
} ,
child: Text (
TranslationBase . of ( context ) . bookAppo ,
style: TextStyle (
fontSize: 16.0 ,
letterSpacing: - 0.64 ,
) ,
) ,
) ,
) ,
] ,
) ,
) ,
) ,
) ,
) ,
) ,
)
] ,
) ,
) ;
) ;
}
}
Widget _buildTableCalendarWithBuilders ( ProjectViewModel projectViewModel ) {
Widget _buildTableCalendarWithBuilders ( ProjectViewModel projectViewModel ) {
return Card (
return TableCalendar (
shape: cardRadius ( 12 ) ,
margin: EdgeInsets . all ( 16 ) ,
clipBehavior: Clip . antiAlias ,
child: Padding (
padding: const EdgeInsets . only ( bottom: 12 ) ,
child: TableCalendar (
locale: projectViewModel . isArabic ? ' ar_SA ' : ' en_US ' ,
locale: projectViewModel . isArabic ? ' ar_SA ' : ' en_US ' ,
calendarController: _calendarController ,
calendarController: _calendarController ,
events: _events ,
events: _events ,
@ -258,7 +264,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
opacity: Tween ( begin: 0.0 , end: 1.0 ) . animate ( _animationController ) ,
opacity: Tween ( begin: 0.0 , end: 1.0 ) . animate ( _animationController ) ,
child: Container (
child: Container (
margin: const EdgeInsets . all ( 4.0 ) ,
margin: const EdgeInsets . all ( 4.0 ) ,
padding: const EdgeInsets . only ( top: 5.0 , left: 5 .0) ,
padding: const EdgeInsets . only ( top: 5.0 , left: 6 .0) ,
color: Colors . transparent ,
color: Colors . transparent ,
width: 0 ,
width: 0 ,
height: 0 ,
height: 0 ,
@ -314,8 +320,6 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
} ,
} ,
onVisibleDaysChanged: _onVisibleDaysChanged ,
onVisibleDaysChanged: _onVisibleDaysChanged ,
onCalendarCreated: _onCalendarCreated ,
onCalendarCreated: _onCalendarCreated ,
) ,
) ,
) ;
) ;
}
}
@ -353,7 +357,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
_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 ( ( ) {
setState ( ( ) {
CovidTimeSlots . selectedDate = dateFormatter . format ( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
CovidTimeSlots . selectedDate = dateFormatter . format ( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
selectedDate = DateUtil . get WeekDay MonthDayYearDateFormatted( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) , projectViewModel . isArabic ? " ar " : " en " ) ;
selectedDate = DateUtil . get MonthDayYearDateFormatted( DateUtil . convertStringToDate ( freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ) ) ;
selectedDateJSON = freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ;
selectedDateJSON = freeSlotsResponse [ 0 ] [ ' FreeTimeSlots ' ] ;
} ) ;
} ) ;
openTimeSlotsPickerForDate ( DateUtil . convertStringToDate ( selectedDateJSON ) , docFreeSlots ) ;
openTimeSlotsPickerForDate ( DateUtil . convertStringToDate ( selectedDateJSON ) , docFreeSlots ) ;
@ -363,6 +367,15 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
Widget _buildEventsMarker ( DateTime date , List events ) {
Widget _buildEventsMarker ( DateTime date , List events ) {
return Container (
return Container (
/ / decoration: BoxDecoration (
/ / shape: BoxShape . circle ,
/ / color: _calendarController . isSelected ( date )
/ / ? Colors . green [ 400 ]
/ / : _calendarController . isToday ( date )
/ / ? Colors . brown [ 300 ]
/ / : Colors . blue [ 400 ] ,
/ / ) ,
decoration: containerColorRadiusBorderWidth (
decoration: containerColorRadiusBorderWidth (
_calendarController . isSelected ( date )
_calendarController . isSelected ( date )
? CustomColors . green
? CustomColors . green
@ -379,7 +392,7 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
' ${ 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: 1 4 .0,
fontSize: 1 3 .0,
) ,
) ,
) ,
) ,
) ,
) ,
@ -395,53 +408,35 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
setState ( ( ) {
setState ( ( ) {
selectedButtonIndex = index ;
selectedButtonIndex = index ;
CovidTimeSlots . selectedTime = dayEvents [ index ] . isoTime ;
CovidTimeSlots . selectedTime = dayEvents [ index ] . isoTime ;
print ( CovidTimeSlots . selectedTime ) ;
} ) ;
} ) ;
} ,
} ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 )) ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 , fontWeight: FontWeight . bold )) ,
) ;
) ;
}
}
Widget getSelectedButton ( int index ) {
Widget getSelectedButton ( int index ) {
return RaisedButton (
return RaisedButton (
color: CustomColors . green ,
color: CustomColors . green , / / Color of the border
/ / Color of the border
textColor: Colors . white ,
textColor: Colors . white ,
elevation: 0 ,
onPressed: ( ) {
onPressed: ( ) {
setState ( ( ) {
setState ( ( ) {
selectedButtonIndex = index ;
selectedButtonIndex = index ;
CovidTimeSlots . selectedTime = dayEvents [ index ] . isoTime ;
CovidTimeSlots . selectedTime = dayEvents [ index ] . isoTime ;
print ( CovidTimeSlots . selectedTime ) ;
} ) ;
} ) ;
} ,
} ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 )) ,
child: Text ( dayEvents [ index ] . isoTime , style: TextStyle ( fontSize: 12.0 , fontWeight: FontWeight . bold )) ,
) ;
) ;
}
}
bookCovidTestAppointment ( ) {
bookCovidTestAppointment ( ) {
var messageEn = " This Appointment is being booked for patient " +
projectViewModel . user . firstName +
" " +
projectViewModel . user . lastName +
" , Having file number " +
projectViewModel . user . patientID . toString ( ) +
" . Please confirm! " ;
var messageAr =
" يتم حجز هذا الموعد المراجع " + projectViewModel . user . firstName + " " + projectViewModel . user . lastName + " , وجود رقم الملف " + projectViewModel . user . patientID . toString ( ) + " . يرجى تأكيد! " ;
ConfirmDialog dialog = new ConfirmDialog (
context: context ,
confirmMessage: projectViewModel . isArabic ? messageAr : messageEn ,
okText: TranslationBase . of ( context ) . confirm ,
cancelText: TranslationBase . of ( context ) . cancel_nocaps ,
okFunction: ( ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
DoctorList docObject = new DoctorList ( ) ;
DoctorList docObject = new DoctorList ( ) ;
docObject . doctorID = widget . selectedDoctorID ;
docObject . doctorID = widget . selectedDoctorID ;
docObject . clinicID = widget . selectedClinicID ;
docObject . clinicID = widget . selectedClinicID ;
docObject . projectID = widget . projectID ;
docObject . projectID = widget . projectID ;
insertAppointmentCovidTest ( context , docObject ) ;
insertAppointmentCovidTest ( context , docObject ) ;
} ,
cancelFunction: ( ) = > { } ) ;
dialog . showAlertDialog ( context ) ;
}
}
insertAppointmentCovidTest ( context , DoctorList docObject ) {
insertAppointmentCovidTest ( context , DoctorList docObject ) {
@ -489,7 +484,9 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
DoctorsListService service = new DoctorsListService ( ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . cancelAppointment ( appo , context ) . then ( ( res ) {
service . cancelAppointment ( appo , context ) . then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
/ / Future . delayed ( new Duration ( milliseconds: 1500 ) , ( ) {
insertAppointmentCovidTest ( context , docObject ) ;
insertAppointmentCovidTest ( context , docObject ) ;
/ / } ) ;
} else {
} else {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
@ -522,21 +519,17 @@ class _CovidTimeSlotsState extends State<CovidTimeSlots> with TickerProviderStat
}
}
getCovidFreeSlots ( BuildContext context , int projectID ) {
getCovidFreeSlots ( BuildContext context , int projectID ) {
CovidTimeSlots . areSlotsAvailable = false ;
CovidDriveThruService service = new CovidDriveThruService ( ) ;
CovidDriveThruService service = new CovidDriveThruService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
service . getCovidFreeSlots ( context , projectID ) . then ( ( res ) {
service . getCovidFreeSlots ( context , projectID ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
if ( res [ ' COVID19_FreeTimeSlots ' ] . length ! = 0 ) {
if ( res [ ' COVID19_FreeTimeSlots ' ] . length ! = 0 ) {
CovidTimeSlots . areSlotsAvailable = true ;
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 { }
CovidTimeSlots . areSlotsAvailable = false ;
}
} else {
} else {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;