mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Ability to use different templates for iOS and Android added
This commit is contained in:
3
apps/platform-specific-template/app.ts
Normal file
3
apps/platform-specific-template/app.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import application = require("application");
|
||||||
|
application.mainModule = "app/main-page";
|
||||||
|
application.start();
|
||||||
5
apps/platform-specific-template/main-page.android.xml
Normal file
5
apps/platform-specific-template/main-page.android.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<Page loaded="onPageLoaded">
|
||||||
|
<StackLayout id="stack">
|
||||||
|
<Label id="label" text="Hello, Android!" />
|
||||||
|
</StackLayout>
|
||||||
|
</Page>
|
||||||
5
apps/platform-specific-template/main-page.ios.xml
Normal file
5
apps/platform-specific-template/main-page.ios.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<Page loaded="onPageLoaded">
|
||||||
|
<StackLayout id="stack">
|
||||||
|
<Label id="label" text="Hello, iOS!" />
|
||||||
|
</StackLayout>
|
||||||
|
</Page>
|
||||||
1
apps/platform-specific-template/main-page.ts
Normal file
1
apps/platform-specific-template/main-page.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
2
apps/platform-specific-template/package.json
Normal file
2
apps/platform-specific-template/package.json
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{ "name" : "platform-specific-template",
|
||||||
|
"main" : "app.js" }
|
||||||
@@ -6,6 +6,7 @@ import trace = require("trace");
|
|||||||
import builder = require("ui/builder");
|
import builder = require("ui/builder");
|
||||||
import fs = require("file-system");
|
import fs = require("file-system");
|
||||||
import utils = require("utils/utils");
|
import utils = require("utils/utils");
|
||||||
|
import platform = require("platform");
|
||||||
|
|
||||||
var frameStack: Array<Frame> = [];
|
var frameStack: Array<Frame> = [];
|
||||||
|
|
||||||
@@ -67,12 +68,22 @@ function resolvePageFromEntry(entry: definition.NavigationEntry): pages.Page {
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolvePlatformPath(path, ext) {
|
||||||
|
var platformName = platform.device.os.toLowerCase();
|
||||||
|
var platformPath = [path, platformName, ext].join(".");
|
||||||
|
if (fs.File.exists(platformPath)) {
|
||||||
|
return platformPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [path, ext].join(".");
|
||||||
|
}
|
||||||
|
|
||||||
function pageFromBuilder(moduleNamePath: string, moduleName: string, moduleExports: any): pages.Page {
|
function pageFromBuilder(moduleNamePath: string, moduleName: string, moduleExports: any): pages.Page {
|
||||||
var page: pages.Page;
|
var page: pages.Page;
|
||||||
var element: view.View;
|
var element: view.View;
|
||||||
|
|
||||||
// Possible XML file path.
|
// Possible XML file path.
|
||||||
var fileName = moduleNamePath + ".xml";
|
var fileName = resolvePlatformPath(moduleNamePath, "xml");
|
||||||
|
|
||||||
if (fs.File.exists(fileName)) {
|
if (fs.File.exists(fileName)) {
|
||||||
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);
|
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);
|
||||||
|
|||||||
Reference in New Issue
Block a user