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: support semantic/named colors for color properties #11699
Conversation
Tests:
|
|
||
if (semanticColors == nil) { | ||
NSString *colorsPath = [NSBundle.mainBundle pathForResource:@"semantic.colors" ofType:@"json"]; | ||
if (![NSFileManager.defaultManager fileExistsAtPath:colorsPath]) { |
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.
Do we need to worry about an encrypted version of the file?
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.
Are JSON resource files encrypted as well? Looking at a recent production build, it doesn't seem to.
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.
We don't encrypt JSON files under "Resources". So, we should be okay, but it doesn't hurt to test with a device build just in case.
(We do encrypt our internal bootstrap JSON and app properties JSON though. Our build system is capable of doing this for all JSON files if we wanted to.)
return nil; | ||
} | ||
|
||
NSString *currentTraitCollection = TiApp.controller.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? @"dark" : @"light"; |
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 new chunk of code feels like it should live in the common
JS area, but I don't see how we could do that and have it effectively hijack all the possible places where colors are set (i.e. all the proxies with various color properties).
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.
Yep, that was the reason to do it here. And since the JSON only needs to be loaded once, it doesn't cause an overhead to process the array (which wouldn't be a problem on the JS side as well though).
@hansemannn If you keep the SDK's npm packages up to date while developing, it should use a husky hook to auto-format the source on IOS when you commit. Otherwise, try |
I updated it, but running |
@hansemannn You should be able to plop the tests and Resources files into the |
Note also, the semantic.colors.json file seems to have broken the actual iOS app build?
|
@sgtcoolguy I will check that one! I thought it might be cool to have a semantic.colors.json in development as well, but it seems like some refs of it are taken over to the app template and cause duplicate resource issues there. |
I'm afraid that I won't be able to update the sample app and remove the demo files from the project before next week, so we may need to close this or hand it over! |
@sgtcoolguy I removed the file again and added a (very basic) mocha test: https://github.com/appcelerator/titanium-mobile-mocha-suite/pull/255 |
Relates to #11315 |
|
||
NSString *currentTraitCollection = TiApp.controller.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? @"dark" : @"light"; | ||
|
||
return [Webcolor webColorNamed:colorMap[currentTraitCollection]]; |
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.
I think this will cause an infinite loop...
5180ae0
to
226ee8f
Compare
Alos support ArrayBuffer.isView and BYTES_PER_ELEMENT sniffing pixelmatch does
gets pngjs and browserify zlib working
**/ | ||
async function getSDKInstallDir() { | ||
// TODO: Use fork since we're spawning off another node process | ||
const { stdout, _stderr } = await exec(`node "${titanium}" info -o json -t titanium`); |
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.
⚠️ tests/scripts/test.js line 79 – '_stderr' is assigned a value but never used. (no-unused-vars)
JIRA: https://jira.appcelerator.org/browse/TIMOB-27895
Notes:
This adds the following:
Ti.UI.Color
proxy on AndroidtoHex()
method that returns the color's hex string as ARRGGBB formatTi.UI.Android.getColorResource()
which can take a numeric argument (for the resource id for the color) or a string argument (for the short color name).Ti.UI.Android.getColorResource(Ti.Android.R.color.darker_gray)
orTi.UI.Android.getColorResource('holo_blue_bright')
Ti.UI.Color
proxy instance that wraps the underlyingandroid.graphics.Color
instancergb()
,rgba()
and some of the standard web color names like'cyan'
,'magenta'
, etc)Ti.UI.fetchSemanticColor()
will fall back to usingTi.UI.Android.getColorResource()
under the hood if the name isn't in thesemantic.colors.json
file but there is aTi.Android.R.color[name]
entry (and will still return a valid string to be passed to a color property, should be a hex string in this case).