예제 #1
0
        public void ChangeCurrentActivity(ActivityModel newActivity, int nextIndex)
        {
            if (_activities.Count <= nextIndex)
            {
                _activities.Add(newActivity);
            }

            CurrentIndex = nextIndex;
            BackStackChanged?.Invoke();
        }
예제 #2
0
        private Task <bool> NavigateWithMode(ActivityModel newActivity, NavigationMode navigationMode)
        {
            return(RunNavigationWithCheck(async() =>
            {
                var currentActivity = CurrentActivityModel;

                _activityStackManager.ClearForwardStack();

                await NavigateImplAsync(navigationMode, currentActivity, newActivity,
                                        _activityStackManager.CurrentIndex + 1);

                return true;
            }));
        }
예제 #3
0
        private async Task UpdateContent(NavigationMode navigationMode, ActivityModel currentActivity,
                                         ActivityModel nextActivity)
        {
            var animation = ActualActivityTransition;
            var current   = currentActivity?.GetActivity(this);
            var next      = nextActivity?.GetActivity(this);

            if (animation != null)
            {
                AddActivityToContentRoot(navigationMode, animation.InsertionMode, next);
                switch (navigationMode)
                {
                case NavigationMode.New:
                    await animation.OnStart(next, current);

                    break;

                case NavigationMode.Back:
                    await animation.OnClose(current, next);

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(navigationMode), navigationMode, null);
                }

                Children.Remove(current);
            }
            else
            {
                if (Children.Any())
                {
                    Children[0] = next;
                }
                else
                {
                    Children.Add(next);
                }
            }
        }
예제 #4
0
        private async Task NavigateImplAsync(NavigationMode navigationMode,
                                             ActivityModel currentActivity, ActivityModel nextActivity, int nextIndex)
        {
            IsHitTestVisible = false;

            InvokeLifecycleBeforeContentChanged(navigationMode, currentActivity, nextActivity);

            _activityStackManager.ChangeCurrentActivity(nextActivity, nextIndex);

            OnCurrentActivityChanged(currentActivity?.Activity, nextActivity?.Activity);

            Navigating?.Invoke(this, EventArgs.Empty);

            await UpdateContent(navigationMode, currentActivity, nextActivity);

            InvokeLifecycleAfterContentChanged(navigationMode, currentActivity, nextActivity);

            IsHitTestVisible = true;

            ReleaseActivity(currentActivity);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
예제 #5
0
        public Task <bool> Navigate(Type activityType, object parameter)
        {
            var newActivity = new ActivityModel(activityType, parameter);

            return(NavigateWithMode(newActivity, NavigationMode.New));
        }
예제 #6
0
        private void InvokeLifecycleAfterContentChanged(NavigationMode navigationMode, ActivityModel currentActivity,
                                                        ActivityModel nextActivity)
        {
            switch (navigationMode)
            {
            case NavigationMode.New:
                currentActivity?.GetActivity(this)?.OnStop();
                nextActivity?.GetActivity(this)?.OnResume();
                break;

            case NavigationMode.Back:
                currentActivity?.GetActivity(this)?.OnDestroy();
                nextActivity?.GetActivity(this).OnResume();
                break;

            case NavigationMode.Forward:
                break;

            case NavigationMode.Refresh:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(navigationMode), navigationMode, null);
            }
        }