public void ApplyActions(int popsCount, IEnumerable <PushInformation <TViewModel> > pushesCount, CallbackActionWaiter callbackActionWaiter)
        {
            var pops   = Pop(popsCount);
            var pushes = Push(pushesCount);
            MergedPopPushOperation mergedOp = null;

            if (pops.Count > 0 && pushes.Count > 0 && TryMerge(pops[pops.Count - 1], pushes[0], out mergedOp))
            {
                pops.RemoveAt(pops.Count - 1);
                pushes.RemoveAt(0);
            }

            int  popAnimatedIndex  = mergedOp is null && pushes.Count == 0 ? pops.Count - 1 : -1;
            bool mergedAnimated    = pushes.Count == 0;
            int  pushAnimatedIndex = pushes.Count - 1;

            for (var index = 0; index < pops.Count; index++)
            {
                pops[index].Execute(callbackActionWaiter, popAnimatedIndex == index);
            }

            mergedOp?.Execute(callbackActionWaiter, mergedAnimated);

            for (var index = 0; index < pushes.Count; index++)
            {
                pushes[index].Execute(callbackActionWaiter, pushAnimatedIndex == index);
            }

            Console.WriteLine("apply actions");
        }
예제 #2
0
        public void ApplyActions(int popsCount, List <PushInformation <TViewModel> > pushesInformations)
        {
            List <PopOperation>    pops     = Pop(popsCount);
            List <PushOperation>   pushes   = Push(pushesInformations);
            MergedPopPushOperation mergedOp = null;

            if (pops.Count > 0 && pushes.Count > 0 && TryMerge(pops[pops.Count - 1], pushes[0], out mergedOp))
            {
                pops.RemoveAt(pops.Count - 1);
                pushes.RemoveAt(0);
            }

            var activity = CrossCurrentActivity.Current.Activity;

            foreach (PopOperation pop in pops)
            {
                pop.Execute(activity);
            }

            mergedOp?.Execute(activity);

            foreach (PushOperation push in pushes)
            {
                push.Execute(activity);
            }

            Console.WriteLine("apply actions");
        }
        private bool TryMerge(PopOperation popOp, PushOperation pushOp, out MergedPopPushOperation res)
        {
            if (popOp is NavigationControllerPopOperation navigationControllerPopOperation &&
                pushOp is NavigationControllerPushOperation navigationControllerPushOperation)
            {
                if (navigationControllerPopOperation.HostStack == navigationControllerPushOperation.HostStack)
                {
                    res = new MergedPopPushNavigationControllerOperation(navigationControllerPopOperation, navigationControllerPushOperation);
                    return(true);
                }
            }

            res = null;
            return(false);
        }
예제 #4
0
        private bool TryMerge(PopOperation popOp, PushOperation pushOp, out MergedPopPushOperation res)
        {
            if (popOp is FragmentPopOperation <TViewModel> fragmentPopOperation && pushOp is FragmentPushOperation <TViewModel> fragmentPushOperation)
            {
                if (fragmentPopOperation.HostStack == fragmentPushOperation.HostStack)
                {
                    res = new MergedFragmentPopPushOperation <TViewModel>(fragmentPopOperation.HostStack, fragmentPopOperation.FragmentStacksToPop, fragmentPushOperation.FragmentStacksToPush);
                    return(true);
                }
            }

            if (popOp is ActivityPopOperation <TViewModel> activityPopOperation && pushOp is ActivityPushOperation <TViewModel> activityPushOperation)
            {
                res = new MergedActivityPopPushOperation <TViewModel>(activityPopOperation, activityPushOperation);
                return(true);
            }

            res = null;
            return(false);
        }