Ability to use different templates for iOS and Android added

This commit is contained in:
Andreww8xx8
2015-03-13 13:52:17 +03:00
committed by vakrilov
parent e727538d6d
commit 88f5c9a7fd
7 changed files with 30 additions and 3 deletions

View File

@@ -0,0 +1,3 @@
import application = require("application");
application.mainModule = "app/main-page";
application.start();

View File

@@ -0,0 +1,5 @@
<Page loaded="onPageLoaded">
<StackLayout id="stack">
<Label id="label" text="Hello, Android!" />
</StackLayout>
</Page>

View File

@@ -0,0 +1,5 @@
<Page loaded="onPageLoaded">
<StackLayout id="stack">
<Label id="label" text="Hello, iOS!" />
</StackLayout>
</Page>

View File

@@ -0,0 +1 @@


View File

@@ -0,0 +1,2 @@
{ "name" : "platform-specific-template",
"main" : "app.js" }

View File

@@ -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);