From 82326c519914ba90beda3239e179d99071415394 Mon Sep 17 00:00:00 2001 From: Mark Kevin Baldemor Date: Sat, 11 Jan 2020 11:47:52 +0800 Subject: [PATCH] Added dark theme support --- README.md | 8 +- gwt-test/pom.xml | 2 +- pom.xml | 4 +- .../META-INF/maven/archetype-metadata.xml | 2 +- .../resources/archetype-resources/pom.xml | 2 +- .../AppDarkThemeLoader.java} | 16 +- .../application/ApplicationPresenter.java | 23 +- .../client/application/ApplicationView.ui.xml | 9 +- .../main/java/client/gin/ClientModule.java | 3 - .../java/client/resources/AppResources.java | 15 +- .../client/resources/css/app-dark.css | 1 + .../resources/client/resources/css/app.css | 1 + .../client/resources/css/normalize.gss | 409 ------------------ .../resources/client/resources/css/style.gss | 0 14 files changed, 52 insertions(+), 443 deletions(-) rename src/main/resources/archetype-resources/src/main/java/client/{resources/ResourceLoader.java => application/AppDarkThemeLoader.java} (64%) create mode 100644 src/main/resources/archetype-resources/src/main/resources/client/resources/css/app-dark.css create mode 100644 src/main/resources/archetype-resources/src/main/resources/client/resources/css/app.css delete mode 100644 src/main/resources/archetype-resources/src/main/resources/client/resources/css/normalize.gss delete mode 100644 src/main/resources/archetype-resources/src/main/resources/client/resources/css/style.gss diff --git a/README.md b/README.md index 3e47a2e..bf575fb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -19,7 +19,7 @@ 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! @@ -27,7 +27,7 @@ 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 \ -DgroupId=your.company.domain \ -Dpackage=your.company.domain.myapp \ -DartifactId=your-project \ diff --git a/gwt-test/pom.xml b/gwt-test/pom.xml index 12e968c..c67c61b 100644 --- a/gwt-test/pom.xml +++ b/gwt-test/pom.xml @@ -36,7 +36,7 @@ 2.8.2 1.6 2.1.2 - 2.3-SNAPSHOT + 2.3.0 1.8 1.8 diff --git a/pom.xml b/pom.xml index f1213dc..58bd79c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,12 +4,12 @@ gwt-material-parent com.github.gwtmaterialdesign - 2.3-SNAPSHOT + 2.3.0 com.github.gwtmaterialdesign gwt-material-pwa-archetype - 2.3-SNAPSHOT + 2.3.0 jar diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index b67100b..e21d14b 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -40,7 +40,7 @@ ${groupId} - 2.3 + 2.3.0 diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index 1e4fdb0..e0f26b9 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -36,7 +36,7 @@ 2.8.2 1.6 2.1.2 - 2.3-SNAPSHOT + 2.3.0 1.8 1.8 diff --git a/src/main/resources/archetype-resources/src/main/java/client/resources/ResourceLoader.java b/src/main/resources/archetype-resources/src/main/java/client/application/AppDarkThemeLoader.java similarity index 64% rename from src/main/resources/archetype-resources/src/main/java/client/resources/ResourceLoader.java rename to src/main/resources/archetype-resources/src/main/java/client/application/AppDarkThemeLoader.java index 8422f09..7a120b1 100644 --- a/src/main/resources/archetype-resources/src/main/java/client/resources/ResourceLoader.java +++ b/src/main/resources/archetype-resources/src/main/java/client/application/AppDarkThemeLoader.java @@ -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. @@ -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()); } } diff --git a/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationPresenter.java b/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationPresenter.java index 88fada0..6436f57 100644 --- a/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationPresenter.java +++ b/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationPresenter.java @@ -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 { @@ -47,4 +52,18 @@ interface MyProxy extends Proxy { 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()); + } } diff --git a/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationView.ui.xml b/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationView.ui.xml index 9cc9e9f..11384ac 100644 --- a/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationView.ui.xml +++ b/src/main/resources/archetype-resources/src/main/java/client/application/ApplicationView.ui.xml @@ -27,7 +27,8 @@ - + + @@ -35,9 +36,9 @@ - - - + + + diff --git a/src/main/resources/archetype-resources/src/main/java/client/gin/ClientModule.java b/src/main/resources/archetype-resources/src/main/java/client/gin/ClientModule.java index 0b26e34..a30df97 100644 --- a/src/main/resources/archetype-resources/src/main/java/client/gin/ClientModule.java +++ b/src/main/resources/archetype-resources/src/main/java/client/gin/ClientModule.java @@ -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; @@ -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); diff --git a/src/main/resources/archetype-resources/src/main/java/client/resources/AppResources.java b/src/main/resources/archetype-resources/src/main/java/client/resources/AppResources.java index e162602..26232d0 100644 --- a/src/main/resources/archetype-resources/src/main/java/client/resources/AppResources.java +++ b/src/main/resources/archetype-resources/src/main/java/client/resources/AppResources.java @@ -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(); } diff --git a/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app-dark.css b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app-dark.css new file mode 100644 index 0000000..b2e55af --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app-dark.css @@ -0,0 +1 @@ +/** Dark theme Style for your application specific styles **/ \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app.css b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app.css new file mode 100644 index 0000000..0143cbf --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/app.css @@ -0,0 +1 @@ +/** Default Style for your application specific styles **/ \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/resources/client/resources/css/normalize.gss b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/normalize.gss deleted file mode 100644 index 7f4e79a..0000000 --- a/src/main/resources/archetype-resources/src/main/resources/client/resources/css/normalize.gss +++ /dev/null @@ -1,409 +0,0 @@ -/*! normalize.css v3.0.1 | MIT License | git.io/normalize */ - -/** - * 1. Set default font family to sans-serif. - * 2. Prevent iOS text size adjust after orientation change, without disabling - * user zoom. - */ - -html { - font-family: sans-serif; /* 1 */ - -ms-text-size-adjust: 100%; /* 2 */ - -webkit-text-size-adjust: 100%; /* 2 */ -} - -/** - * Remove default margin. - */ - -body { - margin: 0; -} - -/* HTML5 display definitions -========================================================================== */ - -/** - * Correct `block` display not defined for any HTML5 element in IE 8/9. - * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. - * Correct `block` display not defined for `main` in IE 11. - */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -nav, -section, -summary { - display: block; -} - -/** - * 1. Correct `inline-block` display not defined in IE 8/9. - * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. - */ - -audio, -canvas, -progress, -video { - display: inline-block; /* 1 */ - vertical-align: baseline; /* 2 */ -} - -/** - * Address `[hidden]` styling not present in IE 8/9/10. - * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. - */ - -[hidden], -template { - display: none; -} - -/* Links -========================================================================== */ - -/** - * Remove the gray background color from active links in IE 10. - */ - -a { - background: transparent; -} - -/** - * Improve readability when focused and also mouse hovered in all browsers. - */ - -a:active, -a:hover, -button:active, -button:hover { - outline: 0; -} - -/* Text-level semantics -========================================================================== */ - -/** - * Address styling not present in IE 8/9/10/11, Safari, and Chrome. - */ - -abbr[title] { - border-bottom: 1px dotted; -} - -/** - * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. - */ - -b, -strong { - font-weight: bold; -} - -/** - * Address styling not present in Safari and Chrome. - */ - -dfn { - font-style: italic; -} - -/** - * Address variable `h1` font-size and margin within `section` and `article` - * contexts in Firefox 4+, Safari, and Chrome. - */ - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -/** - * Address styling not present in IE 8/9. - */ - -mark { - background: #ff0; - color: #000; -} - -/** - * Address inconsistent and variable font size in all browsers. - */ - -small { - font-size: 80%; -} - -/** - * Prevent `sub` and `sup` affecting `line-height` in all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -/* Embedded content -========================================================================== */ - -/** - * Remove border when inside `a` element in IE 8/9/10. - */ - -img { - border: 0; -} - -/* Grouping content -========================================================================== */ - -/** - * Address margin not present in IE 8/9 and Safari. - */ - -figure { - margin: 1em 40px; -} - -/** - * Address differences between Firefox and other browsers. - */ - -hr { - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0; -} - -/** - * Contain overflow in all browsers. - */ - -pre { - overflow: auto; -} - -/** - * Address odd `em`-unit font size rendering in all browsers. - */ - -code, -kbd, -pre, -samp { - font-family: monospace, monospace; - font-size: 1em; -} - -/* Forms -========================================================================== */ - -/** - * Known limitation: by default, Chrome and Safari on OS X allow very limited - * styling of `select`, unless a `border` property is set. - */ - -/** - * 1. Correct color not being inherited. - * Known issue: affects color of disabled elements. - * 2. Correct font properties not being inherited. - * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. - */ - -button, -input, -optgroup, -select, -textarea { - color: inherit; /* 1 */ - font: inherit; /* 2 */ - margin: 0; /* 3 */ -} - -/** - * Address `overflow` set to `hidden` in IE 8/9/10/11. - */ - -button { - overflow: visible; -} - -/** - * Address inconsistent `text-transform` inheritance for `button` and `select`. - * All other form control elements do not inherit `text-transform` values. - * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. - * Correct `select` style inheritance in Firefox. - */ - -button, -select { - text-transform: none; -} - -/** - * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` - * and `video` controls. - * 2. Correct inability to style clickable `input` types in iOS. - * 3. Improve usability and consistency of cursor style between image-type - * `input` and others. - */ - -button, -html input[type="button"], /* 1 */ -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; /* 2 */ - cursor: pointer; /* 3 */ -} - -/** - * Re-set default cursor for disabled elements. - */ - -button[disabled], -html input[disabled] { - cursor: default; -} - -/** - * Remove inner padding and border in Firefox 4+. - */ - -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} - -/** - * Address Firefox 4+ setting `line-height` on `input` using `!important` in - * the UA stylesheet. - */ - -input { - line-height: normal; -} - -/** - * It's recommended that you don't attempt to style these elements. - * Firefox's implementation doesn't respect box-sizing, padding, or width. - * - * 1. Address box sizing set to `content-box` in IE 8/9/10. - * 2. Remove excess padding in IE 8/9/10. - */ - -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Fix the cursor style for Chrome's increment/decrement buttons. For certain - * `font-size` values of the `input`, it causes the cursor style of the - * decrement button to change from `default` to `text`. - */ - -input[type="number"]::-webkit-inner-spin-button, -input[type="number"]::-webkit-outer-spin-button { - height: auto; -} - -/** - * 1. Address `appearance` set to `searchfield` in Safari and Chrome. - * 2. Address `box-sizing` set to `border-box` in Safari and Chrome - * (include `-moz` to future-proof). - */ - -input[type="search"] { - -webkit-appearance: textfield; /* 1 */ - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; /* 2 */ - box-sizing: content-box; -} - -/** - * Remove inner padding and search cancel button in Safari and Chrome on OS X. - * Safari (but not Chrome) clips the cancel button when the search input has - * padding (and `textfield` appearance). - */ - -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/** - * Define consistent border, margin, and padding. - */ - -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} - -/** - * 1. Correct `color` not being inherited in IE 8/9/10/11. - * 2. Remove padding so people aren't caught out if they zero out fieldsets. - */ - -legend { - border: 0; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Remove default vertical scrollbar in IE 8/9/10/11. - */ - -textarea { - overflow: auto; -} - -/** - * Don't inherit the `font-weight` (applied by a rule above). - * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. - */ - -optgroup { - font-weight: bold; -} - -/* Tables -========================================================================== */ - -/** - * Remove most spacing between table cells. - */ - -table { - border-collapse: collapse; - border-spacing: 0; -} - -td, -th { - padding: 0; -} diff --git a/src/main/resources/archetype-resources/src/main/resources/client/resources/css/style.gss b/src/main/resources/archetype-resources/src/main/resources/client/resources/css/style.gss deleted file mode 100644 index e69de29..0000000