1 | import { View } from '../core/view';
|
2 | import { ViewBase } from '../core/view-base';
|
3 | import { EventData } from '../../data/observable';
|
4 |
|
5 | /**
|
6 | * Provides an abstraction over the ActionBar (android) and NavigationBar (iOS).
|
7 | */
|
8 | export class ActionBar extends View {
|
9 | /**
|
10 | * Gets or sets the action bar title.
|
11 | */
|
12 | title: string;
|
13 |
|
14 | /**
|
15 | * Gets or sets the title view. When set - replaces the title with a custom view.
|
16 | */
|
17 | titleView: View;
|
18 |
|
19 | /**
|
20 | * Gets or sets the navigation button (a.k.a. the back button).
|
21 | */
|
22 | navigationButton: NavigationButton;
|
23 |
|
24 | /**
|
25 | * Removes the shadow/border at the bottom of the ActionBar and removes translucency on iOS.
|
26 | * Default false.
|
27 | */
|
28 | flat: boolean;
|
29 |
|
30 | /**
|
31 | * Gets the collection of action items.
|
32 | */
|
33 | actionItems: ActionItems;
|
34 |
|
35 | /**
|
36 | * Gets the android specific options of the action bar.
|
37 | */
|
38 | android: AndroidActionBarSettings;
|
39 |
|
40 | /**
|
41 | * Gets the native iOS [UINavigationBar](https://developer.apple.com/documentation/uikit/uinavigationbar) that represents the user interface for this component. Valid only when running on iOS.
|
42 | */
|
43 | ios: any /* UITabBarController */;
|
44 |
|
45 | /**
|
46 | * Gets or set the UIImageRenderingMode of the action bar icons in iOS. Defaults to "alwaysOriginal"
|
47 | * Valid values are:
|
48 | * - automatic
|
49 | * - alwaysOriginal
|
50 | * - alwaysTemplate
|
51 | */
|
52 | iosIconRenderingMode: 'automatic' | 'alwaysOriginal' | 'alwaysTemplate';
|
53 |
|
54 | public effectiveContentInsetLeft: number;
|
55 | public effectiveContentInsetRight: number;
|
56 |
|
57 | /**
|
58 | * Updates the action bar.
|
59 | */
|
60 | update();
|
61 |
|
62 | //@private
|
63 | /**
|
64 | * @private
|
65 | */
|
66 | _isEmpty(): boolean;
|
67 | /**
|
68 | * @private
|
69 | */
|
70 | _getActualSize?: { width: number; height: number };
|
71 | //@endprivate
|
72 | }
|
73 |
|
74 | /**
|
75 | * Represents a collection of ActionItems.
|
76 | */
|
77 | export class ActionItems {
|
78 | /**
|
79 | * Adds an item to the collection.
|
80 | * @param item - the item to be added
|
81 | */
|
82 | addItem(item: ActionItem): void;
|
83 |
|
84 | /**
|
85 | * Removes an item to the collection.
|
86 | * @param item - The item to be removed.
|
87 | */
|
88 | removeItem(item: ActionItem): void;
|
89 |
|
90 | /**
|
91 | * Gets an array of the current action items in the collection.
|
92 | */
|
93 | getItems(): Array<ActionItem>;
|
94 |
|
95 | /**
|
96 | * Gets an item at a specified index.
|
97 | * @param index - The index.
|
98 | */
|
99 | getItemAt(index: number): ActionItem;
|
100 | }
|
101 |
|
102 | /**
|
103 | * Represents an action item in the action bar.
|
104 | */
|
105 | export class ActionItem extends ViewBase {
|
106 | /**
|
107 | * Gets or sets the text of the action item.
|
108 | */
|
109 | text: string;
|
110 |
|
111 | /**
|
112 | * Gets or sets the icon of the action item.
|
113 | */
|
114 | icon: string;
|
115 |
|
116 | /**
|
117 | * Gets or sets the custom action view of the action item.
|
118 | */
|
119 | actionView: View;
|
120 |
|
121 | /**
|
122 | * Gets or sets the visibility of the action item.
|
123 | */
|
124 | visibility: string;
|
125 |
|
126 | /**
|
127 | * Gets the action bar that contains the action item.
|
128 | */
|
129 | actionBar: ActionBar;
|
130 |
|
131 | /**
|
132 | * Adds a listener for the specified event name.
|
133 | *
|
134 | * @param eventName The name of the event.
|
135 | * @param callback The event listener to add. Will be called when an event of
|
136 | * the given name is raised.
|
137 | * @param thisArg An optional parameter which, when set, will be bound as the
|
138 | * `this` context when the callback is called. Falsy values will be not be
|
139 | * bound.
|
140 | */
|
141 | on(eventName: string, callback: (data: EventData) => void): void;
|
142 |
|
143 | /**
|
144 | * Raised when a tap event occurs.
|
145 | */
|
146 | on(event: 'tap', callback: (args: EventData) => void): void;
|
147 |
|
148 | //@private
|
149 | /**
|
150 | * @private
|
151 | */
|
152 | _raiseTap(): void;
|
153 | //@endprivate
|
154 |
|
155 | /**
|
156 | * Gets the iOS specific options of the action item.
|
157 | */
|
158 | // @ts-ignore
|
159 | ios: IOSActionItemSettings;
|
160 |
|
161 | /**
|
162 | * Gets the Android specific options of the action item.
|
163 | */
|
164 | // @ts-ignore
|
165 | android: AndroidActionItemSettings;
|
166 | }
|
167 |
|
168 | /**
|
169 | * Represents Android specific options of the action item.
|
170 | */
|
171 | export interface AndroidActionItemSettings {
|
172 | /**
|
173 | * Gets or sets the position of the action item in the action bar.
|
174 | * 1. actionBar - item is shown in the action bar.
|
175 | * 2. actionBarIfRoom - item is shown in the action bar if there is room for it. Otherwise it is put in the popup menu.
|
176 | * 3. popup - item is shown in the popup menu.
|
177 | * Note: Property not applicable to NavigationButton
|
178 | */
|
179 | position: 'actionBar' | 'actionBarIfRoom' | 'popup';
|
180 |
|
181 | /**
|
182 | * Gets or sets the name of the system drawable resource to be displayed.
|
183 | * Use this property instead of ActionItem.icon if you want to diplsay a built-in Android system icon.
|
184 | * The value should be a string such as 'ic_menu_search' if you want to display the built-in Android Menu Search icon for example.
|
185 | * For a full list of Android drawable names, please visit http://androiddrawables.com
|
186 | */
|
187 | systemIcon: string;
|
188 | }
|
189 |
|
190 | /**
|
191 | * Represents iOS specific options of the action item.
|
192 | */
|
193 | export interface IOSActionItemSettings {
|
194 | /**
|
195 | * Gets or sets the position of the action item in the action bar.
|
196 | * 1. left - items is shown at the left part of the navigation bar. This is the default value.
|
197 | * 2. right - items is shown at the right part of the navigation bar.
|
198 | * Note: Property not applicable to NavigationButton
|
199 | */
|
200 | position: 'left' | 'right';
|
201 |
|
202 | /**
|
203 | * Gets or sets a number representing the iOS system item to be displayed.
|
204 | * Use this property instead of ActionItem.icon if you want to diplsay a built-in iOS system icon.
|
205 | * Note: Property not applicable to NavigationButton
|
206 | * The value should be a number from the UIBarButtonSystemItem enumeration
|
207 | * (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBarButtonItem_Class/#//apple_ref/c/tdef/UIBarButtonSystemItem)
|
208 | * 0: Done
|
209 | * 1: Cancel
|
210 | * 2: Edit
|
211 | * 3: Save
|
212 | * 4: Add
|
213 | * 5: FlexibleSpace
|
214 | * 6: FixedSpace
|
215 | * 7: Compose
|
216 | * 8: Reply
|
217 | * 9: Action
|
218 | * 10: Organize
|
219 | * 11: Bookmarks
|
220 | * 12: Search
|
221 | * 13: Refresh
|
222 | * 14: Stop
|
223 | * 15: Camera
|
224 | * 16: Trash
|
225 | * 17: Play
|
226 | * 18: Pause
|
227 | * 19: Rewind
|
228 | * 20: FastForward
|
229 | * 21: Undo
|
230 | * 22: Redo
|
231 | * 23: PageCurl
|
232 | */
|
233 | systemIcon: number;
|
234 | }
|
235 |
|
236 | /**
|
237 | * Represents Android specific options of the action bar.
|
238 | */
|
239 | export interface AndroidActionBarSettings {
|
240 | /**
|
241 | * Gets or sets the action bar icon.
|
242 | */
|
243 | icon: string;
|
244 |
|
245 | /**
|
246 | * Gets or sets the visibility of the action bar icon.
|
247 | * The icon is visible by default in pre-lollipop (API level < 20) versions of android and is hidden in lollipop (API level >= 20)
|
248 | * The possible values are:
|
249 | * 1. auto - the default behavior. This is the default value.
|
250 | * 2. always - the icon is always shown.
|
251 | * 3. never - the icon is always hidden.
|
252 | */
|
253 | iconVisibility: string;
|
254 | }
|
255 |
|
256 | /**
|
257 | * Represents the navigation (a.k.a. "back") button.
|
258 | */
|
259 | export class NavigationButton extends ActionItem {
|
260 | //@private
|
261 | /**
|
262 | * @private
|
263 | */
|
264 | _navigationItem?: any;
|
265 | //@endprivate
|
266 | }
|
267 |
|
268 | /** @internal */
|
269 | export function _setNavBarColor(navBar: any /* UINavigationBar */, color: any /* UIColor */);
|
270 | /** @internal */
|
271 | export function _setNavBarBackgroundColor(navBar: any /* UINavigationBar */, color: any /* UIColor */);
|