use of com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton in project vaadin-app-layout by appreciated.
the class MainAppLayout method initSearchOverlayButton.
private SearchOverlayButton<TestSearchResult, SerializablePredicate<TestSearchResult>> initSearchOverlayButton() {
// The data provider that provides the entities for the search
ListDataProvider<TestSearchResult> listDataProvider = new ListDataProvider<>(Arrays.asList(new TestSearchResult("Header1", "Description1"), new TestSearchResult("Header2", "Description2"), new TestSearchResult("Header3", "Description3"), new TestSearchResult("Header4", "Description4"), new TestSearchResult("Header5", "Description5"), new TestSearchResult("Header6", "Description6"), new TestSearchResult("Header7", "Description7"), new TestSearchResult("Header8", "Description8"), new TestSearchResult("Header9", "Description9"), new TestSearchResult("Header10", "Description10")));
return new SearchOverlayButtonBuilder<TestSearchResult, SerializablePredicate<TestSearchResult>>().withDataProvider(listDataProvider).withQueryProvider(s -> new Query<>(testEntity -> !s.equals("") && testEntity.getHeader().startsWith(s))).withDataViewProvider(queryResult -> {
RippleClickableCard card = new RippleClickableCard(new Item(queryResult.getHeader(), queryResult.getDescription()));
card.setWidthFull();
card.setBackground("var(--lumo-base-color)");
return card;
}).withQueryResultListener(testSearchResult -> Notification.show(testSearchResult.getHeader())).build();
}
use of com.github.appreciated.app.layout.addons.search.overlay.SearchOverlayButton in project vaadin-app-layout by appreciated.
the class SearchView method furtherConfiguration.
@Override
public void furtherConfiguration(AppLayoutBuilder builder) {
ListDataProvider<TestSearchResult> dataProvider = new ListDataProvider<>(Arrays.asList(new TestSearchResult("Header1", "Description1"), new TestSearchResult("Header2", "Description2"), new TestSearchResult("Header3", "Description3"), new TestSearchResult("Header4", "Description4"), new TestSearchResult("Header5", "Description5"), new TestSearchResult("Header6", "Description6"), new TestSearchResult("Header7", "Description7"), new TestSearchResult("Header8", "Description8"), new TestSearchResult("Header9", "Description9"), new TestSearchResult("Header10", "Description10")));
SearchOverlayButton<TestSearchResult, SerializablePredicate<TestSearchResult>> button = new SearchOverlayButtonBuilder<TestSearchResult, SerializablePredicate<TestSearchResult>>().withDataProvider(dataProvider).withQueryProvider(s -> new Query<TestSearchResult, SerializablePredicate<TestSearchResult>>(testEntity -> !s.equals("") && testEntity.getHeader().startsWith(s))).withDataViewProvider(result -> {
RippleClickableCard card = new RippleClickableCard(new Item(result.getHeader(), result.getDescription()));
card.setWidthFull();
card.setBackground("var(--lumo-base-color)");
return card;
}).withQueryResultListener(testSearchResult -> Notification.show(testSearchResult.header + " clicked")).build();
button.setId("it-test-search-button");
button.getSearchView().getSearchField().setId("it-test-search-field");
button.getSearchView().getCloseButton().setId("it-test-search-close");
builder.withAppBar(button);
}
Aggregations