You are reading 12.8.0. See this page in 13.4.1.
Titanium.UI.DashboardView
Extends Titanium.UI.ViewTitanium.Proxy
A dashboard view is an iOS Springboard-like view of Titanium.UI.DashboardItem items that may be deleted and reordered by the user using its built-in edit mode.
The DashboardView is created using the Titanium.UI.createDashboardView method or <DashboardView>
Alloy element.
Dashboard view's edit mode may be activated by a longpress of a Titanium.UI.DashboardItem item, unless this behavior has been disabled by the editable property. As a dashboard view does not inherently provide a way to exit edit mode, this must be explicitly defined.
When edit mode has been activated, the item icons wobble by default to act as a visual cue. This behavior may be disabled using the wobble property.
If a dashboard contains more than 9 items, it will be paged into screens in a 3 x 3 formation using its built-in scrollable view. A paging control is added to the bottom of the view to indicate the active page.
Note that a dashboard is only intended to be used in PORTRAIT orientation mode.
Examples
Dashboard Demo
Create a toolbar with an edit/done button and a dashboard of items on a single screen. Set the badge value for some items, and allow them to be reset with a click. Enter edit mode with a longpress of a dashboard item (default behavior). Toggle edit mode with a click to the toolbar button.
Copy your image files to the local project /images/dashboard directory.
var win = Ti.UI.createWindow({
backgroundColor: '#13386c'
});
var button = Ti.UI.createButton({
title: 'Edit',
style: Ti.UI.iOS.SystemButtonStyle.DONE,
});
var toolbar = Ti.UI.iOS.createToolbar({
items: [button],
top: 0
});
win.add(toolbar);
var label = Ti.UI.createLabel({
color: 'white',
font: { fontSize: 14 },
text: 'Click an item to reset badge\nPress and hold an item to enable edit mode',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 55,
height: 40,
width: 300
});
win.add(label);
var dashboardData = [];
var itemData = [
{ name: 'account', badge: 10 },
{ name: 'cases', badge: 2 },
{ name: 'calls', badge: 2 },
{ name: 'contacts', badge: 5},
{ name: 'emps' },
{ name: 'leads' },
{ name: 'meetings', badge: 3 },
{ name: 'opps', badge: 126 }, // badge will be displayed as "99+"
{ name: 'tasks' }
];
for (var i = 0; i < itemData.length; i++) {
var item = Ti.UI.createDashboardItem({
badge: itemData[i].badge,
image: '/images/dashboard/' + itemData[i].name + '_off.png',
selectedImage: '/images/dashboard/' + itemData[i].name + '_on.png',
label: itemData[i].name
});
dashboardData.push(item);
}
var dashboard = Ti.UI.createDashboardView({
data: dashboardData,
wobble: true,
top: 100
});
win.add(dashboard);
var isEditable = false;
button.addEventListener('click', function(e) {
if (isEditable) {
dashboard.stopEditing();
} else {
dashboard.startEditing();
}
});
dashboard.addEventListener('edit', function(e) {
button.title = 'Done';
button.style = Ti.UI.iOS.SystemButtonStyle.DONE;
isEditable = true;
});
dashboard.addEventListener('commit', function(e) {
button.title = 'Edit';
button.style = Ti.UI.iOS.SystemButtonStyle.PLAIN;
isEditable = false;
});
dashboard.addEventListener('click', function(e) {
e.item.badge = 0;
});
win.open();
Alloy XML Markup
Previous example as an Alloy view.
dashboard.xml:
<Alloy>
<Window id="win" backgroundColor="#13386c">
<Toolbar id="toolbar" top="0">
<Items>
<Button id="button" onClick="changeMode">Edit</Button>
</Items>
</Toolbar>
<Label id="label" color="white" top="55" height="40" width="300">
Click an item to reset badge\nPress and hold an item to enable edit mode
</Label>
<DashboardView id="dashboard" top="100" wobble="true"
onClick="resetBadge" onEdit="handleEdit" onCommit="handleCommit">
<DashboardItem image="account_off.png" selectedImage="account_on.png" badge="10" label="account"/>
<DashboardItem image="calls_off.png" selectedImage="calls_on.png" badge="110" label="calls"/>
<DashboardItem image="cases_off.png" selectedImage="cases_on.png" label="cases"/>
<DashboardItem image="contacts_off.png" selectedImage="contacts_on.png" badge="23" label="contacts"/>
<DashboardItem image="emps_off.png" selectedImage="emps_on.png" label="employees"/>
<DashboardItem image="leads_off.png" selectedImage="leads_on.png" badge="1" label="leads"/>
<DashboardItem image="meetings_off.png" selectedImage="meetings_on.png" badge="5" label="meetings"/>
<DashboardItem image="opps_off.png" selectedImage="opps_on.png" label="opps"/>
<DashboardItem image="tasks_off.png" selectedImage="tasks_on.png" label="tasks"/>
</DashboardView>
</Window>
</Alloy>
dashboard.js:
var isEditable = false;
function changeMode(e) {
if (isEditable) {
$.dashboard.stopEditing();
} else {
$.dashboard.startEditing();
}
}
function handleEdit(e) {
$.button.title = 'Done';
$.button.style = Ti.UI.iOS.SystemButtonStyle.DONE;
isEditable = true;
}
function handleCommit(e) {
$.button.title = 'Edit';
$.button.style = Ti.UI.iOS.SystemButtonStyle.PLAIN;
isEditable = false;
}
function resetBadge(e) {
e.item.badge = 0;
}
Properties 51
Inherited from Titanium.UI.View
Whether the view should be "hidden" from (i.e., ignored by) the accessibility service.
Default: false
Inherited from Titanium.UI.View
Briefly describes what performing an action (such as a click) on the view will do.
Default: null
Inherited from Titanium.UI.View
A succint label identifying the view for the device's accessibility service.
Inherited from Titanium.UI.View
A string describing the value (if any) of the view for the device's accessibility service.
Inherited from Titanium.UI.View
Coordinate of the view about which to pivot an animation.
Inherited from Titanium.UI.View
Current position of the view during an animation.
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
backgroundColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
A background gradient for the view.
Linear and Radial Gradients
The following code excerpt creates two views, one with a linear gradient and one with a radial gradient.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var radialGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'radial',
startPoint: { x: 50, y: 50 },
endPoint: { x: 50, y: 50 },
colors: [ 'red', 'blue'],
startRadius: 50,
endRadius: 0,
backfillStart: true
}
});
var linearGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '50%' },
endPoint: { x: '100%', y: '50%' },
colors: [ { color: 'red', offset: 0.0}, { color: 'blue', offset: 0.25 }, { color: 'red', offset: 1.0 } ],
}
});
win1.add(radialGradient);
win1.add(linearGradient);
win1.open();
backgroundImage
StringInherited from Titanium.UI.View
Background image for the view, specified as a local file path or URL.
backgroundLeftCap
NumberInherited from Titanium.UI.View
Size of the left end cap.
Default: 0
backgroundRepeat
BooleanInherited from Titanium.UI.View
Determines whether to tile a background across a view.
Default: false
backgroundTopCap
NumberInherited from Titanium.UI.View
Size of the top end cap.
Default: 0
borderColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Border color of the view, as a color name or hex triplet.
borderRadius
Number | String | Array<Number> | Array<String>Inherited from Titanium.UI.View
Radius for the rounded corners of the view's border.
Default: 0
borderWidth
NumberInherited from Titanium.UI.View
Border width of the view.
Default: 0
bottom
Number | StringInherited from Titanium.UI.View
View's bottom position, in platform-specific units.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Inherited from Titanium.UI.View
View's center position, in the parent view's coordinates.
Inherited from Titanium.UI.View
Array of this view's child views.
Inherited from Titanium.UI.View
View's clipping behavior.
The number of columns of items in the view.
Default: 3
Items to display in this view.
editable
BooleanDetermines whether edit mode is activated by a longpress of an item.
Set to false to prevent a longpress from activating edit mode.
Default: true
height
Number | StringInherited from Titanium.UI.View
View height, in platform-specific units.
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
Inherited from Titanium.UI.View
Determines whether the layout has wrapping behavior.
Default: true
id
StringInherited from Titanium.UI.View
View's identifier.
layout
StringInherited from Titanium.UI.View
Specifies how the view positions its children. One of: 'composite', 'vertical', or 'horizontal'.
left
Number | StringInherited from Titanium.UI.View
View's left position, in platform-specific units.
opacity
NumberInherited from Titanium.UI.View
Opacity of this view, from 0.0 (transparent) to 1.0 (opaque). Defaults to 1.0 (opaque).
Inherited from Titanium.UI.View
The preview context used in the 3D-Touch feature "Peek and Pop".
Inherited from Titanium.UI.View
Background color of the wrapper view when this view is used as either Titanium.UI.ListView.pullView or Titanium.UI.TableView.headerPullView.
Defaults to undefined. Results in a light grey background color on the wrapper view.
Inherited from Titanium.UI.View
The bounding box of the view relative to its parent, in system units.
right
Number | StringInherited from Titanium.UI.View
View's right position, in platform-specific units.
Inherited from Titanium.UI.View
Clockwise 2D rotation of the view in degrees.
The number of rows of items in the view.
Default: 3
Inherited from Titanium.UI.View
The size of the view in system units.
Inherited from Titanium.UI.View
The view's tintColor
Default: null
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
top
Number | StringInherited from Titanium.UI.View
The view's top position.
touchEnabled
BooleanInherited from Titanium.UI.View
Determines whether view should receive touch events.
Default: true
Inherited from Titanium.UI.View
Transformation matrix to apply to the view.
Default: Identity matrix
Inherited from Titanium.UI.View
Adds a vertical parallax effect to the view
viewShadowColor
String | Titanium.UI.Colorsince Android 11.1.0, iPhone 3.3.0, iPad 3.3.0, macOS 9.2.0Inherited from Titanium.UI.View
Determines the color of the shadow.
Inherited from Titanium.UI.View
Determines the offset for the shadow of the view.
Inherited from Titanium.UI.View
Determines the blur radius used to create the shadow.
visible
BooleanInherited from Titanium.UI.View
Determines whether the view is visible.
Default: true
width
Number | StringInherited from Titanium.UI.View
View's width, in platform-specific units.
wobble
BooleanDetermines whether the wobble visual editing cue is enabled in edit mode.
Set to false to disable wobble effect.
Must be defined before edit mode is activated in order to take effect.
Default: true
zIndex
NumberInherited from Titanium.UI.View
Z-index stack order position, relative to other sibling views.
Methods 14
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
Inherited from Titanium.UI.View
Animates this view.
| Parameters | Type | Description |
|---|---|---|
| animation | Titanium.UI.Animation | Dictionary<Titanium.UI.Animation> | Either a dictionary of animation properties or an Animation object. |
| callback? | Callback<Object> | Function to be invoked upon completion of the animation. |
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
clearMotionEffects
since 8.2.0Inherited from Titanium.UI.View
Removes all previously added motion effects.
convertPointToView
since Android 1.8, iPhone 1.8, iPad 1.8, macOS 9.2.0Inherited from Titanium.UI.View
Translates a point from this view's coordinate system to another view's coordinate system.
| Parameters | Type | Description |
|---|---|---|
| point | Point | A point in this view's coordinate system. If this argument is missing an |
| destinationView | Titanium.UI.View | View that specifies the destination coordinate system to convert to. If this argument is not a view, an exception will be raised. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
getViewById
since 6.1.0Inherited from Titanium.UI.View
Returns the matching view of a given view ID.
| Parameters | Type | Description |
|---|---|---|
| id | String | The ID of the view that should be returned. Use the |
Inherited from Titanium.UI.View
Hides this view.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and used only on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
insertAt
since 3.3.0Inherited from Titanium.UI.View
Inserts a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) 2 fields
|
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Inherited from Titanium.UI.View
Makes this view visible.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and only used on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
Enable edit mode.
This method causes the Titanium.UI.DashboardView.edit event to fire.
Disable edit mode.
This method causes the Titanium.UI.DashboardView.commit event to fire.
Inherited from Titanium.UI.View
Returns an image of the rendered view, as a Blob.
| Parameters | Type | Description |
|---|---|---|
| callback? | Callback<Titanium.Blob> | Function to be invoked upon completion. If non-null, this method will be performed asynchronously. If null, it will be performed immediately. |
| honorScaleFactor? | Boolean | Determines whether the image is scaled based on scale factor of main screen. (iOS only) When set to true, image is scale factor is honored. When set to false, the image in the blob has the same dimensions for retina and non-retina devices. |
Events 18
| Event properties | Type | Description |
|---|---|---|
| item | Object | Item that was clicked. |
| location | Point | Coordinates x and y of the event from the parent view's coordinate system. |
Fired when edit mode ends.
This event is invoked by the Titanium.UI.DashboardView.stopEditing method.
Inherited from Titanium.UI.View
Fired when the device detects a double click against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Fired when an item is deleted in edit mode.
| Event properties | Type | Description |
|---|---|---|
| item | Titanium.UI.DashboardItem | Item that was deleted. |
Inherited from Titanium.UI.View
Fired when the device detects a double tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
dragend
since 3.0.0Fired when an item finishes being dragged in edit mode.
| Event properties | Type | Description |
|---|---|---|
| item | Titanium.UI.DashboardItem | Item that was dragged. |
dragstart
since 3.0.0Fired when an item starts being dragged in edit mode.
| Event properties | Type | Description |
|---|---|---|
| item | Titanium.UI.DashboardItem | Item that was dragged. |
Fired when edit mode starts.
This event is invoked by a longpress of a Titanium.UI.DashboardItem item or the Titanium.UI.DashboardView.startEditing method.
keypressed
since Android 3.1.0, iPhone 5.4.0, iPad 5.4.0, macOS 9.2.0Inherited from Titanium.UI.View
Fired when a hardware key is pressed in the view.
| Event properties | Type | Description |
|---|---|---|
| keyCode | Number | The code for the physical key that was pressed. For more details, see KeyEvent. This API is experimental and subject to change. |
Inherited from Titanium.UI.View
Fired when the device detects a long press.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Fired when an item is moved in edit mode.
| Event properties | Type | Description |
|---|---|---|
| item | Titanium.UI.DashboardItem | Item that was moved. |
| items | Array<Titanium.UI.DashboardItem> | List of items to be committed, possibly in new order, when edit mode ends. |
pagechanged
since 3.1.0Fired when the current page of the dashboard view changes.
| Event properties | Type | Description |
|---|---|---|
| pageNo | Number | The current page number. |
pinch
since 1.8.0Inherited from Titanium.UI.View
Fired when the device detects a pinch gesture.
| Event properties | Type | Description |
|---|---|---|
| scale | Number | The scale factor relative to the points of the two touches in screen coordinates. |
| velocity | Number | The velocity of the pinch in scale factor per second. |
| time | Number | The event time of the current event being processed. |
| timeDelta | Number | The time difference in milliseconds between the previous accepted scaling event and the current scaling event. |
| currentSpan | Number | The average distance between each of the pointers forming the gesture in progress through the focal point. |
| currentSpanX | Number | The average X distance between each of the pointers forming the gesture in progress through the focal point. |
| currentSpanY | Number | The average Y distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpan | Number | The previous average distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpanX | Number | The previous average X distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpanY | Number | The previous average Y distance between each of the pointers forming the gesture in progress through the focal point. |
| focusX | Number | The X coordinate of the current gesture's focal point. |
| focusY | Number | The Y coordinate of the current gesture's focal point. |
| inProgress | Boolean | Returns |
postlayout
since 2.0.0Inherited from Titanium.UI.View
Fired when a layout cycle is finished.
rotate
since 12.7.0Inherited from Titanium.UI.View
Fired when the device detects a two finger rotation.
| Event properties | Type | Description |
|---|---|---|
| rotate | Number | Rotation in degrees. |
Inherited from Titanium.UI.View
Fired when the device detects a single tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a swipe gesture against the view.
| Event properties | Type | Description |
|---|---|---|
| direction | String | Direction of the swipe--either 'left', 'right', 'up', or 'down'. |
| x | Number | X coordinate of the event's endpoint from the |
| y | Number | Y coordinate of the event's endpoint from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
twofingertap
since 3.0.0Inherited from Titanium.UI.View
Fired when the device detects a two-finger tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |