Skip to content

Commit 91c9aa0

Browse files
committed
Support Toast positioning.
1 parent e8e3e55 commit 91c9aa0

File tree

5 files changed

+181
-131
lines changed

5 files changed

+181
-131
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package gwt.material.design.client.base;
2+
3+
public enum ToastPosition {
4+
DEFAULT(""),
5+
TOP_LEFT("top-left"),
6+
TOP_RIGHT("top-right"),
7+
BOTTOM_LEFT("bottom-left"),
8+
BOTTOM_RIGHT("bottom-right");
9+
10+
private String name;
11+
12+
ToastPosition(String name) {
13+
this.name = name;
14+
}
15+
16+
public String getName() {
17+
return name;
18+
}
19+
}

gwt-material/src/main/java/gwt/material/design/client/events/OpeningEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

gwt-material/src/main/java/gwt/material/design/client/ui/MaterialToast.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.gwt.user.client.DOM;
2525
import com.google.gwt.user.client.ui.RootPanel;
2626
import com.google.gwt.user.client.ui.Widget;
27+
import gwt.material.design.client.base.ToastPosition;
2728
import gwt.material.design.client.js.JsMaterialElement;
2829
import gwt.material.design.jquery.client.api.Functions;
2930
import gwt.material.design.jquery.client.api.JQueryElement;
@@ -137,13 +138,17 @@ public void toast(String msg, String className) {
137138
toast(msg, DURATION, className);
138139
}
139140

141+
public void toast(String msg, int lifeMillis, String className) {
142+
toast(msg, lifeMillis, className, ToastPosition.DEFAULT);
143+
}
144+
140145
/**
141146
* @param msg Message text for your toast.
142147
* @param lifeMillis how long it should present itself before being removed.
143148
* If value is less than 0 - then it will be treated as unlimited duration
144149
* @param className class name to custom style your toast.
145150
*/
146-
public void toast(String msg, int lifeMillis, String className) {
151+
public void toast(String msg, int lifeMillis, String className, ToastPosition position) {
147152
String id;
148153
if (element != null) {
149154
id = (String) element.attr("id");
@@ -171,7 +176,7 @@ public void toast(String msg, int lifeMillis, String className) {
171176
element = $(".toast." + id);
172177
element.attr("id", id);
173178
//element.toggleClass(className, true);
174-
179+
element.addClass(position.getName());
175180
if (widgets != null) {
176181
RootPanel toast = RootPanel.get(id);
177182
for (Widget widget : widgets) {

0 commit comments

Comments
 (0)