From 94161c587011424c76aae6fd128f73ca9b3a3a00 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 6 Sep 2023 19:28:17 +0300 Subject: [PATCH] Added pull to refresh view --- pom.xml | 23 +++++++---- .../org/example/views/PulltoRefreshView.java | 38 +++++++++++++++++++ 2 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/example/views/PulltoRefreshView.java diff --git a/pom.xml b/pom.xml index 0f404cf..278f834 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,18 @@ true + + com.microsoft.playwright + playwright + 1.36.0 + + + + org.springframework.boot + spring-boot-starter-test + test + + @@ -63,16 +75,11 @@ - com.microsoft.playwright - playwright - 1.36.0 + org.parttio + pulltorefresh + 0.0.1 - - org.springframework.boot - spring-boot-starter-test - test - diff --git a/src/main/java/org/example/views/PulltoRefreshView.java b/src/main/java/org/example/views/PulltoRefreshView.java new file mode 100644 index 0000000..b4f2e67 --- /dev/null +++ b/src/main/java/org/example/views/PulltoRefreshView.java @@ -0,0 +1,38 @@ +package org.example.views; + +import com.vaadin.flow.component.html.Paragraph; +import com.vaadin.flow.component.icon.VaadinIcon; +import com.vaadin.flow.component.orderedlayout.Scroller; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.router.Route; +import org.example.Addon; +import org.example.DefaultLayout; +import org.vaadin.addons.pulltorefresh.PullToRefreshScroller; +import org.vaadin.firitin.appframework.MenuItem; + +import java.time.LocalTime; + +@Route(layout = DefaultLayout.class) +@Addon("pulltorefresh--add-on") +@MenuItem(title = "Pull to refresh", icon = VaadinIcon.TOUCH) +public class PulltoRefreshView extends VerticalLayout { + + public PulltoRefreshView() { + + add(new Paragraph("Try with touch device and do a swipe down gesture on the scroller")); + + VerticalLayout layout = new VerticalLayout(); + for (int i = 0; i < 100; i++) { + layout.add(new Paragraph("This is a paragraph " + i + " in scroller.")); + } + Scroller scroller = new PullToRefreshScroller(() -> { + layout.addComponentAsFirst(new Paragraph("Refreshed at " + LocalTime.now())); + }); + scroller.setContent(layout); + + scroller.setHeight("50vh"); + add(scroller); + + + } +}