Replace knownEvents modules with static strings.

This commit is contained in:
Nedyalko Nikolov
2015-04-23 15:47:56 +03:00
parent 8023390692
commit 95ca8d9c8c
101 changed files with 520 additions and 471 deletions

View File

@@ -110,18 +110,14 @@ function pageFromBuilder(moduleNamePath: string, moduleExports: any): pages.Page
return page;
}
export module knownEvents {
export module android {
export var optionSelected = "optionSelected";
}
}
interface NavigationContext {
entry: definition.BackstackEntry;
isBackNavigation: boolean;
}
export class Frame extends view.CustomLayoutView implements definition.Frame {
public static androidOptionSelectedEvent = "optionSelected";
private _navigationQueue: Array<NavigationContext>;
private _backStack: Array<definition.BackstackEntry>;
public _currentEntry: definition.BackstackEntry;

View File

@@ -481,13 +481,13 @@ class NativeActivity extends com.tns.NativeScriptActivity {
}
onOptionsItemSelected(menuItem: android.view.IMenuItem) {
if (!this.androidFrame.hasListeners(frameCommon.knownEvents.android.optionSelected)) {
if (!this.androidFrame.hasListeners(frameCommon.Frame.androidOptionSelectedEvent)) {
return false;
}
var data: definition.AndroidOptionEventData = {
handled: false,
eventName: frameCommon.knownEvents.android.optionSelected,
eventName: frameCommon.Frame.androidOptionSelectedEvent,
item: menuItem,
object: this.androidFrame
}

33
ui/frame/frame.d.ts vendored
View File

@@ -12,6 +12,11 @@ declare module "ui/frame" {
* Nested frames are supported, enabling hierarchical navigation scenarios.
*/
export class Frame extends view.View {
/**
* String value used when hooking to androidOptionSelected event (prefix `android` states that this event is available only in Android).
*/
public static androidOptionSelectedEvent: string;
/**
* Navigates to the previous entry (if any) in the back stack.
*/
@@ -86,6 +91,19 @@ declare module "ui/frame" {
_processNavigationQueue(page: pages.Page);
_invalidateOptionsMenu();
//@endprivate
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (args: observable.EventData) => void, thisArg?: any);
/**
* Raised when native android [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
*/
on(event: "optionSelected", callback: (args: observable.EventData) => void, thisArg?: any);
}
/**
@@ -214,19 +232,4 @@ declare module "ui/frame" {
*/
navBarVisibility: string;
}
/**
* Encapsulates the events raised by the Frame object.
*/
module knownEvents {
/**
* Encapsulates the events raised by the android part of the Frame.
*/
module android {
/**
* Raised when the native [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
*/
export var optionSelected: string;
}
}
}