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

Relative positioning, localized string support, and Chameleon updates for strings #342

Merged
merged 14 commits into from Feb 21, 2013

Conversation

Projects
None yet
2 participants
@djMax

djMax commented Feb 20, 2013

Four main components here:

  1. Relative positioning for CSS. Using the -mobile-relative property with an element id or .first/.last/.next/.prev and margin-top/bottom/left/right, one can position elements by absolute pixel units or percentage of the specified element. "auto" will align centers on that dimension.

  2. Localized string support. Using the -mobile-text-key property, a CSS file can specify the name of a localized string entry and the engine will apply that to the title/text property as appropriate. The engine for resolving keys to strings is pluggable with a default that just calls NSLocalizedString.

  3. Chameleon support for strings files. When the strings file changes, the app will pick it up and the default string resolver will use that file first before falling back on NSLocalizedString. Also, with a special prefix on that file, the engine will show all the string key names in the interface instead of the value. This makes it easy for a copywriter or tester to see exactly what string is used where, and can be toggled at runtime multiple times. In production since Chameleon isn't used, there is essentially zero overhead since we just check for non-nil overrides (which will never be non-nil). There may be some work left here to rationalize projects which have multiple strings files. At the moment, if you change any language file, the interface is likely to change to that language file. I think this is a feature, but could be convinced it's a bug because it doesn't fully switch the app into that locale.

  4. A small but powerful styled view builder that you will love or hate. It allows complex view construction with a javascript like syntax where each element of the array is interpreted according to its type - a view starts a new "directive", a string with a # means the element id, string with a . means the CSS class, any other string is the accessibility label. A localized string (NIUserInterfaceString) will be set as the title/text and then update via Chameleon, an NSInvocation will be the touchupinside target, and an NSArray will construct a set of subviews. You can see in the sample app it's taken about 50 lines of boilerplate code down to 10. Also supports NSDictionary for folks who have a religious aversion to javascript like syntax with more intentional key/value mapping - but it can support both at the same time.

Also, supports maxHeight, maxWidth, button image adjustment. Added addCssClass/removeCssClass for runtime modification of characteristics. For example you can remove/add a class inside an animation block and it will animate the change. To do all this I had to deprecate the applyRuleSet method in favor of applyRuleSet:inDOM:, but it should be backwards compatible.

Updated the sample app to use all this stuff.

@jverkoey

This comment has been minimized.

Show comment
Hide comment
@jverkoey

jverkoey Feb 20, 2013

Owner

This is looking seriously badass. Nice work :)

Owner

jverkoey commented Feb 20, 2013

This is looking seriously badass. Nice work :)

[css] Addressed constant naming convention and converted category to …
…simple C methods. Also added dictionary support to view builder
@djMax

This comment has been minimized.

Show comment
Hide comment
@djMax

djMax Feb 20, 2013

And thanks, this has been fun, can't wait to redo our product with it. :)

djMax commented Feb 20, 2013

And thanks, this has been fun, can't wait to redo our product with it. :)

@jverkoey

This comment has been minimized.

Show comment
Hide comment
@jverkoey

jverkoey Feb 20, 2013

Owner

Are you working at PayPal still? Can't wait to see what comes of this :)

Owner

jverkoey commented Feb 20, 2013

Are you working at PayPal still? Can't wait to see what comes of this :)

@djMax

This comment has been minimized.

Show comment
Hide comment
@djMax

djMax Feb 20, 2013

I am! I'm in the Boston office now via some circuitous luck. Most fun I've had in a long long time. We use Nimbus on PayPal Here, but I'm hoping with this we can really "go deep" from prototyping through delivery using the overall approach. Any code that isn't core to PayPal functionality and is interesting to others I'd rather find a well structured open source home for than keep inside the walls.

On Feb 20, 2013, at 3:14 PM, Jeff Verkoeyen notifications@github.com wrote:

Are you working at PayPal still? Can't wait to see what comes of this :)


Reply to this email directly or view it on GitHub.

djMax commented Feb 20, 2013

I am! I'm in the Boston office now via some circuitous luck. Most fun I've had in a long long time. We use Nimbus on PayPal Here, but I'm hoping with this we can really "go deep" from prototyping through delivery using the overall approach. Any code that isn't core to PayPal functionality and is interesting to others I'd rather find a well structured open source home for than keep inside the walls.

On Feb 20, 2013, at 3:14 PM, Jeff Verkoeyen notifications@github.com wrote:

Are you working at PayPal still? Can't wait to see what comes of this :)


Reply to this email directly or view it on GitHub.

@jverkoey

This comment has been minimized.

Show comment
Hide comment
@jverkoey

jverkoey Feb 20, 2013

You should put your own name here instead :)

jverkoey commented on src/core/src/NIInvocationMethods.h in 97a9039 Feb 20, 2013

You should put your own name here instead :)

jverkoey added a commit that referenced this pull request Feb 21, 2013

Merge pull request #342 from djMax/djMaxM_css_nirvana
Relative positioning, localized string support, and Chameleon updates for strings

@jverkoey jverkoey merged commit 9772a17 into jverkoey:master Feb 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment