diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31011072b..704a46a4e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,29 @@
+
+# [5.3.0](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.3.0) (2019-03-21)
+
+
+### Bug Fixes
+
+* **android:** resource ID not found on navigation between pages with nested and single frames ([#6955](https://github.com/NativeScript/NativeScript/issues/6955)) ([33d6d1f](https://github.com/NativeScript/NativeScript/commit/33d6d1f))
+* **android:** navigation between pages with single and nested frames ([#7011](https://github.com/NativeScript/NativeScript/issues/7011)) ([91d90cc](https://github.com/NativeScript/NativeScript/commit/91d90cc))
+* **http:** ensure httpcontent.toFile() creates intermediate directories ([#6451](https://github.com/NativeScript/NativeScript/issues/6451)) ([d7fb9b8](https://github.com/NativeScript/NativeScript/commit/d7fb9b8))
+* WrappedValue.unwrap empty string behavior ([#6900](https://github.com/NativeScript/NativeScript/issues/6900)) ([0482460](https://github.com/NativeScript/NativeScript/commit/0482460))
+* **android-bottom-tabs:** use immediate transition on programmatic selectedIndex change ([#6942](https://github.com/NativeScript/NativeScript/issues/6942)) ([e9dfa20](https://github.com/NativeScript/NativeScript/commit/e9dfa20))
+* **ios:** disable default tab reselect behavior ([#6968](https://github.com/NativeScript/NativeScript/issues/6968)) ([043cbf3](https://github.com/NativeScript/NativeScript/commit/043cbf3))
+* **ios-webview:** report hostname lookup errors in loadFinished event ([#6988](https://github.com/NativeScript/NativeScript/issues/6988)) ([e6486f6](https://github.com/NativeScript/NativeScript/commit/e6486f6))
+* **ios-webview:** loading of local-file dependency ([#6947](https://github.com/NativeScript/NativeScript/issues/6947)) ([dcad754](https://github.com/NativeScript/NativeScript/commit/dcad754)), closes [/github.com/NativeScript/NativeScript/issues/6377#issuecomment-433322681](https://github.com//github.com/NativeScript/NativeScript/issues/6377/issues/issuecomment-433322681) [#6377](https://github.com/NativeScript/NativeScript/issues/6377)
+* set/unset touchListener.owner onLoaded/onUnloaded ([#6922](https://github.com/NativeScript/NativeScript/issues/6922)) ([f056167](https://github.com/NativeScript/NativeScript/commit/f056167))
+
+
+### Features
+
+* local icon handling in actionbar and tabview ([#7009](https://github.com/NativeScript/NativeScript/issues/7009)) ([cd66300](https://github.com/NativeScript/NativeScript/commit/cd66300))
+* **android:** add openFile to utils ([#6895](https://github.com/NativeScript/NativeScript/issues/6895)) ([f8eee40](https://github.com/NativeScript/NativeScript/commit/f8eee40))
+* **hmr:** style views at runtime ([#7012](https://github.com/NativeScript/NativeScript/issues/7012)) ([3c2c1d9](https://github.com/NativeScript/NativeScript/commit/3c2c1d9))
+* **hmr:** apply changes in page styles at runtime when app root is a frame ([#6857](https://github.com/NativeScript/NativeScript/issues/6857)) ([44b8acd](https://github.com/NativeScript/NativeScript/commit/44b8acd))
+* **view** expose missing backgroundSize, backgroundRepeat, and backgroundPosition properties on View class ([#7032](https://github.com/NativeScript/NativeScript/issues/7032)) ([88f2242](https://github.com/NativeScript/NativeScript/commit/88f2242))
+
+
## [5.2.2](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.2.2) (2019-03-01)
diff --git a/apps/app/ui-tests-app/font/all-fonts.ts b/apps/app/ui-tests-app/font/all-fonts.ts
index 3b4f97260..fd374dae6 100644
--- a/apps/app/ui-tests-app/font/all-fonts.ts
+++ b/apps/app/ui-tests-app/font/all-fonts.ts
@@ -6,7 +6,6 @@ import { Label } from "tns-core-modules/ui/label";
import { FontStyle, FontWeight } from "tns-core-modules/ui/enums";
import * as typeUtils from "tns-core-modules/utils/types";
import { Color } from "tns-core-modules/color";
-import * as utils from "tns-core-modules/utils/utils";
import { isIOS } from "tns-core-modules/platform";
const genericFontFamilies = [
@@ -48,7 +47,7 @@ let compareIgnoreCase = function (a, b) {
};
if (isIOS) {
- const nsFontFamilies = utils.ios.getter(UIFont, UIFont.familyNames);
+ const nsFontFamilies = UIFont.familyNames;
for (let i = 0; i < nsFontFamilies.count; i++) {
const family = nsFontFamilies.objectAtIndex(i);
fontFamilies.push(family)
diff --git a/tests/app/TKUnit.ts b/tests/app/TKUnit.ts
index 72e4ea164..f5fda0c8f 100644
--- a/tests/app/TKUnit.ts
+++ b/tests/app/TKUnit.ts
@@ -15,9 +15,6 @@ import * as timer from "tns-core-modules/timer";
import * as trace from "tns-core-modules/trace";
import * as types from "tns-core-modules/utils/types";
import * as platform from "tns-core-modules/platform";
-import { topmost } from "tns-core-modules/ui/frame";
-
-import * as utils from "tns-core-modules/utils/utils";
const sdkVersion = parseInt(platform.device.sdkVersion);
@@ -371,7 +368,7 @@ export function waitUntilReady(isReady: () => boolean, timeoutSec: number = 3, s
let totalWaitTime = 0;
while (true) {
const begin = time();
- const currentRunLoop = utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop);
+ const currentRunLoop = NSRunLoop.currentRunLoop;
currentRunLoop.limitDateForMode(currentRunLoop.currentMode);
if (isReady()) {
break;
diff --git a/tests/app/application/application-tests.ios.ts b/tests/app/application/application-tests.ios.ts
index 6be1a1073..b019da98f 100644
--- a/tests/app/application/application-tests.ios.ts
+++ b/tests/app/application/application-tests.ios.ts
@@ -1,11 +1,7 @@
/* tslint:disable:no-unused-variable */
import * as app from "tns-core-modules/application";
-import * as TKUnit from "../TKUnit";
import * as commonTests from "./application-tests-common";
-import * as utils from "tns-core-modules/utils/utils";
-import getter = utils.ios.getter;
-
global.moduleMerge(commonTests, exports);
// >> application-ios-observer
@@ -13,7 +9,7 @@ global.moduleMerge(commonTests, exports);
if (app.ios) {
var observer = app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
function onReceiveCallback(notification: NSNotification) {
- var percent = getter(UIDevice, UIDevice.currentDevice).batteryLevel * 100;
+ var percent = UIDevice.currentDevice.batteryLevel * 100;
var message = "Battery: " + percent + "%";
////console.log(message);
});
diff --git a/tests/app/http/http-tests.ts b/tests/app/http/http-tests.ts
index 2921db254..1cd5283e9 100644
--- a/tests/app/http/http-tests.ts
+++ b/tests/app/http/http-tests.ts
@@ -621,7 +621,6 @@ export var test_request_NonStringHeadersSentAndReceivedProperly = function (done
};
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
- // >> http-post-json
var result;
http.request({
diff --git a/tests/app/pages/page5.ts b/tests/app/pages/page5.ts
index cd6f17640..b78b881b2 100644
--- a/tests/app/pages/page5.ts
+++ b/tests/app/pages/page5.ts
@@ -4,8 +4,6 @@ import * as buttons from "tns-core-modules/ui/button";
import * as app from "tns-core-modules/application";
import * as platform from "tns-core-modules/platform";
-import * as utils from "tns-core-modules/utils/utils";
-
function printDeviceInfoAndroid() {
console.log("android.os.Build.DEVICE = " + android.os.Build.DEVICE); //android.os.Build.DEVICE = hammerhead
console.log("android.os.Build.VERSION.SDK = " + android.os.Build.VERSION.SDK); //android.os.Build.VERSION.SDK = 19
@@ -29,7 +27,7 @@ function printDeviceInfoAndroid() {
}
function printDeviceInfoIOS() {
- var device = utils.ios.getter(UIDevice, UIDevice.currentDevice);
+ var device = UIDevice.currentDevice;
console.log("device.name = " + device.name); //device.name = iPhone Simulator
console.log("device.systemName = " + device.systemName); //device.systemName = iPhone OS
console.log("device.systemVersion = " + device.systemVersion); //device.systemVersion = 8.1
@@ -37,7 +35,7 @@ function printDeviceInfoIOS() {
console.log("device.localizedModel = " + device.localizedModel); //device.localizedModel = iPhone Simulator
console.log("device.userInterfaceIdiom = " + device.userInterfaceIdiom); //device.userInterfaceIdiom = 0
console.log("device.batteryLevel = " + device.batteryLevel); //device.batteryLevel = -1
- var screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
+ var screen = UIScreen.mainScreen;
console.log("screen = " + screen);
console.log("screen.nativeBounds = " + screen.nativeBounds.size.width + ", " + screen.nativeBounds.size.height); //screen.nativeBounds = 640, 1136
console.log("screen.scale = " + screen.scale); //screen.scale = 2
diff --git a/tests/app/ui/date-picker/date-picker-tests-native.ios.ts b/tests/app/ui/date-picker/date-picker-tests-native.ios.ts
index 9361d62ef..3a3231eac 100644
--- a/tests/app/ui/date-picker/date-picker-tests-native.ios.ts
+++ b/tests/app/ui/date-picker/date-picker-tests-native.ios.ts
@@ -1,17 +1,15 @@
import * as datePickerModule from "tns-core-modules/ui/date-picker";
-import * as utils from "tns-core-modules/utils/utils";
-
export function getNativeYear(datePicker: datePickerModule.DatePicker): number {
- return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).year;
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).year;
}
export function getNativeMonth(datePicker: datePickerModule.DatePicker): number {
- return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).month;
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).month;
}
export function getNativeDay(datePicker: datePickerModule.DatePicker): number {
- return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).day;
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).day;
}
export function getNativeMaxDate(datePicker: datePickerModule.DatePicker): Date {
@@ -23,31 +21,31 @@ export function getNativeMinDate(datePicker: datePickerModule.DatePicker): Date
}
export function setNativeYear(datePicker: datePickerModule.DatePicker, value: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
comps.year = value;
- datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ datePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(datePicker)._changeHandler.valueChanged(datePicker.ios);
}
export function setNativeMonth(datePicker: datePickerModule.DatePicker, value: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
comps.month = value;
- datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ datePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(datePicker)._changeHandler.valueChanged(datePicker.ios);
}
export function setNativeDay(datePicker: datePickerModule.DatePicker, value: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
comps.day = value;
- datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ datePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(datePicker)._changeHandler.valueChanged(datePicker.ios);
}
export function setNativeDate(datePicker: datePickerModule.DatePicker, year: number, month: number, day: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
comps.year = year;
comps.month = month;
comps.day = day;
- datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ datePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(datePicker)._changeHandler.valueChanged(datePicker.ios);
}
diff --git a/tests/app/ui/helper.ts b/tests/app/ui/helper.ts
index 74bc6dd4a..6ccd5b490 100644
--- a/tests/app/ui/helper.ts
+++ b/tests/app/ui/helper.ts
@@ -10,7 +10,6 @@ import { ActionBar } from "tns-core-modules/ui/action-bar";
import { Color } from "tns-core-modules/color";
import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base";
-import { FlexboxLayout } from "tns-core-modules/ui/layouts/flexbox-layout";
import { FormattedString, Span } from "tns-core-modules/text/formatted-string";
import { _getProperties, _getStyleProperties } from "tns-core-modules/ui/core/properties";
import { device } from "tns-core-modules/platform";
@@ -305,11 +304,11 @@ export function _generateFormattedString(): FormattedString {
return formattedString;
}
-const props = _getProperties();
-const styleProps = _getStyleProperties();
-let setters: Map;
-let cssSetters: Map;
-let defaultNativeGetters: Map any>;
+// const props = _getProperties();
+// const styleProps = _getStyleProperties();
+// let setters: Map;
+// let cssSetters: Map;
+// let defaultNativeGetters: Map any>;
export function nativeView_recycling_test(createNew: () => View, createLayout?: () => LayoutBase, nativeGetters?: Map any>, customSetters?: Map) {
return;
@@ -373,490 +372,490 @@ export function nativeView_recycling_test(createNew: () => View, createLayout?:
// layout.removeChild(first);
}
-function compareUsingReflection(recycledNativeView: View, newNativeView: View): void {
- const recycled: android.view.View = recycledNativeView.nativeViewProtected;
- const newer: android.view.View = newNativeView.nativeViewProtected;
- TKUnit.assertNotEqual(recycled, newer);
- const methods = newer.getClass().getMethods();
- for (let i = 0, length = methods.length; i < length; i++) {
- const method = methods[i];
- const returnType = method.getReturnType();
- const name = method.getName();
- const skip = name.includes("ViewId")
- || name.includes("Accessibility")
- || name.includes("hashCode")
- || name === "getId"
- || name === "hasFocus"
- || name === "isDirty"
- || name === "getLeft"
- || name === "getTop"
- || name === "getRight"
- || name === "getBottom"
- || name === "getWidth"
- || name === "getHeight"
- || name === "getX"
- || name === "getY"
- || name.includes("getMeasured")
- || name === "toString";
-
- if (skip || method.getParameterTypes().length > 0) {
- continue;
- }
-
- if ((java).lang.Comparable.class.isAssignableFrom(returnType)) {
- const defValue = method.invoke(newer, null);
- const currValue = method.invoke(recycled, null);
- if (defValue !== currValue && defValue.compareTo(currValue) !== 0) {
- throw new Error(`Actual: ${currValue}, Expected: ${defValue}, for method: ${method.getName()}`);
- }
- } else if (java.lang.String.class === returnType ||
- java.lang.Character.class === returnType ||
- (java).lang.CharSequence.class === returnType ||
- returnType === java.lang.Byte.TYPE ||
- returnType === java.lang.Double.TYPE ||
- returnType === java.lang.Float.TYPE ||
- returnType === java.lang.Integer.TYPE ||
- returnType === java.lang.Long.TYPE ||
- returnType === java.lang.Short.TYPE ||
- returnType === java.lang.Boolean.TYPE) {
-
- const defValue = method.invoke(newer, null);
- const currValue = method.invoke(recycled, null);
- if ((currValue + "") !== (defValue + "")) {
- throw new Error(`Actual: ${currValue}, Expected: ${defValue}, for method: ${method.getName()}`);
- }
- }
- }
-}
-
-function checkDefaults(newer: View, first: View, props: Array, nativeGetters: Map any>): void {
- props.forEach(prop => {
- const name = (prop).name;
- if (nativeGetters.has(name)) {
- const getter = nativeGetters.get(name);
- TKUnit.assertDeepEqual(getter(newer), getter(first), name);
- } else if (newer[prop.getDefault]) {
- TKUnit.assertDeepEqual(newer[prop.getDefault](), first[prop.getDefault](), name);
- } else if (newer[prop.setNative]) {
- console.log(`Type: ${newer.typeName} has no getter for ${name} property.`)
- }
- });
-}
-
-function setValue(object: Object, setters: Map, customSetters?: Map): void {
- setters.forEach((value1, key) => {
- let value = customSetters && customSetters.has(key) ? customSetters.get(key) : value1;
- const currentValue = object[key];
- if (currentValue === value) {
- if (value === "horizontal" && key === "orientation") {
- // wrap-layout.orientation default value is 'horizontal'
- value = "vertical";
- } else if (value === 2) {
- value = 3;
- }
- }
-
- object[key] = value;
- const newValue = object[key];
- TKUnit.assertNotEqual(newValue, currentValue, `${object} setting ${key} should change current value.`);
- });
-}
-
-function setupSetters(): void {
- if (setters) {
- return;
- }
-
- setters = new Map();
- // view-base
- setters.set("id", "someId");
- setters.set("className", "someClassName");
- setters.set("bindingContext", "someBindingContext");
-
- // view
- setters.set("automationText", "automationText");
- setters.set("originX", 0.2);
- setters.set("originY", 0.2);
- setters.set("isEnabled", false);
- setters.set("isUserInteractionEnabled", false);
-
- // action-bar
- setters.set("title", "title");
- setters.set("text", "text");
- setters.set("icon", "~/logo.png");
- setters.set("visibility", "collapse");
-
- // activity-indicator
- setters.set("busy", true);
-
- // date-picker
- setters.set("year", "2010");
- setters.set("month", "2");
- setters.set("day", "2");
- setters.set("maxDate", "2100");
- setters.set("minDate", "2000");
- setters.set("date", new Date(2011, 3, 3));
-
- // editable-text
- setters.set("keyboardType", "datetime");
- setters.set("returnKeyType", "done");
- setters.set("editable", false);
- setters.set("updateTextTrigger", "focusLost");
- setters.set("autocapitalizationType", "words");
- setters.set("autocorrect", true);
- setters.set("hint", "hint");
- setters.set("maxLength", "10");
-
- // html-view
- setters.set("html", "");
-
- // image-view
- setters.set("imageSource", "");
- setters.set("src", "");
- setters.set("loadMode", "async");
- setters.set("isLoading", true);
- setters.set("stretch", "none");
-
- // layout-base
- setters.set("clipToBounds", false);
-
- // absolute-layout
- setters.set("left", "20");
- setters.set("top", "20");
-
- // dock-layout
- setters.set("dock", "top");
- setters.set("stretchLastChild", false);
-
- // grid-layout props
- setters.set("row", "1");
- setters.set("rowSpan", "2");
- setters.set("col", "1");
- setters.set("colSpan", "2");
-
- // stack-layout
- setters.set("orientation", "horizontal");
-
- // wrap-layout
- // custom orientation value
- // setters.set('orientation', 'vertical');
- setters.set("itemWidth", "50");
- setters.set("itemHeight", "50");
-
- // list-picker
- setters.set("items", ["1", "2", "3"]);
- setters.set("selectedIndex", "1");
-
- // list-view
- setters.set("items", ["1", "2", "3"]);
- setters.set("itemTemplate", "");
- setters.set("itemTemplates", "");
- setters.set("rowHeight", "50");
-
- // page
- setters.set("actionBarHidden", "true");
- setters.set("backgroundSpanUnderStatusBar", "true");
- setters.set("enableSwipeBackNavigation", "false");
-
- // progress
- setters.set("value", "1");
- setters.set("maxValue", "99");
-
- // repeater
- setters.set("items", ["1", "2", "3"]);
- setters.set("itemTemplate", "");
- setters.set("itemsLayout", new StackLayout());
- setters.set("rowHeight", "50");
-
- // scroll-view
- // custom orientation value
- //setters.set('orientation', 'horizontal');
-
- // search-bar
- setters.set("textFieldHintColor", "red");
- setters.set("textFieldBackgroundColor", "red");
-
- // segmented-bar
- // custom items property
-
- // slider
- setters.set("minValue", "5");
-
- // switch
- setters.set("checked", "true");
-
- // tab-view
- // custom items property
- setters.set("androidOffscreenTabLimit", "2");
-
- // text-base
- const formattedText = new FormattedString();
- const span = new Span();
- span.text = "span";
- formattedText.spans.push(span);
- setters.set("formattedText", formattedText);
-
- // text-base
- setters.set("secure", "true");
-
- // time-picker
- setters.set("minHour", 1);
- setters.set("hour", 2);
- setters.set("maxHour", 11);
- setters.set("minMinute", 1);
- setters.set("minute", 2);
- setters.set("maxMinute", 11);
- setters.set("minuteInterval", 2);
- setters.set("time", new Date(2011, 2, 2, 3, 3, 3));
-
- cssSetters = new Map();
-
- // style
- cssSetters.set("rotate", "90");
- cssSetters.set("scaleX", 2);
- cssSetters.set("scaleY", 2);
- cssSetters.set("translateX", 20);
- cssSetters.set("translateY", 20);
-
- cssSetters.set("clipPath", "inset(100px 50px)");
- cssSetters.set("color", "red");
- cssSetters.set("tintColor", "green");
- cssSetters.set("placeholderColor", "green");
-
- cssSetters.set("backgroundColor", "red");
- cssSetters.set("backgroundImage", "~/logo.png");
- cssSetters.set("backgroundRepeat", "repeat");
- cssSetters.set("backgroundSize", "60px 120px");
- cssSetters.set("backgroundPosition", "center");
- cssSetters.set("borderColor", "blue");
- cssSetters.set("borderTopColor", "green");
- cssSetters.set("borderRightColor", "green");
- cssSetters.set("borderBottomColor", "green");
- cssSetters.set("borderLeftColor", "green");
- cssSetters.set("borderWidth", "10px");
- cssSetters.set("borderTopWidth", "5px");
- cssSetters.set("borderRightWidth", "5px");
- cssSetters.set("borderBottomWidth", "5px");
- cssSetters.set("borderLeftWidth", "5px");
- cssSetters.set("borderRadius", "10px");
- cssSetters.set("borderTopLeftRadius", "5px");
- cssSetters.set("borderTopRightRadius", "5px");
- cssSetters.set("borderBottomRightRadius", "5px");
- cssSetters.set("borderBottomLeftRadius", "5px");
-
- cssSetters.set("fontSize", "20");
- cssSetters.set("fontFamily", "monospace");
- cssSetters.set("fontStyle", "italic");
- cssSetters.set("fontWeight", "100");
- cssSetters.set("font", "italic 2 \"Open Sans\", sans-serif");
-
- // zIndex on android is not what you think...
- // cssSetters.set('zIndex', '2');
- cssSetters.set("opacity", "0.5");
- // already set through view properties.
- // cssSetters.set('visibility', 'collapse');
-
- cssSetters.set("letterSpacing", "2");
- cssSetters.set("textAlignment", "center");
- cssSetters.set("textDecoration", "underline");
- cssSetters.set("textTransform", "capitalize");
- cssSetters.set("whiteSpace", "normal");
-
- cssSetters.set("minWidth", 50);
- cssSetters.set("minHeight", 50);
- cssSetters.set("width", 100);
- cssSetters.set("height", 100);
- cssSetters.set("margin", "25");
- cssSetters.set("marginLeft", "30px");
- cssSetters.set("marginTop", "30px");
- cssSetters.set("marginRight", "30px");
- cssSetters.set("marginBottom", "30px");
- cssSetters.set("padding", "25");
- cssSetters.set("paddingLeft", "30px");
- cssSetters.set("paddingTop", "30px");
- cssSetters.set("paddingRight", "30px");
- cssSetters.set("paddingBottom", "30px");
- cssSetters.set("horizontalAlignment", "center");
- cssSetters.set("verticalAlignment", "center");
-
- cssSetters.set("transform", "translate(5, 10), scale(1.2, 1.2), rotate(45)");
-
- // TabView-specific props
- cssSetters.set("tabTextColor", "red");
- cssSetters.set("tabBackgroundColor", "red");
- cssSetters.set("selectedTabTextColor", "red");
- cssSetters.set("androidSelectedTabHighlightColor", "red");
-
- // ListView-specific props
- cssSetters.set("separatorColor", "red");
-
- // SegmentedBar-specific props
- cssSetters.set("selectedBackgroundColor", "red");
-
- // Page-specific props
- cssSetters.set("statusBarStyle", "light");
- cssSetters.set("androidStatusBarBackground", "red");
-
- // Flexbox-layout props
- cssSetters.set("flexDirection", "column");
- cssSetters.set("flexWrap", "wrap");
- cssSetters.set("justifyContent", "center");
- cssSetters.set("alignItems", "center");
- cssSetters.set("alignContent", "center");
- cssSetters.set("order", "2");
- cssSetters.set("flexGrow", "1");
- cssSetters.set("flexShrink", "0");
- cssSetters.set("flexWrapBefore", "true");
- cssSetters.set("alignSelf", "center");
- cssSetters.set("flexFlow", "row-reverse wrap");
- cssSetters.set("flex", "2 0.2");
-
- const nativeGetters = defaultNativeGetters = new Map any>();
-
- nativeGetters.set("marginLeft", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.leftMargin : 0;
- });
-
- nativeGetters.set("marginTop", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.topMargin : 0;
- });
-
- nativeGetters.set("marginRight", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.rightMargin : 0;
- });
-
- nativeGetters.set("marginBottom", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.bottomMargin : 0;
- });
-
- nativeGetters.set("col", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
- });
-
- nativeGetters.set("colSpan", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
- });
-
- nativeGetters.set("row", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
- });
-
- nativeGetters.set("rowSpan", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
- });
-
- nativeGetters.set("width", (v: { nativeView: android.view.View }) => {
- const native = v.nativeView;
- if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
- return -2;
- }
- return native.getLayoutParams().width;
- });
- nativeGetters.set("height", (v: { nativeView: android.view.View }) => {
- const native = v.nativeView;
- if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
- return -2;
- }
- return native.getLayoutParams().height;
- });
-
- nativeGetters.set("paddingLeft", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingLeft());
- nativeGetters.set("paddingTop", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingTop());
- nativeGetters.set("paddingRight", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingRight());
- nativeGetters.set("paddingBottom", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingBottom());
-
- nativeGetters.set("minWidth", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumWidth());
- nativeGetters.set("minHeight", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumHeight());
-
- nativeGetters.set("scaleX", (v: { nativeView: android.view.View }) => v.nativeView.getScaleX());
- nativeGetters.set("scaleY", (v: { nativeView: android.view.View }) => v.nativeView.getScaleY());
- nativeGetters.set("translateX", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationX());
- nativeGetters.set("translateY", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationY());
- nativeGetters.set("isEnabled", (v: { nativeView: android.view.View }) => v.nativeView.isEnabled());
- nativeGetters.set("rotate", (v: { nativeView: android.view.View }) => v.nativeView.getRotation());
-
- nativeGetters.set("order", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.order : 1;
- });
-
- nativeGetters.set("flexGrow", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexGrow : 0;
- });
-
- nativeGetters.set("flexShrink", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexShrink : 1;
- });
-
- nativeGetters.set("flexWrapBefore", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.wrapBefore : false;
- });
-
- nativeGetters.set("alignSelf", (v: { nativeView: android.view.View }) => {
- const lp = v.nativeView.getLayoutParams();
- return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.alignSelf : "auto";
- });
-
- nativeGetters.set("formattedText", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- return (nativeView instanceof android.widget.TextView) ? nativeView.getText().toString() : undefined;
- });
-
- nativeGetters.set("isUserInteractionEnabled", (v) => true);
-
- nativeGetters.set("orientation", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof org.nativescript.widgets.StackLayout) {
- return nativeView.getOrientation();
- } else if (nativeView instanceof org.nativescript.widgets.WrapLayout) {
- return nativeView.getOrientation();
- }
- });
-
- nativeGetters.set("textTransform", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof android.widget.TextView) {
- return nativeView.getTransformationMethod();
- }
- });
-
- nativeGetters.set("editable", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof android.widget.TextView) {
- return nativeView.getKeyListener();
- }
- });
-
- nativeGetters.set("maxLength", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof android.widget.TextView) {
- return nativeView.getFilters();
- }
- });
-
- nativeGetters.set("whiteSpace", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof android.widget.TextView) {
- return { lineCount: nativeView.getLineCount(), ellipsize: nativeView.getEllipsize() };
- }
- });
-
- nativeGetters.set("text", (v: { nativeView: android.view.View }) => {
- const nativeView = v.nativeView;
- if (nativeView instanceof android.widget.TextView) {
- const text = nativeView.getText();
- return text ? text.toString() : text;
- }
- });
-}
+// function compareUsingReflection(recycledNativeView: View, newNativeView: View): void {
+// const recycled: android.view.View = recycledNativeView.nativeViewProtected;
+// const newer: android.view.View = newNativeView.nativeViewProtected;
+// TKUnit.assertNotEqual(recycled, newer);
+// const methods = newer.getClass().getMethods();
+// for (let i = 0, length = methods.length; i < length; i++) {
+// const method = methods[i];
+// const returnType = method.getReturnType();
+// const name = method.getName();
+// const skip = name.includes("ViewId")
+// || name.includes("Accessibility")
+// || name.includes("hashCode")
+// || name === "getId"
+// || name === "hasFocus"
+// || name === "isDirty"
+// || name === "getLeft"
+// || name === "getTop"
+// || name === "getRight"
+// || name === "getBottom"
+// || name === "getWidth"
+// || name === "getHeight"
+// || name === "getX"
+// || name === "getY"
+// || name.includes("getMeasured")
+// || name === "toString";
+
+// if (skip || method.getParameterTypes().length > 0) {
+// continue;
+// }
+
+// if ((java).lang.Comparable.class.isAssignableFrom(returnType)) {
+// const defValue = method.invoke(newer, null);
+// const currValue = method.invoke(recycled, null);
+// if (defValue !== currValue && defValue.compareTo(currValue) !== 0) {
+// throw new Error(`Actual: ${currValue}, Expected: ${defValue}, for method: ${method.getName()}`);
+// }
+// } else if (java.lang.String.class === returnType ||
+// java.lang.Character.class === returnType ||
+// (java).lang.CharSequence.class === returnType ||
+// returnType === java.lang.Byte.TYPE ||
+// returnType === java.lang.Double.TYPE ||
+// returnType === java.lang.Float.TYPE ||
+// returnType === java.lang.Integer.TYPE ||
+// returnType === java.lang.Long.TYPE ||
+// returnType === java.lang.Short.TYPE ||
+// returnType === java.lang.Boolean.TYPE) {
+
+// const defValue = method.invoke(newer, null);
+// const currValue = method.invoke(recycled, null);
+// if ((currValue + "") !== (defValue + "")) {
+// throw new Error(`Actual: ${currValue}, Expected: ${defValue}, for method: ${method.getName()}`);
+// }
+// }
+// }
+// }
+
+// function checkDefaults(newer: View, first: View, props: Array, nativeGetters: Map any>): void {
+// props.forEach(prop => {
+// const name = (prop).name;
+// if (nativeGetters.has(name)) {
+// const getter = nativeGetters.get(name);
+// TKUnit.assertDeepEqual(getter(newer), getter(first), name);
+// } else if (newer[prop.getDefault]) {
+// TKUnit.assertDeepEqual(newer[prop.getDefault](), first[prop.getDefault](), name);
+// } else if (newer[prop.setNative]) {
+// console.log(`Type: ${newer.typeName} has no getter for ${name} property.`)
+// }
+// });
+// }
+
+// function setValue(object: Object, setters: Map, customSetters?: Map): void {
+// setters.forEach((value1, key) => {
+// let value = customSetters && customSetters.has(key) ? customSetters.get(key) : value1;
+// const currentValue = object[key];
+// if (currentValue === value) {
+// if (value === "horizontal" && key === "orientation") {
+// // wrap-layout.orientation default value is 'horizontal'
+// value = "vertical";
+// } else if (value === 2) {
+// value = 3;
+// }
+// }
+
+// object[key] = value;
+// const newValue = object[key];
+// TKUnit.assertNotEqual(newValue, currentValue, `${object} setting ${key} should change current value.`);
+// });
+// }
+
+// function setupSetters(): void {
+// if (setters) {
+// return;
+// }
+
+// setters = new Map();
+// // view-base
+// setters.set("id", "someId");
+// setters.set("className", "someClassName");
+// setters.set("bindingContext", "someBindingContext");
+
+// // view
+// setters.set("automationText", "automationText");
+// setters.set("originX", 0.2);
+// setters.set("originY", 0.2);
+// setters.set("isEnabled", false);
+// setters.set("isUserInteractionEnabled", false);
+
+// // action-bar
+// setters.set("title", "title");
+// setters.set("text", "text");
+// setters.set("icon", "~/logo.png");
+// setters.set("visibility", "collapse");
+
+// // activity-indicator
+// setters.set("busy", true);
+
+// // date-picker
+// setters.set("year", "2010");
+// setters.set("month", "2");
+// setters.set("day", "2");
+// setters.set("maxDate", "2100");
+// setters.set("minDate", "2000");
+// setters.set("date", new Date(2011, 3, 3));
+
+// // editable-text
+// setters.set("keyboardType", "datetime");
+// setters.set("returnKeyType", "done");
+// setters.set("editable", false);
+// setters.set("updateTextTrigger", "focusLost");
+// setters.set("autocapitalizationType", "words");
+// setters.set("autocorrect", true);
+// setters.set("hint", "hint");
+// setters.set("maxLength", "10");
+
+// // html-view
+// setters.set("html", "");
+
+// // image-view
+// setters.set("imageSource", "");
+// setters.set("src", "");
+// setters.set("loadMode", "async");
+// setters.set("isLoading", true);
+// setters.set("stretch", "none");
+
+// // layout-base
+// setters.set("clipToBounds", false);
+
+// // absolute-layout
+// setters.set("left", "20");
+// setters.set("top", "20");
+
+// // dock-layout
+// setters.set("dock", "top");
+// setters.set("stretchLastChild", false);
+
+// // grid-layout props
+// setters.set("row", "1");
+// setters.set("rowSpan", "2");
+// setters.set("col", "1");
+// setters.set("colSpan", "2");
+
+// // stack-layout
+// setters.set("orientation", "horizontal");
+
+// // wrap-layout
+// // custom orientation value
+// // setters.set('orientation', 'vertical');
+// setters.set("itemWidth", "50");
+// setters.set("itemHeight", "50");
+
+// // list-picker
+// setters.set("items", ["1", "2", "3"]);
+// setters.set("selectedIndex", "1");
+
+// // list-view
+// setters.set("items", ["1", "2", "3"]);
+// setters.set("itemTemplate", "");
+// setters.set("itemTemplates", "");
+// setters.set("rowHeight", "50");
+
+// // page
+// setters.set("actionBarHidden", "true");
+// setters.set("backgroundSpanUnderStatusBar", "true");
+// setters.set("enableSwipeBackNavigation", "false");
+
+// // progress
+// setters.set("value", "1");
+// setters.set("maxValue", "99");
+
+// // repeater
+// setters.set("items", ["1", "2", "3"]);
+// setters.set("itemTemplate", "");
+// setters.set("itemsLayout", new StackLayout());
+// setters.set("rowHeight", "50");
+
+// // scroll-view
+// // custom orientation value
+// //setters.set('orientation', 'horizontal');
+
+// // search-bar
+// setters.set("textFieldHintColor", "red");
+// setters.set("textFieldBackgroundColor", "red");
+
+// // segmented-bar
+// // custom items property
+
+// // slider
+// setters.set("minValue", "5");
+
+// // switch
+// setters.set("checked", "true");
+
+// // tab-view
+// // custom items property
+// setters.set("androidOffscreenTabLimit", "2");
+
+// // text-base
+// const formattedText = new FormattedString();
+// const span = new Span();
+// span.text = "span";
+// formattedText.spans.push(span);
+// setters.set("formattedText", formattedText);
+
+// // text-base
+// setters.set("secure", "true");
+
+// // time-picker
+// setters.set("minHour", 1);
+// setters.set("hour", 2);
+// setters.set("maxHour", 11);
+// setters.set("minMinute", 1);
+// setters.set("minute", 2);
+// setters.set("maxMinute", 11);
+// setters.set("minuteInterval", 2);
+// setters.set("time", new Date(2011, 2, 2, 3, 3, 3));
+
+// cssSetters = new Map();
+
+// // style
+// cssSetters.set("rotate", "90");
+// cssSetters.set("scaleX", 2);
+// cssSetters.set("scaleY", 2);
+// cssSetters.set("translateX", 20);
+// cssSetters.set("translateY", 20);
+
+// cssSetters.set("clipPath", "inset(100px 50px)");
+// cssSetters.set("color", "red");
+// cssSetters.set("tintColor", "green");
+// cssSetters.set("placeholderColor", "green");
+
+// cssSetters.set("backgroundColor", "red");
+// cssSetters.set("backgroundImage", "~/logo.png");
+// cssSetters.set("backgroundRepeat", "repeat");
+// cssSetters.set("backgroundSize", "60px 120px");
+// cssSetters.set("backgroundPosition", "center");
+// cssSetters.set("borderColor", "blue");
+// cssSetters.set("borderTopColor", "green");
+// cssSetters.set("borderRightColor", "green");
+// cssSetters.set("borderBottomColor", "green");
+// cssSetters.set("borderLeftColor", "green");
+// cssSetters.set("borderWidth", "10px");
+// cssSetters.set("borderTopWidth", "5px");
+// cssSetters.set("borderRightWidth", "5px");
+// cssSetters.set("borderBottomWidth", "5px");
+// cssSetters.set("borderLeftWidth", "5px");
+// cssSetters.set("borderRadius", "10px");
+// cssSetters.set("borderTopLeftRadius", "5px");
+// cssSetters.set("borderTopRightRadius", "5px");
+// cssSetters.set("borderBottomRightRadius", "5px");
+// cssSetters.set("borderBottomLeftRadius", "5px");
+
+// cssSetters.set("fontSize", "20");
+// cssSetters.set("fontFamily", "monospace");
+// cssSetters.set("fontStyle", "italic");
+// cssSetters.set("fontWeight", "100");
+// cssSetters.set("font", "italic 2 \"Open Sans\", sans-serif");
+
+// // zIndex on android is not what you think...
+// // cssSetters.set('zIndex', '2');
+// cssSetters.set("opacity", "0.5");
+// // already set through view properties.
+// // cssSetters.set('visibility', 'collapse');
+
+// cssSetters.set("letterSpacing", "2");
+// cssSetters.set("textAlignment", "center");
+// cssSetters.set("textDecoration", "underline");
+// cssSetters.set("textTransform", "capitalize");
+// cssSetters.set("whiteSpace", "normal");
+
+// cssSetters.set("minWidth", 50);
+// cssSetters.set("minHeight", 50);
+// cssSetters.set("width", 100);
+// cssSetters.set("height", 100);
+// cssSetters.set("margin", "25");
+// cssSetters.set("marginLeft", "30px");
+// cssSetters.set("marginTop", "30px");
+// cssSetters.set("marginRight", "30px");
+// cssSetters.set("marginBottom", "30px");
+// cssSetters.set("padding", "25");
+// cssSetters.set("paddingLeft", "30px");
+// cssSetters.set("paddingTop", "30px");
+// cssSetters.set("paddingRight", "30px");
+// cssSetters.set("paddingBottom", "30px");
+// cssSetters.set("horizontalAlignment", "center");
+// cssSetters.set("verticalAlignment", "center");
+
+// cssSetters.set("transform", "translate(5, 10), scale(1.2, 1.2), rotate(45)");
+
+// // TabView-specific props
+// cssSetters.set("tabTextColor", "red");
+// cssSetters.set("tabBackgroundColor", "red");
+// cssSetters.set("selectedTabTextColor", "red");
+// cssSetters.set("androidSelectedTabHighlightColor", "red");
+
+// // ListView-specific props
+// cssSetters.set("separatorColor", "red");
+
+// // SegmentedBar-specific props
+// cssSetters.set("selectedBackgroundColor", "red");
+
+// // Page-specific props
+// cssSetters.set("statusBarStyle", "light");
+// cssSetters.set("androidStatusBarBackground", "red");
+
+// // Flexbox-layout props
+// cssSetters.set("flexDirection", "column");
+// cssSetters.set("flexWrap", "wrap");
+// cssSetters.set("justifyContent", "center");
+// cssSetters.set("alignItems", "center");
+// cssSetters.set("alignContent", "center");
+// cssSetters.set("order", "2");
+// cssSetters.set("flexGrow", "1");
+// cssSetters.set("flexShrink", "0");
+// cssSetters.set("flexWrapBefore", "true");
+// cssSetters.set("alignSelf", "center");
+// cssSetters.set("flexFlow", "row-reverse wrap");
+// cssSetters.set("flex", "2 0.2");
+
+// const nativeGetters = defaultNativeGetters = new Map any>();
+
+// nativeGetters.set("marginLeft", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.leftMargin : 0;
+// });
+
+// nativeGetters.set("marginTop", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.topMargin : 0;
+// });
+
+// nativeGetters.set("marginRight", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.rightMargin : 0;
+// });
+
+// nativeGetters.set("marginBottom", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.bottomMargin : 0;
+// });
+
+// nativeGetters.set("col", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
+// });
+
+// nativeGetters.set("colSpan", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
+// });
+
+// nativeGetters.set("row", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
+// });
+
+// nativeGetters.set("rowSpan", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
+// });
+
+// nativeGetters.set("width", (v: { nativeView: android.view.View }) => {
+// const native = v.nativeView;
+// if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
+// return -2;
+// }
+// return native.getLayoutParams().width;
+// });
+// nativeGetters.set("height", (v: { nativeView: android.view.View }) => {
+// const native = v.nativeView;
+// if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
+// return -2;
+// }
+// return native.getLayoutParams().height;
+// });
+
+// nativeGetters.set("paddingLeft", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingLeft());
+// nativeGetters.set("paddingTop", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingTop());
+// nativeGetters.set("paddingRight", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingRight());
+// nativeGetters.set("paddingBottom", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingBottom());
+
+// nativeGetters.set("minWidth", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumWidth());
+// nativeGetters.set("minHeight", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumHeight());
+
+// nativeGetters.set("scaleX", (v: { nativeView: android.view.View }) => v.nativeView.getScaleX());
+// nativeGetters.set("scaleY", (v: { nativeView: android.view.View }) => v.nativeView.getScaleY());
+// nativeGetters.set("translateX", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationX());
+// nativeGetters.set("translateY", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationY());
+// nativeGetters.set("isEnabled", (v: { nativeView: android.view.View }) => v.nativeView.isEnabled());
+// nativeGetters.set("rotate", (v: { nativeView: android.view.View }) => v.nativeView.getRotation());
+
+// nativeGetters.set("order", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.order : 1;
+// });
+
+// nativeGetters.set("flexGrow", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexGrow : 0;
+// });
+
+// nativeGetters.set("flexShrink", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexShrink : 1;
+// });
+
+// nativeGetters.set("flexWrapBefore", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.wrapBefore : false;
+// });
+
+// nativeGetters.set("alignSelf", (v: { nativeView: android.view.View }) => {
+// const lp = v.nativeView.getLayoutParams();
+// return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.alignSelf : "auto";
+// });
+
+// nativeGetters.set("formattedText", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// return (nativeView instanceof android.widget.TextView) ? nativeView.getText().toString() : undefined;
+// });
+
+// nativeGetters.set("isUserInteractionEnabled", (v) => true);
+
+// nativeGetters.set("orientation", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof org.nativescript.widgets.StackLayout) {
+// return nativeView.getOrientation();
+// } else if (nativeView instanceof org.nativescript.widgets.WrapLayout) {
+// return nativeView.getOrientation();
+// }
+// });
+
+// nativeGetters.set("textTransform", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof android.widget.TextView) {
+// return nativeView.getTransformationMethod();
+// }
+// });
+
+// nativeGetters.set("editable", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof android.widget.TextView) {
+// return nativeView.getKeyListener();
+// }
+// });
+
+// nativeGetters.set("maxLength", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof android.widget.TextView) {
+// return nativeView.getFilters();
+// }
+// });
+
+// nativeGetters.set("whiteSpace", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof android.widget.TextView) {
+// return { lineCount: nativeView.getLineCount(), ellipsize: nativeView.getEllipsize() };
+// }
+// });
+
+// nativeGetters.set("text", (v: { nativeView: android.view.View }) => {
+// const nativeView = v.nativeView;
+// if (nativeView instanceof android.widget.TextView) {
+// const text = nativeView.getText();
+// return text ? text.toString() : text;
+// }
+// });
+// }
diff --git a/tests/app/ui/layouts/safe-area-tests.ts b/tests/app/ui/layouts/safe-area-tests.ts
index 15350f634..965d89b07 100644
--- a/tests/app/ui/layouts/safe-area-tests.ts
+++ b/tests/app/ui/layouts/safe-area-tests.ts
@@ -3,7 +3,6 @@ import * as TKUnit from "../../TKUnit";
import * as view from "tns-core-modules/ui/core/view";
import * as testModule from "../../ui-test";
import * as platform from "tns-core-modules/platform";
-import { ios as iosUtils } from "tns-core-modules/utils/utils";
import * as helper from "../helper";
import { parse } from "tns-core-modules/ui/builder";
import { Page } from "tns-core-modules/ui/page";
@@ -75,7 +74,7 @@ export class SafeAreaTests extends testModule.UITest {
};
private layout_insets_top_action_bar_test(layout: view.View) {
- const app = iosUtils.getter(UIApplication, UIApplication.sharedApplication);
+ const app = UIApplication.sharedApplication;
const statusBarHeight = round(dipToDp(app.statusBarFrame.size.height));
const actionBarHeight = round(dipToDp(layout.page.actionBar.nativeViewProtected.frame.size.height));
const topInset = statusBarHeight + actionBarHeight;
@@ -85,7 +84,7 @@ export class SafeAreaTests extends testModule.UITest {
}
private layout_insets_top_action_bar_hidden_test(layout: view.View) {
- const app = iosUtils.getter(UIApplication, UIApplication.sharedApplication);
+ const app = UIApplication.sharedApplication;
const statusBarHeight = round(dipToDp(app.statusBarFrame.size.height));
const topInset = statusBarHeight;
diff --git a/tests/app/ui/time-picker/time-picker-tests-native.ios.ts b/tests/app/ui/time-picker/time-picker-tests-native.ios.ts
index 553181c3e..b8f06729c 100644
--- a/tests/app/ui/time-picker/time-picker-tests-native.ios.ts
+++ b/tests/app/ui/time-picker/time-picker-tests-native.ios.ts
@@ -1,33 +1,31 @@
import * as timePickerModule from "tns-core-modules/ui/time-picker";
-import * as utils from "tns-core-modules/utils/utils";
-
export function getNativeHour(timePicker: timePickerModule.TimePicker): number {
- return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).hour;
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).hour;
}
export function getNativeMinute(timePicker: timePickerModule.TimePicker): number {
- return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).minute;
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).minute;
}
export function setNativeHour(timePicker: timePickerModule.TimePicker, value: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
comps.hour = value;
- timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ timePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(timePicker)._changeHandler.valueChanged(timePicker.ios);
}
export function setNativeMinute(timePicker: timePickerModule.TimePicker, value: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
comps.minute = value;
- timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ timePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(timePicker)._changeHandler.valueChanged(timePicker.ios);
}
export function setNativeTime(timePicker: timePickerModule.TimePicker, hour: number, minute: number): void {
- var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
+ var comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
comps.hour = hour;
comps.minute = minute;
- timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ timePicker.ios.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
(timePicker)._changeHandler.valueChanged(timePicker.ios);
}
diff --git a/tns-core-modules/application-settings/application-settings.ios.ts b/tns-core-modules/application-settings/application-settings.ios.ts
index 3fbfc9db8..6c2c4b757 100644
--- a/tns-core-modules/application-settings/application-settings.ios.ts
+++ b/tns-core-modules/application-settings/application-settings.ios.ts
@@ -2,7 +2,7 @@
import * as utils from "../utils/utils";
-var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
+var userDefaults = NSUserDefaults.standardUserDefaults;
export var hasKey = function (key: string): boolean {
Common.checkKey(key);
@@ -59,7 +59,7 @@ export var remove = function (key: string): void {
}
export var clear = function (): void {
- userDefaults.removePersistentDomainForName(utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier);
+ userDefaults.removePersistentDomainForName(NSBundle.mainBundle.bundleIdentifier);
}
export var flush = function (): boolean {
diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts
index df635cf5f..11fe3d657 100644
--- a/tns-core-modules/application/application.ios.ts
+++ b/tns-core-modules/application/application.ios.ts
@@ -18,9 +18,11 @@ export * from "./application-common";
import { createViewFromEntry } from "../ui/builder";
import { ios as iosView, View } from "../ui/core/view";
import { Frame, NavigationEntry } from "../ui/frame";
-import * as utils from "../utils/utils";
+import { ios } from "../utils/utils";
import { profile, level as profilingLevel, Level } from "../profiling";
+const getVisibleViewController = ios.getVisibleViewController;
+
// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430
// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved:
// https://github.com/NativeScript/ios-runtime/issues/1012
@@ -60,7 +62,7 @@ let displayedLink;
class CADisplayLinkTarget extends NSObject {
onDisplayed(link: CADisplayLink) {
link.invalidate();
- const ios = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
+ const ios = UIApplication.sharedApplication;
const object = iosApp;
displayedOnce = true;
notify({ eventName: displayedEvent, object, ios });
@@ -74,7 +76,7 @@ class CADisplayLinkTarget extends NSObject {
class IOSApplication implements IOSApplicationDefinition {
private _delegate: typeof UIApplicationDelegate;
- private _currentOrientation = utils.ios.getter(UIDevice, UIDevice.currentDevice).orientation;
+ private _currentOrientation = UIDevice.currentDevice.orientation;
private _window: UIWindow;
private _observers: Array;
private _rootView: View;
@@ -94,7 +96,7 @@ class IOSApplication implements IOSApplicationDefinition {
}
get nativeApp(): UIApplication {
- return utils.ios.getter(UIApplication, UIApplication.sharedApplication);
+ return UIApplication.sharedApplication;
}
get window(): UIWindow {
@@ -116,7 +118,7 @@ class IOSApplication implements IOSApplicationDefinition {
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
- utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
+ NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
this._observers.push(observer);
return observer;
}
@@ -125,7 +127,7 @@ class IOSApplication implements IOSApplicationDefinition {
var index = this._observers.indexOf(observer);
if (index >= 0) {
this._observers.splice(index, 1);
- utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(observer, notificationName, null);
+ NSNotificationCenter.defaultCenter.removeObserverNameObject(observer, notificationName, null);
}
}
@@ -138,9 +140,9 @@ class IOSApplication implements IOSApplicationDefinition {
displayedLink.addToRunLoopForMode(NSRunLoop.mainRunLoop, UITrackingRunLoopMode);
}
- this._window = UIWindow.alloc().initWithFrame(utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds);
+ this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
// TODO: Expose Window module so that it can we styled from XML & CSS
- this._window.backgroundColor = utils.ios.getter(UIColor, UIColor.whiteColor);
+ this._window.backgroundColor = UIColor.whiteColor;
this.notifyAppStarted(notification);
@@ -166,7 +168,7 @@ class IOSApplication implements IOSApplicationDefinition {
@profile
private didBecomeActive(notification: NSNotification) {
- const ios = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
+ const ios = UIApplication.sharedApplication;
const object = this;
notify({ eventName: resumeEvent, object, ios });
const rootView = this._rootView;
@@ -176,7 +178,7 @@ class IOSApplication implements IOSApplicationDefinition {
}
private didEnterBackground(notification: NSNotification) {
- notify({ eventName: suspendEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
+ notify({ eventName: suspendEvent, object: this, ios: UIApplication.sharedApplication });
const rootView = this._rootView;
if (rootView && rootView.isLoaded) {
rootView.callUnloaded();
@@ -184,7 +186,7 @@ class IOSApplication implements IOSApplicationDefinition {
}
private willTerminate(notification: NSNotification) {
- notify({ eventName: exitEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
+ notify({ eventName: exitEvent, object: this, ios: UIApplication.sharedApplication });
const rootView = this._rootView;
if (rootView && rootView.isLoaded) {
rootView.callUnloaded();
@@ -192,11 +194,11 @@ class IOSApplication implements IOSApplicationDefinition {
}
private didReceiveMemoryWarning(notification: NSNotification) {
- notify({ eventName: lowMemoryEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
+ notify({ eventName: lowMemoryEvent, object: this, ios: UIApplication.sharedApplication });
}
private orientationDidChange(notification: NSNotification) {
- const orientation = utils.ios.getter(UIDevice, UIDevice.currentDevice).orientation;
+ const orientation = UIDevice.currentDevice.orientation;
if (this._currentOrientation !== orientation) {
this._currentOrientation = orientation;
@@ -324,7 +326,7 @@ export function start(entry?: string | NavigationEntry) {
if (embedderDelegate) {
embedderDelegate.presentNativeScriptApp(controller);
} else {
- let visibleVC = utils.ios.getVisibleViewController(rootController);
+ let visibleVC = getVisibleViewController(rootController);
visibleVC.presentViewControllerAnimatedCompletion(controller, true, null);
}
iosApp.notifyAppStarted();
diff --git a/tns-core-modules/debugger/webinspector-network.ios.ts b/tns-core-modules/debugger/webinspector-network.ios.ts
index bce24b9c7..80b627e6c 100644
--- a/tns-core-modules/debugger/webinspector-network.ios.ts
+++ b/tns-core-modules/debugger/webinspector-network.ios.ts
@@ -4,19 +4,6 @@ var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBacken
import * as debuggerDomains from "./debugger";
declare var __inspectorSendEvent;
-/**
- * Checks if the property is a function and if it is, calls it on this.
- * Designed to support backward compatibility for methods that became properties.
- * Will not work on delegates since it checks if the propertyValue is a function, and delegates are marshalled as functions.
- * Example: getter(NSRunLoop, NSRunLoop.currentRunLoop).runUntilDate(NSDate.dateWithTimeIntervalSinceNow(waitTime));
- */
-function getter(_this: any, property: T | {(): T}): T {
- if (typeof property === "function") {
- return (<{(): T}>property).call(_this);
- } else {
- return property;
- }
-}
declare var __inspectorTimestamp;
@@ -237,9 +224,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
*/
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string, mimeType: string, status: number } {
- let appPath = getter(NSBundle, NSBundle.mainBundle).bundlePath;
+ let appPath = NSBundle.mainBundle.bundlePath;
let pathUrl = params.url.replace("file://", appPath);
- let fileManager = getter(NSFileManager, NSFileManager.defaultManager);
+ let fileManager = NSFileManager.defaultManager;
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : "";
diff --git a/tns-core-modules/file-system/file-system-access.ios.ts b/tns-core-modules/file-system/file-system-access.ios.ts
index 23c7faf1f..c11629c44 100644
--- a/tns-core-modules/file-system/file-system-access.ios.ts
+++ b/tns-core-modules/file-system/file-system-access.ios.ts
@@ -6,7 +6,7 @@ import { ios } from "../utils/utils";
export class FileSystemAccess {
public getLastModified(path: string): Date {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const attributes = fileManager.attributesOfItemAtPathError(path);
if (attributes) {
@@ -17,7 +17,7 @@ export class FileSystemAccess {
}
public getFileSize(path: string): number {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const attributes = fileManager.attributesOfItemAtPathError(path);
if (attributes) {
return attributes.objectForKey("NSFileSize");
@@ -28,7 +28,7 @@ export class FileSystemAccess {
public getParent(path: string, onError?: (error: any) => any): { path: string; name: string } {
try {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const nsString = NSString.stringWithString(path);
const parentPath = nsString.stringByDeletingLastPathComponent;
@@ -49,7 +49,7 @@ export class FileSystemAccess {
public getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string } {
try {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const exists = fileManager.fileExistsAtPath(path);
if (!exists) {
@@ -81,7 +81,7 @@ export class FileSystemAccess {
public getFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
try {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const exists = this.folderExists(path);
if (!exists) {
@@ -114,7 +114,7 @@ export class FileSystemAccess {
public getExistingFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
try {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const exists = this.folderExists(path);
if (exists) {
@@ -179,7 +179,7 @@ export class FileSystemAccess {
}
private exists(path: string): { exists: boolean, isDirectory: boolean } {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const isDirectory = new interop.Reference(interop.types.bool, false);
const exists = fileManager.fileExistsAtPathIsDirectory(path, isDirectory);
@@ -199,7 +199,7 @@ export class FileSystemAccess {
}
public emptyFolder(path: string, onError?: (error: any) => any) {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const entities = this.getEntities(path, onError);
if (!entities) {
@@ -221,7 +221,7 @@ export class FileSystemAccess {
}
public rename(path: string, newPath: string, onError?: (error: any) => any) {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
try {
fileManager.moveItemAtPathToPathError(path, newPath);
@@ -233,7 +233,7 @@ export class FileSystemAccess {
}
public getLogicalRootPath(): string {
- const mainBundlePath = ios.getter(NSBundle, NSBundle.mainBundle).bundlePath;
+ const mainBundlePath = NSBundle.mainBundle.bundlePath;
const resolvedPath = NSString.stringWithString(mainBundlePath).stringByResolvingSymlinksInPath;
return resolvedPath;
}
@@ -299,7 +299,7 @@ export class FileSystemAccess {
}
private getKnownPath(folderType: number): string {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
const paths = fileManager.URLsForDirectoryInDomains(folderType, NSSearchPathDomainMask.UserDomainMask);
const url = paths.objectAtIndex(0);
@@ -327,7 +327,7 @@ export class FileSystemAccess {
}
private deleteEntity(path: string, onError?: (error: any) => any) {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
try {
fileManager.removeItemAtPathError(path);
} catch (ex) {
@@ -339,7 +339,7 @@ export class FileSystemAccess {
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
try {
- const fileManager = ios.getter(NSFileManager, NSFileManager.defaultManager);
+ const fileManager = NSFileManager.defaultManager;
let files: NSArray;
try {
files = fileManager.contentsOfDirectoryAtPathError(path);
diff --git a/tns-core-modules/fps-meter/fps-native.ios.ts b/tns-core-modules/fps-meter/fps-native.ios.ts
index b4c4ff388..2b631d93b 100644
--- a/tns-core-modules/fps-meter/fps-native.ios.ts
+++ b/tns-core-modules/fps-meter/fps-native.ios.ts
@@ -37,10 +37,10 @@ export class FPSCallback implements definition.FPSCallback {
this.displayLink = CADisplayLink.displayLinkWithTargetSelector(this.impl, "handleFrame");
this.displayLink.paused = true;
- this.displayLink.addToRunLoopForMode(utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop), NSDefaultRunLoopMode);
+ this.displayLink.addToRunLoopForMode(NSRunLoop.currentRunLoop, NSDefaultRunLoopMode);
// UIScrollView (including in UIITableView) will run a loop in UITrackingRunLoopMode during scrolling.
// If we do not add the CADisplayLink in this mode, it would appear paused during scrolling.
- this.displayLink.addToRunLoopForMode(utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop), UITrackingRunLoopMode);
+ this.displayLink.addToRunLoopForMode(NSRunLoop.currentRunLoop, UITrackingRunLoopMode);
}
public start() {
diff --git a/tns-core-modules/http/http-request/http-request.android.ts b/tns-core-modules/http/http-request/http-request.android.ts
index a6a1f04bc..150b2ba89 100644
--- a/tns-core-modules/http/http-request/http-request.android.ts
+++ b/tns-core-modules/http/http-request/http-request.android.ts
@@ -1,14 +1,10 @@
-/**
- * Android specific http request implementation.
- */
-import { fromNativeSource } from "../../image-source";
-import { screen } from "../../platform";
-import { File } from "../../file-system";
+// imported for definition purposes only
+import * as httpModule from "../../http";
+import * as imageSourceModule from "../../image-source";
+import * as platformModule from "../../platform";
+import * as fsModule from "../../file-system";
+
import { getFilenameFromUrl } from "./http-request-common";
-
-// this is imported for definition purposes only
-import * as http from "../../http";
-
import { NetworkAgent } from "../../debugger/debugger";
export enum HttpResponseEncoding {
@@ -28,6 +24,27 @@ function parseJSON(source: string): any {
let requestIdCounter = 0;
const pendingRequests = {};
+let imageSource: typeof imageSourceModule;
+function ensureImageSource() {
+ if (!imageSource) {
+ imageSource = require("image-source");
+ }
+}
+
+let platform: typeof platformModule;
+function ensurePlatform() {
+ if (!platform) {
+ platform = require("platform");
+ }
+}
+
+let fs: typeof fsModule;
+function ensureFileSystem() {
+ if (!fs) {
+ fs = require("file-system");
+ }
+}
+
let completeCallback: org.nativescript.widgets.Async.CompleteCallback;
function ensureCompleteCallback() {
if (completeCallback) {
@@ -55,7 +72,7 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
}
// read the headers
- const headers: http.Headers = {};
+ const headers: httpModule.Headers = {};
if (result.headers) {
const jHeaders = result.headers;
const length = jHeaders.size();
@@ -97,9 +114,11 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
return parseJSON(str);
},
toImage: () => {
+ ensureImageSource();
+
return new Promise((resolveImage, rejectImage) => {
if (result.responseAsImage != null) {
- resolveImage(fromNativeSource(result.responseAsImage));
+ resolveImage(imageSource.fromNativeSource(result.responseAsImage));
}
else {
rejectImage(new Error("Response content may not be converted to an Image"));
@@ -107,13 +126,15 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
});
},
toFile: (destinationFilePath: string) => {
+ ensureFileSystem();
+
if (!destinationFilePath) {
destinationFilePath = getFilenameFromUrl(callbacks.url);
}
let stream: java.io.FileOutputStream;
try {
// ensure destination path exists by creating any missing parent directories
- const file = File.fromPath(destinationFilePath);
+ const file = fs.File.fromPath(destinationFilePath);
const javaFile = new java.io.File(destinationFilePath);
stream = new java.io.FileOutputStream(javaFile);
@@ -144,7 +165,7 @@ function onRequestError(error: string, requestId: number) {
}
}
-function buildJavaOptions(options: http.HttpRequestOptions) {
+function buildJavaOptions(options: httpModule.HttpRequestOptions) {
if (typeof options.url !== "string") {
throw new Error("Http request must provide a valid url.");
}
@@ -177,20 +198,23 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
javaOptions.headers = arrayList;
}
+ ensurePlatform();
+
// pass the maximum available image size to the request options in case we need a bitmap conversion
- javaOptions.screenWidth = screen.mainScreen.widthPixels;
- javaOptions.screenHeight = screen.mainScreen.heightPixels;
+ const screen = platform.screen.mainScreen;
+ javaOptions.screenWidth = screen.widthPixels;
+ javaOptions.screenHeight = screen.heightPixels;
return javaOptions;
}
-export function request(options: http.HttpRequestOptions): Promise {
+export function request(options: httpModule.HttpRequestOptions): Promise {
if (options === undefined || options === null) {
// TODO: Shouldn't we throw an error here - defensive programming
return;
}
- return new Promise((resolve, reject) => {
+ return new Promise((resolve, reject) => {
try {
// initialize the options
const javaOptions = buildJavaOptions(options);
@@ -228,7 +252,7 @@ function decodeResponse(raw: any, encoding?: HttpResponseEncoding) {
return raw.toString(charsetName)
}
-export function addHeader(headers: http.Headers, key: string, value: string): void {
+export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
if (!headers[key]) {
headers[key] = value;
} else if (Array.isArray(headers[key])) {
diff --git a/tns-core-modules/http/http-request/http-request.ios.ts b/tns-core-modules/http/http-request/http-request.ios.ts
index 6e02247b2..ad53e823c 100644
--- a/tns-core-modules/http/http-request/http-request.ios.ts
+++ b/tns-core-modules/http/http-request/http-request.ios.ts
@@ -1,15 +1,9 @@
-/**
- * iOS specific http request implementation.
- */
+// imported for definition purposes only
+import * as httpModule from "../../http";
+import * as imageSourceModule from "../../image-source";
+import * as fsModule from "../../file-system";
-import { HttpRequestOptions, HttpResponse, Headers } from "../../http";
import * as types from "../../utils/types";
-import { fromNativeSource } from "../../image-source";
-import { File } from "../../file-system";
-
-import * as utils from "../../utils/utils";
-import getter = utils.ios.getter;
-
import * as domainDebugger from "../../debugger/debugger";
import { getFilenameFromUrl } from "./http-request-common";
@@ -18,15 +12,15 @@ export enum HttpResponseEncoding {
GBK
}
-const currentDevice = getter(UIDevice, UIDevice.currentDevice);
+const currentDevice = UIDevice.currentDevice;
const device = currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Phone ? "Phone" : "Pad";
const osVersion = currentDevice.systemVersion;
const GET = "GET";
const USER_AGENT_HEADER = "User-Agent";
const USER_AGENT = `Mozilla/5.0 (i${device}; CPU OS ${osVersion.replace(".", "_")} like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/${osVersion} Mobile/10A5355d Safari/8536.25`;
-const sessionConfig = getter(NSURLSessionConfiguration, NSURLSessionConfiguration.defaultSessionConfiguration);
-const queue = getter(NSOperationQueue, NSOperationQueue.mainQueue);
+const sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration;
+const queue = NSOperationQueue.mainQueue;
function parseJSON(source: string): any {
const src = source.trim();
@@ -59,8 +53,22 @@ function ensureSessionNotFollowingRedirects() {
}
}
-export function request(options: HttpRequestOptions): Promise {
- return new Promise((resolve, reject) => {
+let imageSource: typeof imageSourceModule;
+function ensureImageSource() {
+ if (!imageSource) {
+ imageSource = require("image-source");
+ }
+}
+
+let fs: typeof fsModule;
+function ensureFileSystem() {
+ if (!fs) {
+ fs = require("file-system");
+ }
+}
+
+export function request(options: httpModule.HttpRequestOptions): Promise {
+ return new Promise((resolve, reject) => {
if (!options.url) {
reject(new Error("Request url was empty."));
@@ -106,7 +114,7 @@ export function request(options: HttpRequestOptions): Promise {
if (error) {
reject(new Error(error.localizedDescription));
} else {
- const headers: Headers = {};
+ const headers: httpModule.Headers = {};
if (response && response.allHeaderFields) {
const headerFields = response.allHeaderFields;
@@ -136,10 +144,12 @@ export function request(options: HttpRequestOptions): Promise {
toString: (encoding?: any) => NSDataToString(data, encoding),
toJSON: (encoding?: any) => parseJSON(NSDataToString(data, encoding)),
toImage: () => {
+ ensureImageSource();
+
return new Promise((resolve, reject) => {
(UIImage).tns_decodeImageWithDataCompletion(data, image => {
if (image) {
- resolve(fromNativeSource(image));
+ resolve(imageSource.fromNativeSource(image));
} else {
reject(new Error("Response content may not be converted to an Image"));
}
@@ -147,12 +157,14 @@ export function request(options: HttpRequestOptions): Promise {
});
},
toFile: (destinationFilePath?: string) => {
+ ensureFileSystem();
+
if (!destinationFilePath) {
destinationFilePath = getFilenameFromUrl(options.url);
}
if (data instanceof NSData) {
// ensure destination path exists by creating any missing parent directories
- const file = File.fromPath(destinationFilePath);
+ const file = fs.File.fromPath(destinationFilePath);
data.writeToFileAtomically(destinationFilePath, true);
@@ -192,7 +204,7 @@ function NSDataToString(data: any, encoding?: HttpResponseEncoding): string {
return NSString.alloc().initWithDataEncoding(data, code).toString();
}
-export function addHeader(headers: Headers, key: string, value: string): void {
+export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
if (!headers[key]) {
headers[key] = value;
} else if (Array.isArray(headers[key])) {
diff --git a/tns-core-modules/platform/platform.ios.ts b/tns-core-modules/platform/platform.ios.ts
index 58a0b17ca..f9fd215d8 100644
--- a/tns-core-modules/platform/platform.ios.ts
+++ b/tns-core-modules/platform/platform.ios.ts
@@ -26,7 +26,7 @@ class Device implements DeviceDefinition {
get osVersion(): string {
if (!this._osVersion) {
- this._osVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
+ this._osVersion = UIDevice.currentDevice.systemVersion;
}
return this._osVersion;
@@ -34,7 +34,7 @@ class Device implements DeviceDefinition {
get model(): string {
if (!this._model) {
- this._model = utils.ios.getter(UIDevice, UIDevice.currentDevice).model;
+ this._model = UIDevice.currentDevice.model;
}
return this._model;
@@ -42,7 +42,7 @@ class Device implements DeviceDefinition {
get sdkVersion(): string {
if (!this._sdkVersion) {
- this._sdkVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
+ this._sdkVersion = UIDevice.currentDevice.systemVersion;
}
return this._sdkVersion;
@@ -50,7 +50,7 @@ class Device implements DeviceDefinition {
get deviceType(): "Phone" | "Tablet" {
if (!this._deviceType) {
- if (utils.ios.getter(UIDevice, UIDevice.currentDevice).userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
+ if (UIDevice.currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
this._deviceType = "Phone";
}
else {
@@ -62,7 +62,7 @@ class Device implements DeviceDefinition {
}
get uuid(): string {
- var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
+ var userDefaults = NSUserDefaults.standardUserDefaults;
var uuid_key = "TNSUUID";
var app_uuid = userDefaults.stringForKey(uuid_key);
@@ -77,7 +77,7 @@ class Device implements DeviceDefinition {
get language(): string {
if (!this._language) {
- var languages = utils.ios.getter(NSLocale, NSLocale.preferredLanguages);
+ var languages = NSLocale.preferredLanguages;
this._language = languages[0];
}
@@ -86,7 +86,7 @@ class Device implements DeviceDefinition {
get region(): string {
if (!this._region) {
- this._region = utils.ios.getter(NSLocale, NSLocale.currentLocale).objectForKey(NSLocaleCountryCode);
+ this._region = NSLocale.currentLocale.objectForKey(NSLocaleCountryCode);
}
return this._region;
@@ -98,7 +98,7 @@ class MainScreen implements ScreenMetricsDefinition {
private get screen(): UIScreen {
if (!this._screen) {
- this._screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
+ this._screen = UIScreen.mainScreen;
}
return this._screen;
diff --git a/tns-core-modules/timer/timer.ios.ts b/tns-core-modules/timer/timer.ios.ts
index cf780daa6..097a19bdf 100644
--- a/tns-core-modules/timer/timer.ios.ts
+++ b/tns-core-modules/timer/timer.ios.ts
@@ -55,7 +55,7 @@ function createTimerAndGetId(callback: Function, milliseconds: number, shouldRep
let timer = NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(milliseconds / 1000, timerTarget, "tick", null, shouldRepeat);
// https://github.com/NativeScript/NativeScript/issues/2116
- utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop).addTimerForMode(timer, NSRunLoopCommonModes);
+ NSRunLoop.currentRunLoop.addTimerForMode(timer, NSRunLoopCommonModes);
let pair: KeyValuePair = { k: timer, v: timerTarget };
timeoutCallbacks.set(id, pair);
diff --git a/tns-core-modules/ui/animation/animation.ios.ts b/tns-core-modules/ui/animation/animation.ios.ts
index 7f8cfbeee..2007b637e 100644
--- a/tns-core-modules/ui/animation/animation.ios.ts
+++ b/tns-core-modules/ui/animation/animation.ios.ts
@@ -7,12 +7,8 @@ import {
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty
} from "../styling/style-properties";
-import { ios } from "../../utils/utils";
-
export * from "./animation-common";
-let getter = ios.getter;
-
let _transform = "_transform";
let _skip = "_skip";
@@ -283,7 +279,7 @@ export class Animation extends AnimationBase {
};
originalValue = nativeView.layer.backgroundColor;
if (nativeView instanceof UILabel) {
- nativeView.setValueForKey(getter(UIColor, UIColor.clearColor), "backgroundColor");
+ nativeView.setValueForKey(UIColor.clearColor, "backgroundColor");
}
value = value.CGColor;
break;
diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts
index d44e59823..53281f20e 100644
--- a/tns-core-modules/ui/core/view/view.ios.ts
+++ b/tns-core-modules/ui/core/view/view.ios.ts
@@ -431,7 +431,7 @@ export class View extends ViewCommon {
const animated = options.animated === undefined ? true : !!options.animated;
(controller).animated = animated;
parentController.presentViewControllerAnimatedCompletion(controller, animated, null);
- const transitionCoordinator = iosUtils.getter(parentController, parentController.transitionCoordinator);
+ const transitionCoordinator = parentController.transitionCoordinator;
if (transitionCoordinator) {
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion
.call(transitionCoordinator, null, () => this._raiseShownModallyEvent());
@@ -643,7 +643,7 @@ export class CustomLayoutView extends ContainerView {
nativeViewProtected: UIView;
createNativeView() {
- return UIView.alloc().initWithFrame(iosUtils.getter(UIScreen, UIScreen.mainScreen).bounds);
+ return UIView.alloc().initWithFrame(UIScreen.mainScreen.bounds);
}
get ios(): UIView {
diff --git a/tns-core-modules/ui/date-picker/date-picker.ios.ts b/tns-core-modules/ui/date-picker/date-picker.ios.ts
index 3d2533ef0..cc94b34f1 100644
--- a/tns-core-modules/ui/date-picker/date-picker.ios.ts
+++ b/tns-core-modules/ui/date-picker/date-picker.ios.ts
@@ -47,11 +47,11 @@ export class DatePicker extends DatePickerBase {
[dateProperty.setNative](value: Date) {
const picker = this.nativeViewProtected;
- const comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
+ const comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.date);
comps.year = value.getFullYear();
comps.month = value.getMonth() + 1;
comps.day = value.getDate();
- picker.setDateAnimated(ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
+ picker.setDateAnimated(NSCalendar.currentCalendar.dateFromComponents(comps), false);
}
[maxDateProperty.getDefault](): Date {
@@ -91,7 +91,7 @@ class UIDatePickerChangeHandlerImpl extends NSObject {
}
public valueChanged(sender: UIDatePicker) {
- const comps = ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date);
+ const comps = NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date);
const owner = this._owner.get();
if (!owner) {
diff --git a/tns-core-modules/ui/gestures/gestures.ios.ts b/tns-core-modules/ui/gestures/gestures.ios.ts
index c9ed76e09..b9dd31450 100644
--- a/tns-core-modules/ui/gestures/gestures.ios.ts
+++ b/tns-core-modules/ui/gestures/gestures.ios.ts
@@ -4,8 +4,6 @@ import { View, EventData } from "../core/view";
// Types.
import { GesturesObserverBase, toString, TouchAction, GestureStateTypes, GestureTypes, SwipeDirection } from "./gestures-common";
-import { ios } from "../../utils/utils";
-import getter = ios.getter;
export * from "./gestures-common";
@@ -438,7 +436,7 @@ class TouchGestureEventData implements TouchGestureEventData {
}
getPointerCount(): number {
- return getter(this.ios.event, this.ios.event.allTouches).count;
+ return this.ios.event.allTouches.count;
}
private getMainPointer(): UITouch {
@@ -464,7 +462,7 @@ class TouchGestureEventData implements TouchGestureEventData {
if (!this._allPointers) {
this._allPointers = [];
- let nsArr = getter(this.ios.event, this.ios.event.allTouches).allObjects;
+ let nsArr = this.ios.event.allTouches.allObjects;
for (let i = 0; i < nsArr.count; i++) {
this._allPointers.push(new Pointer(nsArr.objectAtIndex(i), this.view));
}
diff --git a/tns-core-modules/ui/image-cache/image-cache.ios.ts b/tns-core-modules/ui/image-cache/image-cache.ios.ts
index 8224fcb56..c4f298a4c 100644
--- a/tns-core-modules/ui/image-cache/image-cache.ios.ts
+++ b/tns-core-modules/ui/image-cache/image-cache.ios.ts
@@ -1,9 +1,9 @@
-import * as common from "./image-cache-common";
-import * as trace from "../../trace";
+// imported for definition purposes only
import * as httpRequestModule from "../../http/http-request";
+import * as common from "./image-cache-common";
+import * as trace from "../../trace";
import * as utils from "../../utils/utils";
-import getter = utils.ios.getter;
var httpRequest: typeof httpRequestModule;
function ensureHttpRequest() {
@@ -12,18 +12,6 @@ function ensureHttpRequest() {
}
}
-//class NSCacheDelegateImpl extends NSObject implements NSCacheDelegate {
-// public static ObjCProtocols = [NSCacheDelegate];
-
-// static new(): NSCacheDelegateImpl {
-// return super.new();
-// }
-
-// public cacheWillEvictObject(cache: NSCache, obj: any): void {
-// traceWrite("NSCacheDelegateImpl.cacheWillEvictObject(" + obj + ");", traceCategories.Debug);
-// }
-//}
-
class MemmoryWarningHandler extends NSObject {
static new(): MemmoryWarningHandler {
return super.new();
@@ -34,7 +22,7 @@ class MemmoryWarningHandler extends NSObject {
public initWithCache(cache: NSCache): MemmoryWarningHandler {
this._cache = cache;
- getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
+ NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
if (trace.isEnabled()) {
trace.write("[MemmoryWarningHandler] Added low memory observer.", trace.categories.Debug);
}
@@ -43,7 +31,7 @@ class MemmoryWarningHandler extends NSObject {
}
public dealloc(): void {
- getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
+ NSNotificationCenter.defaultCenter.removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
if (trace.isEnabled()) {
trace.write("[MemmoryWarningHandler] Removed low memory observer.", trace.categories.Debug);
}
@@ -65,7 +53,6 @@ class MemmoryWarningHandler extends NSObject {
export class Cache extends common.Cache {
private _cache: NSCache;
- //private _delegate: NSCacheDelegate;
//@ts-ignore
private _memoryWarningHandler: MemmoryWarningHandler;
@@ -74,9 +61,6 @@ export class Cache extends common.Cache {
this._cache = new NSCache();
- //this._delegate = NSCacheDelegateImpl.new();
- //this._cache.delegate = this._delegate;
-
this._memoryWarningHandler = MemmoryWarningHandler.new().initWithCache(this._cache);
}
diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts b/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts
index aa7e87c75..1bf2e8381 100644
--- a/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts
+++ b/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts
@@ -4,8 +4,6 @@ import {
colorProperty, fontInternalProperty, Color
} from "./segmented-bar-common";
-import { ios } from "../../utils/utils";
-
export * from "./segmented-bar-common";
export class SegmentedBarItem extends SegmentedBarItemBase {
@@ -93,7 +91,7 @@ export class SegmentedBar extends SegmentedBarBase {
return null
}
[fontInternalProperty.setNative](value: Font) {
- let font: UIFont = value ? value.getUIFont(UIFont.systemFontOfSize(ios.getter(UIFont, UIFont.labelFontSize))) : null;
+ let font: UIFont = value ? value.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)) : null;
let bar = this.ios;
let currentAttrs = bar.titleTextAttributesForState(UIControlState.Normal);
let attrs = currentAttrs ? currentAttrs.mutableCopy() : NSMutableDictionary.new();
diff --git a/tns-core-modules/ui/styling/background.ios.ts b/tns-core-modules/ui/styling/background.ios.ts
index 9a4440c62..025fb3df4 100644
--- a/tns-core-modules/ui/styling/background.ios.ts
+++ b/tns-core-modules/ui/styling/background.ios.ts
@@ -4,7 +4,7 @@ import { Background as BackgroundDefinition } from "./background";
import { View, Point } from "../core/view";
import { LinearGradient } from "./linear-gradient";
import { Color } from "../../color";
-import { ios as utilsIos, isDataURI, isFileOrResourcePath, layout } from "../../utils/utils";
+import { isDataURI, isFileOrResourcePath, layout } from "../../utils/utils";
import { fromFileOrResource, fromBase64, fromUrl } from "../../image-source";
import { CSSValue, parse as cssParse } from "../../css-value";
@@ -33,7 +33,7 @@ interface Rect {
bottom: number;
}
-const clearCGColor = utilsIos.getter(UIColor, UIColor.clearColor).CGColor;
+const clearCGColor = UIColor.clearColor.CGColor;
const symbolUrl = Symbol("backgroundImageUrl");
export module ios {
diff --git a/tns-core-modules/ui/styling/font.ios.ts b/tns-core-modules/ui/styling/font.ios.ts
index 6cf0afaf7..6a4dbf9fa 100644
--- a/tns-core-modules/ui/styling/font.ios.ts
+++ b/tns-core-modules/ui/styling/font.ios.ts
@@ -2,7 +2,6 @@
import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceMessageType } from "../../trace";
import { device } from "../../platform"
import * as fs from "../../file-system";
-import * as utils from "../../utils/utils";
export * from "./font-common";
const EMULATE_OBLIQUE = true;
@@ -103,7 +102,7 @@ function getNativeFontWeight(fontWeight: FontWeight): number {
function getSystemFont(size: number, nativeWeight: number, italic: boolean, symbolicTraits: number): UIFont {
let result = UIFont.systemFontOfSizeWeight(size, nativeWeight);
if (italic) {
- let descriptor = utils.ios.getter(result, result.fontDescriptor).fontDescriptorWithSymbolicTraits(symbolicTraits);
+ let descriptor = result.fontDescriptor.fontDescriptorWithSymbolicTraits(symbolicTraits);
result = UIFont.fontWithDescriptorSize(descriptor, size);
}
@@ -149,7 +148,7 @@ function createUIFont(font: Font, defaultFont: UIFont): UIFont {
let descriptor = UIFontDescriptor.fontDescriptorWithFontAttributes(fontAttributes);
result = UIFont.fontWithDescriptorSize(descriptor, size);
- let actualItalic = utils.ios.getter(result, result.fontDescriptor).symbolicTraits & UIFontDescriptorSymbolicTraits.TraitItalic;
+ let actualItalic = result.fontDescriptor.symbolicTraits & UIFontDescriptorSymbolicTraits.TraitItalic;
if (font.isItalic && !actualItalic && EMULATE_OBLIQUE) {
// The font we got is not actually italic so emulate that with a matrix
descriptor = descriptor.fontDescriptorWithMatrix(OBLIQUE_TRANSFORM);
@@ -180,7 +179,7 @@ export module ios {
if (!fs.File.exists(filePath)) {
filePath = fs.path.join(fs.knownFolders.currentApp().path, fontFile);
}
- const fontData = utils.ios.getter(NSFileManager, NSFileManager.defaultManager).contentsAtPath(filePath);
+ const fontData = NSFileManager.defaultManager.contentsAtPath(filePath);
if (!fontData) {
throw new Error("Could not load font from: " + fontFile);
}
diff --git a/tns-core-modules/ui/time-picker/time-picker.ios.ts b/tns-core-modules/ui/time-picker/time-picker.ios.ts
index 25688987f..887a18c63 100644
--- a/tns-core-modules/ui/time-picker/time-picker.ios.ts
+++ b/tns-core-modules/ui/time-picker/time-picker.ios.ts
@@ -4,20 +4,17 @@
hourProperty, minHourProperty, maxHourProperty, colorProperty, Color
} from "./time-picker-common";
-import { ios } from "../../utils/utils";
-import getter = ios.getter;
-
export * from "./time-picker-common";
function getDate(hour: number, minute: number): Date {
let components = NSDateComponents.alloc().init();
components.hour = hour;
components.minute = minute;
- return getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(components);
+ return NSCalendar.currentCalendar.dateFromComponents(components);
}
function getComponents(date: Date | NSDate): NSDateComponents {
- return getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, date);
+ return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, date);
}
export class TimePicker extends TimePickerBase {
diff --git a/tns-core-modules/ui/utils.ios.ts b/tns-core-modules/ui/utils.ios.ts
index 08028330a..fe6bd6799 100644
--- a/tns-core-modules/ui/utils.ios.ts
+++ b/tns-core-modules/ui/utils.ios.ts
@@ -1,6 +1,5 @@
import { View } from "./core/view";
import * as utils from "../utils/utils";
-import getter = utils.ios.getter;
export module ios {
export function getActualHeight(view: UIView): number {
@@ -12,7 +11,7 @@ export module ios {
}
export function getStatusBarHeight(viewController?: UIViewController): number {
- const app = getter(UIApplication, UIApplication.sharedApplication);
+ const app = UIApplication.sharedApplication;
if (!app || app.statusBarHidden) {
return 0;
}
diff --git a/tns-core-modules/utils/utils.d.ts b/tns-core-modules/utils/utils.d.ts
index 2e4e06fca..1b8fe4959 100644
--- a/tns-core-modules/utils/utils.d.ts
+++ b/tns-core-modules/utils/utils.d.ts
@@ -184,6 +184,8 @@ export module ad {
*/
export module ios {
/**
+ * @deprecated use the respective native property directly
+ *
* Checks if the property is a function and if it is, calls it on this.
* Designed to support backward compatibility for methods that became properties.
* Will not work on delegates since it checks if the propertyValue is a function, and delegates are marshalled as functions.
diff --git a/tns-core-modules/utils/utils.ios.ts b/tns-core-modules/utils/utils.ios.ts
index 53c2c19a7..976a43880 100644
--- a/tns-core-modules/utils/utils.ios.ts
+++ b/tns-core-modules/utils/utils.ios.ts
@@ -46,6 +46,7 @@ export module layout {
export module ios {
export function getter(_this: any, property: T | { (): T }): T {
+ console.log("utils.ios.getter() is deprecated; use the respective native property instead");
if (typeof property === "function") {
return (<{ (): T }>property).call(_this);
} else {
@@ -72,13 +73,13 @@ export module ios {
}
export function isLandscape(): boolean {
- const device = getter(UIDevice, UIDevice.currentDevice);
- const statusBarOrientation = getter(UIApplication, UIApplication.sharedApplication).statusBarOrientation;
+ const device = UIDevice.currentDevice;
+ const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
const isStatusBarOrientationLandscape = isOrientationLandscape(statusBarOrientation);
return isOrientationLandscape(device.orientation) || isStatusBarOrientationLandscape;
}
- export var MajorVersion = NSString.stringWithString(getter(UIDevice, UIDevice.currentDevice).systemVersion).intValue;
+ export var MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
export function openFile(filePath: string): boolean {
try {
@@ -147,8 +148,8 @@ export function releaseNativeObject(object: NSObject) {
export function openUrl(location: string): boolean {
try {
var url = NSURL.URLWithString(location.trim());
- if (ios.getter(UIApplication, UIApplication.sharedApplication).canOpenURL(url)) {
- return ios.getter(UIApplication, UIApplication.sharedApplication).openURL(url);
+ if (UIApplication.sharedApplication.canOpenURL(url)) {
+ return UIApplication.sharedApplication.openURL(url);
}
}
catch (e) {
@@ -162,7 +163,7 @@ class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UI
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
public getViewController(): UIViewController {
- const app = ios.getter(UIApplication, UIApplication.sharedApplication);
+ const app = UIApplication.sharedApplication;
return app.keyWindow.rootViewController;
}
@@ -179,4 +180,4 @@ class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UI
}
}
-mainScreenScale = ios.getter(UIScreen, UIScreen.mainScreen).scale;
+mainScreenScale = UIScreen.mainScreen.scale;