You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2018/09/10 09:19:31 UTC

[GitHub] carlosrovira commented on a change in pull request #292: new component snackbar

carlosrovira commented on a change in pull request #292: new component snackbar
URL: https://github.com/apache/royale-asjs/pull/292#discussion_r216251861
 
 

 ##########
 File path: frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Snackbar.as
 ##########
 @@ -0,0 +1,223 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.jewel
+{
+    import org.apache.royale.core.IPopUp;
+    import org.apache.royale.core.StyledUIBase;
+    import org.apache.royale.core.UIBase;
+    import org.apache.royale.jewel.beads.models.SnackbarModel;
+
+    COMPILE::JS
+    {
+		import org.apache.royale.core.WrappedHTMLElement;
+		import org.apache.royale.html.util.addElementToWrapper;
+    }
+
+    [Event(name="action", type="org.apache.royale.events.Event")]
+	/**
+	 *  The Snackbar class is a component that provide brief messages
+     *  about app processes at the bottom that pops up over all other controls.
+     *  The Snackbar component uses the SnackbarView bead to display messages
+     *  and can contain a single action which configured through the action property.
+     *  Because Snackbar disappear automatically, the action shouldn’t be “Dismiss” or “Cancel.”
+	 *  The Snackbar component uses the following beads:
+	 * 
+	 *  org.apache.royale.core.IBeadModel: the data model for the Snackbar.
+	 *  org.apache.royale.core.IBeadView: the bead used to create the parts of the Snackbar.
+	 *  org.apache.royale.core.IBeadController: the bead used to handle disappear automatically.
+	 *  
+	 * 
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.4
+	 */
+	public class Snackbar extends StyledUIBase implements IPopUp
+	{
+		/**
+		 *  constructor.
+         * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public function Snackbar()
+		{
+			super();
+			
+			typeNames = "jewel snackbar layout itemsCenter";
+		}
+
+		/**
+		 *  Action event name.
+         * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public static const ACTION:String = "action";
+
+		private var _emphasis:String;
+
+		public function get emphasis():String
+		{
+			return _emphasis;
+		}
+
+		public function set emphasis(value:String):void
+		{
+			if (_emphasis != value)
+            {
+                if(_emphasis)
+                {
+                    classSelectorList.toggle(_emphasis, false);
+                }
+                _emphasis = value;
+
+                classSelectorList.toggle(_emphasis, value);
+            }
+		}
+
+		/**
+		 *  The number of milliseconds to show the Snackbar.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public function get duration():int
+		{
+			return SnackbarModel(model).duration;
+		}
+
+		public function set duration(value:int):void
+		{
+			SnackbarModel(model).duration = value;
+		}
+
+		/**
+		 *  The text message to display in the Snackbar.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public function get message():String
+		{
+			return SnackbarModel(model).message;
+		}
+
+		public function set message(value:String):void
+		{
+			SnackbarModel(model).message = value;
+		}
+
+		/**
+		 *  The action to display on the Snackbar.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.4
+		 */
+		public function get action():String
+		{
+			return SnackbarModel(model).action;
+		}
+
+		public function set action(value:String):void
+		{
+			SnackbarModel(model).action = value;
+		}
+
+        /**
+          *  This static method is a convenience function to quickly create and display an Snackbar. The
+          *  message paramters are required, the others will default.
+          *
+          *  @param String message The message content of the Snackbar.
+          *  @param int duration How long to show the Snackbar for.
+		  *  @param String actionText The action text of the Snackbar.
+          *  @param Object parent The object that hosts the pop-up.
+          *
+          *  @langversion 3.0
+          *  @playerversion Flash 10.2
+          *  @playerversion AIR 2.6
+          *  @productversion Royale 0.9.4
+          */
+        static public function show(message:String, duration:int = 4000, actionText:String = null, parent:Object = null) : Snackbar
+		{
+            var snackbar:Snackbar = new Snackbar();
 
 Review comment:
   Right, this is the same the Alert component works

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services