Tests added and master-detail tempalte updated

This commit is contained in:
vakrilov
2015-03-18 12:37:33 +02:00
parent 0b2c4cc523
commit 88f6a936fc
21 changed files with 439 additions and 144 deletions

View File

@@ -82,6 +82,7 @@
<TypeScriptCompile Include="apps\template-blank\main-page.ts">
<DependentUpon>main-page.xml</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="apps\template-master-detail\main-page.ts" />
<TypeScriptCompile Include="apps\template-settings\app.ts" />
<TypeScriptCompile Include="apps\template-settings\main-page.ts">
<DependentUpon>main-page.xml</DependentUpon>
@@ -96,15 +97,13 @@
<TypeScriptCompile Include="apps\template-master-detail\details-page.ts">
<DependentUpon>details-page.xml</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="apps\template-master-detail\main-page.ts">
<DependentUpon>main-page.xml</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="apps\tests\app\binding_tests.ts">
<DependentUpon>binding_tests.xml</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="apps\tests\app\location-example.ts" />
<TypeScriptCompile Include="apps\tests\app\style_props.ts" />
<TypeScriptCompile Include="apps\tests\console-tests.ts" />
<TypeScriptCompile Include="apps\tests\file-name-resolver-tests\file-name-resolver-tests.ts" />
<TypeScriptCompile Include="apps\tests\frame-tests.ts" />
<TypeScriptCompile Include="apps\tests\gestures-tests.ts" />
<TypeScriptCompile Include="apps\tests\layouts\dock-layout-tests.ts" />
@@ -542,6 +541,8 @@
<SubType>Designer</SubType>
</Content>
<Content Include="apps\gallery-app\layouts\dock-layout.xml" />
<Content Include="apps\template-master-detail\details-view.xml" />
<Content Include="apps\template-master-detail\main-page.minWH600.xml" />
<Content Include="apps\template-settings\app.css" />
<Content Include="apps\tests\app\binding_tests.xml" />
<Content Include="apps\tests\ui\label\label-tests-wrong.css" />
@@ -551,6 +552,11 @@
<Content Include="apps\tests\pages\files\test.minWH300.xml" />
<Content Include="apps\tests\pages\files\test.minWH450.xml" />
<Content Include="apps\tests\pages\files\test.xml" />
<Content Include="apps\tests\file-name-resolver-tests\files\other.xml" />
<Content Include="apps\tests\file-name-resolver-tests\files\test.android.xml" />
<Content Include="apps\tests\file-name-resolver-tests\files\test.ios.land.xml" />
<Content Include="apps\tests\file-name-resolver-tests\files\test.android.minWH600.xml" />
<Content Include="apps\tests\file-name-resolver-tests\files\test.xml" />
<Content Include="apps\ui-tests-app\pages\i86.xml" />
<Content Include="apps\template-blank\app.css" />
<Content Include="apps\template-hello-world\app.css" />
@@ -1511,7 +1517,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -13,15 +13,22 @@ ListView {
horizontal-align: center;
}
.detail-title {
margin: 10;
font-size: 26;
color: #3c3c3c;
horizontal-align: center;
}
.listItem {
margin: 10;
horizontal-align: center;
color: #808080;
font-size: 24;
font-size: 20;
}
.info {
margin: 10;
font-size: 24;
font-size: 20;
color: #808080;
}

View File

@@ -1,8 +1,8 @@
import pages = require("ui/page");
import observable = require("data/observable");
import vmModule = require("./main-view-model");
// Event handler for Page "navigatedTo" event attached in details-page.xml
export function pageNavigatedTo(args: observable.EventData) {
var page = <pages.Page>args.object;
page.bindingContext = page.navigationContext;
page.bindingContext = vmModule.mainViewModel.get("selectedItem");
}

View File

@@ -1,6 +1,5 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" navigatedTo="pageNavigatedTo">
<StackLayout>
<Label text="{{ title }}" cssClass="title"/>
<Label text="{{ info }}" cssClass="info" textWrap="true"/>
</StackLayout>
<Page xmlns="http://www.nativescript.org/tns.xsd"
xmlns:app="app"
navigatedTo="pageNavigatedTo">
<app:details-view />
</Page>

View File

@@ -0,0 +1,4 @@
<StackLayout xmlns="http://www.nativescript.org/tns.xsd">
<Label text="{{ title }}" cssClass="detail-title"/>
<Label text="{{ info }}" cssClass="info" textWrap="true"/>
</StackLayout>

View File

@@ -0,0 +1,17 @@
<Page xmlns="http://www.nativescript.org/tns.xsd"
xmlns:app="app"
loaded="pageLoaded">
<GridLayout rows="auto, *" columns="300, *">
<Label text="Master Details Page" cssClass="title" colSpan="2" />
<ListView items="{{ items }}" itemTap="listViewItemTap" row="1">
<ListView.itemTemplate>
<Label text="{{ title }}" cssClass="listItem" />
</ListView.itemTemplate>
</ListView>
<GridLayout row="1" col="1" bindingContext="{{ selectedItem }}">
<app:details-view/>
</GridLayout>
</GridLayout>
</Page>

View File

@@ -1,9 +1,12 @@
import observable = require("data/observable");
import pages = require("ui/page");
import frames = require("ui/frame");
import platform = require("platform");
import listView = require("ui/list-view");
import vmModule = require("./main-view-model");
var twoPaneLayout = Math.min(platform.screen.mainScreen.widthDIPs, platform.screen.mainScreen.heightDIPs) > 600;
// Event handler for Page "loaded" event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
var page = <pages.Page>args.object;
@@ -12,8 +15,9 @@ export function pageLoaded(args: observable.EventData) {
export function listViewItemTap(args: listView.ItemEventData) {
// Navigate to the details page with context set to the current data item
frames.topmost().navigate({
moduleName: "app/details-page",
context: args.view.bindingContext
});
if (!twoPaneLayout) {
frames.topmost().navigate("app/details-page");
}
vmModule.mainViewModel.set("selectedItem", args.view.bindingContext);
}

View File

@@ -1,4 +1,5 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<Page xmlns="http://www.nativescript.org/tns.xsd"
loaded="pageLoaded">
<GridLayout rows="auto, *">
<Label text="Items Page" cssClass="title" />

View File

@@ -0,0 +1,245 @@
import TKUnit = require("../TKUnit");
import fs = require("file-system");
import enums = require("ui/enums");
import resolver = require("file-system/file-name-resolver");
var androidPhonePortraitContext: resolver.PlatformContext = {
width: 360,
height: 640,
deviceType: enums.DeviceType.Phone,
os: "android"
}
var androidPhoneLandsacpeContext: resolver.PlatformContext = {
width: 640,
height: 360,
deviceType: enums.DeviceType.Phone,
os: "android"
}
var androidTabletPortraitContext: resolver.PlatformContext = {
width: 600,
height: 960,
deviceType: enums.DeviceType.Tablet,
os: "android"
}
var iPhonePortraitContext: resolver.PlatformContext = {
width: 320,
height: 480,
deviceType: enums.DeviceType.Phone,
os: "ios"
}
var iPhoneLandscapeContext: resolver.PlatformContext = {
width: 480,
height: 320,
deviceType: enums.DeviceType.Phone,
os: "ios"
}
export function test_findFileMatch_fileName() {
var candidates: Array<string> = [
"test.xml",
"test2.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.xml")
};
export function test_findFileMatch_os_android() {
var candidates: Array<string> = [
"test.xml",
"test.ios.xml",
"test.android.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.android.xml")
};
export function test_findFileMatch_os_ios() {
var candidates: Array<string> = [
"test.xml",
"test.ios.xml",
"test.android.xml",
"other.xml"
];
testTemplate(candidates, iPhonePortraitContext, "test.ios.xml")
};
export function test_findFileMatch_os_fallback() {
var candidates: Array<string> = [
"test.xml",
"test.ios.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.xml")
};
export function test_findFileMatch_minWH_fallback() {
var candidates: Array<string> = [
"test.xml",
"test.minWH600.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.xml")
}
export function test_findFileMatch_minWH_best_value() {
var candidates: Array<string> = [
"test.xml",
"test.minWH400.xml",
"test.minWH500.xml",
"test.minWH600.xml",
"test.minWH700.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.minWH600.xml")
}
export function test_findFileMatch_minW_fallback() {
var candidates: Array<string> = [
"test.xml",
"test.minW600.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.xml")
}
export function test_findFileMatch_minW_best_value() {
var candidates: Array<string> = [
"test.xml",
"test.minW400.xml",
"test.minW500.xml",
"test.minW600.xml",
"test.minW700.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.minW600.xml")
}
export function test_findFileMatch_minH_fallback() {
var candidates: Array<string> = [
"test.xml",
"test.minH600.xml",
"other.xml"
];
testTemplate(candidates, androidPhoneLandsacpeContext, "test.xml")
}
export function test_findFileMatch_minH_best_value() {
var candidates: Array<string> = [
"test.xml",
"test.minH400.xml",
"test.minH500.xml",
"test.minH600.xml",
"test.minH700.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.minH600.xml")
}
export function test_findFileMatch_orienation_fallback() {
var candidates: Array<string> = [
"test.xml",
"test.land.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.xml")
}
export function test_findFileMatch_orienation_portrait() {
var candidates: Array<string> = [
"test.xml",
"test.land.xml",
"test.port.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.port.xml")
}
export function test_findFileMatch_orienation_landscape() {
var candidates: Array<string> = [
"test.xml",
"test.land.xml",
"test.port.xml",
"other.xml"
];
testTemplate(candidates, androidPhoneLandsacpeContext, "test.land.xml")
}
export function test_findFileMatch_choose_most_specific_file() {
var candidates: Array<string> = [
"test.xml",
"test.android.xml",
"test.android.port.xml",
"other.xml"
];
testTemplate(candidates, androidPhonePortraitContext, "test.android.port.xml")
}
export function test_findFileMatch_with_multiple_matches_loads_by_priority() {
var candidates: Array<string> = [
"test.xml",
"test.android.xml",
"test.tablet.xml",
"test.land.xml",
"test.minH600.xml",
"test.minW600.xml",
"test.minWH600.xml",
"other.xml"
];
testTemplate(candidates, androidTabletPortraitContext, "test.minWH600.xml")
}
function testTemplate(candidates: Array<string>, context: resolver.PlatformContext, expected: string) {
var result = resolver.findFileMatch("test", ".xml", candidates, context);
TKUnit.assertEqual(result, expected, "File path");
}
var testFilePath = fs.path.join(fs.knownFolders.currentApp().path, "app/tests/file-name-resolver-tests/files/test");
export function test_file_resolver_with_andorid_phone_portratit() {
var fileResolver = new resolver.FileNameResolver(androidPhonePortraitContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".android.xml", "File path");
}
export function test_file_resolver_with_andorid_phone_landscape() {
var fileResolver = new resolver.FileNameResolver(androidPhoneLandsacpeContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".android.xml", "File path");
}
export function test_file_resolver_with_andorid_tablet_portrait() {
var fileResolver = new resolver.FileNameResolver(androidTabletPortraitContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".android.minWH600.xml", "File path");
}
export function test_file_resolver_with_ios_phone_landscape() {
var fileResolver = new resolver.FileNameResolver(iPhoneLandscapeContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".ios.land.xml", "File path");
}
export function test_file_resolver_with_ios_phone_portrait() {
var fileResolver = new resolver.FileNameResolver(iPhonePortraitContext);
var result = fileResolver.resolveFileName(testFilePath, "xml");
TKUnit.assertEqual(result, testFilePath + ".xml", "File path");
}

View File

@@ -1 +0,0 @@
test.android.phone.xml

View File

@@ -1,6 +1,6 @@
import btns = require("ui/button");
import gridModule = require("ui/layouts/grid-layout");
import gridModule = require("ui/layouts/grid-layout");
import pages = require("ui/page");
import buttons = require("ui/button");
import app = require("application");
import platform = require("platform");
@@ -12,7 +12,6 @@ function printDeviceInfoAndroid() {
console.log("android.os.Build.VERSION.RELEASE = " + android.os.Build.VERSION.RELEASE); //android.os.Build.VERSION.RELEASE = 4.4.4
android.os.Build.MANUFACTURER
var metrics: android.util.DisplayMetrics = app.android.context.getResources().getDisplayMetrics();
console.log("metrics.density = " + metrics.density); //metrics.density = 3
console.log("metrics.scaledDensity = " + metrics.scaledDensity); //metrics.scaledDensity = 3
console.log("metrics.densityDpi = " + metrics.densityDpi); //metrics.densityDpi = 480
@@ -20,6 +19,12 @@ function printDeviceInfoAndroid() {
console.log("metrics.yxdpi = " + metrics.ydpi); //metrics.yxdpi = 443.3450012207031
console.log("metrics.widthPixels = " + metrics.widthPixels); //metrics.widthPixels = 1080
console.log("metrics.heightPixels = " + metrics.heightPixels); //metrics.heightPixels = 1776
var config = app.android.context.getResources().getConfiguration();
console.log("config.screenWidthDp = " + config.screenWidthDp);
console.log("config.screenHeightDp = " + config.screenHeightDp);
console.log("config.smallestScreenWidthDp = " + config.smallestScreenWidthDp);
console.log("config.orientation = " + (config.orientation === android.content.res.Configuration.ORIENTATION_PORTRAIT ? "portrait" : "ladscape"));
}
function printDeviceInfoIOS() {
@@ -45,11 +50,14 @@ function printTNSInfo() {
console.log("platform.device.sdkVersion = " + platform.device.sdkVersion);
console.log("platform.device.deviceType = " + platform.device.deviceType);
console.log("platform.screen.mainScreen.widthDIPs = " + platform.screen.mainScreen.widthDIPs);
console.log("platform.screen.mainScreen.heightDIPs = " + platform.screen.mainScreen.heightDIPs);
console.log("platform.screen.mainScreen.scale = " + platform.screen.mainScreen.scale);
console.log("platform.screen.mainScreen.widthPixels = " + platform.screen.mainScreen.widthPixels);
console.log("platform.screen.mainScreen.heightPixels = " + platform.screen.mainScreen.heightPixels);
console.log("platform.screen.mainScreen.scale = " + platform.screen.mainScreen.scale);
}
function print() {
if (app.android) {
printDeviceInfoAndroid();
}
@@ -57,33 +65,20 @@ else {
printDeviceInfoIOS();
}
printTNSInfo();
}
print();
export function createPage() {
var page = new pages.Page();
var grid = new gridModule.GridLayout();
var rows = 100;
var cols = 3;
var row;
var col;
var btn = new buttons.Button();
btn.text = "print";
btn.on("tap", (d) => {
print();
});
for (row = 0; row < rows; row++) {
grid.addRow(new gridModule.ItemSpec(1, gridModule.GridUnitType.auto));
}
for (col = 0; col < cols; col++) {
grid.addColumn(new gridModule.ItemSpec(1, gridModule.GridUnitType.auto));
}
for (col = 0; col < cols; col++) {
for (row = 0; row < rows; row++) {
var btn = new btns.Button();
btn.text = "Col: " + col + ", Row: " + row;
gridModule.GridLayout.setColumn(btn, col);
gridModule.GridLayout.setRow(btn, row);
grid.addChild(btn);
}
}
page.content = grid;
return page;

View File

@@ -46,6 +46,7 @@ allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests");
allTests["TEXT-VIEW"] = require("./ui/text-view/text-view-tests");
allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests");
allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests");
allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests");
allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");
allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests");
allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests");

View File

@@ -2,15 +2,19 @@
* Provides FileNameResolver class used for loading files based on device capabilities.
*/
declare module "file-system/file-name-resolver" {
interface PlatformContext {
export interface PlatformContext {
width: number;
height: number;
os: string;
deviceType: string;
}
class FileNameResolver {
export class FileNameResolver {
constructor(context: PlatformContext);
resolveFileName(path: string, ext: string): string;
}
//@private
export function findFileMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string
//@endprivate
}

View File

@@ -1,6 +1,7 @@
import definition = require("file-system/file-name-resolver");
import fs = require("file-system");
import types = require("utils/types");
import trace = require("trace");
var MIN_WH: string = "minWH";
var MIN_W: string = "minW";
@@ -72,19 +73,6 @@ var minHeightQualifier: QualifierSpec = {
}
}
var fromQualifier: QualifierSpec = {
isMatch: function (value: string): boolean {
return value === "tablet" || value === "phone";
},
getMatchValue(value: string, context: definition.PlatformContext): number{
if (value !== context.deviceType.toLocaleLowerCase()) {
return -1;
}
return 1;
}
}
var paltformQualifier: QualifierSpec = {
isMatch: function (value: string): boolean {
return value === "android" ||
@@ -96,13 +84,26 @@ var paltformQualifier: QualifierSpec = {
}
}
var orientationQualifier: QualifierSpec = {
isMatch: function (value: string): boolean {
return value === "land" ||
value === "port";
},
getMatchValue(value: string, context: definition.PlatformContext): number{
var isLandscape: number = (context.width > context.height) ? 1 : -1;
return (value === "land") ? isLandscape : -isLandscape;
}
}
// List of supported qualifiers ordered by priority
var supportedQualifiers: Array<QualifierSpec> = [
minWidthHeightQualifier,
minWidthQualifier,
minHeightQualifier,
paltformQualifier,
fromQualifier];
orientationQualifier,
paltformQualifier
];
export class FileNameResolver implements definition.FileNameResolver {
private _context: definition.PlatformContext;
@@ -124,60 +125,69 @@ export class FileNameResolver implements definition.FileNameResolver {
}
private resolveFileNameImpl(path: string, ext: string): string {
var result: string = null;
path = fs.path.normalize(path);
ext = "." + ext;
var candidates = this.getFileCandidatesFromFolder(path, ext);
result = findFileMatch(path, ext, candidates, this._context);
trace.write("Resolved file name for \"" + path + ext + "\" result: " + (result ? result : "no match found"), trace.categories.Navigation);
return result;
}
private getFileCandidatesFromFolder(path: string, ext: string): Array<string> {
var candidates = new Array<string>();
var folderPath = path.substring(0, path.lastIndexOf(fs.path.separator) + 1);
console.log("search folderPath: " + folderPath);
if (fs.Folder.exists(folderPath)) {
var folder = fs.Folder.fromPath(folderPath);
var candidates = new Array<fs.File>();
folder.eachEntity((e) => {
if (e instanceof fs.File) {
var file = <fs.File>e;
console.log("File path: " + e.path);
if (file.path.indexOf(path) === 0 && file.extension === ext) {
candidates.push(file);
candidates.push(file.path);
}
}
return true;
});
}
else {
trace.write("Could not find folder " + folderPath + " when loading " + path + ext, trace.categories.Navigation);
}
var bestValue = Number.MIN_VALUE;
var bestCandidate: fs.File = null;
return candidates;
}
}
console.log("Candidates:");
export function findFileMatch(path: string, ext: string, candidates: Array<string>, context: definition.PlatformContext): string {
var bestValue = -1
var result: string = null;
trace.write("Candidates for " + path + ext + ": " + candidates.join(", "), trace.categories.Navigation);
for (var i = 0; i < candidates.length; i++) {
console.log("---------- candiate[" + i + "]: " + candidates[i].name);
var filePath = candidates[i].path;
var filePath = candidates[i];
var qualifiersStr: string = filePath.substr(path.length, filePath.length - path.length - ext.length);
var qualifiers = qualifiersStr.split(".");
var value = this.checkQualifiers(qualifiers);
console.log("qualifiers: " + qualifiersStr + " result: " + value);
var value = checkQualifiers(qualifiers, context);
if (value >= 0 && value > bestValue) {
bestValue = value;
bestCandidate = candidates[i];
}
result = candidates[i];
}
}
return bestCandidate ? bestCandidate.path : null;
return result;
}
private checkQualifiers(qualifiers: Array<string>): number {
function checkQualifiers(qualifiers: Array<string>, context: definition.PlatformContext): number {
var result = 0;
for (var i = 0; i < qualifiers.length; i++) {
if (qualifiers[i]) {
var value = this.checkQualifier(qualifiers[i]);
console.log("checking qualifier: " + qualifiers[i] + " result: " + value);
var value = checkQualifier(qualifiers[i], context);
if (value < 0) {
// Non of the supported qualifiers matched this or the match was not satisified
return -1;
@@ -190,10 +200,10 @@ export class FileNameResolver implements definition.FileNameResolver {
return result;
}
private checkQualifier(value: string) {
function checkQualifier(value: string, context: definition.PlatformContext) {
for (var i = 0; i < supportedQualifiers.length; i++) {
if (supportedQualifiers[i].isMatch(value)) {
var result = supportedQualifiers[i].getMatchValue(value, this._context);
var result = supportedQualifiers[i].getMatchValue(value, context);
if (result > 0) {
result += (supportedQualifiers.length - i) * PRIORITY_STEP;
}
@@ -203,4 +213,3 @@ export class FileNameResolver implements definition.FileNameResolver {
return -1;
}
}

View File

@@ -88,8 +88,7 @@ function pageFromBuilder(moduleNamePath: string, moduleName: string, moduleExpor
// Possible XML file path.
var fileName = resolveFilePath(moduleNamePath, "xml");
if (fs.File.exists(fileName)) {
if (fileName) {
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);
// Or check if the file exists in the app modules and load the page from XML.
@@ -99,9 +98,11 @@ function pageFromBuilder(moduleNamePath: string, moduleName: string, moduleExpor
// Possible CSS file path.
var cssFileName = resolveFilePath(moduleName, "css");
if (cssFileName) {
page.addCssFile(cssFileName);
}
}
}
return page;
}

View File

@@ -61,10 +61,13 @@ export class Page extends contentView.ContentView implements dts.Page {
}
public addCssFile(cssFileName: string) {
if (cssFileName.indexOf(fs.knownFolders.currentApp().path) !== 0) {
cssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFileName);
}
var cssString;
var realCssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFileName);
if (fs.File.exists(realCssFileName)) {
new fileSystemAccess.FileSystemAccess().readText(realCssFileName, r => { cssString = r; });
if (fs.File.exists(cssFileName)) {
new fileSystemAccess.FileSystemAccess().readText(cssFileName, r => { cssString = r; });
this._addCssInternal(cssString, cssFileName);
}
}