@ -14,29 +14,53 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import ' package:diplomaticquarterapp/widgets/transitions/fade_page.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter_inappwebview/flutter_inappwebview.dart ' ;
import ' package:jiffy/jiffy.dart ' ;
import ' package:permission_handler/permission_handler.dart ' ;
import ' BookSuccess.dart ' ;
class BookReminderPage extends State less Widget {
class BookReminderPage extends State fu lWidget {
PatientShareResponse patientShareResponse ;
DoctorList docObject ;
MyInAppBrowser browser ;
final ChromeSafariBrowser chromeBrowser = new MyChromeSafariBrowser ( new MyInAppBrowser ( ) ) ;
String selectedTime ;
String appoDateFormatted ;
String appoTimeFormatted ;
DateTime dateTime ;
BookReminderPage ( { @ required this . patientShareResponse , @ required this . docObject , @ required this . appoDateFormatted , @ required this . appoTimeFormatted , this . dateTime } ) ;
BookReminderPage ( { @ required this . patientShareResponse , @ required this . docObject , @ required this . appoDateFormatted , @ required this . appoTimeFormatted , this . dateTime } ) ;
@ override
_BookReminderPageState createState ( ) = > _BookReminderPageState ( ) ;
}
class _BookReminderPageState extends State < BookReminderPage > {
MyInAppBrowser browser ;
final ChromeSafariBrowser chromeBrowser = new MyChromeSafariBrowser ( new MyInAppBrowser ( ) ) ;
String selectedTime ;
bool isSuccessShow = true ;
@ override
void initState ( ) {
/ / TODO: implement initState
super . initState ( ) ;
Future . delayed ( const Duration ( seconds: 2 ) , ( ) {
/ / Here you can write your code
setState ( ( ) {
isSuccessShow = false ;
} ) ;
} ) ;
}
@ override
Widget build ( BuildContext context ) {
/ / print ( " selectedTime " + selectedTime ? ? " " ) ;
print ( " appoDateFormatted " + appoDateFormatted ? ? " " ) ;
print ( " appoTimeFormatted " + appoDateFormatted ? ? " " ) ;
print ( " appoDateFormatted " + widget . appoDateFormatted ? ? " " ) ;
print ( " appoTimeFormatted " + widget . appoTimeFormatted ? ? " " ) ;
return AppScaffold (
appBarTitle: docObject . doctorTitle + " " + docObject . name ,
appBarTitle: widget. docObject. doctorTitle + " " + widget . docObject . name ,
isShowDecPage: false ,
isShowAppBar: true ,
showNewAppBarTitle: true ,
@ -48,17 +72,17 @@ class BookReminderPage extends StatelessWidget {
children: < Widget > [
DoctorHeader (
headerModel: HeaderModel (
docObject. name ,
docObject. doctorImageURL ,
docObject. speciality ,
widget. docObject. name ,
widget. docObject. doctorImageURL ,
widget. docObject. speciality ,
" " ,
docObject. projectName ,
widget. docObject. projectName ,
null ,
null ,
docObject. nationalityFlagURL ,
docObject. doctorRate ,
widget. docObject. nationalityFlagURL ,
widget. docObject. doctorRate ,
null ,
docObject. noOfPatientsRate ,
widget. docObject. noOfPatientsRate ,
" " ,
) ,
isNeedToShowButton: false ,
@ -78,7 +102,7 @@ class BookReminderPage extends StatelessWidget {
size: 60 ,
) ,
Text (
" Would you like to set a reminder for this appointment in your calendar? " ,
TranslationBase . of ( context ) . appointmentCalendar ,
style: TextStyle (
fontSize: 20 ,
fontWeight: FontWeight . w600 ,
@ -86,40 +110,41 @@ class BookReminderPage extends StatelessWidget {
) ,
) ,
mFlex ( 1 ) ,
Container (
width: double . infinity ,
child: Card (
shape: cardRadius ( 12 ) ,
margin: EdgeInsets . all ( 10 ) ,
child: Padding (
padding: const EdgeInsets . all ( 16.0 ) ,
child: Row (
children: [
circularAviator (
30 ,
icon: Icons . done_rounded ,
iconColor: Colors . white ,
bcColor: CustomColors . green ,
brColor: CustomColors . green ,
) ,
mWidth ( 10 ) ,
Expanded (
child: AutoSizeText (
" Appointment is successfully booked " ,
maxLines: 1 ,
minFontSize: 6 ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.65 ,
) ,
if ( isSuccessShow )
Container (
width: double . infinity ,
child: Card (
shape: cardRadius ( 12 ) ,
margin: EdgeInsets . all ( 10 ) ,
child: Padding (
padding: const EdgeInsets . all ( 16.0 ) ,
child: Row (
children: [
circularAviator (
30 ,
icon: Icons . done_rounded ,
iconColor: Colors . white ,
bcColor: CustomColors . green ,
brColor: CustomColors . green ,
) ,
)
] ,
mWidth ( 10 ) ,
Expanded (
child: AutoSizeText (
TranslationBase . of ( context ) . appointmentSuccess ,
maxLines: 1 ,
minFontSize: 6 ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.65 ,
) ,
) ,
)
] ,
) ,
) ,
) ,
) ,
) ,
] ,
) ,
) ,
@ -168,8 +193,16 @@ class BookReminderPage extends StatelessWidget {
textColor: Colors . white ,
disabledTextColor: Colors . white ,
disabledColor: CustomColors . green ,
onPressed: ( ) {
_showReminderDialog ( context ) ;
onPressed: ( ) async {
if ( await Permission . contacts . request ( ) . isGranted ) {
_showReminderDialog ( context ) ;
} else {
requestPermissions ( ) . then ( ( results ) {
if ( results [ Permission . calendar ] . isGranted ) {
_showReminderDialog ( context ) ;
}
} ) ;
}
} ,
child: Text ( TranslationBase . of ( context ) . yes , style: TextStyle ( fontSize: 16.0 , letterSpacing: - 0.48 ) ) ,
) ,
@ -183,7 +216,11 @@ class BookReminderPage extends StatelessWidget {
}
Future navigateToBookSuccess ( BuildContext context ) async {
Navigator . push ( context , FadePage ( page: BookSuccess ( docObject: docObject , patientShareResponse: patientShareResponse , appoDateFormatted: appoDateFormatted , appoTimeFormatted: appoTimeFormatted ) ) ) ;
Navigator . push (
context ,
FadePage (
page:
BookSuccess ( docObject: widget . docObject , patientShareResponse: widget . patientShareResponse , appoDateFormatted: widget . appoDateFormatted , appoTimeFormatted: widget . appoTimeFormatted ) ) ) ;
}
Future < void > _showReminderDialog ( BuildContext context ) async {
@ -195,26 +232,42 @@ class BookReminderPage extends StatelessWidget {
shape: RoundedRectangleBorder ( borderRadius: BorderRadius . circular ( 12.0 ) ) , / / this right here
child: ReminderDialog (
onClick: ( int i ) async {
CalendarUtils calendarUtils = await CalendarUtils . getInstance ( ) ;
calendarUtils . createOrUpdateEvent ( title: " title " , description: " descriptipn " , scheduleDateTime: dateTime ) . then ( ( value ) {
AppToast . showSuccessToast ( message: TranslationBase . of ( context ) . reminderSuccess ) ;
} ) ;
if ( i = = 0 ) {
/ / Before 30 mints
widget . dateTime = Jiffy ( widget . dateTime ) . subtract ( minutes: 30 ) ;
/ / dateTime . add ( new Duration ( minutes: - 30 ) ) ;
} else if ( i = = 1 ) {
/ / Before 1 hour
/ / dateTime . add ( new Duration ( minutes: - 60 ) ) ;
widget . dateTime = Jiffy ( widget . dateTime ) . subtract ( hours: 1 ) ;
} else if ( i = = 2 ) {
/ / Before 1 hour and 30 mints
/ / dateTime . add ( new Duration ( minutes: - 90 ) ) ;
widget . dateTime = Jiffy ( widget . dateTime ) . subtract ( hours: 1 , minutes: 30 ) ;
} else if ( i = = 3 ) {
/ / Before 2 hours
/ / dateTime . add ( new Duration ( minutes: - 120 ) ) ;
widget . dateTime = Jiffy ( widget . dateTime ) . subtract ( hours: 2 ) ;
}
CalendarUtils calendarUtils = await CalendarUtils . getInstance ( ) ;
calendarUtils
. createOrUpdateEvent (
title: TranslationBase . of ( context ) . reminderTitle + " " + widget . docObject . name ,
description: " At " + widget . appoDateFormatted + " " + widget . appoTimeFormatted ,
scheduleDateTime: widget . dateTime )
. then ( ( value ) {
AppToast . showSuccessToast ( message: TranslationBase . of ( context ) . reminderSuccess ) ;
navigateToBookSuccess ( context ) ;
} ) ;
} ,
) ,
) ;
} ,
) ;
}
Future < Map < Permission , PermissionStatus > > requestPermissions ( ) async {
var permissionResults = [ Permission . calendar ] . request ( ) ;
return permissionResults ;
}
}