Skip to content

Commit b7ac448

Browse files
mlopezFCjavier-godoy
authored andcommitted
feat: add support for drawerPersistent wc feature
1 parent efe5a10 commit b7ac448

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,13 @@ public void setReveals(boolean reveals) {
174174
public void setSwipeOpen(boolean swipeOpen) {
175175
this.getElement().setAttribute("swipeOpen", swipeOpen);
176176
}
177-
177+
178+
/**
179+
* Sets the persistent attribute so it will make the drawer to be always
180+
* opened in a non-modal way
181+
* @param drawerPersistent
182+
*/
183+
public void setDrawerPersistent(boolean drawerPersistent) {
184+
this.getElement().setAttribute("drawerPersistent", drawerPersistent);
185+
}
178186
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public ApplayoutDemoView() {
6969
app.setMenuItems(createMenuItems());
7070

7171
app.setToolbarIconButtons(miSettings);
72-
this.add(app, container);
72+
app.add(container);
73+
this.add(app);
7374

7475
settings.setSwipeOpen(true);
7576
settings.setMenuVisible(true);
@@ -85,7 +86,8 @@ private void applySettings() {
8586
app.setSwipeOpen(settings.isSwipeOpen());
8687
app.setFixed(settings.isFixed());
8788
app.setReveals(settings.isReveals());
88-
89+
app.setDrawerPersistent(settings.isDrawerPersistent());
90+
8991
if (settings.isCompact()) {
9092
app.addClassName("compact");
9193
} else {
@@ -104,7 +106,8 @@ private void openSettings() {
104106
Checkbox cbFixed = new Checkbox("Fixed");
105107
Checkbox cbReveals = new Checkbox("Reveals");
106108
Checkbox cbCompact = new Checkbox("Compact");
107-
109+
Checkbox cbPersistent = new Checkbox("Drawer Persistent");
110+
108111
cbMenuVisible.getElement().setAttribute("title", "Toggle visibility of the hamburguer icon.");
109112
cbSwipeOpen
110113
.getElement()
@@ -121,17 +124,21 @@ private void openSettings() {
121124
cbCompact
122125
.getElement()
123126
.setAttribute("title", "When enabled, the height of the header is set to 32px.");
127+
cbPersistent
128+
.getElement()
129+
.setAttribute("title", "When enabled, the drawer will be opened in a non-modal way");
124130

125131
Binder<DemoSettings> binder = new Binder<>();
126132
binder.forField(cbMenuVisible).bind(DemoSettings::isMenuVisible, DemoSettings::setMenuVisible);
127133
binder.forField(cbSwipeOpen).bind(DemoSettings::isSwipeOpen, DemoSettings::setSwipeOpen);
128134
binder.forField(cbFixed).bind(DemoSettings::isFixed, DemoSettings::setFixed);
129135
binder.forField(cbReveals).bind(DemoSettings::isReveals, DemoSettings::setReveals);
130136
binder.forField(cbCompact).bind(DemoSettings::isCompact, DemoSettings::setCompact);
137+
binder.forField(cbPersistent).bind(DemoSettings::isDrawerPersistent, DemoSettings::setDrawerPersistent);
131138
binder.setBean(this.settings);
132139

133140
VerticalLayout content =
134-
new VerticalLayout(cbMenuVisible, cbSwipeOpen, cbFixed, cbReveals, cbCompact);
141+
new VerticalLayout(cbMenuVisible, cbSwipeOpen, cbFixed, cbReveals, cbCompact, cbPersistent);
135142
content.setSpacing(false);
136143

137144
HorizontalLayout buttons = new HorizontalLayout();

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class DemoSettings {
3333

3434
private boolean compact;
3535

36+
private boolean drawerPersistent;
37+
3638
public boolean isEnabled() {
3739
return enabled;
3840
}
@@ -80,4 +82,12 @@ public boolean isCompact() {
8082
public void setCompact(boolean compact) {
8183
this.compact = compact;
8284
}
85+
86+
public boolean isDrawerPersistent() {
87+
return drawerPersistent;
88+
}
89+
90+
public void setDrawerPersistent(boolean drawerPersistent) {
91+
this.drawerPersistent = drawerPersistent;
92+
}
8393
}

0 commit comments

Comments
 (0)