Skip to content

Commit

Permalink
Added dark theme support
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzlou7979 committed Jan 11, 2020
1 parent d2d9aef commit 82326c5
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 443 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# gwt-material-pwa-archetype
PWA (Progressive Web App) + GMD Archetype

# Current Version - 2.3
# Current Version - 2.3.0
### Includes
- Updated GWT Version to 2.8.2
- Updated GWTP Version to 1.5.3
- Updated GMD Version to 2.3
- Updated GMD Version to 2.3.0

# Usage:
1. Download the archetype
Expand All @@ -19,15 +19,15 @@ PWA (Progressive Web App) + GMD Archetype

mvn archetype:generate -DarchetypeGroupId=com.github.gwtmaterialdesign \
-DarchetypeArtifactId=gwt-material-pwa-archetype \
-DarchetypeVersion=2.3
-DarchetypeVersion=2.3.0

4. Follow the prompts. That's it!

5. Optionally you could specify all the parameters in the command line instead of following the prompts:

mvn archetype:generate -DarchetypeGroupId=com.github.gwtmaterialdesign \
-DarchetypeArtifactId=gwt-material-pwa-archetype \
-DarchetypeVersion=2.3 \
-DarchetypeVersion=2.3.0 \
-DgroupId=your.company.domain \
-Dpackage=your.company.domain.myapp \
-DartifactId=your-project \
Expand Down
2 changes: 1 addition & 1 deletion gwt-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<gwt.version>2.8.2</gwt.version>
<gwtp.version>1.6</gwtp.version>
<gin.version>2.1.2</gin.version>
<gwt-material.version>2.3-SNAPSHOT</gwt-material.version>
<gwt-material.version>2.3.0</gwt-material.version>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.3-SNAPSHOT</version>
<version>2.3.0</version>
</parent>

<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-pwa-archetype</artifactId>
<version>2.3-SNAPSHOT</version>
<version>2.3.0</version>
<packaging>jar</packaging>

<distributionManagement>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/maven/archetype-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<defaultValue>${groupId}</defaultValue>
</requiredProperty>
<requiredProperty key="gwt-material-version">
<defaultValue>2.3</defaultValue>
<defaultValue>2.3.0</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<gwt.version>2.8.2</gwt.version>
<gwtp.version>1.6</gwtp.version>
<gin.version>2.1.2</gin.version>
<gwt-material.version>2.3-SNAPSHOT</gwt-material.version>
<gwt-material.version>2.3.0</gwt-material.version>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2017 GwtMaterialDesign
* Copyright (C) 2015 - 2020 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,14 +17,14 @@
* limitations under the License.
* #L%
*/
package ${package}.client.resources;
package ${package}.client.application;

import javax.inject.Inject;
import ${package}.client.resources.AppResources;
import gwt.material.design.client.theme.dark.DarkThemeLoader;

public class ResourceLoader {
@Inject
ResourceLoader(AppResources appResources) {
appResources.normalize().ensureInjected();
appResources.style().ensureInjected();
public class AppDarkThemeLoader extends DarkThemeLoader {

public AppDarkThemeLoader() {
super(AppResources.INSTANCE.appDarkCss());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
*/
package ${package}.client.application;

import ${package}.client.resources.AppResources;
import com.google.gwt.event.shared.GwtEvent;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.google.gwt.dom.client.StyleInjector;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.ProxyStandard;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import gwt.material.design.addins.client.dark.AddinsDarkThemeLoader;
import gwt.material.design.client.theme.dark.CoreDarkThemeLoader;
import gwt.material.design.client.theme.dark.DarkThemeManager;

public class ApplicationPresenter
extends Presenter<ApplicationPresenter.MyView, ApplicationPresenter.MyProxy> {
Expand All @@ -47,4 +52,18 @@ interface MyProxy extends Proxy<ApplicationPresenter> {
MyProxy proxy) {
super(eventBus, view, proxy, RevealType.Root);
}

@Override
protected void onBind() {
super.onBind();

// Dark Theme Mode
DarkThemeManager.get()
.register(new CoreDarkThemeLoader())
.register(new AddinsDarkThemeLoader())
.register(new AppDarkThemeLoader())
.load();

StyleInjector.inject(AppResources.INSTANCE.appCss().getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@
<m:MaterialHeader>
<m:MaterialNavBar ui:field="navBar" activates="sidenav" backgroundColor="INDIGO">
<m:MaterialNavBrand fontSize="1.2em" text="${projectName}" />
<m:MaterialNavSection float="RIGHT">
<m:MaterialNavSection float="RIGHT" hideOn="NONE">
<m:MaterialDarkModeToggle/>
<m:MaterialLink text="Link 1"/>
<m:MaterialLink iconType="POLYMER" />
</m:MaterialNavSection>
</m:MaterialNavBar>
</m:MaterialHeader>

<m:MaterialSideNavPush m:id="sidenav" width="280">
<m:MaterialLink text="Link 1" iconType="POLYMER"/>
<m:MaterialLink text="Link 2" iconType="POLYMER"/>
<m:MaterialLink text="Link 3" iconType="POLYMER"/>
<m:MaterialLink text="Link 1" />
<m:MaterialLink text="Link 2" />
<m:MaterialLink text="Link 3" />
</m:MaterialSideNavPush>

<m:MaterialContainer ui:field="container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import ${package}.client.application.ApplicationModule;
import ${package}.client.place.NameTokens;
import ${package}.client.resources.ResourceLoader;
import com.gwtplatform.mvp.client.annotations.DefaultPlace;
import com.gwtplatform.mvp.client.annotations.ErrorPlace;
import com.gwtplatform.mvp.client.annotations.UnauthorizedPlace;
Expand All @@ -34,8 +33,6 @@ protected void configure() {
install(new DefaultModule.Builder().build());
install(new ApplicationModule());

bind(ResourceLoader.class).asEagerSingleton();

// DefaultPlaceManager Places
bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.HOME);
bindConstant().annotatedWith(ErrorPlace.class).to(NameTokens.HOME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
*/
package ${package}.client.resources;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.TextResource;

public interface AppResources extends ClientBundle {
interface Normalize extends CssResource {
}

interface Style extends CssResource {
}
AppResources INSTANCE = GWT.create(AppResources.class);

@Source("css/normalize.gss")
Normalize normalize();
@Source("css/app.css")
TextResource appCss();

@Source("css/style.gss")
Style style();
@Source("css/app-dark.css")
TextResource appDarkCss();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Dark theme Style for your application specific styles **/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Default Style for your application specific styles **/
Loading

0 comments on commit 82326c5

Please sign in to comment.