ebryn / ember-titanium

Titanium Mobile wrapped in Ember (formerly SproutCore-Titanium)
41 stars 2 forks source link

Proposal for handling stupid Titanium constants #9

Closed brianpattison closed 13 years ago

brianpattison commented 13 years ago

I know you hate the impossible to remember constants. I happen to be thinking about it and thought of one possible solution.

We could do something similar for tiOptions as we have for renamed tiEvents. As an example, in SCTi.Button's tiOptions we could have style:styleContstant.

Then we could define styleConstant as a SproutCore computed property within SCTi.Button:

styleContstant: function() {
  var style = this.get('style'),
      styleConstant = Titanium.UI.iPhone.SystemButtonStyle.PLAIN;

  // Handle whether style was already given as a constant
  // Handle converting a simple string like 'done' to the constant Titanium.UI.iPhone.SystemButtonStyle.DONE
  // Handle differences between iPhone and Android

  return styleConstant;
}.property('style').cacheable()

Constants would be handled as usual and easy to remembered shortcuts could be used easily as well!

ebryn commented 13 years ago

Check out my implementation and let me know what you think - https://github.com/ebryn/sproutcore-titanium/commit/73239ffe7fbe5f594c59ba26e2e6a986b3b85e3f