Initial prototype of Frame + Page + Navigation.

This commit is contained in:
atanasovg
2014-06-12 17:37:55 +03:00
parent ef7c3ce677
commit 2c4781db01
26 changed files with 520 additions and 80 deletions

View File

@@ -1,5 +1,6 @@
import appModule = require("application/application-common");
import dts = require("application");
import frame = require("ui/frame");
// merge the exports of the application_common file with the exports of this file
declare var exports;
@@ -112,7 +113,7 @@ class AndroidApplication implements dts.AndroidApplication {
public foregroundActivity: android.app.Activity;
public startActivity: android.app.Activity;
public packageName: string;
public getActivity: (intent: android.content.Intent) => any;
// public getActivity: (intent: android.content.Intent) => any;
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
public onActivityDestroyed: (activity: android.app.Activity) => void;
@@ -128,7 +129,15 @@ class AndroidApplication implements dts.AndroidApplication {
this.nativeApp = nativeApp;
this.packageName = nativeApp.getPackageName();
this.context = nativeApp.getApplicationContext();
this.getActivity = undefined;
}
public getActivity(intent: android.content.Intent): any {
var currentPage = rootFrame.currentPage;
if (!currentPage) {
throw new Error("Root frame not navigated to a page.");
}
return currentPage.android.getActivityExtends();
}
public init() {
@@ -136,4 +145,7 @@ class AndroidApplication implements dts.AndroidApplication {
this.nativeApp.registerActivityLifecycleCallbacks(this._eventsToken);
this.context = this.nativeApp.getApplicationContext();
}
}
}
// The root frame of the application
export var rootFrame = new frame.Frame();

View File

@@ -1,11 +1,13 @@

declare module "application" {
import frame = require("ui/frame");
export var rootFrame: frame.Frame;
/**
* The main entry point event. This method is expected to return an instance of the root UI for the application.
* This will be an Activity extends for Android and a RootViewController for iOS.
* The main entry point event. This method is expected to use the root frame to navigate to the main application page.
*/
export function onLaunch(): any;
export function onLaunch(): void;
/**
* This method will be called when the Application is suspended.
@@ -85,7 +87,7 @@ declare module "application" {
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
*/
getActivity: (intent: android.content.Intent) => any;
getActivity(intent: android.content.Intent): any;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.