Exemple #1
0
        private void Show(RouterItem routerItem)
        {
            if (routerItem.panel == null)
            {
                Debug.LogError("Can not transition to null view.");
                return;
            }

            if (topPanel != null && topPanel.Equals(routerItem.panel) && routerItem.mode == RouterHistoryMode.pushState)
            {
                RefreshCurrentView();
                CheckQueue();
                return;
            }

            if (IsPanelInStack(routerItem.panel))
            {
                Debug.LogError("Component already in stack, can not spawn copies of component.");
                return;
            }

            if (routerItem.config == null)
            {
                Debug.LogError("Transition config must be defined to display component.");
                return;
            }

            IUITransitable currentPanel = topPanel;
            UITransition   transition   = Registry.transitionRegistry[routerItem.config.type];

            if (transition == null)
            {
                Debug.LogError("No transition with id: " + routerItem.config.type.ToString() + " found.");
                return;
            }

            transitionInProcess = true;
            UITransitionContext context = new UITransitionContext(routerItem.config, currentPanel, routerItem.panel);

            transition.Do(context, (string error, UITransitionContext inContext) => {
                transitionInProcess = false;
                if (error != null)
                {
                    Debug.LogError(error);
                    return;
                }

                if (inContext.from != null && routerItem.mode == RouterHistoryMode.replaceState)
                {
                    viewStack.RemoveFirst();
                }

                viewStack.AddFirst(routerItem.panel);

                routerItem.panel.OnUITransitionComplete();
                CheckQueue();
            });
        }
Exemple #2
0
        public override void HideTopmost(UITransitionConfig config)
        {
            if (viewStack.Count <= 0)
            {
                Debug.LogError("No Component");
                return;
            }

            if (config == null)
            {
                Debug.LogError("config null");
                return;
            }

            IUITransitable currentPanel = topPanel;
            IUITransitable toPanel      = viewStack.Count > 1 ? viewStack.Skip(1).First() : null;
            UITransition   transition   = Registry.transitionRegistry[config.type];

            if (transition == null)
            {
                Debug.LogError("No transition found to hide view.");
                return;
            }

            transitionInProcess = true;
            UITransitionContext context = new UITransitionContext(config, currentPanel, toPanel);

            transition.Do(context, (string error, UITransitionContext inContext) => {
                transitionInProcess = false;
                if (error != null)
                {
                    Debug.LogError(error);
                    return;
                }

                viewStack.RemoveFirst();
                CheckQueue();
            });
        }