Java Code Examples for gwt.material.design.client.base.viewport.ViewPort

The following examples show how to use gwt.material.design.client.base.viewport.ViewPort. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void open() {
    super.open();

    getToggleStyleMixin().setOn(true);

    ViewPort.when(Resolution.ALL_MOBILE, Resolution.TABLET).then(param1 -> {
        if (isOpen()) {
            super.setWidth("90%");
        }
    }, viewPort -> {
        if (isOpen()) {
            super.setWidth(width);
        }
        return false;
    });
}
 
Example 2
Source Project: gwt-material-addins   Source File: InlineSearch.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoad() {
    super.onLoad();

    ViewPort.when(Resolution.ALL_MOBILE).then(portChange -> {
        focusHandler = registerHandler(addFocusHandler(focusEvent -> addStyleName(AddinsCssName.WIDE)));
        blurHandler = registerHandler(addBlurHandler(blurEvent -> removeStyleName(AddinsCssName.WIDE)));
    }, viewPortRect -> {
        if (focusHandler != null && blurHandler != null) {
            focusHandler.removeHandler();
            blurHandler.removeHandler();
        }

        focusHandler = null;
        blurHandler = null;
        return true;
    });

    IncubatorDarkThemeReloader.get().reload(InlineSearchDarkTheme.class);
}
 
Example 3
Source Project: gwt-material   Source File: AbstractSideNav.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * When enabled the sidenav will auto hide / collapse it durating browser resized.
 * Default true
 */
public void setAutoHideOnResize(boolean autoHideOnResize) {
    if (autoHideOnResize) {
        autoHideViewport = ViewPort.when(getClosingBoundary()).then(param1 -> hide());
    } else {
        if (autoHideViewport != null) {
            autoHideViewport.destroy();
            autoHideViewport = null;
        }
    }
}
 
Example 4
Source Project: gwt-material   Source File: FieldTypeMixin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setFieldType(FieldType type) {
    if (type.equals(FieldType.ALIGNED_LABEL)) {
        ViewPort.when(Resolution.ALL_MOBILE).then(param1 -> {
            getCssNameMixin().setCssName(FieldType.DEFAULT);
        }, viewPort -> {
            getCssNameMixin().setCssName(type);
            return false;
        });
    } else {
        getCssNameMixin().setCssName(type);
    }
}
 
Example 5
Source Project: gwt-material-demo   Source File: HelperView.java    License: Apache License 2.0 5 votes vote down vote up
protected void detectViewPort() {
    ViewPort.when(Resolution.MOBILE_SMALL).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Small");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.MOBILE_MEDIUM).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Medium");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.MOBILE_LARGE).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Mobile Large");
        lblViewPort.setIconType(IconType.PHONE_ANDROID);
    });

    ViewPort.when(Resolution.TABLET).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Tablet");
        lblViewPort.setIconType(IconType.TABLET_ANDROID);
    });

    ViewPort.when(Resolution.LAPTOP).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop");
        lblViewPort.setIconType(IconType.LAPTOP);
    });

    ViewPort.when(Resolution.LAPTOP_LARGE).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop Large");
        lblViewPort.setIconType(IconType.LAPTOP);
    });

    ViewPort.when(Resolution.LAPTOP_4K).then(viewPortChange -> {
        lblViewPort.setText("ViewPort : Laptop 4K");
        lblViewPort.setIconType(IconType.LAPTOP);
    });
}
 
Example 6
Source Project: gwt-material   Source File: AdaptiveWidget.java    License: Apache License 2.0 4 votes vote down vote up
public void load() {
    ViewPort.when(Resolution.ALL_DEVICES).then(viewPortChange -> loadViewPort());
}
 
Example 7
Source Project: gwt-material-addins   Source File: MaterialSignaturePad.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * <b>Handling high DPI screens</b>
 * <p>
 * To correctly handle canvas on low and high DPI screens one has to take devicePixelRatio into account and scale
 * the canvas accordingly. </p>
 *
 * @see <a href="https://github.com/szimek/signature_pad#handling-high-dpi-screens">More info</a>
 */
protected void resizeCanvas() {
    applyResize();
    ViewPort.when(new WidthBoundary(0, 5120)).then(param1 -> applyResize());
}