Skip to content

Commit

Permalink
Merge pull request #421 from GwtMaterialDesign/release_2.5.0
Browse files Browse the repository at this point in the history
Release 2.5.0
  • Loading branch information
kevzlou7979 authored Sep 6, 2021
2 parents bf25eec + 24a4306 commit f91df01
Show file tree
Hide file tree
Showing 34 changed files with 1,573 additions and 56 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gwt-material <br>

## Current Version 2.5.0-rc1
## Current Version 2.5.0
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>2.5.0-rc1</version>
<version>2.5.0</version>
</dependency>
```

## Snapshot Version 2.5.0-SNAPSHOT
## Snapshot Version 2.5.0
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>2.5.0</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.5.0-rc1</version>
<version>2.5.0</version>
</parent>

<artifactId>gwt-material-addins</artifactId>
Expand All @@ -24,7 +24,7 @@
<connection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</connection>
<developerConnection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
<tag>v2.5.0-rc1</tag>
<tag>v2.5.0</tag>
</scm>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import gwt.material.design.addins.client.MaterialAddins;
import gwt.material.design.addins.client.avatar.js.AvatarOptions;
import gwt.material.design.addins.client.avatar.js.JsAvatar;
import gwt.material.design.addins.client.md5.Md5ClientBundle;
import gwt.material.design.addins.client.md5.Md5DebugClientBundle;
import gwt.material.design.client.MaterialDesignBase;
import gwt.material.design.client.base.AbstractValueWidget;
import gwt.material.design.client.base.JsLoader;
Expand Down Expand Up @@ -59,10 +61,10 @@ public class MaterialAvatar extends AbstractValueWidget<String> implements JsLoa
static {
if (MaterialAddins.isDebug()) {
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.jdenticonDebugJs());
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.md5DebugJs());
MaterialDesignBase.injectDebugJs(Md5DebugClientBundle.INSTANCE.md5DebugJs());
} else {
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.jdenticonJs());
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.md5Js());
MaterialDesignBase.injectJs(Md5ClientBundle.INSTANCE.md5Js());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@ public interface MaterialAvatarClientBundle extends ClientBundle {

@Source("resources/js/jdenticon-2.2.0.min.js")
TextResource jdenticonJs();

@Source("resources/js/md5.min.js")
TextResource md5Js();

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ public interface MaterialAvatarDebugClientBundle extends ClientBundle {

@Source("resources/js/jdenticon-2.2.0.js")
TextResource jdenticonDebugJs();

@Source("resources/js/md5.js")
TextResource md5DebugJs();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2021 GwtMaterialDesign
* %%
* Licensed 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.
* #L%
*/
package gwt.material.design.addins.client.banner;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.event.logical.shared.OpenHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.addins.client.MaterialAddins;
import gwt.material.design.addins.client.banner.event.HasBannerHandlers;
import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader;
import gwt.material.design.client.MaterialDesignBase;
import gwt.material.design.client.base.HasOpenClose;
import gwt.material.design.client.base.MaterialWidget;
import gwt.material.design.client.base.mixin.ToggleStyleMixin;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.ui.MaterialIcon;
import gwt.material.design.client.ui.MaterialLabel;
import gwt.material.design.client.ui.MaterialPanel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static gwt.material.design.jquery.client.api.JQuery.$;

public class MaterialBanner extends MaterialWidget implements HasOpenClose, HasBannerHandlers {

private final MaterialIcon icon;
private final MaterialLabel messageLabel;
private final MaterialPanel actions;
private int offsetTop = 0;
private int durationInMillis = 300;
private List<Element> targetPushElements;

private ToggleStyleMixin<Widget> openMixin;

static {
if (MaterialAddins.isDebug()) {
MaterialDesignBase.injectCss(MaterialBannerDebugClientBundle.INSTANCE.bannerDebugCss());
} else {
MaterialDesignBase.injectCss(MaterialBannerClientBundle.INSTANCE.bannerCss());
}
}

public MaterialBanner() {
super(Document.get().createDivElement(), "banner");

icon = new MaterialIcon();
icon.setVisible(false);
icon.addStyleName("banner-icon");

messageLabel = new MaterialLabel();
messageLabel.addStyleName("message");

actions = new MaterialPanel();
actions.addStyleName("actions");

targetPushElements = new ArrayList<>();
}

@Override
protected void onLoad() {
super.onLoad();

add(icon);
add(messageLabel);
add(actions);

close();

AddinsDarkThemeReloader.get().reload(MaterialBannerDarkTheme.class);
}

@Override
public void add(Widget child) {
if (child instanceof MaterialBannerActions) {
actions.add(child);
} else {
super.add(child);
}
}

@Override
public boolean isOpen() {
return false;
}

@Override
public void open() {
getOpenMixin().setOn(true);
setTop(offsetTop);
pushTargetElements(getOuterHeight());
OpenEvent.fire(this, getMessage());
}

public void open(Element... targetElements) {
setTargetPushElements(Arrays.asList(targetElements));
open();
}

@Override
public void close() {
getOpenMixin().setOn(false);
setTop(-getOuterHeight());
pushTargetElements(0);
CloseEvent.fire(this, getMessage());
}

protected void pushTargetElements(int translateY) {
$(getElement()).css("transition", "all " + durationInMillis + "ms ease");
for (Element element : targetPushElements) {
$(element).css("transition", "all " + durationInMillis + "ms ease");
$(element).css("transform", "translateY(" + translateY + "px)");
}
}

public int getDurationInMillis() {
return durationInMillis;
}

public void setDurationInMillis(int durationInMillis) {
this.durationInMillis = durationInMillis;
}

public String getMessage() {
return messageLabel.getText();
}

public void setMessage(String message) {
if (message != null && !message.isEmpty()) {
messageLabel.setText(message);
} else {
messageLabel.setText("");
}
}

public IconType getIconType() {
return icon.getIconType();
}

public void setIconType(IconType iconType) {
if (iconType != null) {
icon.setIconType(iconType);
icon.setVisible(true);
} else {
icon.setVisible(false);
}
}

public MaterialIcon getIcon() {
return icon;
}

public MaterialLabel getMessageLabel() {
return messageLabel;
}

public List<Element> getTargetPushElements() {
return targetPushElements;
}

public void setTargetPushElements(List<Element> targetPushElements) {
this.targetPushElements = targetPushElements;
}

public int getOffsetTop() {
return offsetTop;
}

public void setOffsetTop(int offsetTop) {
this.offsetTop = offsetTop;
}

public int getOuterHeight() {
return $(getElement()).outerHeight(true);
}

public ToggleStyleMixin<Widget> getOpenMixin() {
if (openMixin == null) {
openMixin = new ToggleStyleMixin<>(RootPanel.get(), "banner-open");
}
return openMixin;
}

@Override
public HandlerRegistration addCloseHandler(CloseHandler handler) {
return addHandler(handler, CloseEvent.getType());
}

@Override
public HandlerRegistration addOpenHandler(OpenHandler handler) {
return addHandler(handler, OpenEvent.getType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2021 GwtMaterialDesign
* %%
* Licensed 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.
* #L%
*/
package gwt.material.design.addins.client.banner;

import gwt.material.design.client.ui.MaterialPanel;

public class MaterialBannerActions extends MaterialPanel {

public MaterialBannerActions() {
super();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2017 GwtMaterialDesign
* %%
* Licensed 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.
* #L%
*/
package gwt.material.design.addins.client.banner;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.TextResource;

/**
* Client Bundle for Avatar component
*
* @author kevzlou7979
*/
public interface MaterialBannerClientBundle extends ClientBundle {

MaterialBannerClientBundle INSTANCE = GWT.create(MaterialBannerClientBundle.class);

@Source("resources/css/banner.min.css")
TextResource bannerCss();

@Source("resources/css/banner-dark.min.css")
TextResource bannerDarkCss();
}
Loading

0 comments on commit f91df01

Please sign in to comment.