pebble / pebblejs

Program the Pebble with simply JavaScript
MIT License
456 stars 229 forks source link

Color Adaptation Handled Poorly (Aplite) #126

Open gitgud-software opened 8 years ago

gitgud-software commented 8 years ago

a comparison

The current Aplite builds for pebblejs adapt colors and make decisions about them poorly. As demonstrated by the comparison above, it is not always in the best interest of the developer to let the choice of color scheme for Aplite be handled by the build script. Ideally, decisions regarding how the app looks in Aplite should be possible to determine as a separate attributes.

{
  ...
  backgroundColor: 'blue',
  backgroundColorAplite: 'black',
  textColor: 'white',
  textColorAplite: 'white',
  ...
}

Color handling should only switch to defaults when an Aplite color attribute is not specified for an element.

Meiguro commented 8 years ago

Ah, good point, I'll need to think about how to handle this (or use your suggestion!). Probably something similar to the PBL_IF_COLOR macros in C would be preferable. In the mean time, you can use the undocumented Platform module:

var Platform = require('platform');
var color = Platform.version() === 'aplite' ? 'black' : 'blue';

The platform module was made for internal use, but I think it's very unlikely that usage would change. Its version function is a tiny wrapper around Pebble.getActiveWatchInfo().platform which is not always available.

gitgud-software commented 8 years ago

This is incredibly helpful actually, I'm surprised it isn't in the documentation in the first place now that we have most applications building for multiple platforms. Glad to see that the support is there at least.