Do not use lazy requires where not needed.

This commit is contained in:
atanasovg
2016-01-25 16:33:18 +02:00
parent 62d85b0dc0
commit 56f1aaa795
63 changed files with 581 additions and 237 deletions

View File

@@ -1,7 +1,7 @@
import common = require("./label-common");
import definition = require("ui/label");
import * as enumsModule from "ui/enums";
import * as utilsModule from "utils/utils";
import * as enums from "ui/enums";
import * as utils from "utils/utils";
import * as backgroundModule from "ui/styling/background";
import view = require("ui/core/view");
import style = require("ui/styling/style");
@@ -9,6 +9,13 @@ import styling = require("ui/styling");
global.moduleMerge(common, exports);
var background: typeof backgroundModule;
function ensureBackground() {
if (!background) {
background = require("ui/styling/background");
}
}
class UILabelImpl extends UILabel {
private _owner: WeakRef<Label>;
@@ -73,8 +80,6 @@ export class Label extends common.Label {
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
var nativeView = this._nativeView;
if (nativeView) {
var utils: typeof utilsModule = require("utils/utils");
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
@@ -92,8 +97,6 @@ export class Label extends common.Label {
var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height));
var labelWidth = nativeSize.width;
var enums: typeof enumsModule = require("ui/enums");
if (!this.textWrap && this.style.whiteSpace !== enums.WhiteSpace.nowrap) {
labelWidth = Math.min(labelWidth, width);
}
@@ -115,7 +118,7 @@ export class LabelStyler implements style.Styler {
var uiLabel: UILabel = <UILabel>view._nativeView;
if (uiLabel && uiLabel.layer) {
var flipImage = true;
var background: typeof backgroundModule = require("ui/styling/background");
ensureBackground();
var uiColor = <UIColor>background.ios.createBackgroundUIColor(view, flipImage);
var cgColor = uiColor ? uiColor.CGColor : null;
uiLabel.layer.backgroundColor = cgColor;