Exemplo n.º 1
0
 protected void HandleParentRouteExit()
 {
     if (activeChild != null)
     {
         activeChild.Exit();
         activeChild = null;
     }
 }
Exemplo n.º 2
0
 public void RemoveChildRoute(RouteElement routeElement)
 {
     m_ChildRoutes.Remove(routeElement);
     if (activeChild == routeElement)
     {
         activeChild = null;
     }
 }
Exemplo n.º 3
0
        public void AddChildRoute(RouteElement routeElement)
        {
            if (m_ChildRoutes.Contains(routeElement))
            {
                return;
            }

            m_ChildRoutes.Add(routeElement);
            routeElement.SetEnabled(false);
        }
Exemplo n.º 4
0
 public override void Enter(RouteMatch route)
 {
     base.Enter(route);
     RouteElement[] routes = m_ChildRoutes.Array;
     for (int i = 0; i < m_ChildRoutes.Count; i++)
     {
         RouteMatch childMatch;
         if (routes[i].TryMatch(route, out childMatch))
         {
             activeChild = routes[i];
             routes[i].Enter(childMatch);
             break;
         }
     }
 }
Exemplo n.º 5
0
        protected void HandleParentRouteUpdate()
        {
            bool wasMatched = IsRouteMatched;

            match = RouteMatch.Match(FullPath, 0, new RouteMatch(parentRoute.CurrentMatch.url));

            if (!wasMatched && match.IsMatch)
            {
                Enter(match);
            }
            else if (wasMatched && !match.IsMatch)
            {
                Exit();
            }
            else if (wasMatched && match.IsMatch)
            {
                RouteMatch route = string.IsNullOrEmpty(path) ? parentRoute.CurrentMatch : CurrentMatch;
                Update(route); // todo -- not sure about this
                RouteElement[] routes = m_ChildRoutes.Array;
                for (int i = 0; i < m_ChildRoutes.Count; i++)
                {
                    RouteMatch childMatch;
                    if (routes[i].TryMatch(route, out childMatch))
                    {
                        if (activeChild == routes[i])
                        {
                            activeChild.Update(childMatch);
                            return;
                        }

                        activeChild?.Exit();
                        activeChild = routes[i];
                        activeChild.Enter(childMatch);
                        onRouteChanged?.Invoke();
                        return;
                    }
                }

                if (activeChild != null)
                {
                    activeChild.Exit();
                    activeChild = null;
                }

                onRouteChanged?.Invoke();
            }
        }
Exemplo n.º 6
0
        public override void OnCreate()
        {
            style.SetPreferredWidth(UIMeasurement.Parent100, StyleState.Normal);
            style.SetPreferredHeight(UIMeasurement.Parent100, StyleState.Normal);
            UIElement ptr = parent;

            while (ptr != null)
            {
                if (ptr is RouteElement routeParent)
                {
                    parentRoute = routeParent;
                    break;
                }

                ptr = ptr.parent;
            }

            parentRoute.onRouteEnter  += HandleParentRouteEnter;
            parentRoute.onRouteExit   += HandleParentRouteExit;
            parentRoute.onRouteUpdate += HandleParentRouteUpdate;
        }