Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

uMobile Specific Architecture

Facade

...

Façade

  • Located at Resources/js/Facade.js
  • A singleton with access to all views, models, and some controllers. 
  • Also provides access to other intormation (localization, stylesheet)
  • mostly concerned with providing global constants for events and states, such as events for session changes.
  • Usually called "app" inside controllers. Gets into window controllers by creating an "app" attribute when creating the window in app.js

Local Dictionary

  • Allows translation of all native text (not text provided from web services or web views)
  • In project root: localization.js
  • Currently contains en_US
  • Could easily add another language, and switch the property in config.js: Titanium.App.Properties.setString('locale','en_US');
  • Implement in any controller or view that has access to the facade, app.localDictionary.key: require('/js/localization')[Titanium.App.Properties.getString('locale')]. Will automatically display the correct language.
  • Will eventually allow for user customization, or retrieval of portal preferences for locale.

Models/Proxies

  • Are responsible for managing data for native windows (map points for search, directory entries for search).
  • Found in js/models. 
  • Aren't aware of controllers, provide public methods to access data and search for data
  • Broadcast application-level events (for now) , found in the Facade, so that controllers can respond to model events (such as search begin, search complete, login complete) 

Controllers

  • Each window that is opened in app.js is bound to a controller, found in js/controllers.
  • Responsible for initializing views, reacting to events, and displaying data.Currently, tightly coupled with views, although much view logic has been abstracted into factory-type scripts

Views/Factories

  • Found in js/views.

Views/Factories

  • Accept two arguments: facade instance, and optional attributes object to be passed into Titanium to render view. 
  • Found in js/views
  • Views are usually added as references to the facade, sometimes as instances (as in the case of the global alert window which has no reason to have multiple instances.). 
  • Usually instantiated with new keyword, titleBar = new app.views.GenericTitleBar(app,{backgroundColor: '#f00'});
  • Most views are for use in specific window controllers.
  • Common UI views are found in js/views/UI, and usually create objects by requiring the module and then invoking a create___() method to generate unique instances of views. Eg: require('/js/views/UI/TitleBar').createTitleBar()

"Stylesheet"

  • A Javascript dictionary of styles, attached to the facade as "styles".Global stylesheet in resources root: style.cssloaded by calling require('/js/style');
  • Not automatically applied to elements with selectors, each "class" must be passed in as object to view factories during creation, such as searchButton = Titanium.UI.createButton(app.styles.searchButton);