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 ed14387aa0b6c79dffb0055d76ebab9d7e1a3528 Author: Harbs <ha...@in-tools.com> AuthorDate: Sun Feb 2 00:31:15 2020 +0200 Fixed router bugs --- .../Basic/src/main/resources/basic-manifest.xml | 1 + .../org/apache/royale/routing/RouteToState.as | 36 +++++++++------------- .../royale/org/apache/royale/routing/Router.as | 20 ++++++------ .../org/apache/royale/routing/SetRouteTitle.as | 1 + 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml index 0f01dc0..7f898e4 100644 --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml @@ -285,6 +285,7 @@ <component id="RouteToParameters" class="org.apache.royale.routing.RouteToParameters"/> <component id="RouteToState" class="org.apache.royale.routing.RouteToState"/> <component id="SetRouteTitle" class="org.apache.royale.routing.SetRouteTitle"/> + <component id="RouteTitleLookup" class="org.apache.royale.routing.RouteTitleLookup"/> <component id="Router" class="org.apache.royale.routing.Router"/> <component id="UIGraphicsBase" class="org.apache.royale.display.UIGraphicsBase"/> diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToState.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToState.as index cbe9d96..6a6fcd3 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToState.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/RouteToState.as @@ -52,28 +52,15 @@ package org.apache.royale.routing */ private function attachStateEvent():void { - var statesObject:IStatesObject = component; - if(!statesObject) - { - assert(host.host is IStatesObject,"syncState can only be used on IStatesObjects"); - statesObject = host.host as IStatesObject; - - } - statesObject.addEventListener("currentStateChange",handleStateChange); - + getStateComponent().addEventListener("currentStateChange",handleStateChange); } private function handleStateChange():void { if(settingState)// don't do anything if the event was fired as a result of a hash. return; //TODO what about a parent path - var statesObject:IStatesObject = component; - if(!statesObject) - { - statesObject = host.host as IStatesObject; - } - host.routeState.path = statesObject.currentState; + host.routeState.path = getStateComponent().currentState; host.setState(); } private function hashNeeded(ev:ValueEvent):void @@ -96,7 +83,7 @@ package org.apache.royale.routing if(delim) trailing = hash.slice(hash.indexOf(delim)); - ev.value = parentPath + (host.host as IStatesObject).currentState + trailing; + ev.value = parentPath + getStateComponent().currentState + trailing; } private function hashReceived(ev:ValueEvent):void { @@ -119,17 +106,24 @@ package org.apache.royale.routing */ private function stateChanged(ev:ValueEvent):void { + settingState = true; + //TODO what about using the base name of the path? + getStateComponent().currentState = host.routeState.path; + settingState = false; + + } + /** + * @royaleignorecoercion org.apache.royale.core.IStatesObject + */ + private function getStateComponent():IStatesObject + { var statesObject:IStatesObject = component; if(!statesObject) { assert(host.host is IStatesObject,"syncState can only be used on IStatesObjects"); statesObject = host.host as IStatesObject; } - settingState = true; - //TODO what about using the base name of the path? - statesObject.currentState = host.routeState.path; - settingState = false; - + return statesObject; } /** * The component whose state we sync. (Defaults to the strand of the router.) diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as index 55b0881..05ad347 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/Router.as @@ -55,17 +55,10 @@ package org.apache.royale.routing { } - /** - * Use this to automatically sync the state of the strand. - * This only works for the state property of the RouterState. - * It also assumes that the strand is an IStatesObject. - * For this to work correctly, it's usually assumed that the bead is attached to the application View - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.9.7 - */ - public var host:IStrand; + public function get host():IStrand + { + return _strand; + } private var _strand:IStrand; public function set strand(value:IStrand):void { @@ -91,6 +84,11 @@ package org.apache.royale.routing } private function onInit(event:Event):void { + if(beads) + { + for each (var bead:IBead in beads) + addBead(bead); + } COMPILE::JS { if(location.hash) diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as index cd2b222..924f132 100644 --- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as +++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/SetRouteTitle.as @@ -37,6 +37,7 @@ package org.apache.royale.routing override public function set strand(value:IStrand):void { + _strand = value; COMPILE::JS { initialTitle = document.title;