-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): semantic colors and night mode #11301
Conversation
|
4ab4f4b
to
8a52141
Compare
@Kroll.constant | ||
public static final int MODE_NIGHT_YES = Configuration.UI_MODE_NIGHT_YES; | ||
@Kroll.constant | ||
public static final int MODE_NIGHT_UNDEFINED = Configuration.UI_MODE_NIGHT_UNDEFINED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you map nightModeStatus
to the existing https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI-property-semanticColorType property and it's Ti.UI.SEMANTIC_COLOR_TYPE_DARK
+ SEMANTIC_COLOR_TYPE_LIGHT
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those constants are used as values of Ti.UI.Android.nightModeStatus
which is an Android analogue of Titanium.App.iOS.userInterfaceStyle
.
I believe Titanium.App.iOS.userInterfaceStyle
does not return SEMANTIC_COLOR_TYPE_DARK
or SEMANTIC_COLOR_TYPE_LIGHT, does it (never checked, docs says it is
String[]`)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns a Number (USER_INTERFACE_STYLE_UNSPECIFIED = 0, USER_INTERFACE_STYLE_LIGHT = 1, USER_INTERFACE_STYLE_DARK = 2). So if you change the docs, it should be all set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USER_INTERFACE_STYLE_*
constants are defined in Ti.App.iOS
namespace.
android/cli/commands/_build.js
Outdated
@@ -3554,6 +3555,96 @@ AndroidBuilder.prototype.generateI18N = function generateI18N(next) { | |||
next(); | |||
}; | |||
|
|||
AndroidBuilder.prototype.generateSemanticColors = function generateSemanticColors(next) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also allow the UI to "refresh" automatically? Otherwise I wonder whats the benefit over using the existing one. Thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method generates two resource-files with colors defined in them:
- /res/values/semantic.colors.xml
- /res/values-night/semantic.colors.xml
The goal is to be able to reuse these color in custom theme without defining them again.
Automatic "refresh" will require to restart activity (all of them), AFAIK we never do this in Titanium.
FYI: We're feature freezing Titanium 8.3.0. The plan is to release 8.3.0 in the very near future. Our current focus is "gradle" support in Titanium 9.0.0 and we don't really want any more changes that will cause merge conflicts at the moment. Also, I think it's important that we line-up the dark/light mode handling between Android and iOS as much as possible. That may mean moving our |
@jquick-axway At least for the constants, I think it's a pretty lightweight change for parity. Right now, it's already on the parity namespace ( |
guess this won't make it into 9.0.0? Would be nice to have parity for the dark-mode that is already working on iOS |
@m1ga It works well without these changes (we're not using it and have night mode support live in production). |
@hansemannn interesting. For me |
Oh, we made an own module for that (to stay SDK independent). I'll send it to you tomorrow! |
20e4b1d
to
9500e22
Compare
Conflicts resolved. One of the features provided by this PR is:
So you will be able to use the same colors in custom |
- generate color resources from semantic.colors.json - add Ti.UI.Android.nightModeStatus API - add Ti.UI.Android.MODE_NIGHT_* constants refs TIMOB-27501
Closed in favor of now-merged #11457 Thanks again @drauggres ! |
JIRA: https://jira.appcelerator.org/browse/TIMOB-27501
Sample app:
ewanharris/darkmode-example#1