mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix: PR comments
This commit is contained in:
4
ui/core/dependency-observable.d.ts
vendored
4
ui/core/dependency-observable.d.ts
vendored
@@ -73,6 +73,10 @@ declare module "ui/core/dependency-observable" {
|
||||
* Gets or sets the callback to be raised whenever the associated property is about to change for any DependencyObservable instance that uses the property to store a value.
|
||||
*/
|
||||
onValidateValue: PropertyValidationCallback;
|
||||
/**
|
||||
* Gets function that used to compare if two property values are equal.
|
||||
*/
|
||||
equalityComparer: PropertyEqualityComparer;
|
||||
/**
|
||||
* Checks whether the PropertyMetadataSettings.affectsLayout bit is present in the options value.
|
||||
*/
|
||||
|
||||
@@ -1,32 +1,11 @@
|
||||
import enums = require("ui/enums");
|
||||
import common = require("ui/styling/font-common");
|
||||
import fs = require("file-system");
|
||||
import fs = require("file-system");
|
||||
|
||||
var DEFAULT_SERIF = "Times New Roman";
|
||||
var DEFAULT_SANS_SERIF = "Helvetica";
|
||||
var DEFAULT_MONOSPACE = "Courier New";
|
||||
|
||||
var areSystemFontSetsValid: boolean = false;
|
||||
var systemFontFamilies = new Set();
|
||||
var systemFonts = new Set();
|
||||
|
||||
function assureSystemFotnSets() {
|
||||
if (!areSystemFontSetsValid) {
|
||||
var nsFontFamilies = UIFont.familyNames();
|
||||
for (var i = 0; i < nsFontFamilies.count; i++) {
|
||||
var family = nsFontFamilies.objectAtIndex(i);
|
||||
systemFontFamilies.add(family);
|
||||
|
||||
var nsFonts = UIFont.fontNamesForFamilyName(family);
|
||||
for (var j = 0; j < nsFonts.count; j++) {
|
||||
var font = nsFonts.objectAtIndex(j);
|
||||
systemFonts.add(font);
|
||||
}
|
||||
}
|
||||
areSystemFontSetsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
export class Font extends common.Font {
|
||||
public static default = new Font(undefined, undefined, enums.FontStyle.normal, enums.FontWeight.normal);
|
||||
|
||||
@@ -48,9 +27,8 @@ export class Font extends common.Font {
|
||||
|
||||
var descriptor = resolveFontDescriptor(this.fontFamily, symbolicTraits);
|
||||
if (!descriptor) {
|
||||
descriptor = UIFontDescriptor.new().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||
descriptor = defaultFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||
}
|
||||
|
||||
var size = this.fontSize || defaultFont.pointSize;
|
||||
|
||||
this._uiFont = UIFont.fontWithDescriptorSize(descriptor, size);
|
||||
@@ -75,6 +53,27 @@ export class Font extends common.Font {
|
||||
}
|
||||
}
|
||||
|
||||
var areSystemFontSetsValid: boolean = false;
|
||||
var systemFontFamilies = new Set();
|
||||
var systemFonts = new Set();
|
||||
|
||||
function assureSystemFontSets() {
|
||||
if (!areSystemFontSetsValid) {
|
||||
var nsFontFamilies = UIFont.familyNames();
|
||||
for (var i = 0; i < nsFontFamilies.count; i++) {
|
||||
var family = nsFontFamilies.objectAtIndex(i);
|
||||
systemFontFamilies.add(family);
|
||||
|
||||
var nsFonts = UIFont.fontNamesForFamilyName(family);
|
||||
for (var j = 0; j < nsFonts.count; j++) {
|
||||
var font = nsFonts.objectAtIndex(j);
|
||||
systemFonts.add(font);
|
||||
}
|
||||
}
|
||||
areSystemFontSetsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveFontDescriptor(fontFamilyValue: string, symbolicTraits: number): UIFontDescriptor {
|
||||
var fonts = common.parseFontFamily(fontFamilyValue);
|
||||
var result: UIFontDescriptor = null;
|
||||
@@ -82,7 +81,7 @@ function resolveFontDescriptor(fontFamilyValue: string, symbolicTraits: number):
|
||||
return null;
|
||||
}
|
||||
|
||||
assureSystemFotnSets();
|
||||
assureSystemFontSets();
|
||||
|
||||
for (var i = 0; i < fonts.length; i++) {
|
||||
var fontFamily = getFontFamilyRespectingGenericFonts(fonts[i]);
|
||||
|
||||
@@ -318,7 +318,15 @@ export class Style extends observable.DependencyObservable implements styling.St
|
||||
else {
|
||||
trace.write("Found handler for property: " + property.name + ", view:" + this._view, trace.categories.Style);
|
||||
|
||||
if (types.isUndefined(newValue) || newValue === property.metadata.defaultValue) {
|
||||
var shouldReset = false;
|
||||
if (property.metadata.equalityComparer) {
|
||||
shouldReset = property.metadata.equalityComparer(newValue, property.metadata.defaultValue);
|
||||
}
|
||||
else {
|
||||
shouldReset = (newValue === property.metadata.defaultValue);
|
||||
}
|
||||
|
||||
if (shouldReset) {
|
||||
(<any>handler).resetProperty(property, this._view);
|
||||
} else {
|
||||
(<any>handler).applyProperty(property, this._view, newValue);
|
||||
|
||||
Reference in New Issue
Block a user