Skip to content

Commit 88f5c9a

Browse files
Andrew8xx8vakrilov
authored and
vakrilov
committed
Ability to use different templates for iOS and Android added
1 parent e727538 commit 88f5c9a

File tree

7 files changed

+30
-3
lines changed

7 files changed

+30
-3
lines changed

apps/editable-text-demo/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import application = require("application");
22
application.mainModule = "app/main-page";
3-
application.start();
3+
application.start();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import application = require("application");
2+
application.mainModule = "app/main-page";
3+
application.start();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Page loaded="onPageLoaded">
2+
<StackLayout id="stack">
3+
<Label id="label" text="Hello, Android!" />
4+
</StackLayout>
5+
</Page>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Page loaded="onPageLoaded">
2+
<StackLayout id="stack">
3+
<Label id="label" text="Hello, iOS!" />
4+
</StackLayout>
5+
</Page>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{ "name" : "platform-specific-template",
2+
"main" : "app.js" }

ui/frame/frame-common.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import trace = require("trace");
66
import builder = require("ui/builder");
77
import fs = require("file-system");
88
import utils = require("utils/utils");
9+
import platform = require("platform");
910

1011
var frameStack: Array<Frame> = [];
1112

@@ -39,7 +40,7 @@ function resolvePageFromEntry(entry: definition.NavigationEntry): pages.Page {
3940
}
4041
}
4142
else if (entry.moduleName) {
42-
// Current app full path.
43+
// Current app full path.
4344
var currentAppPath = fs.knownFolders.currentApp().path;
4445
//Full path of the module = current app full path + module name.
4546
var moduleNamePath = fs.path.join(currentAppPath, entry.moduleName);
@@ -67,12 +68,22 @@ function resolvePageFromEntry(entry: definition.NavigationEntry): pages.Page {
6768
return page;
6869
}
6970

71+
function resolvePlatformPath(path, ext) {
72+
var platformName = platform.device.os.toLowerCase();
73+
var platformPath = [path, platformName, ext].join(".");
74+
if (fs.File.exists(platformPath)) {
75+
return platformPath;
76+
}
77+
78+
return [path, ext].join(".");
79+
}
80+
7081
function pageFromBuilder(moduleNamePath: string, moduleName: string, moduleExports: any): pages.Page {
7182
var page: pages.Page;
7283
var element: view.View;
7384

7485
// Possible XML file path.
75-
var fileName = moduleNamePath + ".xml";
86+
var fileName = resolvePlatformPath(moduleNamePath, "xml");
7687

7788
if (fs.File.exists(fileName)) {
7889
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);

0 commit comments

Comments
 (0)