Skip to content

Commit

Permalink
docs: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Jun 8, 2020
1 parent 6e69c90 commit 73fa558
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 39 deletions.
62 changes: 62 additions & 0 deletions apidoc/Titanium/UI/Shortcut.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Titanium.UI.Shortcut
summary: Manage application shortcuts.
description: |
Allows the creation of application shortcuts, which can be detected using
the `shortcutitemclick` event from <Titanium.App>.
Use the <Titanium.UI.createShortcut> method to manage shortcut creation.
extends: Titanium.Proxy
since: "9.1.0"
platforms: [android]
osver: {android: {min: "7.1"}}

properties:
- name: items
summary: List current shortcuts.
type: Array<ShortcutItem>

- name: staticItems
summary: List current pinned/static shortcuts.
type: Array<ShortcutItem>

methods:
- name: add
summary: Add shortcut to application.

- name: remove
summary: Remove shortcut from application.

- name: removeAll
summary: Remove all shortcuts from application.

examples:
- title: Simple Shortcut Example
example: |
Create a shortcut item and detect its click with the `shortcutitemclick` event.
const win = Ti.UI.createWindow({ backgroundColor: 'grey' }),
const btn = Ti.UI.createButton({ title: 'ADD SHORTCUT' }),
const shortcut = Ti.UI.createShortcut();
const shortcutItem = Ti.UI.createShortcutItem({
id: 'test_shortcut',
title: 'TEST',
description: 'DESCRIPTION'
});
Ti.App.addEventListener('shortcutitemclick', () => {
// Set background to 'blue' on shortcut click event.
win.backgroundColor = 'blue';
});
btn.addEventListener('click', () => {
// Add shortcut.
shortcut.add(shortcutItem);
});
win.add(btn);
win.open();
61 changes: 22 additions & 39 deletions apidoc/Titanium/UI/ShortcutItem.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
---
name: Titanium.UI.ShortcutItem
summary: An application shortcut.
summary: An application shortcut item.
description: |
Allows the creation of application shortcuts, which can be detected using
the `shortcutitemclick` event from <Titanium.App>.
Allows the creation of application shortcut items.
Use the <Titanium.UI.createShortcutItem> method to create a shortcut.
Use the <Titanium.UI.createShortcutItem> method to create a shortcut
and <Titanium.UI.createShortcut> to manage shortcuts.
extends: Titanium.Proxy
since: "7.5.0"
platforms: [android]
since: { android: 7.5.0, iphone: 9.1.0, ipad: 9.1.0 }
platforms: [android, ios]

methods:
- name: show
summary: Allow the shortcut to show.
platforms: [android]
deprecated:
since: "9.1.0"
notes: Use [Titanium.UI.Shortcut.add](Titanium.UI.Shortcut.add) instead.

- name: hide
summary: Hide the shortcut.
platforms: [android]
deprecated:
since: "9.1.0"
notes: Use [Titanium.UI.Shortcut.remove](Titanium.UI.Shortcut.remove) instead.

- name: pin
summary: Pin shortcut to launcher.
Expand All @@ -30,54 +36,31 @@ properties:
summary: Determines shortcut id.
description: This should be a unique identifier for the shortcut.
type: String
platforms: [android]
platforms: [android, ios]
availability: creation

- name: title
summary: Title of the shortcut.
type: String
platforms: [android]
platforms: [android, ios]
availability: creation

- name: description
summary: Description of the shortcut.
type: String
platforms: [android]
platforms: [android, ios]
availability: creation

- name: icon
summary: Shortcut icon.
description: This can be set as a resource id or file path.
type: [String, Number]
platforms: [android]
platforms: [android, ios]
availability: creation

examples:
- title: Simple ShortcutItem Example
example: |
Create a shortcut item and detect its click with the `shortcutitemclick` event.
var win = Ti.UI.createWindow({ backgroundColor: 'grey' }),
btn = Ti.UI.createButton({ title: 'TOGGLE SHORTCUT' }),
shortcut = Ti.UI.createShortcutItem({
id: 'test_shortcut',
title: 'TEST',
description: 'DESCRIPTION'
});
Ti.App.addEventListener('shortcutitemclick', function () {
win.backgroundColor = 'blue';
});
btn.addEventListener('click', function () {
if (shortcut.visible) {
win.backgroundColor = 'red';
shortcut.hide();
} else {
win.backgroundColor = 'green';
shortcut.show();
}
});
win.add(btn);
win.open();
- name: data
summary: Shortcut data.
description: Additional data that can be stored with the shortcut.
type: [String, Number]
platforms: [android, ios]
availability: creation

0 comments on commit 73fa558

Please sign in to comment.