@ -52,6 +52,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
ProjectViewModel projectViewModel ;
var notificationCount = ' ' ;
var themeNotifier ;
/ / / inject the user data
AuthenticatedUserObject authenticatedUserObject =
locator < AuthenticatedUserObject > ( ) ;
@ -140,18 +141,17 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
_firebaseMessaging . setAutoInitEnabled ( true ) ;
locationUtils =
new LocationUtils ( isShowConfirmDialog: true , context: context ) ;
new LocationUtils ( isShowConfirmDialog: true , context: context ) ;
WidgetsBinding . instance
. addPostFrameCallback ( ( _ ) = > locationUtils . getCurrentLocation ( ) ) ;
if ( Platform . isIOS ) {
_firebaseMessaging . requestNotificationPermissions ( ) ;
}
_firebaseMessaging . getToken ( ) . then ( ( String token ) async {
sharedPref . setString ( PUSH_TOKEN , token ) ;
if ( token ! = null & & await sharedPref . getObject ( USER_PROFILE ) = = null ) {
if ( token ! = null & & await sharedPref . getObject ( USER_PROFILE ) = = null ) {
DEVICE_TOKEN = token ;
checkUserStatus ( token ) ;
}
@ -159,122 +159,124 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
} ) . catchError ( ( err ) {
print ( err ) ;
} ) ;
/ /
/ / / / _firebase Background message handler
Future . delayed ( Duration . zero , ( ) = > setTheme ( ) ) ;
/ / _firebase Background message handler
/ / _firebaseMessaging . configure (
/ / onMessage: ( Map < String , dynamic > message ) async {
/ / showDialog ( " onMessage: $ message " ) ;
/ / print ( " onMessage: $ message " ) ;
/ / print ( message ) ;
/ / print ( message [ ' name ' ] ) ;
/ / print ( message [ ' appointmentdate ' ] ) ;
/ /
/ / if ( Platform . isIOS ) {
/ / if ( message [ ' is_call ' ] = = " true " ) {
/ / var route = ModalRoute . of ( context ) ;
/ /
/ / if ( route ! = null ) {
/ / print ( route . settings . name ) ;
/ / }
/ /
/ / Map < String , dynamic > myMap = new Map < String , dynamic > . from ( message ) ;
/ / print ( myMap ) ;
/ / LandingPage . isOpenCallPage = true ;
/ / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / if ( ! isPageNavigated ) {
/ / isPageNavigated = true ;
/ / Navigator . push (
/ / context ,
/ / MaterialPageRoute (
/ / builder: ( context ) = > IncomingCall (
/ / incomingCallData: LandingPage . incomingCallData ) ) )
/ / . then ( ( value ) {
/ / isPageNavigated = false ;
/ / } ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found iOS " ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found iOS " ) ;
/ / }
/ /
/ / if ( Platform . isAndroid ) {
/ / if ( message [ ' data ' ] . containsKey ( " is_call " ) ) {
/ / var route = ModalRoute . of ( context ) ;
/ /
/ / if ( route ! = null ) {
/ / print ( route . settings . name ) ;
/ / }
/ /
/ / Map < String , dynamic > myMap =
/ / new Map < String , dynamic > . from ( message [ ' data ' ] ) ;
/ / print ( myMap ) ;
/ / LandingPage . isOpenCallPage = true ;
/ / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / if ( ! isPageNavigated ) {
/ / isPageNavigated = true ;
/ / Navigator . push (
/ / context ,
/ / MaterialPageRoute (
/ / builder: ( context ) = > IncomingCall (
/ / incomingCallData: LandingPage . incomingCallData ) ) )
/ / . then ( ( value ) {
/ / isPageNavigated = false ;
/ / } ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found Android " ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found Android " ) ;
/ / }
/ / } ,
/ / onBackgroundMessage: Platform . isIOS ? null : myBackgroundMessageHandler ,
/ / onLaunch: ( Map < String , dynamic > message ) async {
/ / print ( " onLaunch: $ message " ) ;
/ / showDialog ( " onLaunch: $ message " ) ;
/ / } ,
/ / onResume: ( Map < String , dynamic > message ) async {
/ / print ( " onResume: $ message " ) ;
/ / print ( message ) ;
/ / print ( message [ ' name ' ] ) ;
/ / print ( message [ ' appointmentdate ' ] ) ;
/ /
/ / showDialog ( " onResume: $ message " ) ;
/ /
/ / if ( Platform . isIOS ) {
/ / if ( message [ ' is_call ' ] = = " true " ) {
/ / var route = ModalRoute . of ( context ) ;
/ /
/ / if ( route ! = null ) {
/ / print ( route . settings . name ) ;
/ / }
/ /
/ / Map < String , dynamic > myMap =
/ / new Map < String , dynamic > . from ( message ) ;
/ / print ( myMap ) ;
/ / LandingPage . isOpenCallPage = true ;
/ / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / if ( ! isPageNavigated ) {
/ / isPageNavigated = true ;
/ / Navigator . push (
/ / context ,
/ / MaterialPageRoute (
/ / builder: ( context ) = > IncomingCall (
/ / incomingCallData: LandingPage . incomingCallData ) ) )
/ / . then ( ( value ) {
/ / isPageNavigated = false ;
/ / } ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found iOS " ) ;
/ / }
/ / } else {
/ / print ( " Is Call Not Found iOS " ) ;
/ / }
/ / } ,
/ / ) ;
/ / / / onMessage: ( Map < String , dynamic > message ) async {
/ / / / showDialog ( " onMessage: $ message " ) ;
/ / / / print ( " onMessage: $ message " ) ;
/ / / / print ( message ) ;
/ / / / print ( message [ ' name ' ] ) ;
/ / / / print ( message [ ' appointmentdate ' ] ) ;
/ / / /
/ / / / if ( Platform . isIOS ) {
/ / / / if ( message [ ' is_call ' ] = = " true " ) {
/ / / / var route = ModalRoute . of ( context ) ;
/ / / /
/ / / / if ( route ! = null ) {
/ / / / print ( route . settings . name ) ;
/ / / / }
/ / / /
/ / / / Map < String , dynamic > myMap = new Map < String , dynamic > . from ( message ) ;
/ / / / print ( myMap ) ;
/ / / / LandingPage . isOpenCallPage = true ;
/ / / / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / / / if ( ! isPageNavigated ) {
/ / / / isPageNavigated = true ;
/ / / / Navigator . push (
/ / / / context ,
/ / / / MaterialPageRoute (
/ / / / builder: ( context ) = > IncomingCall (
/ / / / incomingCallData: LandingPage . incomingCallData ) ) )
/ / / / . then ( ( value ) {
/ / / / isPageNavigated = false ;
/ / / / } ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found iOS " ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found iOS " ) ;
/ / / / }
/ / / /
/ / / / if ( Platform . isAndroid ) {
/ / / / if ( message [ ' data ' ] . containsKey ( " is_call " ) ) {
/ / / / var route = ModalRoute . of ( context ) ;
/ / / /
/ / / / if ( route ! = null ) {
/ / / / print ( route . settings . name ) ;
/ / / / }
/ / / /
/ / / / Map < String , dynamic > myMap =
/ / / / new Map < String , dynamic > . from ( message [ ' data ' ] ) ;
/ / / / print ( myMap ) ;
/ / / / LandingPage . isOpenCallPage = true ;
/ / / / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / / / if ( ! isPageNavigated ) {
/ / / / isPageNavigated = true ;
/ / / / Navigator . push (
/ / / / context ,
/ / / / MaterialPageRoute (
/ / / / builder: ( context ) = > IncomingCall (
/ / / / incomingCallData: LandingPage . incomingCallData ) ) )
/ / / / . then ( ( value ) {
/ / / / isPageNavigated = false ;
/ / / / } ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found Android " ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found Android " ) ;
/ / / / }
/ / / / } ,
/ / / / onBackgroundMessage: Platform . isIOS ? null : myBackgroundMessageHandler ,
/ / / / onLaunch: ( Map < String , dynamic > message ) async {
/ / / / print ( " onLaunch: $ message " ) ;
/ / / / showDialog ( " onLaunch: $ message " ) ;
/ / / / } ,
/ / / / onResume: ( Map < String , dynamic > message ) async {
/ / / / print ( " onResume: $ message " ) ;
/ / / / print ( message ) ;
/ / / / print ( message [ ' name ' ] ) ;
/ / / / print ( message [ ' appointmentdate ' ] ) ;
/ / / /
/ / / / showDialog ( " onResume: $ message " ) ;
/ / / /
/ / / / if ( Platform . isIOS ) {
/ / / / if ( message [ ' is_call ' ] = = " true " ) {
/ / / / var route = ModalRoute . of ( context ) ;
/ / / /
/ / / / if ( route ! = null ) {
/ / / / print ( route . settings . name ) ;
/ / / / }
/ / / /
/ / / / Map < String , dynamic > myMap =
/ / / / new Map < String , dynamic > . from ( message ) ;
/ / / / print ( myMap ) ;
/ / / / LandingPage . isOpenCallPage = true ;
/ / / / LandingPage . incomingCallData = IncomingCallData . fromJson ( myMap ) ;
/ / / / if ( ! isPageNavigated ) {
/ / / / isPageNavigated = true ;
/ / / / Navigator . push (
/ / / / context ,
/ / / / MaterialPageRoute (
/ / / / builder: ( context ) = > IncomingCall (
/ / / / incomingCallData: LandingPage . incomingCallData ) ) )
/ / / / . then ( ( value ) {
/ / / / isPageNavigated = false ;
/ / / / } ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found iOS " ) ;
/ / / / }
/ / / / } else {
/ / / / print ( " Is Call Not Found iOS " ) ;
/ / / / }
/ / / / } ,
/ / ) ;
}
showDialogs ( String message ) {
@ -390,7 +392,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
notificationCount ,
style: new TextStyle (
color: Colors . white ,
fontSize: projectViewModel . isArabic ? 8 : 9 ,
fontSize: projectViewModel . isArabic ? 8 : 9 ,
) ,
textAlign: TextAlign . center ,
) ,
@ -405,16 +407,18 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
IconButton (
/ / iconSize: 70 ,
icon: Icon (
projectViewModel . isLogin ? Icons . settings : Icons . login ,
projectViewModel . isLogin & & projectViewModel . user ! = null
? Icons . settings
: Icons . login ,
color: Colors . white ,
) ,
onPressed: ( ) {
if ( projectViewModel . isLogin )
if ( projectViewModel . isLogin & & projectViewModel . user ! = null )
Navigator . of ( context ) . pushNamed (
SETTINGS ,
) ;
else
login ( ) ;
login ( ) ;
} , / / do something ,
)
] ,
@ -428,7 +432,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
children: [
HomePage (
goToMyProfile: ( ) {
_changeCurrentTab ( 1 ) ;
/ / _changeCurrentTab ( 1 ) ;
} ,
) ,
MedicalProfilePage ( ) ,
@ -464,50 +468,51 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
case 2 :
return TranslationBase . of ( context ) . bookAppo ;
case 3 :
return TranslationBase . of ( context ) . myFamily ;
case 4 :
return TranslationBase . of ( context ) . services ;
case 4 :
return TranslationBase . of ( context ) . bookAppo ;
}
}
setTheme ( ) async {
/ /
/ / defaultTheme =
/ / ThemeData (
/ / fontFamily: projectViewModel . isArabic ? ' Cairo ' : ' WorkSans ' ,
/ / primarySwatch: Colors . blue ,
/ / visualDensity: VisualDensity . adaptivePlatformDensity ,
/ / brightness: Brightness . light ,
/ / pageTransitionsTheme: const PageTransitionsTheme (
/ / builders: {
/ / TargetPlatform . android: ZoomPageTransitionsBuilder ( ) ,
/ / TargetPlatform . iOS: CupertinoPageTransitionsBuilder ( ) ,
/ / } ,
/ / ) ,
/ / hintColor: Colors . grey [ 400 ] ,
/ / disabledColor: Colors . grey [ 300 ] ,
/ / errorColor: Color . fromRGBO ( 235 , 80 , 60 , 1.0 ) ,
/ / scaffoldBackgroundColor: Color ( 0xffEEEEEE ) ,
/ / textSelectionColor: Color . fromRGBO ( 80 , 100 , 253 , 0.5 ) ,
/ / textSelectionHandleColor: Colors . grey ,
/ / canvasColor: Colors . white ,
/ / backgroundColor: Colors . white ,
/ / highlightColor: Colors . grey [ 100 ] . withOpacity ( 0.4 ) ,
/ / splashColor: Colors . transparent ,
/ / primaryColor: Color ( 0xff40ACC9 ) ,
/ / bottomSheetTheme: BottomSheetThemeData ( backgroundColor: Color ( 0xffE0E0E0 ) ) ,
/ / cursorColor: Colors . grey ,
/ / cardColor: Colors . white ,
/ / iconTheme: IconThemeData ( ) ,
/ / appBarTheme: AppBarTheme (
/ / color: Color ( 0xff40ACC9 ) ,
/ / brightness: Brightness . dark ,
/ / elevation: 10.0 ,
/ / actionsIconTheme: IconThemeData (
/ / color: Color ( 0xff40ACC9 ) ,
/ / ) ,
/ / ) ,
/ / ) ;
/ / themeNotifier . setTheme ( defaultTheme ) ;
setTheme ( ) async {
/ /
/ / defaultTheme =
/ / ThemeData (
/ / fontFamily: projectViewModel . isArabic ? ' Cairo ' : ' WorkSans ' ,
/ / primarySwatch: Colors . blue ,
/ / visualDensity: VisualDensity . adaptivePlatformDensity ,
/ / brightness: Brightness . light ,
/ / pageTransitionsTheme: const PageTransitionsTheme (
/ / builders: {
/ / TargetPlatform . android: ZoomPageTransitionsBuilder ( ) ,
/ / TargetPlatform . iOS: CupertinoPageTransitionsBuilder ( ) ,
/ / } ,
/ / ) ,
/ / hintColor: Colors . grey [ 400 ] ,
/ / disabledColor: Colors . grey [ 300 ] ,
/ / errorColor: Color . fromRGBO ( 235 , 80 , 60 , 1.0 ) ,
/ / scaffoldBackgroundColor: Color ( 0xffEEEEEE ) ,
/ / textSelectionColor: Color . fromRGBO ( 80 , 100 , 253 , 0.5 ) ,
/ / textSelectionHandleColor: Colors . grey ,
/ / canvasColor: Colors . white ,
/ / backgroundColor: Colors . white ,
/ / highlightColor: Colors . grey [ 100 ] . withOpacity ( 0.4 ) ,
/ / splashColor: Colors . transparent ,
/ / primaryColor: Color ( 0xff40ACC9 ) ,
/ / bottomSheetTheme: BottomSheetThemeData ( backgroundColor: Color ( 0xffE0E0E0 ) ) ,
/ / cursorColor: Colors . grey ,
/ / cardColor: Colors . white ,
/ / iconTheme: IconThemeData ( ) ,
/ / appBarTheme: AppBarTheme (
/ / color: Color ( 0xff40ACC9 ) ,
/ / brightness: Brightness . dark ,
/ / elevation: 10.0 ,
/ / actionsIconTheme: IconThemeData (
/ / color: Color ( 0xff40ACC9 ) ,
/ / ) ,
/ / ) ,
/ / ) ;
/ / themeNotifier . setTheme ( defaultTheme ) ;
}
void checkUserStatus ( token ) async {
authService
@ -522,8 +527,9 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
. then ( ( res ) = > { print ( res ) } ) ;
authService . getDashboard ( ) . then ( ( value ) = > {
setState ( ( ) {
notificationCount = value [ ' List_PatientDashboard ' ]
[ 0 ] [ ' UnreadPatientNotificationCount ' ] . toString ( ) ;
notificationCount = value [ ' List_PatientDashboard ' ] [ 0 ]
[ ' UnreadPatientNotificationCount ' ]
. toString ( ) ;
} )
} ) ;
}
@ -555,6 +561,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
_changeCurrentTab ( 2 ) ;
}
}
login ( ) async {
var data = await sharedPref . getObject ( IMEI_USER_DATA ) ;
sharedPref . remove ( REGISTER_DATA_FOR_LOGIIN ) ;