Skip to content

Commit

Permalink
Merge pull request #5 from parttio/feature/pulltorefresh
Browse files Browse the repository at this point in the history
Added pull to refresh view
  • Loading branch information
mstahv authored Sep 6, 2023
2 parents 1e08253 + 94161c5 commit 698035e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.36.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- Add-ons -->

<dependency>
Expand All @@ -63,16 +75,11 @@
</dependency>

<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.36.0</version>
<groupId>org.parttio</groupId>
<artifactId>pulltorefresh</artifactId>
<version>0.0.1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/org/example/views/PulltoRefreshView.java
Original file line number Diff line number Diff line change
@@ -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);


}
}

0 comments on commit 698035e

Please sign in to comment.