Skip to content

Commit b57d286

Browse files
committed
Fixed MaterialStep Description on Vertical axis.
Added support for Stepper's orientation.
1 parent bd12291 commit b57d286

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/main/java/gwt/material/design/addins/client/stepper/MaterialStep.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ public void setAxis(Axis axis) {
224224
break;
225225
case VERTICAL:
226226
conBody.insert(divTitle, 0);
227+
conBody.insert(divDescription, 1);
227228
conCircle.add(divLine);
229+
228230
break;
229231
}
230232
}
@@ -253,4 +255,4 @@ public MaterialIcon getIconError() {
253255
public MaterialIcon getIconSuccess() {
254256
return iconSuccess;
255257
}
256-
}
258+
}

src/main/java/gwt/material/design/addins/client/stepper/MaterialStepper.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import gwt.material.design.client.base.MaterialWidget;
4242
import gwt.material.design.client.base.mixin.CssNameMixin;
4343
import gwt.material.design.client.constants.Axis;
44+
import gwt.material.design.client.js.Window;
4445
import gwt.material.design.client.ui.MaterialLoader;
4546
import gwt.material.design.client.ui.animate.MaterialAnimator;
4647
import gwt.material.design.client.ui.animate.Transition;
@@ -92,6 +93,8 @@ public class MaterialStepper extends MaterialWidget implements HasAxis, HasError
9293
private Div divFeedback = new Div();
9394
private Span feedbackSpan = new Span();
9495
private boolean stepSkippingAllowed = true;
96+
private boolean detectOrientation = false;
97+
protected HandlerRegistration orientationHandler;
9598

9699
private final CssNameMixin<MaterialStepper, Axis> axisMixin = new CssNameMixin<>(this);
97100

@@ -111,6 +114,34 @@ protected void onLoad() {
111114
}
112115
}
113116

117+
public void setDetectOrientation(boolean detectOrientation) {
118+
this.detectOrientation = detectOrientation;
119+
120+
if(orientationHandler != null) {
121+
orientationHandler.removeHandler();
122+
orientationHandler = null;
123+
}
124+
125+
if(detectOrientation) {
126+
orientationHandler = com.google.gwt.user.client.Window.addResizeHandler(resizeEvent -> {
127+
detectAndApplyOrientation();
128+
});
129+
detectAndApplyOrientation();
130+
}
131+
}
132+
133+
protected void detectAndApplyOrientation() {
134+
if (Window.matchMedia("(orientation: portrait)")) {
135+
setAxis(Axis.VERTICAL);
136+
} else {
137+
setAxis(Axis.HORIZONTAL);
138+
}
139+
}
140+
141+
public boolean isDetectOrientation() {
142+
return detectOrientation;
143+
}
144+
114145
/**
115146
* Specific method to add {@link MaterialStep}s to the stepper.
116147
*/

0 commit comments

Comments
 (0)