Ejemplo n.º 1
0
        /// <inheritdoc />
        /// <summary>
        /// register ioc modules
        /// </summary>
        /// <param name="builder"></param>
        protected override void Load(ContainerBuilder builder)
        {
            // standard Xamarin.Forms INavigation
            // remember to always use this as a deferred parameter in c'tor injection (Lazy<INavigation>)
            //this is flexible with multi Application MainPage
            //this - can't SingleInstance if app containt multi type of Appication MainPage
            builder.Register(x => PageExs.GetCurrentContentPage().Navigation);

            //XNavigator - can't SingleInstance if app containt multi type of Appication MainPage
            builder.RegisterType <CrossNavigator>()
            .As <ICrossNavigator>();

            //CrossNamingConventions
            builder.RegisterType <CrossNamingConventions>()
            .As <ICrossNamingConventions>()
            .SingleInstance();

            //XViewFactory
            builder.RegisterType <CrossViewFactory>()
            .As <ICrossViewFactory>()
            .SingleInstance();

            //Func<Page> - always can't SingleInstance
            builder.RegisterInstance <Func <Page> >(PageExs.GetCurrentContentPage);

            //DialogService
            builder.RegisterType <CrossDialogProvider>()
            .As <ICrossDialogProvider>()
            .SingleInstance();

            //ActivationForViewFetcher
            builder.RegisterType <ActivationForViewFetcher>()
            .As <IActivationForViewFetcher>()
            .SingleInstance();
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        /// <summary>
        /// pop to previous page
        /// </summary>
        /// <param name="animated"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task PopAsync(bool animated, NavigationParameters parameters = null)
        {
            await _lazyNavigation.Value.PopAsync(animated);

            //back with param
            var curPage = PageExs.GetCurrentContentPage();
            await curPage.OnNavigatedBackTo(parameters);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        /// <summary>
        /// pop modal page
        /// </summary>
        /// <param name="animated"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task PopModalAsync(bool animated, NavigationParameters parameters = null)
        {
            //neu khong co trang nao trong modal stack thi return
            if (!_lazyNavigation.Value.ModalStack.Any())
            {
                return;
            }

            //tien hanh pop modal va truyen back param toi trang truoc
            await _lazyNavigation.Value.PopModalAsync(animated);

            //back with param
            var curPage = PageExs.GetCurrentContentPage();
            await curPage.OnNavigatedBackTo(parameters);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// pop all modal page
        /// </summary>
        /// <param name="animated"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task PopAllModalAsync(bool animated, NavigationParameters parameters = null)
        {
            //neu khong co trang nao trong modal stack thi return
            if (!_lazyNavigation.Value.ModalStack.Any())
            {
                return;
            }

            var numberModalPage = _lazyNavigation.Value.ModalStack.Count;

            for (var i = 0; i < numberModalPage; i++)
            {
                //tien hanh pop modal
                await _lazyNavigation.Value.PopModalAsync(animated);
            }

            //back with param
            var curPage = PageExs.GetCurrentContentPage();
            await curPage.OnNavigatedBackTo(parameters);
        }