Skip to content

Commit cbd2ae6

Browse files
mlopezFCjavier-godoy
authored andcommitted
feat!: make AppLayout the RouterLayout provided by the addon
Avoid potential API duplication by making AppLayout to be the RouterLayout implementation to be used and removing AbstractFCAppRouterLayout.
1 parent 980a3be commit cbd2ae6

File tree

3 files changed

+11
-107
lines changed

3 files changed

+11
-107
lines changed

src/main/java/com/flowingcode/addons/applayout/AbstractFcAppRouterLayout.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/main/java/com/flowingcode/addons/applayout/AppLayout.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@
1919
*/
2020
package com.flowingcode.addons.applayout;
2121

22+
import java.util.ArrayList;
23+
import java.util.Arrays;
24+
import java.util.List;
2225
import com.vaadin.flow.component.Component;
2326
import com.vaadin.flow.component.Tag;
2427
import com.vaadin.flow.component.dependency.CssImport;
2528
import com.vaadin.flow.component.dependency.JsModule;
2629
import com.vaadin.flow.component.dependency.NpmPackage;
2730
import com.vaadin.flow.component.html.Div;
2831
import com.vaadin.flow.component.html.Image;
29-
import com.vaadin.flow.server.InitialPageSettings;
30-
import com.vaadin.flow.server.PageConfigurator;
31-
import java.util.ArrayList;
32-
import java.util.Arrays;
33-
import java.util.List;
32+
import com.vaadin.flow.router.RouterLayout;
3433

3534
/**
3635
* Component that renders the div that contains the entire layout.
@@ -42,7 +41,7 @@
4241
@JsModule("@flowingcode/fc-applayout/fc-applayout.js")
4342
@NpmPackage(value = "@flowingcode/fc-applayout", version = "0.9.5")
4443
@CssImport(value = "./styles/applayout-styles.css", themeFor = "fc-applayout")
45-
public class AppLayout extends Div implements PageConfigurator {
44+
public class AppLayout extends Div implements RouterLayout {
4645

4746
private static final String PROFILE_SLOT_NAME = "profile";
4847
private static final String APP_LAYOUT_TITLE_SLOT_NAME = "title";
@@ -139,11 +138,6 @@ public boolean isMenuVisible() {
139138
return this.getElement().getProperty("drawerVisible", true);
140139
}
141140

142-
@Override
143-
public void configurePage(InitialPageSettings settings) {
144-
settings.addMetaTag("viewport", "width=device-width, initial-scale=1.0");
145-
}
146-
147141
/**
148142
* Sets the toolbar title
149143
* @param caption

src/test/java/com/flowingcode/addons/applayout/AbstractLayoutDemo.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
*/
2020
package com.flowingcode.addons.applayout;
2121

22-
import com.vaadin.flow.component.HasElement;
2322
import com.vaadin.flow.component.html.Div;
2423
import com.vaadin.flow.component.html.H4;
2524
import com.vaadin.flow.component.html.Image;
2625
import com.vaadin.flow.component.html.Span;
2726

28-
public class AbstractLayoutDemo extends AbstractFcAppRouterLayout {
27+
public class AbstractLayoutDemo extends AppLayout {
2928

30-
@Override
31-
protected void configure(AppLayout app) {
32-
app.setMenuItems(new MenuItem("Item 1"), new MenuItem("Item 2"));
29+
public AbstractLayoutDemo() {
30+
setMenuItems(new MenuItem("Item 1"), new MenuItem("Item 2"));
3331

3432
// menu header
3533
Div container = new Div();
@@ -39,19 +37,15 @@ protected void configure(AppLayout app) {
3937
img.getStyle().set("margin-top", "20px");
4038
H4 h4 = new H4("User");
4139
container.add(img, h4);
42-
app.setMenuHeader(container);
40+
setMenuHeader(container);
4341

4442
// logo
4543
Image imglogo = new Image("frontend/images/applogo.png", "applogo");
4644
imglogo.setWidth("25px");
47-
app.addToTitleSection(imglogo);
45+
addToTitleSection(imglogo);
4846

4947
// title
50-
app.addToTitleSection(new Div(new Span("Test Application")));
48+
addToTitleSection(new Div(new Span("Test Application")));
5149
}
5250

53-
@Override
54-
public void showRouterLayoutContent(AppLayout app, HasElement content) {
55-
super.showRouterLayoutContent(app, content);
56-
}
5751
}

0 commit comments

Comments
 (0)