royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] branch develop updated: Cleaned up ViewManager code Added TopViewManagerView to replace TabbedViewManagerView for view stacks which have the tabs at the top.
Date Wed, 01 Nov 2017 11:39:13 GMT
This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new b199cb8  Cleaned up ViewManager code Added TopViewManagerView to replace TabbedViewManagerView
for view stacks which have the tabs at the top.
b199cb8 is described below

commit b199cb8d46751c7ebefcad53131d4b48037bd32f
Author: Harbs <harbs@in-tools.com>
AuthorDate: Wed Nov 1 13:39:07 2017 +0200

    Cleaned up ViewManager code
    Added TopViewManagerView to replace TabbedViewManagerView for view stacks which have the
tabs at the top.
---
 .../Mobile/src/main/royale/MobileClasses.as        |  1 +
 .../royale/mobile/beads/StackedViewManagerView.as  | 27 +++-----
 .../royale/mobile/beads/TabbedViewManagerView.as   | 31 ++++-----
 .../mobile/beads/TopTabbedViewManagerView.as       | 79 ++++++++++++++++++++++
 .../royale/mobile/beads/ViewManagerViewBase.as     | 28 +++++---
 5 files changed, 120 insertions(+), 46 deletions(-)

diff --git a/frameworks/projects/Mobile/src/main/royale/MobileClasses.as b/frameworks/projects/Mobile/src/main/royale/MobileClasses.as
index b97c2ff..d78c28f 100644
--- a/frameworks/projects/Mobile/src/main/royale/MobileClasses.as
+++ b/frameworks/projects/Mobile/src/main/royale/MobileClasses.as
@@ -35,6 +35,7 @@ internal class MobileClasses
 	import org.apache.royale.mobile.ViewManagerBase; ViewManagerBase;
 	import org.apache.royale.mobile.beads.StackedViewManagerView; StackedViewManagerView;
 	import org.apache.royale.mobile.beads.TabbedViewManagerView; TabbedViewManagerView;
+	import org.apache.royale.mobile.beads.TopTabbedViewManagerView; TopTabbedViewManagerView;
 	import org.apache.royale.mobile.beads.ViewManagerViewBase; ViewManagerViewBase;
 	import org.apache.royale.mobile.beads.ToggleSwitchView; ToggleSwitchView;
 	import org.apache.royale.mobile.beads.controllers.ToggleSwitchMouseController; ToggleSwitchMouseController;
diff --git a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/StackedViewManagerView.as
b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/StackedViewManagerView.as
index a698c06..71bb7b3 100644
--- a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/StackedViewManagerView.as
+++ b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/StackedViewManagerView.as
@@ -57,20 +57,18 @@ package org.apache.royale.mobile.beads
 			super();
 		}
 		
-		private var _strand:IStrand;
-		
 		/*
 		 * Children
 		 */
 		
 		public function get toolBar():ToolBar
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			return model.toolBar;
 		}
 		public function set toolBar(value:ToolBar):void
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			model.toolBar = value;
 		}
 		
@@ -78,13 +76,8 @@ package org.apache.royale.mobile.beads
 		 * ViewBead
 		 */
 		
-		override public function get strand():IStrand
-		{
-			return _strand;
-		}
 		override public function set strand(value:IStrand):void
 		{
-			_strand = value;
 			super.strand = value;
 			
 			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
@@ -98,16 +91,16 @@ package org.apache.royale.mobile.beads
 			}
 		}
 		
-		override protected function handleInitComplete(event:Event):void
+		override protected function addViewElements():void
 		{			
-			super.handleInitComplete(event);
+			super.addViewElements();
 			
 			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
-			IEventDispatcher(model).addEventListener("viewPushed", handlePushEvent);
-			IEventDispatcher(model).addEventListener("viewPopped", handlePopEvent);
+			model.addEventListener("viewPushed", handlePushEvent);
+			model.addEventListener("viewPopped", handlePopEvent);
 			
 			if (toolBar) {
-				UIBase(_strand).addElement(toolBar);
+				getHost().addElement(toolBar);
 			}
 			
 			showViewByIndex(0);
@@ -149,12 +142,12 @@ package org.apache.royale.mobile.beads
 			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			
 			if (_topView != null) {
-				UIBase(_strand).removeElement(_topView);
+				getHost().removeElement(_topView);
 			}
 			_topView = model.views[index] as IViewManagerView;
 			_topView.viewManager = _strand as IViewManager;
 			
-			UIBase(_strand).addElementAt(_topView,(navigationBar == null ? 0 : 1));
+			getHost().addElementAt(_topView,(navigationBar == null ? 0 : 1));
 			
 			COMPILE::JS {
 				if (_topView) {
@@ -170,7 +163,7 @@ package org.apache.royale.mobile.beads
 			}
 			
 			// Now that a view has changed, refresh the layout for this component.
-			UIBase(_strand).dispatchEvent(new Event("layoutNeeded"));
+			getHost().dispatchEvent(new Event("layoutNeeded"));
 		}
 	}
 }
diff --git a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TabbedViewManagerView.as
b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TabbedViewManagerView.as
index f6557d2..64c7b80 100644
--- a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TabbedViewManagerView.as
+++ b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TabbedViewManagerView.as
@@ -58,20 +58,18 @@ package org.apache.royale.mobile.beads
 			super();
 		}
 		
-		private var _strand:IStrand;
-		
 		/*
 		 * Children
 		 */
 		
 		public function get tabBar():TabBar
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			return model.tabBar;
 		}
 		public function set tabBar(value:TabBar):void
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			model.tabBar = value;
 		}
 		
@@ -79,13 +77,8 @@ package org.apache.royale.mobile.beads
 		 * ViewBead
 		 */
 		
-		override public function get strand():IStrand
-		{
-			return _strand;
-		}
 		override public function set strand(value:IStrand):void
 		{
-			_strand = value;
 			super.strand = value;
 			
 			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
@@ -98,12 +91,12 @@ package org.apache.royale.mobile.beads
 			tabBar = tbar;
 		}
 		
-		override protected function handleInitComplete(event:Event):void
+		override protected function addViewElements():void
 		{			
-			super.handleInitComplete(event);
+			super.addViewElements();
 			
 			if (tabBar) {
-				UIBase(_strand).addElement(tabBar);
+				getHost().addElement(tabBar);
 			}
 			
 			showViewByIndex(0);
@@ -116,17 +109,17 @@ package org.apache.royale.mobile.beads
 			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			
 			if (_currentView != null) {
-				UIBase(_strand).removeElement(_currentView);
+				getHost().removeElement(_currentView);
 			}
 			_currentView = model.views[index] as IViewManagerView;
 			_currentView.viewManager = _strand as IViewManager;
-			UIBase(_strand).addElementAt(_currentView,(navigationBar == null ? 0 : 1));
+			insertCurrentView(_currentView);
 			
 			COMPILE::JS {
 				if (_currentView) {
 					UIBase(_currentView).element.style["flex-grow"] = "1";
 				}
-				UIBase(_strand).dispatchEvent(new Event("layoutNeeded"));
+				getHost().dispatchEvent(new Event("layoutNeeded"));
 			}
 			COMPILE::SWF {
 				if (UIBase(_currentView).style == null) {
@@ -137,16 +130,18 @@ package org.apache.royale.mobile.beads
 			}
 			
 			// Now that the view has changed, refresh the layout on this component.
-			UIBase(_strand).dispatchEvent(new Event("layoutNeeded"));
+			getHost().dispatchEvent(new Event("layoutNeeded"));
+		}
+		protected function insertCurrentView(view:IViewManagerView):void{
+			getHost().addElementAt(view,(navigationBar ? 1 : 0));
 		}
-		
 		/**
 		 * @private
 		 */		
 		private function handleButtonBarChange(event:Event):void
 		{
 			var newIndex:Number = tabBar.selectedIndex;
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			
 			// doing this will trigger the selectedIndexChanged event which will
 			// tell the strand to switch views
diff --git a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TopTabbedViewManagerView.as
b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TopTabbedViewManagerView.as
new file mode 100644
index 0000000..aaed83b
--- /dev/null
+++ b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/TopTabbedViewManagerView.as
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.mobile.beads
+{
+	import org.apache.royale.core.IBeadModel;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IViewportModel;
+	import org.apache.royale.core.UIBase;
+	import org.apache.royale.core.SimpleCSSStylesWithFlex;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.html.beads.ContainerView;
+	import org.apache.royale.html.beads.layouts.HorizontalLayout;
+	import org.apache.royale.mobile.IViewManager;
+	import org.apache.royale.mobile.IViewManagerView;
+	import org.apache.royale.mobile.chrome.NavigationBar;
+	import org.apache.royale.mobile.chrome.TabBar;
+	import org.apache.royale.mobile.models.ViewManagerModel;
+	import org.apache.royale.mobile.beads.TabbedViewManagerView;
+	
+	/**
+	 * The TopTabbedViewManagerView constructs the visual elements of the TabbedViewManager.
+	 * It always contains a tab bar and it's located at the top.
+	 * It may contain a navigation bar at the bottom.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.0
+	 */
+	public class TopTabbedViewManagerView extends TabbedViewManagerView
+	{
+		/**
+		 * Constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		public function TopTabbedViewManagerView()
+		{
+			super();
+		}
+		
+		override protected function addViewElements():void
+		{			
+			
+			if (tabBar) {
+				getHost().addElement(tabBar);
+			}
+			if (navigationBar) {
+				getHost().addElement(navigationBar);
+			}
+			
+			showViewByIndex(0);
+		}
+		override protected function insertCurrentView(view:IViewManagerView):void{
+			getHost().addElementAt(view,(tabBar ? 1 : 0));
+		}
+
+	}
+}
diff --git a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/ViewManagerViewBase.as
b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/ViewManagerViewBase.as
index b8ce417..de5a84a 100644
--- a/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/ViewManagerViewBase.as
+++ b/frameworks/projects/Mobile/src/main/royale/org/apache/royale/mobile/beads/ViewManagerViewBase.as
@@ -42,7 +42,7 @@ package org.apache.royale.mobile.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.0
 	 */
-	public class ViewManagerViewBase extends GroupView implements IBeadView
+	public class ViewManagerViewBase extends GroupView
 	{
 		/**
 		 * Constructor.
@@ -61,14 +61,23 @@ package org.apache.royale.mobile.beads
 		 * Children
 		 */
 		
+		/**
+		 * @private
+		 * @royaleignorecoercion org.apache.royale.core.IUIBase
+		 */
+		protected function getHost():UIBase
+		{
+			return _strand as UIBase;
+		}
+
 		public function get navigationBar():NavigationBar
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			return model.navigationBar;
 		}
 		public function set navigationBar(value:NavigationBar):void
 		{
-			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			model.navigationBar = value;
 		}
 		
@@ -76,15 +85,9 @@ package org.apache.royale.mobile.beads
 		 * ViewBead
 		 */
 		
-		private var _strand:IStrand;
-		public function get strand():IStrand
-		{
-			return _strand;
-		}
 		override public function set strand(value:IStrand):void
 		{
 			super.strand = value;
-			_strand = value;
 			
 			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
 //			model.addEventListener("selectedIndexChanged", viewsChangedHandler);
@@ -101,9 +104,12 @@ package org.apache.royale.mobile.beads
 		override protected function handleInitComplete(event:Event):void
 		{
 			super.handleInitComplete(event);
-			
+			addViewElements();
+		}
+		protected function addViewElements():void
+		{
 			if (navigationBar) {
-				UIBase(_strand).addElement(navigationBar);
+				getHost().addElement(navigationBar);
 			}
 		}
 		

-- 
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <commits@royale.apache.org>'].

Mime
View raw message