flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Add method "show" to snackbar - Add event "action" - indicates whether snackbar action has been clicked - Add snackbar to MDL examples
Date Wed, 21 Dec 2016 20:18:40 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 33dc90054 -> e6350fd10


Add method "show" to snackbar
- Add event "action" - indicates whether snackbar action has been clicked
- Add snackbar to MDL examples


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/e6350fd1
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e6350fd1
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e6350fd1

Branch: refs/heads/develop
Commit: e6350fd1046df8c4acd2d54d2fb29b5266cc0876
Parents: 33dc900
Author: piotrz <piotrz@apache.org>
Authored: Wed Dec 21 21:18:34 2016 +0100
Committer: piotrz <piotrz@apache.org>
Committed: Wed Dec 21 21:18:34 2016 +0100

----------------------------------------------------------------------
 .../src/main/flex/MainNavigation.mxml           |  3 ++
 .../MDLExample/src/main/flex/Snackbar.mxml      | 44 +++++++++++++++++
 .../main/flex/org/apache/flex/mdl/Snackbar.as   | 52 +++++++++++++++++++-
 .../src/main/resources/mdl-manifest.xml         |  1 +
 4 files changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e6350fd1/examples/flexjs/MDLExample/src/main/flex/MainNavigation.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MDLExample/src/main/flex/MainNavigation.mxml b/examples/flexjs/MDLExample/src/main/flex/MainNavigation.mxml
index 632c332..a73559d 100644
--- a/examples/flexjs/MDLExample/src/main/flex/MainNavigation.mxml
+++ b/examples/flexjs/MDLExample/src/main/flex/MainNavigation.mxml
@@ -41,6 +41,7 @@ limitations under the License.
             <mdl:TabBarButton text="Tabs" href="#tabs_panel"/>
             <mdl:TabBarButton text="Buttons" href="#buttons_panel" />
             <mdl:TabBarButton text="TextFields" href="#textfield_panel"/>
+            <mdl:TabBarButton text="Snackbar" href="#snackbar_panel"/>
             <mdl:TabBarButton text="Toggles" href="#toggles_panel"/>
             <mdl:TabBarButton text="Lists" href="#lists_panel"/>
             <mdl:TabBarButton text="Loading" href="#loading_panel"/>
@@ -78,6 +79,8 @@ limitations under the License.
 
         <local:Toggles id="toggles_panel"/>
 
+        <local:Snackbar id="snackbar_panel"/>
+
         <local:Lists id="lists_panel"/>
 
         <local:Loading id="loading_panel"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e6350fd1/examples/flexjs/MDLExample/src/main/flex/Snackbar.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MDLExample/src/main/flex/Snackbar.mxml b/examples/flexjs/MDLExample/src/main/flex/Snackbar.mxml
new file mode 100644
index 0000000..a3f5a8b
--- /dev/null
+++ b/examples/flexjs/MDLExample/src/main/flex/Snackbar.mxml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+
+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.
+
+-->
+<mdl:TabBarPanel xmlns:fx="http://ns.adobe.com/mxml/2009"
+                 xmlns:mdl="library://ns.apache.org/flexjs/mdl">
+    <mdl:Grid>
+        <mdl:GridCell column="1">
+            <mdl:Button id="showSnackbar" click="onShowSnackBarClick(event)"
+                        text="Show snackbar!"/>
+            <mdl:Snackbar id="snackbar" message="Snack bar message" actionText="Undo"
timeout="3000"
+                          action="onSnackBarAction(event)"/>
+        </mdl:GridCell>
+    </mdl:Grid>
+    <fx:Script><![CDATA[
+        import org.apache.flex.events.Event;
+        import org.apache.flex.events.MouseEvent;
+
+        private function onShowSnackBarClick(event:MouseEvent):void
+        {
+            snackbar.show();
+        }
+
+        private function onSnackBarAction(event:Event):void
+        {
+           //some action here
+        }
+        ]]></fx:Script>
+</mdl:TabBarPanel>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e6350fd1/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Snackbar.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Snackbar.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Snackbar.as
index e4151f4..51b104a 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Snackbar.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Snackbar.as
@@ -18,6 +18,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mdl
 {
+    import org.apache.flex.events.EventDispatcher;
+
+    COMPILE::SWF
+    {
+        import flash.events.Event;
+    }
+
     COMPILE::JS
     {
         import org.apache.flex.events.Event;
@@ -25,8 +32,18 @@ package org.apache.flex.mdl
         import org.apache.flex.core.WrappedHTMLElement;
     }
 
+    /**
+     *  Dispatched when the user click on Snackbar
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+    [Event(name="action", type="org.apache.flex.events.Event")]
+
     COMPILE::SWF
-    public class Snackbar
+    public class Snackbar extends EventDispatcher
     {
         private var _message:String;
         private var _actionText:String;
@@ -86,6 +103,19 @@ package org.apache.flex.mdl
         {
             _timeout = value;
         }
+
+        /**
+         *  Show the snackbar
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function show():void
+        {
+            dispatchEvent(new Event("action"));
+        }
     }
 
     COMPILE::JS
@@ -137,6 +167,26 @@ package org.apache.flex.mdl
             _timeout = value;
         }
 
+        public function show():void
+        {
+            if (snackbar)
+            {
+                var snackbarData = {
+                    message: _message,
+                    timeout: _timeout,
+                    actionHandler: onActionHandler,
+                    actionText: _actionText
+                };
+
+                snackbar.showSnackbar(snackbarData);
+            }
+        }
+
+        private function onActionHandler(event:Event):void
+        {
+            dispatchEvent(new Event("action"));
+        }
+
         /**
          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
          * @flexjsignorecoercion HTMLDivElement

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e6350fd1/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
index 69059bd..09f446c 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
@@ -86,4 +86,5 @@
     <component id="MdlTextColor" class="org.apache.flex.mdl.beads.MdlTextColor"/>
     <component id="Spinner" class="org.apache.flex.mdl.Spinner"/>
     <component id="ProgressBar" class="org.apache.flex.mdl.ProgressBar"/>
+    <component id="Snackbar" class="org.apache.flex.mdl.Snackbar"/>
 </componentPackage>


Mime
View raw message