Skip to content

Commit c8fb8ad

Browse files
author
aklabox
committed
Fixed Sidebar and MaterialTopNav profile added
1 parent 25405b7 commit c8fb8ad

File tree

16 files changed

+271
-9
lines changed

16 files changed

+271
-9
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package gwt.material.design.client.custom;
2+
3+
/*
4+
* #%L
5+
* GwtMaterial
6+
* %%
7+
* Copyright (C) 2015 GwtMaterialDesign
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.google.gwt.uibinder.client.UiChild;
24+
import com.google.gwt.user.client.DOM;
25+
import com.google.gwt.user.client.ui.ComplexPanel;
26+
import com.google.gwt.user.client.ui.Widget;
27+
28+
@SuppressWarnings("deprecation")
29+
public class CustomHeader extends ComplexPanel {
30+
31+
32+
public CustomHeader() {
33+
setElement(DOM.createElement("HEADER"));
34+
}
35+
36+
@UiChild(tagname = "child")
37+
public void addWidget(final Widget item) {
38+
add(item);
39+
}
40+
41+
public void add(Widget w) {
42+
super.add(w, getElement());
43+
}
44+
45+
public void insert(Widget w, int beforeIndex) {
46+
super.insert(w, getElement(), beforeIndex, true);
47+
}
48+
49+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package gwt.material.design.client.custom;
2+
3+
/*
4+
* #%L
5+
* GwtMaterial
6+
* %%
7+
* Copyright (C) 2015 GwtMaterialDesign
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.google.gwt.uibinder.client.UiChild;
24+
import com.google.gwt.user.client.DOM;
25+
import com.google.gwt.user.client.ui.ComplexPanel;
26+
import com.google.gwt.user.client.ui.Widget;
27+
28+
@SuppressWarnings("deprecation")
29+
public class CustomMain extends ComplexPanel {
30+
31+
32+
public CustomMain() {
33+
setElement(DOM.createElement("MAIN"));
34+
}
35+
36+
@UiChild(tagname = "child")
37+
public void addWidget(final Widget item) {
38+
add(item);
39+
}
40+
41+
public void add(Widget w) {
42+
super.add(w, getElement());
43+
}
44+
45+
public void insert(Widget w, int beforeIndex) {
46+
super.insert(w, getElement(), beforeIndex, true);
47+
}
48+
49+
}

src/main/java/gwt/material/design/client/resources/MaterialCSS.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
public interface MaterialCSS extends CssResource {
2626
String showPanel();
2727
String fullBackground();
28+
String sideBarProfile();
2829

2930
//ADNIMATIONS
3031
String materialScale();

src/main/java/gwt/material/design/client/resources/MaterialResources.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public interface MaterialResources extends ClientBundle {
3131

3232
@Source("image.png")
3333
ImageResource image();
34+
35+
@Source("yuna.jpg")
36+
ImageResource yuna();
3437

3538
@Source("ic_progress_cancel.png")
3639
ImageResource ic_progress_cancel();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package gwt.material.design.client.ui;
2+
3+
import gwt.material.design.client.custom.CustomMain;
4+
5+
public class MaterialContainer extends CustomMain{
6+
7+
8+
public MaterialContainer() {
9+
10+
}
11+
12+
13+
14+
}

src/main/java/gwt/material/design/client/ui/MaterialFooter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ public void setType(String type) {
8686
}
8787
}
8888

89+
90+
8991
}

src/main/java/gwt/material/design/client/ui/MaterialImage.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public MaterialImage() {
3636
protected void onAttach() {
3737
// TODO Auto-generated method stub
3838
super.onAttach();
39-
this.setWidth("100%");
4039
this.addStyleName("responsive-img");
4140
onInitMaterialDesign();
4241

src/main/java/gwt/material/design/client/ui/MaterialLink.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class MaterialLink extends FocusPanel {
4242
private String tooltipDelay = "50";
4343
private Widget container;
4444

45+
46+
private boolean separator = false;
4547
private boolean active = false;
4648

4749
public MaterialLink() {
@@ -199,5 +201,37 @@ public native void initToolTip()/*-{
199201
$wnd.jQuery('.tooltipped').tooltip({delay: 50});
200202
});
201203
}-*/;
204+
205+
206+
207+
public boolean isActive() {
208+
return active;
209+
}
210+
211+
212+
213+
public void setActive(boolean active) {
214+
this.active = active;
215+
if(active){
216+
this.addStyleName("active");
217+
}
218+
}
219+
220+
221+
222+
public boolean isSeparator() {
223+
return separator;
224+
}
225+
226+
227+
228+
public void setSeparator(boolean separator) {
229+
this.separator = separator;
230+
if(separator){
231+
this.getElement().setAttribute("style", "border-bottom: 1px solid #e9e9e9;");
232+
}
233+
}
234+
235+
202236

203237
}

src/main/java/gwt/material/design/client/ui/MaterialNavBar.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
import gwt.material.design.client.custom.CustomAnchor;
24+
import gwt.material.design.client.custom.CustomHeader;
2425
import gwt.material.design.client.custom.CustomNav;
2526

2627
import com.google.gwt.core.client.GWT;
@@ -43,7 +44,7 @@ interface MaterialNavBarUiBinder extends UiBinder<Widget, MaterialNavBar> {
4344
}
4445

4546
@UiField
46-
HTMLPanel navBar;
47+
CustomHeader navBar;
4748
@UiField
4849
CustomAnchor anchor, navMenu;
4950
@UiField
@@ -56,6 +57,7 @@ interface MaterialNavBarUiBinder extends UiBinder<Widget, MaterialNavBar> {
5657
private String align = "";
5758
private String wave = "";
5859
private String sideBar = "";
60+
private String sideBarWidth = "";
5961

6062
public MaterialNavBar() {
6163
initWidget(uiBinder.createAndBindUi(this));
@@ -78,7 +80,7 @@ protected void onAttach() {
7880
String name = String.valueOf(hashCode());
7981
navMenu.getElement().setAttribute("data-activates", name);
8082
mobileNav.getElement().setId(name);
81-
initNavBar();
83+
initNavBar(Integer.parseInt(getSideBarWidth()));
8284

8385
}
8486

@@ -93,8 +95,11 @@ public void addWidgetSideNav(final Widget item) {
9395
}
9496

9597

96-
public static native void initNavBar()/*-{
97-
$wnd.jQuery(".button-collapse").sideNav();
98+
public static native void initNavBar(int width)/*-{
99+
$wnd.jQuery(".button-collapse").sideNav({
100+
menuWidth: width
101+
}
102+
);
98103
}-*/;
99104

100105
public static native void hideNav()/*-{
@@ -225,5 +230,14 @@ public void setSideBar(String sideBar) {
225230
mobileNav.addStyleName(sideBar);
226231
}
227232

233+
public String getSideBarWidth() {
234+
return sideBarWidth;
235+
}
236+
237+
public void setSideBarWidth(String sideBarWidth) {
238+
this.sideBarWidth = sideBarWidth;
239+
mobileNav.setWidth(sideBarWidth + "px");
240+
}
241+
228242

229243
}

src/main/java/gwt/material/design/client/ui/MaterialTopNav.java

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import gwt.material.design.client.resources.MaterialResources;
2424

2525
import com.google.gwt.core.client.GWT;
26+
import com.google.gwt.dom.client.Style.FontWeight;
2627
import com.google.gwt.dom.client.Style.Unit;
2728
import com.google.gwt.resources.client.ImageResource;
2829
import com.google.gwt.uibinder.client.UiBinder;
@@ -51,8 +52,12 @@ interface MaterialTopNavUiBinder extends UiBinder<Widget, MaterialTopNav> {
5152
private String textColor = "white";
5253
private String fontSize ;
5354
private String padding = "";
55+
private String type = "";
5456
private ImageResource resource;
5557
private String url;
58+
59+
private String profileImageUrl = "";
60+
private String profileName = "";
5661

5762
public MaterialTopNav() {
5863
initWidget(uiBinder.createAndBindUi(this));
@@ -136,7 +141,7 @@ public void setUrl(String url) {
136141

137142
private void generateBackground(String url){
138143
panel.addStyleName(MaterialResources.INSTANCE.materialcss().fullBackground());
139-
panel.getElement().setAttribute("style", "background-image: url(" + url + ");" );
144+
panel.getElement().setAttribute("style", "background-image: url(" + url + "); background-size: 100%;" );
140145
}
141146

142147
public String getFontSize() {
@@ -148,4 +153,52 @@ public void setFontSize(String fontSize) {
148153
this.getElement().getStyle().setFontSize(Double.valueOf(fontSize), Unit.EM);
149154
}
150155

156+
public String getType() {
157+
return type;
158+
}
159+
160+
public void setType(String type) {
161+
this.type = type;
162+
if(type.equals("sidebar")){
163+
panel.addStyleName("sidebar");
164+
}
165+
}
166+
167+
168+
169+
private void generateProfile(){
170+
panel.clear();
171+
MaterialImage profile = new MaterialImage();
172+
MaterialLink link = new MaterialLink();
173+
link.getElement().getStyle().setFontWeight(FontWeight.BOLD);
174+
link.setTextColor("white");
175+
link.setText(profileName);
176+
profile.setType("circle");
177+
profile.setUrl(profileImageUrl);
178+
profile.getElement().getStyle().setWidth(60, Unit.PX);
179+
profile.getElement().getStyle().setHeight(60, Unit.PX);
180+
panel.add(profile);
181+
panel.add(link);
182+
customPanel.getElement().getStyle().setMarginTop(20, Unit.PX);
183+
panel.add(customPanel);
184+
}
185+
186+
public String getProfileName() {
187+
return profileName;
188+
}
189+
190+
public void setProfileName(String profileName) {
191+
this.profileName = profileName;
192+
generateProfile();
193+
}
194+
195+
public String getProfileImageUrl() {
196+
return profileImageUrl;
197+
}
198+
199+
public void setProfileImageUrl(String profileImageUrl) {
200+
this.profileImageUrl = profileImageUrl;
201+
generateProfile();
202+
}
203+
151204
}

0 commit comments

Comments
 (0)