Dojo Mobile Themes
An application running on Android needn't (and probably shouldn't) look exactly the same as the
same application running on iOS. Both operating systems provide native "look and feels" which a
user has come to expect to see when working with an application on a particular OS. Dojo Mobile
provides the capability for the same developed application to appear/look like a "native"
application. To do this, it needs to change the appearance of the widgets depending on whether
they are running on one OS or another. This concept is generally termed "themeing". Dojo
supplies themes for Android and iOS.
The View Model
When we work with applications in the desktop environment, we are familiar with the notion of
new windows appearing as we navigate from one part of an application to another. In the mobile
platform, this may not be possible because of limited screen space and, even when screen space is
available, the notion of a "window" is alien.
The architecture of Dojo Mobile is that we have "views" which correspond to a full screen of data.
When a Dojo view is added it consumes all the available space. A page can have multiple views
but only one view is ever visible at a time. What we wish to do is to present a view and then allow
the user to navigate between the views.
There are a number of types of views available including:
• dojox/mobile/View
• dojox/mobile/ScrollableView
• dojox/mobile/SwapView
When a view is shown or hidden, a set of events are fired associated with that view. We can
register callback functions that can do work based on these events. These callbacks can update the
data in the views or other tasks in order to prepare the data for visualization or save data that was
previously entered.
We can register these with the Dojo "on" function which takes the format:
on(widget, event, function)
for example:
on(myView, "beforetransitionin", function(...) { … });
The events which can be connected are:
• onStartView – Called when the view is default
• onBeforeTransitionIn
• onAfterTransitionIn
• onBeforeTransitionOut
• onAfterTransitionOut
Note for use with the Dojo "on" function, the event names have the "on" prefix removed and are
lower-cased.
Views provide an explicitly callable method named "performTransition()" which performs
a view switch from one view to another. The parameters to this method are:
• moveTo – The name of the view that will be newly shown
Page 228
Kommentare zu diesen Handbüchern