private void NativeShowPage(AppercodePage page, NavigationMode mode, bool isTabSwitching)
        {
            this.Title = page.Title;

            this.visualRoot.Child = page;

            frameLayout.Visibility = ViewStates.Visible;
            var transaction = this.FragmentManager.BeginTransaction();

            transaction.SetCustomAnimations(Resource.Animation.fadein, Resource.Animation.fadeout, Resource.Animation.fadein, Resource.Animation.fadeout);
            transaction.Replace(this.fragmentPageFrameLayoutResourceId, page.NativeFragment);

            page.NativeFragment.Create += (s, e) =>
            {
                if (mode == NavigationMode.New && !isTabSwitching)
                {
                    ChangeActionBarNavigationMode(ActionBarNavigationMode.Standard);
                }
                else if (mode == NavigationMode.Back && this.backStack.Count == 0)
                {
                    ChangeActionBarNavigationMode(ActionBarNavigationMode.Tabs);
                }
                UpdateRootLayouts();
            };

            transaction.Commit();
        }
        private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
        {
            if (mode == NavigationMode.New || mode == NavigationMode.Forward)
            {
                if (navigationType == NavigationType.Modal)
                {
                    // the idea taken at https://github.com/HugeLawn-MiracleApps/Xamarin-Forms-Labs/commit/87a8d5a5c1b9628de222d1d509e46865d255db7b
                    var topViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                    while (topViewController.PresentedViewController != null)
                    {
                        topViewController = topViewController.PresentedViewController;
                    }

                    var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
                    topViewController.PresentViewController(modalNavigationFrame, true, null);
                }
                else
                {
                    this.PushViewController(pageInstance.ViewController, true);
                }
            }
            else if (mode == NavigationMode.Back)
            {
                if (navigationType == NavigationType.Modal)
                {
                    this.DismissViewController(true, null);
                }
                else
                {
                    this.isGoingBack = true;
                    this.PopToViewController(pageInstance.ViewController, true);
                }
            }
        }
Ejemplo n.º 3
0
 internal void AddPage(AppercodePage appercodePage, object p)
 {
     appercodePage.InternalOnNavigatedTo(new NavigationEventArgs(appercodePage.GetType(), p));
     this.AddLogicalChild(appercodePage);
     appercodePage.LayoutUpdated += appercodePage_LayoutUpdated;
     (this.ViewPager.Adapter as AppercodeFragmentPageAdapter).Pages.Add(appercodePage);
     (this.ViewPager.Adapter as AppercodeFragmentPageAdapter).NotifyDataSetChanged();
 }
Ejemplo n.º 4
0
        private void NativeShowPage(AppercodePage page, NavigationMode mode, NavigationType navigationType)
        {
            this.Title = page.Title;
            var transaction = this.FragmentManager.BeginTransaction();

            transaction.Replace(this.fragmentPageFrameLayoutResourceId, page.NativeFragment);
            transaction.Commit();
        }
Ejemplo n.º 5
0
 internal void AddPage(AppercodePage appercodePage, object p)
 {
     appercodePage.InternalOnNavigatedTo(new NavigationEventArgs(appercodePage.GetType(), p));
     this.AddLogicalChild(appercodePage);
     appercodePage.LayoutUpdated += appercodePage_LayoutUpdated;
     (this.ViewPager.Adapter as AppercodeFragmentPageAdapter).Pages.Add(appercodePage);
     (this.ViewPager.Adapter as AppercodeFragmentPageAdapter).NotifyDataSetChanged();
 }
        internal AppercodePage InstantiatePage(Type sourcePageType)
        {
            var pageConstructorInfo    = sourcePageType.GetConstructor(new Type[] {
            });
            AppercodePage pageInstance = null;

            try
            {
                pageInstance = (AppercodePage)pageConstructorInfo.Invoke(new object[] {});
            }
            catch (System.Reflection.TargetInvocationException e)
            {
                this.IsNavigationInProgress = false;
                throw e.InnerException;
            }
            return(pageInstance);
        }
 private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
 {
     if (mode == NavigationMode.New || mode == NavigationMode.Forward)
     {
         if (navigationType == NavigationType.Modal)
         {
             var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
             this.PresentViewController(modalNavigationFrame, true, null);
         }
         else
         {
             this.PushViewController(pageInstance.ViewController, true);
         }
     }
     else if (mode == NavigationMode.Back)
     {
         if (navigationType == NavigationType.Modal)
         {
             this.DismissViewController(true, null);
         }
         else
         {
             this.isGoingBack = true;
             this.PopToViewController(pageInstance.ViewController, true);
         }
     }
 }
Ejemplo n.º 8
0
        private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
        {
            if (mode == NavigationMode.New || mode == NavigationMode.Forward)
            {
                if (navigationType == NavigationType.Modal)
                {
                    // the idea taken at https://github.com/HugeLawn-MiracleApps/Xamarin-Forms-Labs/commit/87a8d5a5c1b9628de222d1d509e46865d255db7b
                    var topViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                    while (topViewController.PresentedViewController != null)
                    {
                        topViewController = topViewController.PresentedViewController;
                    }

                    var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
                    topViewController.PresentViewController(modalNavigationFrame, true, null);
                }
                else
                {
                    this.PushViewController(pageInstance.ViewController, true);
                }
            }
            else if (mode == NavigationMode.Back)
            {
                if (navigationType == NavigationType.Modal)
                {
                    this.DismissViewController(true, null);
                }
                else
                {
                    this.isGoingBack = true;
                    this.PopToViewController(pageInstance.ViewController, true);
                }
            }
        }
Ejemplo n.º 9
0
        private bool Navigate(Type sourcePageType, object parameter, bool isTabSwitching, NavigationType navigationType, AppercodePage tabPage = null)
        {
#if __ANDROID__ || WINDOWS_PHONE
            if (sourcePageType == null)
            {
                throw new ArgumentNullException("sourcePageType", "sourcePageType must not be null");
            }
            if (!sourcePageType.IsSubclassOf(typeof(AppercodePage)) && sourcePageType != typeof(AppercodePage))
            {
                throw new ArgumentException("sourcePageType must be an AppercodePage", "sourcePageType");
            }

            if (this.IsNavigationInProgress)
            {
                return false;
            }
            this.IsNavigationInProgress = true;

            // navigating from with check
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New);

            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
                if (navigatingCancelEventArgs.Cancel == true)
                {
                    this.IsNavigationInProgress = false;
                    return false;
                }
            }
            AppercodePage pageInstance;

            // navigated from
            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(sourcePageType, parameter));
                this.backStack.Push(this.CurrentPage);
            }

            // Create page
            if (isTabSwitching && backStack.Any())
            {
                this.backStack.Clear();
            }

            if (isTabSwitching && tabPage != null)
            {
                pageInstance = tabPage;
            }
            else
            {
                pageInstance = InstantiatePage(sourcePageType);
            }

            pageInstance.NavigationService = this.navigationService;
            //this.visualRoot.Child = pageInstance;
            this.NativeShowPage(pageInstance, NavigationMode.New, isTabSwitching);

            // navigated to
            pageInstance.InternalOnNavigatedTo(new NavigationEventArgs(sourcePageType, parameter));

            this.CurrentPage = pageInstance;

            this.IsNavigationInProgress = false;
            return true;
#else
            if (this.currentTabIndex < 0 || this.currentTabIndex >= this.navigationStacks.Count)
            {
                return false; 
            }
            return this.navigationStacks[this.currentTabIndex].Navigate(sourcePageType, parameter, navigationType);
#endif
        }
Ejemplo n.º 10
0
        private void NativeShowPage(AppercodePage page, NavigationMode mode, bool isTabSwitching)
        {
            this.Title = page.Title;

            this.visualRoot.Child = page;

            frameLayout.Visibility = ViewStates.Visible;
            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();

            transaction.SetCustomAnimations(Resource.Animation.fadein, Resource.Animation.fadeout, Resource.Animation.fadein, Resource.Animation.fadeout);

            transaction.Replace(this.fragmentPageFrameLayoutResourceId, page.NativeFragment);

            page.NativeFragment.Create += (s, e) =>
            {
                if (mode == NavigationMode.New && !isTabSwitching)
                {
                    ChangeActionBarNavigationMode(ActionBarNavigationMode.Standard);
                }
                else if (mode == NavigationMode.Back && this.backStack.Count == 0)
                {
                    ChangeActionBarNavigationMode(ActionBarNavigationMode.Tabs);
                }
                UpdateRootLayouts();
            };

            transaction.Commit();
        }
Ejemplo n.º 11
0
 private void NativeShowPage(AppercodePage page, NavigationMode mode, NavigationType navigationType)
 {
     this.Title = page.Title;
     Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
     transaction.Replace(this.fragmentPageFrameLayoutResourceId, page.NativeFragment);
     transaction.Commit();
 }
        private bool Navigate(Type sourcePageType, object parameter, bool isTabSwitching, NavigationType navigationType, AppercodePage tabPage = null)
        {
#if __ANDROID__ || WINDOWS_PHONE
            if (sourcePageType == null)
            {
                throw new ArgumentNullException("sourcePageType", "sourcePageType must not be null");
            }
            if (!sourcePageType.IsSubclassOf(typeof(AppercodePage)) && sourcePageType != typeof(AppercodePage))
            {
                throw new ArgumentException("sourcePageType must be an AppercodePage", "sourcePageType");
            }

            if (this.IsNavigationInProgress)
            {
                return(false);
            }
            this.IsNavigationInProgress = true;

            // navigating from with check
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New);

            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
                if (navigatingCancelEventArgs.Cancel == true)
                {
                    this.IsNavigationInProgress = false;
                    return(false);
                }
            }
            AppercodePage pageInstance;

            // navigated from
            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(sourcePageType, parameter));
                this.backStack.Push(this.CurrentPage);
            }

            // Create page
            if (isTabSwitching && backStack.Any())
            {
                this.backStack.Clear();
            }

            if (isTabSwitching && tabPage != null)
            {
                pageInstance = tabPage;
            }
            else
            {
                pageInstance = InstantiatePage(sourcePageType);
            }

            pageInstance.NavigationService = this.navigationService;
            //this.visualRoot.Child = pageInstance;
            this.NativeShowPage(pageInstance, NavigationMode.New, isTabSwitching);

            // navigated to
            pageInstance.InternalOnNavigatedTo(new NavigationEventArgs(sourcePageType, parameter));

            this.CurrentPage = pageInstance;

            this.IsNavigationInProgress = false;
            return(true);
#else
            if (this.currentTabIndex < 0 || this.currentTabIndex >= this.navigationStacks.Count)
            {
                return(false);
            }
            return(this.navigationStacks[this.currentTabIndex].Navigate(sourcePageType, parameter, navigationType));
#endif
        }