//
		// This method is invoked when the application has loaded and is ready to run. In this 
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			userDao = new UserDao ();
			courseDao = new CourseDao ();
			this.window = new UIWindow (UIScreen.MainScreen.Bounds);
			var rootNavigationController = new UINavigationController ();

			if (userDao.tokenExists () && courseDao.existCourses ()) 
			{
				CoursesViewController courseView = new CoursesViewController();
				rootNavigationController.PushViewController(courseView,false);
			} 
			else 
			{
				MonoMobilisViewController loginView = new MonoMobilisViewController();
				rootNavigationController.PushViewController(loginView,false);
			}

			//MonoMobilisViewController loginView = new MonoMobilisViewController();
			//rootNavigationController.PushViewController(loginView,false);

			this.window.RootViewController = rootNavigationController;
			this.window.MakeKeyAndVisible();
			ServiceLocator.Dispatcher = new DispatchAdapter(this);
			return true;
		}
Beispiel #2
0
        void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            CourseDao courseDao = new CourseDao();
            // se a navegação não for para a MainPage(login) não há mudança na navegação
            if (e.Uri.ToString().Contains("/MainPage.xaml") != true)
                return;

            if (courseDao.existCourses())
            {
                e.Cancel = true;
                RootFrame.Dispatcher.BeginInvoke(delegate 
                {
                    System.Diagnostics.Debug.WriteLine("TO COURSES");
                    RootFrame.Navigate(new Uri("/Views/CoursePage.xaml", UriKind.Relative));
                });
            }
            else 
            {
                System.Diagnostics.Debug.WriteLine("TO LOGIN");
                e.Cancel = false;
                return;
            }
        }