You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2020/01/27 08:45:59 UTC
[royale-asjs] 02/02: added default route
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/router
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 204a154693220aa7a2c0b5f6a51382b5f13a1ee1
Author: Harbs <ha...@in-tools.com>
AuthorDate: Mon Jan 27 10:45:42 2020 +0200
added default route
---
.../org/apache/royale/routing/ComponentRoute.as | 2 ++
.../org/apache/royale/routing/RouteToComponent.as | 27 +++++++++++++++-------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ComponentRoute.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ComponentRoute.as
index 8957d62..ccfadaa 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ComponentRoute.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/ComponentRoute.as
@@ -43,5 +43,7 @@ package org.apache.royale.routing
public var parent:IParent;
public var title:String;
+
+ public var defaultRoute:Boolean = false;
}
}
\ No newline at end of file
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as
index cdf53bb..0c1c8ba 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToComponent.as
@@ -96,6 +96,7 @@ package org.apache.royale.routing
*/
private function stateChanged():void
{
+ var default:ComponentRoute;
// apply routes
if(routes)
{
@@ -103,20 +104,30 @@ package org.apache.royale.routing
for(var i:int=0;i<routes.length;i++){
var route:ComponentRoute = routes[i];
+ if(route.defaultRoute)
+ default = route;
if(route.baseName == baseName)
{
- var parent:IParent = route.parent || host.host as IParent;
- while(parent.numElements > 0)
- parent.removeElement(parent.getElementAt(0));
-
- var comp:IChild = new route.component();
- parent.addElement(comp);
- if(route.title)
- host.routeState.title = route.title;
+ addComponent(route);
+ return;
}
}
+ if(default)
+ {
+ addComponent(default);
+ }
}
}
+ private function addComponent(route:ComponentRoute):void{
+ var parent:IParent = route.parent || host.host as IParent;
+ while(parent.numElements > 0)
+ parent.removeElement(parent.getElementAt(0));
+
+ var comp:IChild = new route.component();
+ parent.addElement(comp);
+ if(route.title)
+ host.routeState.title = route.title;
+ }
}
}
\ No newline at end of file