Search in sources :

Example 1 with ThemeList

use of com.vaadin.flow.dom.ThemeList in project vaadin-date-range-picker by xdev-software.

the class DateRangePickerStyledDemo method initUI.

protected void initUI() {
    this.btnDarkMode.addClickListener(ev -> {
        final ThemeList themeList = UI.getCurrent().getElement().getThemeList();
        if (themeList.contains(Lumo.DARK)) {
            themeList.remove(Lumo.DARK);
        } else {
            themeList.add(Lumo.DARK);
        }
        this.updateBtnDarkMode();
    });
    this.taResult.setSizeFull();
    this.getContent().setPadding(false);
    this.getContent().add(new VerticalLayout(this.dateRangePicker), new VerticalLayout(this.taResult, this.btnDarkMode));
    this.getContent().getChildren().forEach(comp -> ((HasSize) comp).setHeight("50%"));
    this.getContent().setHeightFull();
    this.dateRangePicker.addValueChangeListener(ev -> {
        final DateRangeModel<SimpleDateRange> modell = ev.getValue();
        this.taResult.clear();
        // @formatter:off
        this.taResult.setValue("DateRange: " + modell.getDateRange().getKey() + "\r\n" + "Start: " + modell.getStart() + "\r\n" + "End: " + modell.getEnd() + "\r\n" + (ev.getOldValue() != null ? "OldValue-DateRange: " + ev.getOldValue().getDateRange().getKey() + "\r\n" + "OldValue-Start: " + ev.getOldValue().getStart() + "\r\n" + "OldValue-End: " + ev.getOldValue().getEnd() : "OldValue: null") + "\r\n" + "IsFromClient: " + ev.isFromClient());
    // @formatter:on
    });
    this.updateBtnDarkMode();
}
Also used : ThemeList(com.vaadin.flow.dom.ThemeList) SimpleDateRange(software.xdev.vaadin.daterange_picker.business.SimpleDateRange) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout)

Example 2 with ThemeList

use of com.vaadin.flow.dom.ThemeList in project linkki by linkki-framework.

the class PlaygroundApplicationHeader method addHelpMenuItems.

@Override
protected void addHelpMenuItems(MenuItem helpMenu) {
    super.addHelpMenuItems(helpMenu);
    helpMenu.getSubMenu().addItem("Locale", i -> {
        new PmoBasedDialogFactory().newOkDialog("Browser Locale", new LocaleInfoPmo()).open();
    });
    helpMenu.getSubMenu().addItem("Toogle Dark Mode", i -> {
        ThemeList themeList = UI.getCurrent().getElement().getThemeList();
        if (themeList.contains(Lumo.DARK)) {
            themeList.remove(Lumo.DARK);
        } else {
            themeList.add(Lumo.DARK);
        }
    });
}
Also used : ThemeList(com.vaadin.flow.dom.ThemeList) PmoBasedDialogFactory(org.linkki.framework.ui.dialogs.PmoBasedDialogFactory)

Aggregations

ThemeList (com.vaadin.flow.dom.ThemeList)2 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 PmoBasedDialogFactory (org.linkki.framework.ui.dialogs.PmoBasedDialogFactory)1 SimpleDateRange (software.xdev.vaadin.daterange_picker.business.SimpleDateRange)1