refactoring circular imports

This commit is contained in:
Hristo Hristov
2017-03-06 14:01:22 +02:00
parent 347755367e
commit ea22eb9c20
82 changed files with 2229 additions and 2188 deletions

View File

@@ -3,6 +3,8 @@ import * as TKUnit from "./TKUnit";
import * as http from "http";
import * as types from "utils/types";
import * as fs from "file-system";
import { addHeader } from "http/http-request";
require("globals");
// >> http-require
@@ -512,10 +514,10 @@ export var test_request_headersWithSameKeyAddedProperly = function (done) {
var value1 = "value1";
var value2 = "value2";
var headers = {};
var headers: http.Headers = {};
(<any>http).addHeader(headers, keyName, value1);
(<any>http).addHeader(headers, keyName, value2);
addHeader(headers, keyName, value1);
addHeader(headers, keyName, value2);
try {
TKUnit.assertTrue(Array.isArray(headers[keyName]));

View File

@@ -1,7 +1,7 @@
import * as buttonModule from "ui/button";
import * as colorModule from "color";
import * as utilsModule from "utils/utils";
import * as enums from "ui/enums";
import { getColor } from "../helper";
export function getNativeText(button: buttonModule.Button): string {
return button.ios.titleForState(UIControlState.Normal);
@@ -16,11 +16,11 @@ export function getNativeFontSize(button: buttonModule.Button): number {
}
export function getNativeColor(button: buttonModule.Button): colorModule.Color {
return utilsModule.ios.getColor(button.ios.titleColorForState(UIControlState.Normal));
return getColor(button.ios.titleColorForState(UIControlState.Normal));
}
export function getNativeBackgroundColor(button: buttonModule.Button): colorModule.Color {
return utilsModule.ios.getColor(button.ios.backgroundColor);
return getColor(button.ios.backgroundColor);
}
export function getNativeTextAlignment(button: buttonModule.Button): string {

View File

@@ -11,12 +11,28 @@ import * as formattedStringModule from "text/formatted-string";
import * as spanModule from "text/span";
import { ActionBar } from "ui/action-bar";
import { unsetValue } from "ui/core/view";
import { Color } from "color";
var DELTA = 0.1;
export var ASYNC = 0.2;
export var MEMORY_ASYNC = 2;
export function getColor(uiColor: UIColor): Color {
var redRef = new interop.Reference<number>();
var greenRef = new interop.Reference<number>();
var blueRef = new interop.Reference<number>();
var alphaRef = new interop.Reference<number>();
uiColor.getRedGreenBlueAlpha(redRef, greenRef, blueRef, alphaRef);
var red = redRef.value * 255;
var green = greenRef.value * 255;
var blue = blueRef.value * 255;
var alpha = alphaRef.value * 255;
return new Color(alpha, red, green, blue);
}
function clearPage(): void {
let newPage = getCurrentPage();
if (!newPage) {

View File

@@ -5,6 +5,7 @@ import { isIOS, isAndroid } from "platform";
import { PropertyChangeData } from "data/observable";
import * as utils from "utils/utils";
import * as TKUnit from "../../TKUnit";
import { getColor } from "../helper";
// >> img-require
import * as ImageModule from "ui/image";
@@ -384,7 +385,7 @@ export const test_tintColor = function () {
TKUnit.assert(tintColor === null, "tintColor expected to be set to null");
}
else if (image.ios) {
const imageColor = utils.ios.getColor(testImage.ios.tintColor);
const imageColor = getColor(testImage.ios.tintColor);
TKUnit.assert(!imageColor.equals(colorRed), "imageColor expected to be different than tintColor");
}
image.tintColor = colorRed;
@@ -393,7 +394,7 @@ export const test_tintColor = function () {
TKUnit.assert(testImage.android.getColorFilter() !== null, "tintColor expected to be set to a nonnull value");
}
else if (image.ios) {
const imageColor = utils.ios.getColor(testImage.ios.tintColor);
const imageColor = getColor(testImage.ios.tintColor);
TKUnit.assert(imageColor.equals(colorRed), "tintColor expected to be set to: " + colorRed);
}
};

View File

@@ -1,7 +1,7 @@
import * as labelModule from "ui/label";
import * as enums from "ui/enums";
import * as colorModule from "color";
import * as utilsModule from "utils/utils";
import { getColor } from "../helper";
export function getNativeTextAlignment(label: labelModule.Label): string {
switch (label.ios.textAlignment) {
@@ -22,5 +22,5 @@ export function getNativeBackgroundColor(label: labelModule.Label): colorModule.
return undefined;
}
var uiColor = UIColor.colorWithCGColor(layer.backgroundColor);
return utilsModule.ios.getColor(uiColor);
return getColor(uiColor);
}

View File

@@ -239,13 +239,13 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
actualTextSize = testLabel.ios.font.pointSize;
TKUnit.assertEqual(actualTextSize, fontSize, "Wrong native FontSize");
normalColor = utils.ios.getColor(testLabel.ios.textColor);
normalColor = helper.getColor(testLabel.ios.textColor);
expColor = new colorModule.Color(color);
TKUnit.assertEqual(normalColor.hex, expColor.hex);
const cgColor = (<UILabel>testLabel.ios).layer.backgroundColor;
const uiColor = UIColor.colorWithCGColor(cgColor);
actualBackgroundColor = utils.ios.getColor(uiColor);
actualBackgroundColor = helper.getColor(uiColor);
expBackgroundColor = new colorModule.Color(backgroundColor);
TKUnit.assertEqual(actualBackgroundColor.hex, expBackgroundColor.hex);
}

View File

@@ -1,9 +1,9 @@
import { SearchBar } from "ui/search-bar";
import { Color } from "color";
import * as utils from "utils/utils";
import { getColor } from "../helper";
export function getNativeHintColor(searchBar: SearchBar): Color {
return (<any>searchBar)._placeholderLabel ? utils.ios.getColor((<any>searchBar)._placeholderLabel.textColor) : undefined;
return (<any>searchBar)._placeholderLabel ? getColor((<any>searchBar)._placeholderLabel.textColor) : undefined;
}
export function getNativeFontSize(searchBar: SearchBar): number {
return (<any>searchBar)._textField ? (<any>searchBar)._textField.font.pointSize : undefined;

View File

@@ -1,6 +1,6 @@
import * as textFieldModule from "ui/text-field";
import * as colorModule from "color";
import * as utilsModule from "utils/utils";
import { getColor } from "../helper";
import * as enums from "ui/enums";
export function getNativeText(textField: textFieldModule.TextField): string {
@@ -20,15 +20,15 @@ export function getNativeFontSize(textField: textFieldModule.TextField): number
}
export function getNativeColor(textField: textFieldModule.TextField): colorModule.Color {
return utilsModule.ios.getColor(textField.ios.textColor);
return getColor(textField.ios.textColor);
}
export function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color {
return utilsModule.ios.getColor(textField.ios.attributedPlaceholder.attributeAtIndexEffectiveRange(NSForegroundColorAttributeName, 0, null));
return getColor(textField.ios.attributedPlaceholder.attributeAtIndexEffectiveRange(NSForegroundColorAttributeName, 0, null));
}
export function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color {
return utilsModule.ios.getColor(textField.ios.backgroundColor);
return getColor(textField.ios.backgroundColor);
}
export function getNativeTextAlignment(textField: textFieldModule.TextField): string {

View File

@@ -1,6 +1,6 @@
import * as textViewModule from "ui/text-view";
import * as colorModule from "color";
import * as utilsModule from "utils/utils";
import { getColor } from "../helper";
import * as enums from "ui/enums";
export function getNativeText(textView: textViewModule.TextView): string {
@@ -25,11 +25,11 @@ export function getNativeFontSize(textView: textViewModule.TextView): number {
}
export function getNativeColor(textView: textViewModule.TextView): colorModule.Color {
return utilsModule.ios.getColor(textView.ios.textColor);
return getColor(textView.ios.textColor);
}
export function getNativeBackgroundColor(textView: textViewModule.TextView): colorModule.Color {
return utilsModule.ios.getColor(textView.ios.backgroundColor);
return getColor(textView.ios.backgroundColor);
}
export function getNativeTextAlignment(textView: textViewModule.TextView): string {