private void ClearBackStack()
        {
            var fragmentNames = _backStack.Dump(ToKey);

            _backStack.Clear();

            CurrentStore.Remove(fragmentNames);
        }
示例#2
0
#pragma warning restore 0649
        void Awake()
        {
            Instance = this;

            //get my components
            audioSource = GetComponent <AudioSource>();

            //clear static lists
            StaticViews.Clear();
            BackStack.Clear();
            FullScreenFadeStack.Clear();

            //init other objects
            dragger       = new Dragger();
            soundsManager = new SoundsManager(BackgroundSoundPrefab, FadeVolume, VolumeChangeSpeed);

            //find all views
            var views = SceneInfoGrabber <BaseView> .GetUIComponentsOnScene(scene : gameObject.scene);

            //grab components for views
            foreach (var view in views)
            {
                view.GrabComponents();
                StaticViews[view.GetType().Name] = view;
            }

            //grab views for views
            foreach (var view in views)
            {
                view.GrabViews(StaticViews);
            }

            //init views
            foreach (var view in views)
            {
                view.Init();
            }

            //subscribe views
            foreach (var view in views)
            {
                view.AutoSubscribe();
            }

            //show views
            foreach (var view in views.Where(v => v.ShowAtStart))
            {
                Show(view, null, noAnimation: true);
            }

            //init gestures
            InitGestures();
        }
示例#3
0
        private void NavigateToViewModel(object viewModel, object parameter)
        {
            _viewModel = viewModel;

            var viewType = ViewLocator.LocateTypeForModelType(_viewModel.GetType(), null, null);

            BackStack.Clear();

            base.Navigate(viewType, parameter);

            _viewModel = null;
        }
示例#4
0
 /// <summary>
 /// Clears the Frame content and its navigation stack without any animation
 /// </summary>
 public void ResetFrame()
 {
     BackStack.Clear();
     if (Content != null)
     {
         try
         {
             // This call causes the current page to execute the OnNavigatedFrom method
             GetNavigationState();
         }
         catch
         {
             // Doesn't matter
         }
     }
     Content = null;
     EmptyContentStateChanged?.Invoke(this, true);
 }
示例#5
0
        /// <summary>
        /// Navigates to the target page type
        /// </summary>
        /// <param name="pageType">The type of the target page</param>
        /// <param name="parameter">The optional parameter</param>
        public new async Task <bool> Navigate(Type pageType, [Optional] object parameter)
        {
            // Avoid accidental inputs while the Frame is navigating
            IsHitTestVisible = false;

            // Create the TaskCompletionSource to await the end of the async method
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

            // Prepare the action that will call the base navigation method and finish the animations
            Action <bool> finishNavigation = async empty =>
            {
                // Set the CustomFrame up before the navigation
                Opacity = 0;
                bool navResult = base.Navigate(pageType, parameter);
                if (empty)
                {
                    BackStack.Clear();
                }
                FrameworkContent.SetVisualOpacity(0);
                Opacity = 1;

                // Setup the right animation
                await GetContentForwardInStoryboard();

                IsHitTestVisible = true;
                tcs.SetResult(navResult);
            };

            // If the current content is not null, animate the fade out for the current page
            if (Content != null)
            {
                await GetContentForwardOutStoryboard();

                finishNavigation(false);
            }
            else
            {
                EmptyContentStateChanged?.Invoke(this, false);
                finishNavigation(true);
            }

            // Wait for all the animations to finish and then return the navigation result
            return(await tcs.Task);
        }