In reaction to
another thread, I took a first cut at a pattern for creating platform-aware controls leveraging the existing enyo theme framework.
The idea is to define a set of controls that each provide the same capability across platforms but are implemented or styled differently. The tab control seems to be a good example which is functionally similar but has unique behavior on each platform. To accomplish this, we'd define a base kind for each capability (Header, FooterToolbar, TabControl, etc...) under the
pac.* namespace that would establish the common interface for all platform-specific implementations. Another set of controls (e.g.
pac.webos.*) would be defined for each platform, inheriting from the appropriate base kind, which would adapt the interface for the particular platform.
The secret sauce is
pac.registerTheme (maybe
registerPlatform instead?) which ensures that only the control set relevant for the active platform is ultimately registered as a theme. The app code can then use the generic base name (e.g. "Header") instead of the pac or platform name (e.g. "pac.webos.Header") which would get resolved to the right kind by the enyo theme framework. There's a little more magic hiding in it but i'll leave it at that for now.
Take a look at the fiddle below and let me know what you think. Good idea? Gaping holes? TL;DR?
http://jsfiddle.net/ryanjduffy/4bv3V/7/
0 • •
Comments
- Spam
- Abuse
0 • Off Topic Insightful •P.S. Nice Commodore 64 joke there!
- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •