diff --git a/README.md b/README.md
index 7afd6dd56..42e033c35 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,7 @@ In addition to the code that makes up the NativeScript framework itself, we also
## Contributing
-We love PRs, and accept them for all of our repositories—even docs! Please follow our [contribution guide](CONTRIBUTING.md) if you want to become part of the project.
+We love PRs, and accept them for all of our repositories—even docs! Please follow our [contribution guide](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md) if you want to become part of the project.
## Angular
@@ -80,6 +80,6 @@ We [worked together with the Google Angular team](http://angularjs.blogspot.com/
## Get Help
-Please, use [github issues](https://github.com/NativeScript/NativeScript/issues) strictly for [reporting a bugs](CONTRIBUTING.md#bugs) or [requesting features](CONTRIBUTING.md#features). For general NativeScript questions and support, check out [Stack Overflow](https://stackoverflow.com/questions/tagged/nativescript) or ask our experts in [NativeScript community Slack channel](http://developer.telerik.com/wp-login.php?action=slack-invitation).
+Please, use [github issues](https://github.com/NativeScript/NativeScript/issues) strictly for [reporting a bugs](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#bugs) or [requesting features](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#features). For general NativeScript questions and support, check out [Stack Overflow](https://stackoverflow.com/questions/tagged/nativescript) or ask our experts in [NativeScript community Slack channel](http://developer.telerik.com/wp-login.php?action=slack-invitation).

diff --git a/apps/app/ui-tests-app/button/button-border.css b/apps/app/ui-tests-app/button/button-border.css
index 644d827a6..3b404e027 100644
--- a/apps/app/ui-tests-app/button/button-border.css
+++ b/apps/app/ui-tests-app/button/button-border.css
@@ -46,7 +46,7 @@ Button {
}
#s10 {
- border-width: 5 0; border-color: black;
+ border-width: 5 0; border-color: black; background-color: white;
}
#s11 {
diff --git a/apps/app/ui-tests-app/css/pixels.xml b/apps/app/ui-tests-app/css/pixels.xml
index b2b61157d..30f25d526 100644
--- a/apps/app/ui-tests-app/css/pixels.xml
+++ b/apps/app/ui-tests-app/css/pixels.xml
@@ -4,7 +4,7 @@
-
+
@@ -12,7 +12,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
diff --git a/apps/app/ui-tests-app/flexbox/flexbox.css b/apps/app/ui-tests-app/flexbox/flexbox.css
index 65d8ae62b..9f2bc32fc 100644
--- a/apps/app/ui-tests-app/flexbox/flexbox.css
+++ b/apps/app/ui-tests-app/flexbox/flexbox.css
@@ -22,6 +22,7 @@
.control Button {
border-width: 1 1 0 0;
border-color: gray;
+ background-color: white;
font-size: 9;
padding: 0;
height: 0;
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/apps/app/ui-tests-app/issues/issue-3113.css b/apps/app/ui-tests-app/issues/issue-3113.css
index dec0844d3..3a3cab238 100644
--- a/apps/app/ui-tests-app/issues/issue-3113.css
+++ b/apps/app/ui-tests-app/issues/issue-3113.css
@@ -1,13 +1,16 @@
#button1 {
- border-color: rgba(0, 0, 0, 0);
+ border-color: transparent;
border-width: 3;
+ background-color: white;
}
#button2 {
border-color: rgba(0, 0, 0, 0.5);
border-width: 3;
+ background-color: white;
}
#button3 {
border-width: 3;
+ background-color: white;
}
\ No newline at end of file
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/app/app.ts b/tests/app/app/app.ts
index a0e348269..4e6e9330a 100644
--- a/tests/app/app/app.ts
+++ b/tests/app/app/app.ts
@@ -135,6 +135,10 @@ if (application.android) {
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
// Set args.cancel = true to cancel back navigation and do something custom.
});
+
+ application.android.on(application.AndroidApplication.activityNewIntentEvent, function (args: application.AndroidActivityNewIntentEventData) {
+ console.log("Event: " + args.eventName + ", Activity: " + args.activity + ", Intent: " + args.intent);
+ });
}
var time;
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-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java
index 3608a195d..247caa6a6 100644
--- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java
+++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java
@@ -8,6 +8,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
+import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
@@ -16,6 +17,7 @@ import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.Shader;
+import android.support.annotation.NonNull;
import org.nativescript.widgets.image.BitmapOwner;
import org.nativescript.widgets.image.Fetcher;
@@ -804,6 +806,23 @@ public class BorderDrawable extends ColorDrawable implements BitmapOwner {
return drawable;
}
+ @Override
+ public void getOutline(@NonNull Outline outline) {
+ if (android.os.Build.VERSION.SDK_INT >= 21) {
+ Path backgroundPath = new Path();
+ float[] backgroundRadii = {
+ Math.max(0, borderTopLeftRadius), Math.max(0, borderTopLeftRadius),
+ Math.max(0, borderTopRightRadius), Math.max(0, borderTopRightRadius),
+ Math.max(0, borderBottomRightRadius), Math.max(0, borderBottomRightRadius),
+ Math.max(0, borderBottomLeftRadius), Math.max(0, borderBottomLeftRadius)
+ };
+ backgroundPath.addRoundRect(new RectF(getBounds()), backgroundRadii, Path.Direction.CW);
+ outline.setConvexPath(backgroundPath);
+ } else {
+ throw new IllegalStateException("Method supported on API 21 or higher");
+ }
+ }
+
private class BackgroundDrawParams {
private boolean repeatX = true;
private boolean repeatY = true;
diff --git a/tns-core-modules-widgets/package.json b/tns-core-modules-widgets/package.json
index 12f88a050..50ed097f7 100644
--- a/tns-core-modules-widgets/package.json
+++ b/tns-core-modules-widgets/package.json
@@ -1,6 +1,6 @@
{
"name": "tns-core-modules-widgets",
- "version": "5.3.0",
+ "version": "5.4.0",
"description": "Native widgets used in the NativeScript framework.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
diff --git a/tns-core-modules/application-settings/application-settings-common.ts b/tns-core-modules/application-settings/application-settings-common.ts
index 6a28f3ca3..39b6008f4 100644
--- a/tns-core-modules/application-settings/application-settings-common.ts
+++ b/tns-core-modules/application-settings/application-settings-common.ts
@@ -1,10 +1,10 @@
-export var checkKey = function (key: string): void {
+export function checkKey(key: string): void {
if (typeof key !== "string") {
throw new Error("key: '" + key + "' must be a string");
}
}
-export var ensureValidValue = function (value: any, valueType: string): void {
+export function ensureValidValue(value: any, valueType: string): void {
if (typeof value !== valueType) {
throw new Error("value: '" + value + "' must be a " + valueType);
}
diff --git a/tns-core-modules/application-settings/application-settings.android.ts b/tns-core-modules/application-settings/application-settings.android.ts
index ccd9e0e27..24b326d99 100644
--- a/tns-core-modules/application-settings/application-settings.android.ts
+++ b/tns-core-modules/application-settings/application-settings.android.ts
@@ -1,7 +1,7 @@
import * as common from "./application-settings-common";
import { getNativeApplication } from "../application";
-var sharedPreferences: android.content.SharedPreferences;
+let sharedPreferences: android.content.SharedPreferences;
function ensureSharedPreferences() {
if (!sharedPreferences) {
sharedPreferences = (getNativeApplication()).getApplicationContext().getSharedPreferences("prefs.db", 0);
@@ -47,7 +47,7 @@ export function getNumber(key: string, defaultValue?: number): number {
export function setBoolean(key: string, value: boolean): void {
verify(key);
common.ensureValidValue(value, "boolean");
- var editor = sharedPreferences.edit();
+ const editor = sharedPreferences.edit();
editor.putBoolean(key, value);
editor.apply();
}
@@ -55,7 +55,7 @@ export function setBoolean(key: string, value: boolean): void {
export function setString(key: string, value: string): void {
verify(key);
common.ensureValidValue(value, "string");
- var editor = sharedPreferences.edit();
+ const editor = sharedPreferences.edit();
editor.putString(key, value);
editor.apply();
}
@@ -63,14 +63,14 @@ export function setString(key: string, value: string): void {
export function setNumber(key: string, value: number): void {
verify(key);
common.ensureValidValue(value, "number");
- var editor = sharedPreferences.edit();
+ const editor = sharedPreferences.edit();
editor.putFloat(key, float(value));
editor.apply();
}
export function remove(key: string): void {
verify(key);
- var editor = sharedPreferences.edit();
+ const editor = sharedPreferences.edit();
editor.remove(key);
editor.apply();
}
@@ -80,14 +80,14 @@ export function clear(): void {
sharedPreferences.edit().clear().apply();
}
-export var flush = function (): boolean {
+export function flush(): boolean {
return sharedPreferences.edit().commit();
}
export function getAllKeys(): Array {
- var mappedPreferences = sharedPreferences.getAll();
- var iterator = mappedPreferences.keySet().iterator();
- var result = [];
+ const mappedPreferences = sharedPreferences.getAll();
+ const iterator = mappedPreferences.keySet().iterator();
+ const result = [];
while (iterator.hasNext()) {
let key = iterator.next();
result.push(key);
diff --git a/tns-core-modules/application-settings/application-settings.ios.ts b/tns-core-modules/application-settings/application-settings.ios.ts
index 3fbfc9db8..508a29237 100644
--- a/tns-core-modules/application-settings/application-settings.ios.ts
+++ b/tns-core-modules/application-settings/application-settings.ios.ts
@@ -2,67 +2,71 @@
import * as utils from "../utils/utils";
-var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
+const userDefaults = NSUserDefaults.standardUserDefaults;
-export var hasKey = function (key: string): boolean {
+export function hasKey(key: string): boolean {
Common.checkKey(key);
+
return userDefaults.objectForKey(key) !== null;
}
// utils.ios.getters
-export var getBoolean = function (key: string, defaultValue?: boolean): boolean {
+export function getBoolean(key: string, defaultValue?: boolean): boolean {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.boolForKey(key);
}
+
return defaultValue;
}
-export var getString = function (key: string, defaultValue?: string): string {
+export function getString(key: string, defaultValue?: string): string {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.stringForKey(key);
}
+
return defaultValue;
}
-export var getNumber = function (key: string, defaultValue?: number): number {
+export function getNumber(key: string, defaultValue?: number): number {
Common.checkKey(key);
if (hasKey(key)) {
return userDefaults.doubleForKey(key);
}
+
return defaultValue;
}
// setters
-export var setBoolean = function (key: string, value: boolean): void {
+export function setBoolean(key: string, value: boolean): void {
Common.checkKey(key);
Common.ensureValidValue(value, "boolean");
userDefaults.setBoolForKey(value, key);
}
-export var setString = function (key: string, value: string): void {
+export function setString(key: string, value: string): void {
Common.checkKey(key);
Common.ensureValidValue(value, "string");
userDefaults.setObjectForKey(value, key);
}
-export var setNumber = function (key: string, value: number): void {
+export function setNumber(key: string, value: number): void {
Common.checkKey(key);
Common.ensureValidValue(value, "number");
userDefaults.setDoubleForKey(value, key);
}
-export var remove = function (key: string): void {
+export function remove(key: string): void {
Common.checkKey(key);
userDefaults.removeObjectForKey(key);
}
-export var clear = function (): void {
- userDefaults.removePersistentDomainForName(utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier);
+export function clear(): void {
+ userDefaults.removePersistentDomainForName(NSBundle.mainBundle.bundleIdentifier);
}
-export var flush = function (): boolean {
+export function flush(): boolean {
return userDefaults.synchronize();
}
diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts
index 14ff82693..f0588976d 100644
--- a/tns-core-modules/application/application.android.ts
+++ b/tns-core-modules/application/application.android.ts
@@ -1,6 +1,6 @@
import {
AndroidActivityBundleEventData, AndroidActivityEventData, ApplicationEventData, OrientationChangedEventData,
- AndroidApplication as AndroidApplicationDefinition,
+ AndroidApplication as AndroidApplicationDefinition, AndroidActivityNewIntentEventData,
AndroidActivityResultEventData, AndroidActivityBackPressedEventData, AndroidActivityRequestPermissionsEventData
} from ".";
@@ -25,6 +25,7 @@ const ActivityStopped = "activityStopped";
const SaveActivityState = "saveActivityState";
const ActivityResult = "activityResult";
const ActivityBackPressed = "activityBackPressed";
+const ActivityNewIntent = "activityNewIntent";
const ActivityRequestPermissions = "activityRequestPermissions";
export class AndroidApplication extends Observable implements AndroidApplicationDefinition {
@@ -37,6 +38,7 @@ export class AndroidApplication extends Observable implements AndroidApplication
public static saveActivityStateEvent = SaveActivityState;
public static activityResultEvent = ActivityResult;
public static activityBackPressedEvent = ActivityBackPressed;
+ public static activityNewIntentEvent = ActivityNewIntent;
public static activityRequestPermissionsEvent = ActivityRequestPermissions;
public paused: boolean;
@@ -119,6 +121,7 @@ export interface AndroidApplication {
on(event: "saveActivityState", callback: (args: AndroidActivityBundleEventData) => void, thisArg?: any);
on(event: "activityResult", callback: (args: AndroidActivityResultEventData) => void, thisArg?: any);
on(event: "activityBackPressed", callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any);
+ on(event: "activityNewIntent", callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any);
on(event: "activityRequestPermissions", callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any);
}
diff --git a/tns-core-modules/application/application.d.ts b/tns-core-modules/application/application.d.ts
index d93c0872f..f85972e8b 100644
--- a/tns-core-modules/application/application.d.ts
+++ b/tns-core-modules/application/application.d.ts
@@ -11,47 +11,47 @@ import { NavigationEntry, View, Observable, EventData } from "../ui/frame";
/**
* String value used when hooking to launch event.
*/
-export var launchEvent: string;
+export const launchEvent: string;
/**
* String value used when hooking to displayed event.
*/
-export var displayedEvent: string;
+export const displayedEvent: string;
/**
* String value used when hooking to uncaughtError event.
*/
-export var uncaughtErrorEvent: string;
+export const uncaughtErrorEvent: string;
/**
* String value used when hooking to discardedError event.
*/
-export var discardedErrorEvent: string;
+export const discardedErrorEvent: string;
/**
* String value used when hooking to suspend event.
*/
-export var suspendEvent: string;
+export const suspendEvent: string;
/**
* String value used when hooking to resume event.
*/
-export var resumeEvent: string;
+export const resumeEvent: string;
/**
* String value used when hooking to exit event.
*/
-export var exitEvent: string;
+export const exitEvent: string;
/**
* String value used when hooking to lowMemory event.
*/
-export var lowMemoryEvent: string;
+export const lowMemoryEvent: string;
/**
* String value used when hooking to orientationChanged event.
*/
-export var orientationChangedEvent: string;
+export const orientationChangedEvent: string;
/**
* Event data containing information for the application events.
@@ -187,7 +187,7 @@ export function off(eventNames: string, callback?: any, thisArg?: any);
/**
* @deprecated use application.run() instead.
- *
+ *
* Call this method to start the application. Important: All code after this method call will not be executed!
*/
export function start(entry?: NavigationEntry | string);
@@ -371,6 +371,16 @@ export interface AndroidActivityResultEventData extends AndroidActivityEventData
intent: any /* android.content.Intent */;
}
+/**
+ * Data for the Android activity newIntent event.
+ */
+export interface AndroidActivityNewIntentEventData extends AndroidActivityEventData {
+ /**
+ * The intent.
+ */
+ intent: any /* android.content.Intent */;
+}
+
/**
* Data for the Android activity back pressed event.
*/
@@ -480,6 +490,11 @@ export class AndroidApplication extends Observable {
*/
on(event: "activityBackPressed", callback: (args: AndroidActivityBackPressedEventData) => void, thisArg?: any);
+ /**
+ * This event is raised when the Android app was launched by an Intent with data.
+ */
+ on(event: "activityNewIntent", callback: (args: AndroidActivityNewIntentEventData) => void, thisArg?: any);
+
/**
* This event is raised when the Android activity requests permissions.
*/
@@ -530,6 +545,11 @@ export class AndroidApplication extends Observable {
*/
public static activityBackPressedEvent: string;
+ /**
+ * String value used when hooking to activityNewIntent event.
+ */
+ public static activityNewIntentEvent: string;
+
/**
* String value used when hooking to requestPermissions event.
*/
diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts
index 53941c9ef..c776fdcf4 100644
--- a/tns-core-modules/application/application.ios.ts
+++ b/tns-core-modules/application/application.ios.ts
@@ -18,13 +18,15 @@ 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
-var Responder = (UIResponder).extend({
+const Responder = (UIResponder).extend({
get window() {
return iosApp ? iosApp.window : undefined;
},
@@ -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,16 +118,16 @@ 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;
}
public removeNotificationObserver(observer: any, notificationName: string) {
- var index = this._observers.indexOf(observer);
+ const 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;
@@ -321,7 +323,7 @@ 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/color/color-common.ts b/tns-core-modules/color/color-common.ts
index 19cc12ce5..18081ff73 100644
--- a/tns-core-modules/color/color-common.ts
+++ b/tns-core-modules/color/color-common.ts
@@ -87,7 +87,7 @@ export class Color implements definition.Color {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
}
- var intVal = parseInt(hex, 16);
+ let intVal = parseInt(hex, 16);
if (hex.length === 6) {
// add the alpha component since the provided string is RRGGBB
intVal = (intVal & 0x00FFFFFF) + 0xFF000000;
diff --git a/tns-core-modules/color/known-colors.d.ts b/tns-core-modules/color/known-colors.d.ts
index 03c241829..b846b02d4 100644
--- a/tns-core-modules/color/known-colors.d.ts
+++ b/tns-core-modules/color/known-colors.d.ts
@@ -2,147 +2,147 @@
* @module "color/known-colors"
*/ /** */
-export var AliceBlue;
-export var AntiqueWhite;
-export var Aqua;
-export var Aquamarine;
-export var Azure;
-export var Beige;
-export var Bisque;
-export var Black;
-export var BlanchedAlmond;
-export var Blue;
-export var BlueViolet;
-export var Brown;
-export var BurlyWood;
-export var CadetBlue;
-export var Chartreuse;
-export var Chocolate;
-export var Coral;
-export var CornflowerBlue;
-export var Cornsilk;
-export var Crimson;
-export var Cyan;
-export var DarkBlue;
-export var DarkCyan;
-export var DarkGoldenRod;
-export var DarkGray;
-export var DarkGreen;
-export var DarkKhaki;
-export var DarkMagenta;
-export var DarkOliveGreen;
-export var DarkOrange;
-export var DarkOrchid;
-export var DarkRed;
-export var DarkSalmon;
-export var DarkSeaGreen;
-export var DarkSlateBlue;
-export var DarkSlateGray;
-export var DarkTurquoise;
-export var DarkViolet;
-export var DeepPink;
-export var DeepSkyBlue;
-export var DimGray;
-export var DodgerBlue;
-export var FireBrick;
-export var FloralWhite;
-export var ForestGreen;
-export var Fuchsia;
-export var Gainsboro;
-export var GhostWhite;
-export var Gold;
-export var GoldenRod;
-export var Gray;
-export var Green;
-export var GreenYellow;
-export var HoneyDew;
-export var HotPink;
-export var IndianRed;
-export var Indigo;
-export var Ivory;
-export var Khaki;
-export var Lavender;
-export var LavenderBlush;
-export var LawnGreen;
-export var LemonChiffon;
-export var LightBlue;
-export var LightCoral;
-export var LightCyan;
-export var LightGoldenRodYellow;
-export var LightGray;
-export var LightGreen;
-export var LightPink;
-export var LightSalmon;
-export var LightSeaGreen;
-export var LightSkyBlue;
-export var LightSlateGray;
-export var LightSteelBlue;
-export var LightYellow;
-export var Lime;
-export var LimeGreen;
-export var Linen;
-export var Magenta;
-export var Maroon;
-export var MediumAquaMarine;
-export var MediumBlue;
-export var MediumOrchid;
-export var MediumPurple;
-export var MediumSeaGreen;
-export var MediumSlateBlue;
-export var MediumSpringGreen;
-export var MediumTurquoise;
-export var MediumVioletRed;
-export var MidnightBlue;
-export var MintCream;
-export var MistyRose;
-export var Moccasin;
-export var NavajoWhite;
-export var Navy;
-export var OldLace;
-export var Olive;
-export var OliveDrab;
-export var Orange;
-export var OrangeRed;
-export var Orchid;
-export var PaleGoldenRod;
-export var PaleGreen;
-export var PaleTurquoise;
-export var PaleVioletRed;
-export var PapayaWhip;
-export var PeachPuff;
-export var Peru;
-export var Pink;
-export var Plum;
-export var PowderBlue;
-export var Purple;
-export var RebeccaPurple;
-export var Red;
-export var RosyBrown;
-export var RoyalBlue;
-export var SaddleBrown;
-export var Salmon;
-export var SandyBrown;
-export var SeaGreen;
-export var SeaShell;
-export var Sienna;
-export var Silver;
-export var SkyBlue;
-export var SlateBlue;
-export var SlateGray;
-export var Snow;
-export var SpringGreen;
-export var SteelBlue;
-export var Tan;
-export var Teal;
-export var Thistle;
-export var Tomato;
-export var Turquoise;
-export var Violet;
-export var Wheat;
-export var White;
-export var WhiteSmoke;
-export var Yellow;
-export var YellowGreen;
+export const AliceBlue;
+export const AntiqueWhite;
+export const Aqua;
+export const Aquamarine;
+export const Azure;
+export const Beige;
+export const Bisque;
+export const Black;
+export const BlanchedAlmond;
+export const Blue;
+export const BlueViolet;
+export const Brown;
+export const BurlyWood;
+export const CadetBlue;
+export const Chartreuse;
+export const Chocolate;
+export const Coral;
+export const CornflowerBlue;
+export const Cornsilk;
+export const Crimson;
+export const Cyan;
+export const DarkBlue;
+export const DarkCyan;
+export const DarkGoldenRod;
+export const DarkGray;
+export const DarkGreen;
+export const DarkKhaki;
+export const DarkMagenta;
+export const DarkOliveGreen;
+export const DarkOrange;
+export const DarkOrchid;
+export const DarkRed;
+export const DarkSalmon;
+export const DarkSeaGreen;
+export const DarkSlateBlue;
+export const DarkSlateGray;
+export const DarkTurquoise;
+export const DarkViolet;
+export const DeepPink;
+export const DeepSkyBlue;
+export const DimGray;
+export const DodgerBlue;
+export const FireBrick;
+export const FloralWhite;
+export const ForestGreen;
+export const Fuchsia;
+export const Gainsboro;
+export const GhostWhite;
+export const Gold;
+export const GoldenRod;
+export const Gray;
+export const Green;
+export const GreenYellow;
+export const HoneyDew;
+export const HotPink;
+export const IndianRed;
+export const Indigo;
+export const Ivory;
+export const Khaki;
+export const Lavender;
+export const LavenderBlush;
+export const LawnGreen;
+export const LemonChiffon;
+export const LightBlue;
+export const LightCoral;
+export const LightCyan;
+export const LightGoldenRodYellow;
+export const LightGray;
+export const LightGreen;
+export const LightPink;
+export const LightSalmon;
+export const LightSeaGreen;
+export const LightSkyBlue;
+export const LightSlateGray;
+export const LightSteelBlue;
+export const LightYellow;
+export const Lime;
+export const LimeGreen;
+export const Linen;
+export const Magenta;
+export const Maroon;
+export const MediumAquaMarine;
+export const MediumBlue;
+export const MediumOrchid;
+export const MediumPurple;
+export const MediumSeaGreen;
+export const MediumSlateBlue;
+export const MediumSpringGreen;
+export const MediumTurquoise;
+export const MediumVioletRed;
+export const MidnightBlue;
+export const MintCream;
+export const MistyRose;
+export const Moccasin;
+export const NavajoWhite;
+export const Navy;
+export const OldLace;
+export const Olive;
+export const OliveDrab;
+export const Orange;
+export const OrangeRed;
+export const Orchid;
+export const PaleGoldenRod;
+export const PaleGreen;
+export const PaleTurquoise;
+export const PaleVioletRed;
+export const PapayaWhip;
+export const PeachPuff;
+export const Peru;
+export const Pink;
+export const Plum;
+export const PowderBlue;
+export const Purple;
+export const RebeccaPurple;
+export const Red;
+export const RosyBrown;
+export const RoyalBlue;
+export const SaddleBrown;
+export const Salmon;
+export const SandyBrown;
+export const SeaGreen;
+export const SeaShell;
+export const Sienna;
+export const Silver;
+export const SkyBlue;
+export const SlateBlue;
+export const SlateGray;
+export const Snow;
+export const SpringGreen;
+export const SteelBlue;
+export const Tan;
+export const Teal;
+export const Thistle;
+export const Tomato;
+export const Turquoise;
+export const Violet;
+export const Wheat;
+export const White;
+export const WhiteSmoke;
+export const Yellow;
+export const YellowGreen;
export function isKnownName(name: string): boolean;
export function getKnownColor(name: string): string
diff --git a/tns-core-modules/color/known-colors.ts b/tns-core-modules/color/known-colors.ts
index 8930248f5..5ebd15567 100644
--- a/tns-core-modules/color/known-colors.ts
+++ b/tns-core-modules/color/known-colors.ts
@@ -1,154 +1,155 @@
-export var Transparent = "#00000000";
-export var AliceBlue = "#F0F8FF";
-export var AntiqueWhite = "#FAEBD7";
-export var Aqua = "#00FFFF";
-export var Aquamarine = "#7FFFD4";
-export var Azure = "#F0FFFF";
-export var Beige = "#F5F5DC";
-export var Bisque = "#FFE4C4";
-export var Black = "#000000";
-export var BlanchedAlmond = "#FFEBCD";
-export var Blue = "#0000FF";
-export var BlueViolet = "#8A2BE2";
-export var Brown = "#A52A2A";
-export var BurlyWood = "#DEB887";
-export var CadetBlue = "#5F9EA0";
-export var Chartreuse = "#7FFF00";
-export var Chocolate = "#D2691E";
-export var Coral = "#FF7F50";
-export var CornflowerBlue = "#6495ED";
-export var Cornsilk = "#FFF8DC";
-export var Crimson = "#DC143C";
-export var Cyan = "#00FFFF";
-export var DarkBlue = "#00008B";
-export var DarkCyan = "#008B8B";
-export var DarkGoldenRod = "#B8860B";
-export var DarkGray = "#A9A9A9";
-export var DarkGreen = "#006400";
-export var DarkKhaki = "#BDB76B";
-export var DarkMagenta = "#8B008B";
-export var DarkOliveGreen = "#556B2F";
-export var DarkOrange = "#FF8C00";
-export var DarkOrchid = "#9932CC";
-export var DarkRed = "#8B0000";
-export var DarkSalmon = "#E9967A";
-export var DarkSeaGreen = "#8FBC8F";
-export var DarkSlateBlue = "#483D8B";
-export var DarkSlateGray = "#2F4F4F";
-export var DarkTurquoise = "#00CED1";
-export var DarkViolet = "#9400D3";
-export var DeepPink = "#FF1493";
-export var DeepSkyBlue = "#00BFFF";
-export var DimGray = "#696969";
-export var DodgerBlue = "#1E90FF";
-export var FireBrick = "#B22222";
-export var FloralWhite = "#FFFAF0";
-export var ForestGreen = "#228B22";
-export var Fuchsia = "#FF00FF";
-export var Gainsboro = "#DCDCDC";
-export var GhostWhite = "#F8F8FF";
-export var Gold = "#FFD700";
-export var GoldenRod = "#DAA520";
-export var Gray = "#808080";
-export var Green = "#008000";
-export var GreenYellow = "#ADFF2F";
-export var HoneyDew = "#F0FFF0";
-export var HotPink = "#FF69B4";
-export var IndianRed = "#CD5C5C";
-export var Indigo = "#4B0082";
-export var Ivory = "#FFFFF0";
-export var Khaki = "#F0E68C";
-export var Lavender = "#E6E6FA";
-export var LavenderBlush = "#FFF0F5";
-export var LawnGreen = "#7CFC00";
-export var LemonChiffon = "#FFFACD";
-export var LightBlue = "#ADD8E6";
-export var LightCoral = "#F08080";
-export var LightCyan = "#E0FFFF";
-export var LightGoldenRodYellow = "#FAFAD2";
-export var LightGray = "#D3D3D3";
-export var LightGreen = "#90EE90";
-export var LightPink = "#FFB6C1";
-export var LightSalmon = "#FFA07A";
-export var LightSeaGreen = "#20B2AA";
-export var LightSkyBlue = "#87CEFA";
-export var LightSlateGray = "#778899";
-export var LightSteelBlue = "#B0C4DE";
-export var LightYellow = "#FFFFE0";
-export var Lime = "#00FF00";
-export var LimeGreen = "#32CD32";
-export var Linen = "#FAF0E6";
-export var Magenta = "#FF00FF";
-export var Maroon = "#800000";
-export var MediumAquaMarine = "#66CDAA";
-export var MediumBlue = "#0000CD";
-export var MediumOrchid = "#BA55D3";
-export var MediumPurple = "#9370DB";
-export var MediumSeaGreen = "#3CB371";
-export var MediumSlateBlue = "#7B68EE";
-export var MediumSpringGreen = "#00FA9A";
-export var MediumTurquoise = "#48D1CC";
-export var MediumVioletRed = "#C71585";
-export var MidnightBlue = "#191970";
-export var MintCream = "#F5FFFA";
-export var MistyRose = "#FFE4E1";
-export var Moccasin = "#FFE4B5";
-export var NavajoWhite = "#FFDEAD";
-export var Navy = "#000080";
-export var OldLace = "#FDF5E6";
-export var Olive = "#808000";
-export var OliveDrab = "#6B8E23";
-export var Orange = "#FFA500";
-export var OrangeRed = "#FF4500";
-export var Orchid = "#DA70D6";
-export var PaleGoldenRod = "#EEE8AA";
-export var PaleGreen = "#98FB98";
-export var PaleTurquoise = "#AFEEEE";
-export var PaleVioletRed = "#DB7093";
-export var PapayaWhip = "#FFEFD5";
-export var PeachPuff = "#FFDAB9";
-export var Peru = "#CD853F";
-export var Pink = "#FFC0CB";
-export var Plum = "#DDA0DD";
-export var PowderBlue = "#B0E0E6";
-export var Purple = "#800080";
-export var RebeccaPurple = "#663399";
-export var Red = "#FF0000";
-export var RosyBrown = "#BC8F8F";
-export var RoyalBlue = "#4169E1";
-export var SaddleBrown = "#8B4513";
-export var Salmon = "#FA8072";
-export var SandyBrown = "#F4A460";
-export var SeaGreen = "#2E8B57";
-export var SeaShell = "#FFF5EE";
-export var Sienna = "#A0522D";
-export var Silver = "#C0C0C0";
-export var SkyBlue = "#87CEEB";
-export var SlateBlue = "#6A5ACD";
-export var SlateGray = "#708090";
-export var Snow = "#FFFAFA";
-export var SpringGreen = "#00FF7F";
-export var SteelBlue = "#4682B4";
-export var Tan = "#D2B48C";
-export var Teal = "#008080";
-export var Thistle = "#D8BFD8";
-export var Tomato = "#FF6347";
-export var Turquoise = "#40E0D0";
-export var Violet = "#EE82EE";
-export var Wheat = "#F5DEB3";
-export var White = "#FFFFFF";
-export var WhiteSmoke = "#F5F5F5";
-export var Yellow = "#FFFF00";
-export var YellowGreen = "#9ACD32";
+export const Transparent = "#00000000";
+export const AliceBlue = "#F0F8FF";
+export const AntiqueWhite = "#FAEBD7";
+export const Aqua = "#00FFFF";
+export const Aquamarine = "#7FFFD4";
+export const Azure = "#F0FFFF";
+export const Beige = "#F5F5DC";
+export const Bisque = "#FFE4C4";
+export const Black = "#000000";
+export const BlanchedAlmond = "#FFEBCD";
+export const Blue = "#0000FF";
+export const BlueViolet = "#8A2BE2";
+export const Brown = "#A52A2A";
+export const BurlyWood = "#DEB887";
+export const CadetBlue = "#5F9EA0";
+export const Chartreuse = "#7FFF00";
+export const Chocolate = "#D2691E";
+export const Coral = "#FF7F50";
+export const CornflowerBlue = "#6495ED";
+export const Cornsilk = "#FFF8DC";
+export const Crimson = "#DC143C";
+export const Cyan = "#00FFFF";
+export const DarkBlue = "#00008B";
+export const DarkCyan = "#008B8B";
+export const DarkGoldenRod = "#B8860B";
+export const DarkGray = "#A9A9A9";
+export const DarkGreen = "#006400";
+export const DarkKhaki = "#BDB76B";
+export const DarkMagenta = "#8B008B";
+export const DarkOliveGreen = "#556B2F";
+export const DarkOrange = "#FF8C00";
+export const DarkOrchid = "#9932CC";
+export const DarkRed = "#8B0000";
+export const DarkSalmon = "#E9967A";
+export const DarkSeaGreen = "#8FBC8F";
+export const DarkSlateBlue = "#483D8B";
+export const DarkSlateGray = "#2F4F4F";
+export const DarkTurquoise = "#00CED1";
+export const DarkViolet = "#9400D3";
+export const DeepPink = "#FF1493";
+export const DeepSkyBlue = "#00BFFF";
+export const DimGray = "#696969";
+export const DodgerBlue = "#1E90FF";
+export const FireBrick = "#B22222";
+export const FloralWhite = "#FFFAF0";
+export const ForestGreen = "#228B22";
+export const Fuchsia = "#FF00FF";
+export const Gainsboro = "#DCDCDC";
+export const GhostWhite = "#F8F8FF";
+export const Gold = "#FFD700";
+export const GoldenRod = "#DAA520";
+export const Gray = "#808080";
+export const Green = "#008000";
+export const GreenYellow = "#ADFF2F";
+export const HoneyDew = "#F0FFF0";
+export const HotPink = "#FF69B4";
+export const IndianRed = "#CD5C5C";
+export const Indigo = "#4B0082";
+export const Ivory = "#FFFFF0";
+export const Khaki = "#F0E68C";
+export const Lavender = "#E6E6FA";
+export const LavenderBlush = "#FFF0F5";
+export const LawnGreen = "#7CFC00";
+export const LemonChiffon = "#FFFACD";
+export const LightBlue = "#ADD8E6";
+export const LightCoral = "#F08080";
+export const LightCyan = "#E0FFFF";
+export const LightGoldenRodYellow = "#FAFAD2";
+export const LightGray = "#D3D3D3";
+export const LightGreen = "#90EE90";
+export const LightPink = "#FFB6C1";
+export const LightSalmon = "#FFA07A";
+export const LightSeaGreen = "#20B2AA";
+export const LightSkyBlue = "#87CEFA";
+export const LightSlateGray = "#778899";
+export const LightSteelBlue = "#B0C4DE";
+export const LightYellow = "#FFFFE0";
+export const Lime = "#00FF00";
+export const LimeGreen = "#32CD32";
+export const Linen = "#FAF0E6";
+export const Magenta = "#FF00FF";
+export const Maroon = "#800000";
+export const MediumAquaMarine = "#66CDAA";
+export const MediumBlue = "#0000CD";
+export const MediumOrchid = "#BA55D3";
+export const MediumPurple = "#9370DB";
+export const MediumSeaGreen = "#3CB371";
+export const MediumSlateBlue = "#7B68EE";
+export const MediumSpringGreen = "#00FA9A";
+export const MediumTurquoise = "#48D1CC";
+export const MediumVioletRed = "#C71585";
+export const MidnightBlue = "#191970";
+export const MintCream = "#F5FFFA";
+export const MistyRose = "#FFE4E1";
+export const Moccasin = "#FFE4B5";
+export const NavajoWhite = "#FFDEAD";
+export const Navy = "#000080";
+export const OldLace = "#FDF5E6";
+export const Olive = "#808000";
+export const OliveDrab = "#6B8E23";
+export const Orange = "#FFA500";
+export const OrangeRed = "#FF4500";
+export const Orchid = "#DA70D6";
+export const PaleGoldenRod = "#EEE8AA";
+export const PaleGreen = "#98FB98";
+export const PaleTurquoise = "#AFEEEE";
+export const PaleVioletRed = "#DB7093";
+export const PapayaWhip = "#FFEFD5";
+export const PeachPuff = "#FFDAB9";
+export const Peru = "#CD853F";
+export const Pink = "#FFC0CB";
+export const Plum = "#DDA0DD";
+export const PowderBlue = "#B0E0E6";
+export const Purple = "#800080";
+export const RebeccaPurple = "#663399";
+export const Red = "#FF0000";
+export const RosyBrown = "#BC8F8F";
+export const RoyalBlue = "#4169E1";
+export const SaddleBrown = "#8B4513";
+export const Salmon = "#FA8072";
+export const SandyBrown = "#F4A460";
+export const SeaGreen = "#2E8B57";
+export const SeaShell = "#FFF5EE";
+export const Sienna = "#A0522D";
+export const Silver = "#C0C0C0";
+export const SkyBlue = "#87CEEB";
+export const SlateBlue = "#6A5ACD";
+export const SlateGray = "#708090";
+export const Snow = "#FFFAFA";
+export const SpringGreen = "#00FF7F";
+export const SteelBlue = "#4682B4";
+export const Tan = "#D2B48C";
+export const Teal = "#008080";
+export const Thistle = "#D8BFD8";
+export const Tomato = "#FF6347";
+export const Turquoise = "#40E0D0";
+export const Violet = "#EE82EE";
+export const Wheat = "#F5DEB3";
+export const White = "#FFFFFF";
+export const WhiteSmoke = "#F5F5F5";
+export const Yellow = "#FFFF00";
+export const YellowGreen = "#9ACD32";
-var _allColors = {};
+declare var exports;
+
+const _allColors = {};
// populate all the declared colors in the _allColors object with name to lower case for faster lookup.
-declare var exports;
(function () {
- var name: string;
- var underscore = "_";
- for (var p in exports) {
+ let name: string;
+ const underscore = "_";
+ for (let p in exports) {
name = p;
if (name.charAt(0) !== underscore) {
_allColors[name.toLowerCase()] = exports[p];
diff --git a/tns-core-modules/css/parser.ts b/tns-core-modules/css/parser.ts
index a7451b7c3..b8818caea 100644
--- a/tns-core-modules/css/parser.ts
+++ b/tns-core-modules/css/parser.ts
@@ -518,7 +518,7 @@ function parseArgumentsList(text: string, start: number, argument: (value: st
return { start, end, value };
}
- for (var index = 0; true; index++) {
+ for (let index = 0; true; index++) {
const arg = argument(text, end, index);
if (!arg) {
return null;
@@ -1490,7 +1490,7 @@ export class CSSNativeScript {
let value = "";
let reading: "property" | "value" = "property";
- for (var i = 0; i < declarationsInputTokens.length; i++) {
+ for (let i = 0; i < declarationsInputTokens.length; i++) {
let inputToken = declarationsInputTokens[i];
if (reading === "property") {
if (inputToken === ":") {
diff --git a/tns-core-modules/debugger/debugger.ts b/tns-core-modules/debugger/debugger.ts
index ae219b2f1..205aaf631 100644
--- a/tns-core-modules/debugger/debugger.ts
+++ b/tns-core-modules/debugger/debugger.ts
@@ -36,7 +36,7 @@ export namespace domains {
}
}
-var network;
+let network;
export function getNetwork(): domains.network.NetworkDomainDebugger {
return network;
@@ -45,7 +45,7 @@ export function setNetwork(newNetwork: domains.network.NetworkDomainDebugger) {
network = newNetwork;
}
-var dom;
+let dom;
export function getDOM(): any {
return dom;
@@ -55,7 +55,7 @@ export function setDOM(newDOM) {
dom = newDOM;
}
-var css;
+let css;
export function getCSS(): any {
return css;
@@ -121,7 +121,7 @@ export namespace NetworkAgent {
// Content-Type and content-type are both common in headers spelling
const mimeType: string = headers["Content-Type"] || headers["content-type"] || "application/octet-stream";
const contentLengthHeader: string = headers["Content-Length"] || headers["content-length"];
- var contentLength = parseInt(contentLengthHeader, 10);
+ let contentLength = parseInt(contentLengthHeader, 10);
if (isNaN(contentLength)) {
contentLength = 0;
}
@@ -203,7 +203,7 @@ export namespace NetworkAgent {
}
function getTimeStamp(): number {
- var d = new Date();
+ const d = new Date();
return Math.round(d.getTime() / 1000);
}
diff --git a/tns-core-modules/debugger/webinspector-css.ios.ts b/tns-core-modules/debugger/webinspector-css.ios.ts
index 8e7c353f4..d14936be6 100644
--- a/tns-core-modules/debugger/webinspector-css.ios.ts
+++ b/tns-core-modules/debugger/webinspector-css.ios.ts
@@ -1,5 +1,5 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
-var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
+const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
import * as debuggerDomains from "./debugger";
diff --git a/tns-core-modules/debugger/webinspector-dom.ios.ts b/tns-core-modules/debugger/webinspector-dom.ios.ts
index 54f934e34..d62175ccb 100644
--- a/tns-core-modules/debugger/webinspector-dom.ios.ts
+++ b/tns-core-modules/debugger/webinspector-dom.ios.ts
@@ -1,6 +1,5 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
-var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
-// var inspectorCommandTypes: any = inspectorCommands;
+const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
import * as debuggerDomains from "./debugger";
diff --git a/tns-core-modules/debugger/webinspector-network.ios.ts b/tns-core-modules/debugger/webinspector-network.ios.ts
index bce24b9c7..06bc44517 100644
--- a/tns-core-modules/debugger/webinspector-network.ios.ts
+++ b/tns-core-modules/debugger/webinspector-network.ios.ts
@@ -1,31 +1,18 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
-var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
+const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
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;
const frameId = "NativeScriptMainFrameIdentifier";
const loaderId = "Loader Identifier";
-var resources_datas = [];
+const resources_datas = [];
-var documentTypeByMimeType = {
+const documentTypeByMimeType = {
"text/xml": "Document",
"text/plain": "Document",
"text/html": "Document",
@@ -67,7 +54,7 @@ export class Request {
this._mimeType = value;
- var resourceType = "Other";
+ let resourceType = "Other";
if (this._mimeType in documentTypeByMimeType) {
resourceType = documentTypeByMimeType[this._mimeType];
@@ -182,8 +169,8 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
* Returns content served for the given request.
*/
getResponseBody(params: inspectorCommandTypes.NetworkDomain.GetResponseBodyMethodArguments): { body: string, base64Encoded: boolean } {
- var resource_data = resources_datas[params.requestId];
- var body = resource_data.hasTextContent ? NSString.alloc().initWithDataEncoding(resource_data.data, 4).toString() :
+ const resource_data = resources_datas[params.requestId];
+ const body = resource_data.hasTextContent ? NSString.alloc().initWithDataEncoding(resource_data.data, 4).toString() :
resource_data.data.base64EncodedStringWithOptions(0);
if (resource_data) {
@@ -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-name-resolver/file-name-resolver.ts b/tns-core-modules/file-system/file-name-resolver/file-name-resolver.ts
index c010f0b5d..800bb9bdb 100644
--- a/tns-core-modules/file-system/file-name-resolver/file-name-resolver.ts
+++ b/tns-core-modules/file-system/file-name-resolver/file-name-resolver.ts
@@ -190,9 +190,10 @@ export function _findFileMatch(path: string, ext: string, candidates: Array, context: PlatformContext): number {
let result = 0;
- for (var i = 0; i < qualifiers.length; i++) {
+ let value: number;
+ for (let i = 0; i < qualifiers.length; i++) {
if (qualifiers[i]) {
- var value = checkQualifier(qualifiers[i], context);
+ value = checkQualifier(qualifiers[i], context);
if (value < 0) {
// Non of the supported qualifiers matched this or the match was not satisified
return -1;
@@ -206,9 +207,10 @@ function checkQualifiers(qualifiers: Array, context: PlatformContext): n
}
function checkQualifier(value: string, context: PlatformContext) {
-for (var i = 0; i < supportedQualifiers.length; i++) {
+ let result: number;
+ for (let i = 0; i < supportedQualifiers.length; i++) {
if (supportedQualifiers[i].isMatch(value)) {
- var result = supportedQualifiers[i].getMatchValue(value, context);
+ result = supportedQualifiers[i].getMatchValue(value, context);
if (result > 0) {
result += (supportedQualifiers.length - i) * PRIORITY_STEP;
}
diff --git a/tns-core-modules/file-system/file-system-access.android.ts b/tns-core-modules/file-system/file-system-access.android.ts
index 13da55dd6..60dacb59e 100644
--- a/tns-core-modules/file-system/file-system-access.android.ts
+++ b/tns-core-modules/file-system/file-system-access.android.ts
@@ -14,7 +14,7 @@ export class FileSystemAccess {
private _pathSeparator = "/";
public getLastModified(path: string): Date {
- var javaFile = new java.io.File(path);
+ const javaFile = new java.io.File(path);
return new Date(javaFile.lastModified());
}
@@ -25,8 +25,8 @@ export class FileSystemAccess {
public getParent(path: string, onError?: (error: any) => any): { path: string; name: string } {
try {
- var javaFile = new java.io.File(path);
- var parent = javaFile.getParentFile();
+ const javaFile = new java.io.File(path);
+ const parent = javaFile.getParentFile();
return { path: parent.getAbsolutePath(), name: parent.getName() };
} catch (exception) {
@@ -44,8 +44,8 @@ export class FileSystemAccess {
}
public getFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
- var javaFile = new java.io.File(path);
- var dirInfo = this.ensureFile(javaFile, true, onError);
+ const javaFile = new java.io.File(path);
+ const dirInfo = this.ensureFile(javaFile, true, onError);
if (!dirInfo) {
return undefined;
}
@@ -62,14 +62,14 @@ export class FileSystemAccess {
}
public getEntities(path: string, onError?: (error: any) => any): Array<{ path: string; name: string; extension: string }> {
- var fileInfos = new Array<{ path: string; name: string; extension: string }>();
- var onEntity = function (entity: { path: string; name: string; extension: string }): boolean {
+ const fileInfos = new Array<{ path: string; name: string; extension: string }>();
+ const onEntity = function (entity: { path: string; name: string; extension: string }): boolean {
fileInfos.push(entity);
return true;
}
- var errorOccurred;
- var localError = function (error: any) {
+ let errorOccurred;
+ const localError = function (error: any) {
if (onError) {
onError(error);
}
@@ -87,18 +87,18 @@ export class FileSystemAccess {
}
public fileExists(path: string): boolean {
- var file = new java.io.File(path);
+ const file = new java.io.File(path);
return file.exists();
}
public folderExists(path: string): boolean {
- var file = new java.io.File(path);
+ const file = new java.io.File(path);
return file.exists() && file.isDirectory();
}
public deleteFile(path: string, onError?: (error: any) => any) {
try {
- var javaFile = new java.io.File(path);
+ const javaFile = new java.io.File(path);
if (!javaFile.isFile()) {
if (onError) {
onError({ message: "The specified parameter is not a File entity." });
@@ -121,7 +121,7 @@ export class FileSystemAccess {
public deleteFolder(path: string, onError?: (error: any) => any) {
try {
- var javaFile = new java.io.File(path);
+ const javaFile = new java.io.File(path);
if (!javaFile.getCanonicalFile().isDirectory()) {
if (onError) {
onError({ message: "The specified parameter is not a Folder entity." });
@@ -147,7 +147,7 @@ export class FileSystemAccess {
public emptyFolder(path: string, onError?: (error: any) => any) {
try {
- var javaFile = new java.io.File(path);
+ const javaFile = new java.io.File(path);
if (!javaFile.getCanonicalFile().isDirectory()) {
if (onError) {
onError({ message: "The specified parameter is not a Folder entity." });
@@ -166,7 +166,7 @@ export class FileSystemAccess {
}
public rename(path: string, newPath: string, onError?: (error: any) => any) {
- var javaFile = new java.io.File(path);
+ const javaFile = new java.io.File(path);
if (!javaFile.exists()) {
if (onError) {
onError(new Error("The file to rename does not exist"));
@@ -175,7 +175,7 @@ export class FileSystemAccess {
return;
}
- var newFile = new java.io.File(newPath);
+ const newFile = new java.io.File(newPath);
if (newFile.exists()) {
if (onError) {
onError(new Error("A file with the same name already exists."));
@@ -192,17 +192,17 @@ export class FileSystemAccess {
}
public getDocumentsFolderPath(): string {
- var dir = getApplicationContext().getFilesDir();
+ const dir = getApplicationContext().getFilesDir();
return dir.getAbsolutePath();
}
public getLogicalRootPath(): string {
- var dir = getApplicationContext().getFilesDir();
+ const dir = getApplicationContext().getFilesDir();
return dir.getCanonicalPath();
}
public getTempFolderPath(): string {
- var dir = getApplicationContext().getCacheDir();
+ const dir = getApplicationContext().getCacheDir();
return dir.getAbsolutePath();
}
@@ -212,10 +212,10 @@ export class FileSystemAccess {
public read(path: string, onError?: (error: any) => any) {
try {
- var javaFile = new java.io.File(path);
- var stream = new java.io.FileInputStream(javaFile);
- var bytes = (Array).create("byte", javaFile.length());
- var dataInputStream = new java.io.DataInputStream(stream);
+ const javaFile = new java.io.File(path);
+ const stream = new java.io.FileInputStream(javaFile);
+ const bytes = (Array).create("byte", javaFile.length());
+ const dataInputStream = new java.io.DataInputStream(stream);
dataInputStream.readFully(bytes);
return bytes;
} catch (exception) {
@@ -227,8 +227,8 @@ export class FileSystemAccess {
public write(path: string, bytes: native.Array, onError?: (error: any) => any) {
try {
- var javaFile = new java.io.File(path);
- var stream = new java.io.FileOutputStream(javaFile);
+ const javaFile = new java.io.File(path);
+ const stream = new java.io.FileOutputStream(javaFile);
stream.write(bytes, 0, bytes.length);
stream.close();
} catch (exception) {
@@ -240,20 +240,20 @@ export class FileSystemAccess {
public readText(path: string, onError?: (error: any) => any, encoding?: any) {
try {
- var javaFile = new java.io.File(path);
- var stream = new java.io.FileInputStream(javaFile);
+ const javaFile = new java.io.File(path);
+ const stream = new java.io.FileInputStream(javaFile);
- var actualEncoding = encoding;
+ let actualEncoding = encoding;
if (!actualEncoding) {
actualEncoding = textModule.encoding.UTF_8;
}
- var reader = new java.io.InputStreamReader(stream, actualEncoding);
- var bufferedReader = new java.io.BufferedReader(reader);
+ const reader = new java.io.InputStreamReader(stream, actualEncoding);
+ const bufferedReader = new java.io.BufferedReader(reader);
// TODO: We will need to read the entire file to a CharBuffer instead of reading it line by line
// TODO: bufferedReader.read(CharBuffer) does not currently work
- var line = undefined;
- var result = "";
+ let line = undefined;
+ let result = "";
while (true) {
line = bufferedReader.readLine();
if (line === null) {
@@ -295,14 +295,14 @@ export class FileSystemAccess {
public writeText(path: string, content: string, onError?: (error: any) => any, encoding?: any) {
try {
- var javaFile = new java.io.File(path);
- var stream = new java.io.FileOutputStream(javaFile);
+ const javaFile = new java.io.File(path);
+ const stream = new java.io.FileOutputStream(javaFile);
- var actualEncoding = encoding;
+ let actualEncoding = encoding;
if (!actualEncoding) {
actualEncoding = textModule.encoding.UTF_8;
}
- var writer = new java.io.OutputStreamWriter(stream, actualEncoding);
+ const writer = new java.io.OutputStreamWriter(stream, actualEncoding);
writer.write(content);
writer.close();
@@ -314,16 +314,15 @@ export class FileSystemAccess {
}
private deleteFolderContent(file: java.io.File): boolean {
- var filesList = file.listFiles();
+ const filesList = file.listFiles();
if (filesList.length === 0) {
return true; // Nothing to delete, so success!
}
- var i,
- childFile: java.io.File,
- success: boolean = false;
+ let childFile: java.io.File;
+ let success: boolean = false;
- for (i = 0; i < filesList.length; i++) {
+ for (let i = 0; i < filesList.length; i++) {
childFile = filesList[i];
if (childFile.getCanonicalFile().isDirectory()) {
success = this.deleteFolderContent(childFile);
@@ -341,7 +340,7 @@ export class FileSystemAccess {
private ensureFile(javaFile: java.io.File, isFolder: boolean, onError?: (error: any) => any): { path: string; name: string; extension: string } {
try {
if (!javaFile.exists()) {
- var created;
+ let created;
if (isFolder) {
created = javaFile.mkdirs();
} else {
@@ -362,7 +361,7 @@ export class FileSystemAccess {
}
}
- var path = javaFile.getAbsolutePath();
+ const path = javaFile.getAbsolutePath();
return { path: path, name: javaFile.getName(), extension: this.getFileExtension(path) };
} catch (exception) {
// TODO: unified approach for error messages
@@ -377,7 +376,7 @@ export class FileSystemAccess {
// TODO: This method is the same as in the iOS implementation.
// Make it in a separate file / module so it can be reused from both implementations.
private getFileExtension(path: string): string {
- var dotIndex = path.lastIndexOf(".");
+ const dotIndex = path.lastIndexOf(".");
if (dotIndex && dotIndex >= 0 && dotIndex < path.length) {
return path.substring(dotIndex);
}
@@ -387,7 +386,7 @@ export class FileSystemAccess {
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
try {
- var javaFile = new java.io.File(path);
+ let javaFile = new java.io.File(path);
if (!javaFile.getCanonicalFile().isDirectory()) {
if (onError) {
onError("There is no folder existing at path " + path);
@@ -396,13 +395,12 @@ export class FileSystemAccess {
return;
}
- var filesList = javaFile.listFiles();
- var length = filesList.length;
- var i;
- var info;
- var retVal;
+ const filesList = javaFile.listFiles();
+ const length = filesList.length;
+ let info;
+ let retVal;
- for (i = 0; i < length; i++) {
+ for (let i = 0; i < length; i++) {
javaFile = filesList[i];
info = {
@@ -431,13 +429,13 @@ export class FileSystemAccess {
}
public normalizePath(path: string): string {
- var file = new java.io.File(path);
+ const file = new java.io.File(path);
return file.getAbsolutePath();
}
public joinPath(left: string, right: string): string {
- var file1 = new java.io.File(left);
- var file2 = new java.io.File(file1, right);
+ const file1 = new java.io.File(left);
+ const file2 = new java.io.File(file1, right);
return file2.getPath();
}
@@ -451,9 +449,8 @@ export class FileSystemAccess {
return paths[0];
}
- var i,
- result = paths[0];
- for (i = 1; i < paths.length; i++) {
+ let result = paths[0];
+ for (let i = 1; i < paths.length; i++) {
result = this.joinPath(result, paths[i]);
}
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/file-system/file-system.d.ts b/tns-core-modules/file-system/file-system.d.ts
index ffed227c9..d3c6e1023 100644
--- a/tns-core-modules/file-system/file-system.d.ts
+++ b/tns-core-modules/file-system/file-system.d.ts
@@ -279,5 +279,5 @@ export module path {
/**
* Gets the string used to separate file paths.
*/
- export var separator: string;
+ export const separator: string;
}
diff --git a/tns-core-modules/file-system/file-system.ts b/tns-core-modules/file-system/file-system.ts
index 14fab4118..da7144d35 100644
--- a/tns-core-modules/file-system/file-system.ts
+++ b/tns-core-modules/file-system/file-system.ts
@@ -1,12 +1,14 @@
-import * as file_access_module from "./file-system-access";
+// imported for definition purposes only
import * as platformModule from "../platform";
+
+import { FileSystemAccess } from "./file-system-access";
import { profile } from "../profiling";
// The FileSystemAccess implementation, used through all the APIs.
-var fileAccess;
-var getFileAccess = function (): file_access_module.FileSystemAccess {
+let fileAccess: FileSystemAccess;
+function getFileAccess(): FileSystemAccess {
if (!fileAccess) {
- fileAccess = new file_access_module.FileSystemAccess();
+ fileAccess = new FileSystemAccess();
}
return fileAccess;
@@ -19,8 +21,8 @@ function ensurePlatform() {
}
}
-var createFile = function (info: { path: string; name: string; extension: string }) {
- var file = new File();
+function createFile(info: { path: string; name: string; extension: string }) {
+ const file = new File();
file._path = info.path;
file._name = info.name;
file._extension = info.extension;
@@ -28,18 +30,18 @@ var createFile = function (info: { path: string; name: string; extension: string
return file;
};
-var createFolder = function (info: { path: string; name: string; }) {
- var documents = knownFolders.documents();
+function createFolder(info: { path: string; name: string; }) {
+ const documents = knownFolders.documents();
if (info.path === documents.path) {
return documents;
}
- var temp = knownFolders.temp();
+ const temp = knownFolders.temp();
if (info.path === temp.path) {
return temp;
}
- var folder = new Folder();
+ const folder = new Folder();
folder._path = info.path;
folder._name = info.name;
@@ -56,11 +58,11 @@ export class FileSystemEntity {
_isKnown: boolean;
get parent(): Folder {
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
- var folderInfo = getFileAccess().getParent(this.path, onError);
+ const folderInfo = getFileAccess().getParent(this.path, onError);
if (!folderInfo) {
return undefined;
}
@@ -70,8 +72,8 @@ export class FileSystemEntity {
public remove(): Promise {
return new Promise((resolve, reject) => {
- var hasError = false;
- var localError = function (error: any) {
+ let hasError = false;
+ const localError = function (error: any) {
hasError = true;
reject(error);
};
@@ -92,7 +94,7 @@ export class FileSystemEntity {
return;
}
- var fileAccess = getFileAccess();
+ const fileAccess = getFileAccess();
if (this instanceof File) {
fileAccess.deleteFile(this.path, onError);
@@ -103,8 +105,8 @@ export class FileSystemEntity {
public rename(newName: string): Promise {
return new Promise((resolve, reject) => {
- var hasError = false;
- var localError = function (error) {
+ let hasError = false;
+ const localError = function (error) {
hasError = true;
reject(error);
}
@@ -125,22 +127,24 @@ export class FileSystemEntity {
return;
}
- var parentFolder = this.parent;
+ const parentFolder = this.parent;
if (!parentFolder) {
if (onError) {
onError(new Error("No parent folder."));
}
+
return;
}
- var fileAccess = getFileAccess();
- var path = parentFolder.path;
- var newPath = fileAccess.joinPath(path, newName);
+ const fileAccess = getFileAccess();
+ const path = parentFolder.path;
+ const newPath = fileAccess.joinPath(path, newName);
- var localError = function (error) {
+ const localError = function (error) {
if (onError) {
onError(error);
}
+
return null;
}
@@ -162,7 +166,7 @@ export class FileSystemEntity {
}
get lastModified(): Date {
- var value = this._lastModified;
+ let value = this._lastModified;
if (!this._lastModified) {
value = this._lastModified = getFileAccess().getLastModified(this.path);
}
@@ -173,11 +177,11 @@ export class FileSystemEntity {
export class File extends FileSystemEntity {
public static fromPath(path: string) {
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
- var fileInfo = getFileAccess().getFile(path, onError);
+ const fileInfo = getFileAccess().getFile(path, onError);
if (!fileInfo) {
return undefined;
}
@@ -207,15 +211,15 @@ export class File extends FileSystemEntity {
this._locked = true;
- var that = this;
- var localError = (error) => {
+ const that = this;
+ const localError = (error) => {
that._locked = false;
if (onError) {
onError(error);
}
};
- var content = getFileAccess().read(this.path, localError);
+ const content = getFileAccess().read(this.path, localError);
this._locked = false;
@@ -229,8 +233,8 @@ export class File extends FileSystemEntity {
try {
this._locked = true;
- var that = this;
- var localError = function (error) {
+ const that = this;
+ const localError = function (error) {
that._locked = false;
if (onError) {
onError(error);
@@ -245,13 +249,13 @@ export class File extends FileSystemEntity {
public readText(encoding?: string): Promise {
return new Promise((resolve, reject) => {
- var hasError = false;
- var localError = (error) => {
+ let hasError = false;
+ const localError = (error) => {
hasError = true;
reject(error);
};
- var content = this.readTextSync(localError, encoding);
+ const content = this.readTextSync(localError, encoding);
if (!hasError) {
resolve(content);
}
@@ -264,15 +268,15 @@ export class File extends FileSystemEntity {
this._locked = true;
- var that = this;
- var localError = (error) => {
+ const that = this;
+ const localError = (error) => {
that._locked = false;
if (onError) {
onError(error);
}
};
- var content = getFileAccess().readText(this.path, localError, encoding);
+ const content = getFileAccess().readText(this.path, localError, encoding);
this._locked = false;
return content;
@@ -280,8 +284,8 @@ export class File extends FileSystemEntity {
public writeText(content: string, encoding?: string): Promise {
return new Promise((resolve, reject) => {
- var hasError = false;
- var localError = function (error) {
+ let hasError = false;
+ const localError = function (error) {
hasError = true;
reject(error);
};
@@ -299,8 +303,8 @@ export class File extends FileSystemEntity {
try {
this._locked = true;
- var that = this;
- var localError = function (error) {
+ const that = this;
+ const localError = function (error) {
that._locked = false;
if (onError) {
onError(error);
@@ -323,11 +327,11 @@ export class File extends FileSystemEntity {
export class Folder extends FileSystemEntity {
public static fromPath(path: string): Folder {
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
- var folderInfo = getFileAccess().getFolder(path, onError);
+ const folderInfo = getFileAccess().getFolder(path, onError);
if (!folderInfo) {
return undefined;
}
@@ -340,8 +344,8 @@ export class Folder extends FileSystemEntity {
}
public contains(name: string): boolean {
- var fileAccess = getFileAccess();
- var path = fileAccess.joinPath(this.path, name);
+ const fileAccess = getFileAccess();
+ const path = fileAccess.joinPath(this.path, name);
if (fileAccess.fileExists(path)) {
return true;
@@ -352,8 +356,8 @@ export class Folder extends FileSystemEntity {
public clear(): Promise {
return new Promise((resolve, reject) => {
- var hasError = false;
- var onError = function (error) {
+ let hasError = false;
+ const onError = function (error) {
hasError = true;
reject(error);
};
@@ -374,14 +378,14 @@ export class Folder extends FileSystemEntity {
}
public getFile(name: string): File {
- var fileAccess = getFileAccess();
- var path = fileAccess.joinPath(this.path, name);
+ const fileAccess = getFileAccess();
+ const path = fileAccess.joinPath(this.path, name);
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
- var fileInfo = fileAccess.getFile(path, onError);
+ const fileInfo = fileAccess.getFile(path, onError);
if (!fileInfo) {
return undefined;
}
@@ -390,14 +394,14 @@ export class Folder extends FileSystemEntity {
}
public getFolder(name: string): Folder {
- var fileAccess = getFileAccess();
- var path = fileAccess.joinPath(this.path, name);
+ const fileAccess = getFileAccess();
+ const path = fileAccess.joinPath(this.path, name);
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
- var folderInfo = fileAccess.getFolder(path, onError);
+ const folderInfo = fileAccess.getFolder(path, onError);
if (!folderInfo) {
return undefined;
}
@@ -407,13 +411,13 @@ export class Folder extends FileSystemEntity {
public getEntities(): Promise> {
return new Promise((resolve, reject) => {
- var hasError = false;
- var localError = function (error) {
+ let hasError = false;
+ const localError = function (error) {
hasError = true;
reject(error);
};
- var entities = this.getEntitiesSync(localError);
+ const entities = this.getEntitiesSync(localError);
if (!hasError) {
resolve(entities);
}
@@ -421,15 +425,13 @@ export class Folder extends FileSystemEntity {
}
public getEntitiesSync(onError?: (error: any) => any): Array {
- var fileInfos = getFileAccess().getEntities(this.path, onError);
+ const fileInfos = getFileAccess().getEntities(this.path, onError);
if (!fileInfos) {
return null;
}
- var entities = new Array();
-
- var i;
- for (i = 0; i < fileInfos.length; i++) {
+ const entities = new Array();
+ for (let i = 0; i < fileInfos.length; i++) {
if (fileInfos[i].extension) {
entities.push(createFile(fileInfos[i]));
} else {
@@ -445,8 +447,8 @@ export class Folder extends FileSystemEntity {
return;
}
- var onSuccess = function (fileInfo: { path: string; name: string; extension: string }): boolean {
- var entity;
+ const onSuccess = function (fileInfo: { path: string; name: string; extension: string }): boolean {
+ let entity;
if (fileInfo.extension) {
entity = createFile(fileInfo);
} else {
@@ -456,7 +458,7 @@ export class Folder extends FileSystemEntity {
return onEntity(entity);
}
- var onError = function (error) {
+ const onError = function (error) {
throw error;
}
@@ -465,13 +467,13 @@ export class Folder extends FileSystemEntity {
}
export module knownFolders {
- var _documents: Folder;
- var _temp: Folder;
- var _app: Folder;
+ let _documents: Folder;
+ let _temp: Folder;
+ let _app: Folder;
- export var documents = function (): Folder {
+ export function documents(): Folder {
if (!_documents) {
- var path = getFileAccess().getDocumentsFolderPath();
+ const path = getFileAccess().getDocumentsFolderPath();
_documents = new Folder();
_documents._path = path;
_documents._isKnown = true;
@@ -480,9 +482,9 @@ export module knownFolders {
return _documents;
};
- export var temp = function (): Folder {
+ export function temp(): Folder {
if (!_temp) {
- var path = getFileAccess().getTempFolderPath();
+ const path = getFileAccess().getTempFolderPath();
_temp = new Folder();
_temp._path = path;
_temp._isKnown = true;
@@ -491,9 +493,9 @@ export module knownFolders {
return _temp;
};
- export var currentApp = function (): Folder {
+ export function currentApp(): Folder {
if (!_app) {
- var path = getFileAccess().getCurrentAppPath();
+ const path = getFileAccess().getCurrentAppPath();
_app = new Folder();
_app._path = path;
_app._isKnown = true;
@@ -511,7 +513,7 @@ export module knownFolders {
}
let _library: Folder;
- export var library = function(): Folder {
+ export function library(): Folder {
_checkPlatform("library");
if (!_library) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.LibraryDirectory);
@@ -527,7 +529,7 @@ export module knownFolders {
};
let _developer: Folder;
- export var developer = function(): Folder {
+ export function developer(): Folder {
_checkPlatform("developer");
if (!_developer) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.DeveloperDirectory);
@@ -543,7 +545,7 @@ export module knownFolders {
};
let _desktop: Folder;
- export var desktop = function(): Folder {
+ export function desktop(): Folder {
_checkPlatform("desktop");
if (!_desktop) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.DesktopDirectory);
@@ -559,7 +561,7 @@ export module knownFolders {
};
let _downloads: Folder;
- export var downloads = function(): Folder {
+ export function downloads(): Folder {
_checkPlatform("downloads");
if (!_downloads) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.DownloadsDirectory);
@@ -575,7 +577,7 @@ export module knownFolders {
};
let _movies: Folder;
- export var movies = function(): Folder {
+ export function movies(): Folder {
_checkPlatform("movies");
if (!_movies) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.MoviesDirectory);
@@ -591,7 +593,7 @@ export module knownFolders {
};
let _music: Folder;
- export var music = function(): Folder {
+ export function music(): Folder {
_checkPlatform("music");
if (!_music) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.MusicDirectory);
@@ -607,7 +609,7 @@ export module knownFolders {
};
let _pictures: Folder;
- export var pictures = function(): Folder {
+ export function pictures(): Folder {
_checkPlatform("pictures");
if (!_pictures) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.PicturesDirectory);
@@ -623,7 +625,7 @@ export module knownFolders {
};
let _sharedPublic: Folder;
- export var sharedPublic = function(): Folder {
+ export function sharedPublic(): Folder {
_checkPlatform("sharedPublic");
if (!_sharedPublic) {
let existingFolderInfo = getExistingFolderInfo(NSSearchPathDirectory.SharedPublicDirectory);
@@ -639,9 +641,9 @@ export module knownFolders {
};
function getExistingFolderInfo(pathDirectory: any /* NSSearchPathDirectory */): { folder: Folder; path: string } {
- var fileAccess = (getFileAccess());
- var folderPath = fileAccess.getKnownPath(pathDirectory);
- var folderInfo = fileAccess.getExistingFolder(folderPath);
+ const fileAccess = (getFileAccess());
+ const folderPath = fileAccess.getKnownPath(pathDirectory);
+ const folderInfo = fileAccess.getExistingFolder(folderPath);
if (folderInfo) {
return {
@@ -661,9 +663,9 @@ export module path {
}
export function join(...paths: string[]): string {
- var fileAccess = getFileAccess();
+ const fileAccess = getFileAccess();
return fileAccess.joinPaths(paths);
}
- export var separator = getFileAccess().getPathSeparator();
+ export const separator = getFileAccess().getPathSeparator();
}
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/globals/globals.ts b/tns-core-modules/globals/globals.ts
index d4b6fa6d5..7e4715852 100644
--- a/tns-core-modules/globals/globals.ts
+++ b/tns-core-modules/globals/globals.ts
@@ -4,7 +4,7 @@ require("./ts-helpers");
// This method iterates all the keys in the source exports object and copies them to the destination exports one.
// Note: the method will not check for naming collisions and will override any already existing entries in the destination exports.
global.moduleMerge = function (sourceExports: any, destExports: any) {
- for (var key in sourceExports) {
+ for (let key in sourceExports) {
destExports[key] = sourceExports[key];
}
}
@@ -135,10 +135,10 @@ export function install() {
if ((global).__snapshot || (global).__snapshotEnabled) {
if (!snapshotGlobals) {
// require in snapshot mode is cheap
- var timer: typeof timerModule = require("timer");
- var dialogs: typeof dialogsModule = require("ui/dialogs");
- var xhr = require("xhr");
- var fetch = require("fetch");
+ const timer: typeof timerModule = require("timer");
+ const dialogs: typeof dialogsModule = require("ui/dialogs");
+ const xhr = require("xhr");
+ const fetch = require("fetch");
snapshotGlobals = snapshotGlobals || {
setTimeout: timer.setTimeout,
@@ -161,7 +161,7 @@ export function install() {
Response: fetch.Response,
}
}
- var consoleModule = require("console").Console;
+ const consoleModule = require("console").Console;
// Object.assign call will fire an error when trying to write to a read-only property of an object, such as 'console'
global.console = global.console || new consoleModule();
Object.assign(global, snapshotGlobals);
@@ -190,7 +190,7 @@ install();
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
- var originalMethod = descriptor.value;
+ const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is deprecated`);
@@ -209,7 +209,7 @@ global.Deprecated = Deprecated;
export function Experimental(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
- var originalMethod = descriptor.value;
+ const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is experimental`);
diff --git a/tns-core-modules/globals/ts-helpers.ts b/tns-core-modules/globals/ts-helpers.ts
index bee3c471e..337b37b9f 100644
--- a/tns-core-modules/globals/ts-helpers.ts
+++ b/tns-core-modules/globals/ts-helpers.ts
@@ -1,7 +1,7 @@
// Required by V8 snapshot generator
if (!global.__extends) {
global.__extends = function (d, b) {
- for (var p in b) {
+ for (let p in b) {
if (b.hasOwnProperty(p)) {
d[p] = b[p];
}
diff --git a/tns-core-modules/http/http-request/http-request.d.ts b/tns-core-modules/http/http-request/http-request.d.ts
index 5907ee534..59261430a 100644
--- a/tns-core-modules/http/http-request/http-request.d.ts
+++ b/tns-core-modules/http/http-request/http-request.d.ts
@@ -6,5 +6,5 @@
//@private
import * as http from "..";
-export var request: (options: http.HttpRequestOptions) => Promise;
+export const request: (options: http.HttpRequestOptions) => Promise;
export function addHeader(headers: http.Headers, key: string, value: string): void;
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 2475fb9c7..ad53e823c 100644
--- a/tns-core-modules/http/http-request/http-request.ios.ts
+++ b/tns-core-modules/http/http-request/http-request.ios.ts
@@ -4,26 +4,23 @@ import * as imageSourceModule from "../../image-source";
import * as fsModule from "../../file-system";
import * as types from "../../utils/types";
-import * as utils from "../../utils/utils";
import * as domainDebugger from "../../debugger/debugger";
import { getFilenameFromUrl } from "./http-request-common";
-const getter = utils.ios.getter;
-
export enum HttpResponseEncoding {
UTF8,
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();
diff --git a/tns-core-modules/http/http.ts b/tns-core-modules/http/http.ts
index 251aa7c00..26300c277 100644
--- a/tns-core-modules/http/http.ts
+++ b/tns-core-modules/http/http.ts
@@ -7,7 +7,7 @@ export function getString(arg: any): Promise {
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
.then(r => {
try {
- var str = r.content.toString();
+ const str = r.content.toString();
resolve(str);
} catch (e) {
reject(e);
@@ -21,7 +21,7 @@ export function getJSON(arg: any): Promise {
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
.then(r => {
try {
- var json = r.content.toJSON();
+ const json = r.content.toJSON();
resolve(json);
} catch (e) {
reject(e);
@@ -50,7 +50,7 @@ export function getFile(arg: any, destinationFilePath?: string): Promise {
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
.then(r => {
try {
- var file = r.content.toFile(destinationFilePath);
+ const file = r.content.toFile(destinationFilePath);
resolve(file);
} catch (e) {
reject(e);
diff --git a/tns-core-modules/image-asset/image-asset-common.ts b/tns-core-modules/image-asset/image-asset-common.ts
index 0bed79c2c..3897d833c 100644
--- a/tns-core-modules/image-asset/image-asset-common.ts
+++ b/tns-core-modules/image-asset/image-asset-common.ts
@@ -47,10 +47,10 @@ export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, req
}
export function getRequestedImageSize(src: { width: number, height: number }, options: definition.ImageAssetOptions): { width: number, height: number } {
- var screen = platform.screen.mainScreen;
+ const screen = platform.screen.mainScreen;
- var reqWidth = options.width || Math.min(src.width, screen.widthPixels);
- var reqHeight = options.height || Math.min(src.height, screen.heightPixels);
+ let reqWidth = options.width || Math.min(src.width, screen.widthPixels);
+ let reqHeight = options.height || Math.min(src.height, screen.heightPixels);
if (options && options.keepAspectRatio) {
let safeAspectSize = getAspectSafeDimensions(src.width, src.height, reqWidth, reqHeight);
diff --git a/tns-core-modules/image-asset/image-asset.android.ts b/tns-core-modules/image-asset/image-asset.android.ts
index 411b772a4..2d7ace664 100644
--- a/tns-core-modules/image-asset/image-asset.android.ts
+++ b/tns-core-modules/image-asset/image-asset.android.ts
@@ -69,7 +69,7 @@ export class ImageAsset extends common.ImageAsset {
}
}
-var calculateAngleFromFile = function (filename: string) {
+function calculateAngleFromFile(filename: string) {
let rotationAngle = 0;
const ei = new android.media.ExifInterface(filename);
const orientation = ei.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL);
diff --git a/tns-core-modules/image-source/image-source.ios.ts b/tns-core-modules/image-source/image-source.ios.ts
index d4771f4f7..b7ff6531b 100644
--- a/tns-core-modules/image-source/image-source.ios.ts
+++ b/tns-core-modules/image-source/image-source.ios.ts
@@ -106,7 +106,7 @@ export class ImageSource implements ImageSourceDefinition {
public fromBase64(source: string): Promise {
return new Promise((resolve, reject) => {
try {
- var data = NSData.alloc().initWithBase64EncodedStringOptions(source, NSDataBase64DecodingOptions.IgnoreUnknownCharacters);
+ const data = NSData.alloc().initWithBase64EncodedStringOptions(source, NSDataBase64DecodingOptions.IgnoreUnknownCharacters);
UIImage.imageWithData["async"](UIImage, [data]).then(image => {
this.ios = image;
resolve(true);
@@ -191,7 +191,7 @@ function getFileName(path: string): string {
}
function getImageData(instance: UIImage, format: "png" | "jpeg" | "jpg", quality = 0.9): NSData {
- var data = null;
+ let data = null;
switch (format) {
case "png":
data = UIImagePNGRepresentation(instance);
@@ -201,6 +201,7 @@ function getImageData(instance: UIImage, format: "png" | "jpeg" | "jpg", quality
data = UIImageJPEGRepresentation(instance, quality);
break;
}
+
return data;
}
diff --git a/tns-core-modules/js-libs/esprima/esprima.d.ts b/tns-core-modules/js-libs/esprima/esprima.d.ts
index 9ce9dd962..c0570dabb 100644
--- a/tns-core-modules/js-libs/esprima/esprima.d.ts
+++ b/tns-core-modules/js-libs/esprima/esprima.d.ts
@@ -9,7 +9,7 @@
// Definitions by: teppeis
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-export var version: string;
+export const version: string;
export function parse(code: string, options?: Options): Syntax.Program;
export function tokenize(code: string, options?: Options): Array;
diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json
index b8e45d1ae..91a26be78 100644
--- a/tns-core-modules/package.json
+++ b/tns-core-modules/package.json
@@ -1,7 +1,7 @@
{
"name": "tns-core-modules",
"description": "Telerik NativeScript Core Modules",
- "version": "5.3.1",
+ "version": "5.4.0",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
@@ -26,7 +26,7 @@
"license": "Apache-2.0",
"typings": "tns-core-modules.d.ts",
"dependencies": {
- "tns-core-modules-widgets": "5.3.0",
+ "tns-core-modules-widgets": "next",
"tslib": "^1.9.3"
},
"devDependencies": {
diff --git a/tns-core-modules/platform/platform.d.ts b/tns-core-modules/platform/platform.d.ts
index 94aaf9967..bc08f2c58 100644
--- a/tns-core-modules/platform/platform.d.ts
+++ b/tns-core-modules/platform/platform.d.ts
@@ -8,19 +8,19 @@
/**
* Gets a value indicating if the app is running on the Android platform.
*/
-export var isAndroid: boolean;
+export const isAndroid: boolean;
/**
* Gets a value indicating if the app is running on the iOS platform.
*/
-export var isIOS: boolean;
+export const isIOS: boolean;
/*
* Enum holding platform names.
*/
export module platformNames {
- export var android: string;
- export var ios: string;
+ export const android: string;
+ export const ios: string;
}
/*
@@ -119,10 +119,10 @@ export module screen {
/**
* Gets information about the main screen of the current device.
*/
- export var mainScreen: ScreenMetrics;
+ export const mainScreen: ScreenMetrics;
}
/**
* Gets the current device information.
*/
-export var device: Device;
+export const device: Device;
diff --git a/tns-core-modules/platform/platform.ios.ts b/tns-core-modules/platform/platform.ios.ts
index 58a0b17ca..881b34e85 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,9 +62,9 @@ class Device implements DeviceDefinition {
}
get uuid(): string {
- var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
- var uuid_key = "TNSUUID";
- var app_uuid = userDefaults.stringForKey(uuid_key);
+ const userDefaults = NSUserDefaults.standardUserDefaults;
+ const uuid_key = "TNSUUID";
+ let app_uuid = userDefaults.stringForKey(uuid_key);
if (!app_uuid) {
app_uuid = NSUUID.UUID().UUIDString;
@@ -77,7 +77,7 @@ class Device implements DeviceDefinition {
get language(): string {
if (!this._language) {
- var languages = utils.ios.getter(NSLocale, NSLocale.preferredLanguages);
+ const 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/profiling/profiling.ts b/tns-core-modules/profiling/profiling.ts
index dd8bb5257..e2c521ad8 100644
--- a/tns-core-modules/profiling/profiling.ts
+++ b/tns-core-modules/profiling/profiling.ts
@@ -177,7 +177,7 @@ const profileMethodUnnamed = (target, key, descriptor) => {
if (descriptor === undefined) {
descriptor = Object.getOwnPropertyDescriptor(target, key);
}
- var originalMethod = descriptor.value;
+ const originalMethod = descriptor.value;
let className = "";
if (target && target.constructor && target.constructor.name) {
@@ -199,7 +199,7 @@ const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
if (descriptor === undefined) {
descriptor = Object.getOwnPropertyDescriptor(ctor, key);
}
- var originalMethod = descriptor.value;
+ const originalMethod = descriptor.value;
let className = "";
if (ctor && ctor.name) {
@@ -222,7 +222,7 @@ function profileMethodNamed(name: string): MethodDecorator {
if (descriptor === undefined) {
descriptor = Object.getOwnPropertyDescriptor(target, key);
}
- var originalMethod = descriptor.value;
+ const originalMethod = descriptor.value;
//editing the descriptor/value parameter
descriptor.value = profileFunctionFactory(originalMethod, name);
diff --git a/tns-core-modules/text/text.android.ts b/tns-core-modules/text/text.android.ts
index c94c44641..f21c80c3c 100644
--- a/tns-core-modules/text/text.android.ts
+++ b/tns-core-modules/text/text.android.ts
@@ -1,8 +1,8 @@
export module encoding {
- export var ISO_8859_1 = "ISO-8859-1";
- export var US_ASCII = "US-ASCII";
- export var UTF_16 = "UTF-16";
- export var UTF_16BE = "UTF-16BE";
- export var UTF_16LE = "UTF-16LE";
- export var UTF_8 = "UTF-8";
+ export const ISO_8859_1 = "ISO-8859-1";
+ export const US_ASCII = "US-ASCII";
+ export const UTF_16 = "UTF-16";
+ export const UTF_16BE = "UTF-16BE";
+ export const UTF_16LE = "UTF-16LE";
+ export const UTF_8 = "UTF-8";
}
\ No newline at end of file
diff --git a/tns-core-modules/text/text.d.ts b/tns-core-modules/text/text.d.ts
index b6712ee26..7e572947e 100644
--- a/tns-core-modules/text/text.d.ts
+++ b/tns-core-modules/text/text.d.ts
@@ -10,30 +10,30 @@ export module encoding {
/**
* Denotes ISO-8859-1 character encoding.
*/
- export var ISO_8859_1: any;
+ export const ISO_8859_1: any;
/**
* Denotes US_ASCII character encoding.
*/
- export var US_ASCII: any;
+ export const US_ASCII: any;
/**
* Denotes UTF_16 character encoding.
*/
- export var UTF_16: any;
+ export const UTF_16: any;
/**
* Denotes UTF_16BE character encoding.
*/
- export var UTF_16BE: any;
+ export const UTF_16BE: any;
/**
* Denotes UTF_16LE character encoding.
*/
- export var UTF_16LE: any;
+ export const UTF_16LE: any;
/**
* Denotes UTF_8 character encoding.
*/
- export var UTF_8: any;
+ export const UTF_8: any;
}
diff --git a/tns-core-modules/text/text.ios.ts b/tns-core-modules/text/text.ios.ts
index 228c03df5..55b9659ce 100644
--- a/tns-core-modules/text/text.ios.ts
+++ b/tns-core-modules/text/text.ios.ts
@@ -1,8 +1,8 @@
export module encoding {
- export var ISO_8859_1 = 5; //NSISOLatin1StringEncoding
- export var US_ASCII = 1; //NSASCIIStringEncoding
- export var UTF_16 = 10; //NSUnicodeStringEncoding
- export var UTF_16BE = 0x90000100; //NSUTF16BigEndianStringEncoding
- export var UTF_16LE = 0x94000100; //NSUTF16LittleEndianStringEncoding
- export var UTF_8 = 4; //NSUTF8StringEncoding
+ export const ISO_8859_1 = 5; //NSISOLatin1StringEncoding
+ export const US_ASCII = 1; //NSASCIIStringEncoding
+ export const UTF_16 = 10; //NSUnicodeStringEncoding
+ export const UTF_16BE = 0x90000100; //NSUTF16BigEndianStringEncoding
+ export const UTF_16LE = 0x94000100; //NSUTF16LittleEndianStringEncoding
+ export const UTF_8 = 4; //NSUTF8StringEncoding
}
\ No newline at end of file
diff --git a/tns-core-modules/timer/timer.android.ts b/tns-core-modules/timer/timer.android.ts
index beedf6ea5..1551d9a8f 100644
--- a/tns-core-modules/timer/timer.android.ts
+++ b/tns-core-modules/timer/timer.android.ts
@@ -1,9 +1,9 @@
/**
* Android specific timer functions implementation.
*/
-var timeoutHandler;
-var timeoutCallbacks = {};
-var timerId = 0;
+let timeoutHandler;
+const timeoutCallbacks = {};
+let timerId = 0;
function createHandlerAndGetId(): number {
if (!timeoutHandler) {
@@ -19,7 +19,7 @@ export function setTimeout(callback: Function, milliseconds = 0, ...args): numbe
const invoke = () => callback(...args);
const zoneBound = zonedCallback(invoke);
- var runnable = new java.lang.Runnable({
+ const runnable = new java.lang.Runnable({
run: () => {
zoneBound();
@@ -52,7 +52,7 @@ export function setInterval(callback: Function, milliseconds = 0, ...args): numb
const invoke = () => callback(...args);
const zoneBound = zonedCallback(invoke);
- var runnable = new java.lang.Runnable({
+ const runnable = new java.lang.Runnable({
run: () => {
zoneBound();
if (timeoutCallbacks[id]) {
@@ -70,4 +70,4 @@ export function setInterval(callback: Function, milliseconds = 0, ...args): numb
return id;
}
-export var clearInterval = clearTimeout;
+export const clearInterval = clearTimeout;
diff --git a/tns-core-modules/timer/timer.ios.ts b/tns-core-modules/timer/timer.ios.ts
index cf780daa6..88dbb036f 100644
--- a/tns-core-modules/timer/timer.ios.ts
+++ b/tns-core-modules/timer/timer.ios.ts
@@ -1,8 +1,8 @@
import * as utils from "../utils/utils";
//iOS specific timer functions implementation.
-var timeoutCallbacks = new Map>();
-var timerId = 0;
+const timeoutCallbacks = new Map>();
+let timerId = 0;
interface KeyValuePair {
k: K;
@@ -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);
@@ -80,4 +80,4 @@ export function setInterval(callback: Function, milliseconds = 0, ...args): numb
return createTimerAndGetId(zonedCallback(invoke), milliseconds, true);
}
-export var clearInterval = clearTimeout;
+export const clearInterval = clearTimeout;
diff --git a/tns-core-modules/trace/trace.d.ts b/tns-core-modules/trace/trace.d.ts
index ef818be8a..838a8729f 100644
--- a/tns-core-modules/trace/trace.d.ts
+++ b/tns-core-modules/trace/trace.d.ts
@@ -88,22 +88,22 @@ export function setErrorHandler(handler: ErrorHandler);
* An enum that defines all predefined categories.
*/
export module categories {
- export var VisualTreeEvents: string;
- export var Layout: string;
- export var Style: string;
- export var ViewHierarchy: string;
- export var NativeLifecycle: string;
- export var Debug: string;
- export var Navigation: string;
- export var Test: string;
- export var Binding: string;
- export var Error: string;
- export var Animation: string;
- export var Transition: string;
+ export const VisualTreeEvents: string;
+ export const Layout: string;
+ export const Style: string;
+ export const ViewHierarchy: string;
+ export const NativeLifecycle: string;
+ export const Debug: string;
+ export const Navigation: string;
+ export const Test: string;
+ export const Binding: string;
+ export const Error: string;
+ export const Animation: string;
+ export const Transition: string;
- export var All: string;
+ export const All: string;
- export var separator: string;
+ export const separator: string;
export function concat(...categories: string[]): string;
}
@@ -111,10 +111,10 @@ export module categories {
* An enum that defines all predefined message types.
*/
export module messageType {
- export var log: number;
- export var info: number;
- export var warn: number;
- export var error: number;
+ export const log: number;
+ export const info: number;
+ export const warn: number;
+ export const error: number;
}
/**
diff --git a/tns-core-modules/trace/trace.ts b/tns-core-modules/trace/trace.ts
index 7c7c84664..497fcf11e 100644
--- a/tns-core-modules/trace/trace.ts
+++ b/tns-core-modules/trace/trace.ts
@@ -102,41 +102,40 @@ export function addEventListener(listener: EventListener) {
}
export function removeEventListener(listener: EventListener) {
- var index = _eventListeners.indexOf(listener);
+ const index = _eventListeners.indexOf(listener);
if (index >= 0) {
_eventListeners.splice(index, 1);
}
}
export module messageType {
- export var log = 0;
- export var info = 1;
- export var warn = 2;
- export var error = 3;
+ export const log = 0;
+ export const info = 1;
+ export const warn = 2;
+ export const error = 3;
}
export module categories {
- export var VisualTreeEvents = "VisualTreeEvents";
- export var Layout = "Layout";
- export var Style = "Style";
- export var ViewHierarchy = "ViewHierarchy";
- export var NativeLifecycle = "NativeLifecycle";
- export var Debug = "Debug";
- export var Navigation = "Navigation";
- export var Test = "Test";
- export var Binding = "Binding";
- export var BindingError = "BindingError";
- export var Error = "Error";
- export var Animation = "Animation";
- export var Transition = "Transition";
- export var All = VisualTreeEvents + "," + Layout + "," + Style + "," + ViewHierarchy + "," + NativeLifecycle + "," + Debug + "," + Navigation + "," + Test + "," + Binding + "," + Error + "," + Animation + "," + Transition;
+ export const VisualTreeEvents = "VisualTreeEvents";
+ export const Layout = "Layout";
+ export const Style = "Style";
+ export const ViewHierarchy = "ViewHierarchy";
+ export const NativeLifecycle = "NativeLifecycle";
+ export const Debug = "Debug";
+ export const Navigation = "Navigation";
+ export const Test = "Test";
+ export const Binding = "Binding";
+ export const BindingError = "BindingError";
+ export const Error = "Error";
+ export const Animation = "Animation";
+ export const Transition = "Transition";
+ export const All = VisualTreeEvents + "," + Layout + "," + Style + "," + ViewHierarchy + "," + NativeLifecycle + "," + Debug + "," + Navigation + "," + Test + "," + Binding + "," + Error + "," + Animation + "," + Transition;
- export var separator = ",";
+ export const separator = ",";
export function concat(): string {
- var i;
- var result: string;
- for (i = 0; i < arguments.length; i++) {
+ let result: string;
+ for (let i = 0; i < arguments.length; i++) {
if (!result) {
result = arguments[i];
continue;
@@ -155,7 +154,7 @@ class ConsoleWriter implements TraceWriter {
return;
}
- var msgType;
+ let msgType;
if (type === undefined) {
msgType = messageType.log;
} else {
diff --git a/tns-core-modules/ui/action-bar/action-bar-common.ts b/tns-core-modules/ui/action-bar/action-bar-common.ts
index 5701364d8..b43d2e47d 100644
--- a/tns-core-modules/ui/action-bar/action-bar-common.ts
+++ b/tns-core-modules/ui/action-bar/action-bar-common.ts
@@ -18,7 +18,7 @@ import {
} from "../core/view";
export module knownCollections {
- export var actionItems = "actionItems";
+ export const actionItems = "actionItems";
}
@CSSType("ActionBar")
@@ -235,7 +235,7 @@ export class ActionItems implements ActionItemsDefinition {
}
// Add new items
- for (var i = 0; i < items.length; i++) {
+ for (let i = 0; i < items.length; i++) {
this.addItem(items[i]);
}
diff --git a/tns-core-modules/ui/animation/animation-common.ts b/tns-core-modules/ui/animation/animation-common.ts
index 20d29c4fb..bf021e52e 100644
--- a/tns-core-modules/ui/animation/animation-common.ts
+++ b/tns-core-modules/ui/animation/animation-common.ts
@@ -16,11 +16,11 @@ export { Color, traceEnabled, traceWrite, traceCategories, traceType };
export { AnimationPromise } from ".";
export module Properties {
- export var opacity = "opacity";
- export var backgroundColor = "backgroundColor";
- export var translate = "translate";
- export var rotate = "rotate";
- export var scale = "scale";
+ export const opacity = "opacity";
+ export const backgroundColor = "backgroundColor";
+ export const translate = "translate";
+ export const rotate = "rotate";
+ export const scale = "scale";
}
export interface PropertyAnimation {
@@ -96,7 +96,7 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
public play(): AnimationPromiseDefinition {
// We have to actually create a "Promise" due to a bug in the v8 engine and decedent promises
// We just cast it to a animationPromise so that all the rest of the code works fine
- var animationFinishedPromise = new Promise((resolve, reject) => {
+ const animationFinishedPromise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
@@ -109,19 +109,19 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
private fixupAnimationPromise(promise: AnimationPromiseDefinition): void {
// Since we are using function() below because of arguments, TS won't automatically do a _this for those functions.
- var _this = this;
+ const _this = this;
promise.cancel = () => {
_this.cancel();
};
- var _then = promise.then;
+ const _then = promise.then;
promise.then = function () {
- var r = _then.apply(promise, arguments);
+ const r = _then.apply(promise, arguments);
_this.fixupAnimationPromise(r);
return r;
};
- var _catch = promise.catch;
+ const _catch = promise.catch;
promise.catch = function () {
- var r = _catch.apply(promise, arguments);
+ const r = _catch.apply(promise, arguments);
_this.fixupAnimationPromise(r);
return r;
};
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/builder/binding-builder.d.ts b/tns-core-modules/ui/builder/binding-builder.d.ts
index 2eed5b7a4..d0e14be7c 100644
--- a/tns-core-modules/ui/builder/binding-builder.d.ts
+++ b/tns-core-modules/ui/builder/binding-builder.d.ts
@@ -5,17 +5,17 @@
//@private
export module bindingConstants {
- export var sourceProperty: string;
- export var targetProperty: string;
- export var expression: string;
- export var twoWay: string;
- export var source: string;
- export var bindingValueKey: string;
- export var parentValueKey: string;
- export var parentsValueKey: string;
- export var newPropertyValueKey: string;
+ export const sourceProperty: string;
+ export const targetProperty: string;
+ export const expression: string;
+ export const twoWay: string;
+ export const source: string;
+ export const bindingValueKey: string;
+ export const parentValueKey: string;
+ export const parentsValueKey: string;
+ export const newPropertyValueKey: string;
}
export function getBindingOptions(name: string, value: string): any;
-export var parentsRegex: RegExp;
+export const parentsRegex: RegExp;
diff --git a/tns-core-modules/ui/builder/binding-builder.ts b/tns-core-modules/ui/builder/binding-builder.ts
index 899b8b5fa..17d6e879f 100644
--- a/tns-core-modules/ui/builder/binding-builder.ts
+++ b/tns-core-modules/ui/builder/binding-builder.ts
@@ -1,54 +1,55 @@
// regex that contains all symbols applicable for expression used to AI detect an expression.
-var expressionSymbolsRegex = /[\+\-\*\/%\?:<>=!\|&\(\)^~]/;
+const expressionSymbolsRegex = /[\+\-\*\/%\?:<>=!\|&\(\)^~]/;
export module bindingConstants {
- export var sourceProperty = "sourceProperty";
- export var targetProperty = "targetProperty";
- export var expression = "expression";
- export var twoWay = "twoWay";
- export var source = "source";
- export var bindingValueKey = "$value";
- export var parentValueKey = "$parent";
- export var parentsValueKey = "$parents";
- export var newPropertyValueKey = "$newPropertyValue";
+ export const sourceProperty = "sourceProperty";
+ export const targetProperty = "targetProperty";
+ export const expression = "expression";
+ export const twoWay = "twoWay";
+ export const source = "source";
+ export const bindingValueKey = "$value";
+ export const parentValueKey = "$parent";
+ export const parentsValueKey = "$parents";
+ export const newPropertyValueKey = "$newPropertyValue";
};
-var hasEqualSignRegex = /=+/;
-var equalSignComparisionOperatorsRegex = /(==|===|>=|<=|!=|!==)/;
+const hasEqualSignRegex = /=+/;
+const equalSignComparisionOperatorsRegex = /(==|===|>=|<=|!=|!==)/;
// this regex is used to search for all instaces of '$parents[]' within an expression
-export var parentsRegex = /\$parents\s*\[\s*(['"]*)\w*\1\s*\]/g;
+export const parentsRegex = /\$parents\s*\[\s*(['"]*)\w*\1\s*\]/g;
function isNamedParam(value) {
- var equalSignIndex = value.search(hasEqualSignRegex);
+ const equalSignIndex = value.search(hasEqualSignRegex);
if (equalSignIndex > -1) {
- var equalSignSurround = value.substr(equalSignIndex > 0 ? equalSignIndex - 1 : 0, 3);
+ const equalSignSurround = value.substr(equalSignIndex > 0 ? equalSignIndex - 1 : 0, 3);
if (equalSignSurround.search(equalSignComparisionOperatorsRegex) === -1) {
return true;
}
}
+
return false;
}
function areNamedParams(params: Array) {
- var i;
- for (i = 0; i < params.length; i++) {
+ for (let i = 0; i < params.length; i++) {
if (isNamedParam(params[i])) {
return true;
}
}
+
return false;
}
-var namedParamConstants = {
+const namedParamConstants = {
propName: "propName",
propValue: "propValue"
}
function getPropertyNameValuePair(param, knownOptions, callback) {
- var nameValuePair = {};
- var propertyName = param.substr(0, param.indexOf("=")).trim();
- var propertyValue = param.substr(param.indexOf("=") + 1).trim();
+ let nameValuePair = {};
+ let propertyName = param.substr(0, param.indexOf("=")).trim();
+ const propertyValue = param.substr(param.indexOf("=") + 1).trim();
if (knownOptions) {
if (!propertyName) {
propertyName = knownOptions.defaultProperty;
@@ -73,25 +74,26 @@ function getPropertyNameValuePair(param, knownOptions, callback) {
}
function parseNamedProperties(parameterList, knownOptions, callback) {
- var result = {};
- var i;
- for (i = 0; i < parameterList.length; i++) {
- var nameValuePair = getPropertyNameValuePair(parameterList[i], knownOptions, callback);
+ const result = {};
+ let nameValuePair;
+ for (let i = 0; i < parameterList.length; i++) {
+ nameValuePair = getPropertyNameValuePair(parameterList[i], knownOptions, callback);
if (nameValuePair) {
result[nameValuePair[namedParamConstants.propName]] = nameValuePair[namedParamConstants.propValue];
}
}
+
return result;
}
function getParamsArray(value: string) {
- var result = [];
- var i;
- var skipComma = 0;
- var indexReached = 0;
- var singleQuoteBlock, doubleQuoteBlock = false;
+ const result = [];
+ let skipComma = 0;
+ let indexReached = 0;
+ let singleQuoteBlock = false;
+ let doubleQuoteBlock = false;
- for (i = 0; i < value.length; i++) {
+ for (let i = 0; i < value.length; i++) {
if (value[i] === "\"") {
doubleQuoteBlock = !doubleQuoteBlock;
}
@@ -121,26 +123,28 @@ function getParamsArray(value: string) {
function isExpression(expression: string): boolean {
if (expression.search(expressionSymbolsRegex) > -1) {
- var parentsMatches = expression.match(parentsRegex);
+ const parentsMatches = expression.match(parentsRegex);
if (parentsMatches) {
- var restOfExpression = expression.substr(expression.indexOf(parentsMatches[0]) + parentsMatches[0].length);
+ const restOfExpression = expression.substr(expression.indexOf(parentsMatches[0]) + parentsMatches[0].length);
// no more expression regognition symbols so it is safe for sourceProperty
if (!(restOfExpression.search(expressionSymbolsRegex) > -1)) {
return false;
}
}
+
return true;
}
+
return false;
}
export function getBindingOptions(name: string, value: string): any {
- var namedParams = [];
- var params = getParamsArray(value);
+ let namedParams = [];
+ const params = getParamsArray(value);
if (!areNamedParams(params)) {
if (params.length === 1) {
- var trimmedValue = params[0].trim();
- var sourceProp;
+ const trimmedValue = params[0].trim();
+ let sourceProp;
if (isExpression(trimmedValue)) {
sourceProp = bindingConstants.bindingValueKey;
namedParams.push(bindingConstants.expression + " = " + trimmedValue);
@@ -155,7 +159,7 @@ export function getBindingOptions(name: string, value: string): any {
else {
namedParams.push(bindingConstants.sourceProperty + " = " + params[0].trim());
namedParams.push(bindingConstants.expression + " = " + params[1].trim());
- var twoWay = params[2] ? params[2].toLowerCase().trim() === "true" : true;
+ const twoWay = params[2] ? params[2].toLowerCase().trim() === "true" : true;
namedParams.push(bindingConstants.twoWay + " = " + twoWay);
}
}
@@ -163,8 +167,8 @@ export function getBindingOptions(name: string, value: string): any {
namedParams = params;
}
- var bindingPropertyHandler = function (prop, value) {
- var result = {};
+ const bindingPropertyHandler = function (prop, value) {
+ const result = {};
result[namedParamConstants.propName] = prop;
if (prop === bindingConstants.twoWay) {
// create a real boolean value
@@ -182,12 +186,12 @@ export function getBindingOptions(name: string, value: string): any {
return result;
};
- var bindingOptionsParameters = parseNamedProperties(namedParams, xmlBindingProperties, bindingPropertyHandler);
- var bindOptions = {
+ const bindingOptionsParameters = parseNamedProperties(namedParams, xmlBindingProperties, bindingPropertyHandler);
+ const bindOptions = {
targetProperty: name
};
- for (var prop in bindingOptionsParameters) {
+ for (let prop in bindingOptionsParameters) {
if (bindingOptionsParameters.hasOwnProperty(prop)) {
bindOptions[prop] = bindingOptionsParameters[prop];
}
@@ -200,10 +204,10 @@ export function getBindingOptions(name: string, value: string): any {
return bindOptions;
}
-var xmlBindingProperties = {
+const xmlBindingProperties = {
sourceProperty: true,
expression: true,
twoWay: true,
source: true,
defaultProperty: bindingConstants.sourceProperty
-};
\ No newline at end of file
+};
diff --git a/tns-core-modules/ui/builder/builder.ts b/tns-core-modules/ui/builder/builder.ts
index 4d4b3e5c1..d3dd8e099 100644
--- a/tns-core-modules/ui/builder/builder.ts
+++ b/tns-core-modules/ui/builder/builder.ts
@@ -2,6 +2,7 @@
import { LoadOptions } from ".";
import { View, ViewBase, Template, KeyedTemplate } from "../core/view";
import { ViewEntry } from "../frame";
+import * as traceModule from "../../trace";
// Types.
import { debug, ScopeError, SourceError, Source } from "../../utils/debug";
@@ -12,14 +13,13 @@ import { ComponentModule, setPropertyValue, getComponentModule } from "./compone
import { platformNames, device } from "../../platform";
import { resolveFileName } from "../../file-system/file-name-resolver";
import { profile } from "../../profiling";
-import * as traceModule from "../../trace";
const ios = platformNames.ios.toLowerCase();
const android = platformNames.android.toLowerCase();
const defaultNameSpaceMatcher = /tns\.xsd$/i;
-var trace: typeof traceModule;
+let trace: typeof traceModule;
function ensureTrace() {
if (!trace) {
trace = require("trace");
@@ -151,7 +151,7 @@ function loadInternal(fileName: string, context?: any, moduleNamePath?: string):
const filePathRelativeToApp = (moduleNamePath && moduleNamePath.startsWith(appPath) ? "./" + moduleNamePath.substr(appPath.length + 1) : moduleNamePath) + ".xml";
if (global.moduleExists(filePathRelativeToApp)) {
- var text = global.loadModule(filePathRelativeToApp);
+ const text = global.loadModule(filePathRelativeToApp);
componentModule = parseInternal(text, context, fileName, moduleNamePath);
} else if (fileName && File.exists(fileName)) {
const file = File.fromPath(fileName);
@@ -228,7 +228,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
// webpack modules require paths to be relative to /app folder.
let cssModulePath = fullComponentPathFilePathWithoutExt + ".css";
if (cssModulePath.startsWith("/")) {
- var app = knownFolders.currentApp().path + "/";
+ const app = knownFolders.currentApp().path + "/";
if (cssModulePath.startsWith(app)) {
cssModulePath = "./" + cssModulePath.substr(app.length);
}
@@ -238,7 +238,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
if (global.moduleExists(cssModulePath)) {
(parentPage).addCssFile(cssModulePath);
} else {
- var cssFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "css");
+ const cssFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "css");
// Add component CSS file if exists.
if (cssFilePath) {
if (parentPage && typeof (parentPage).addCssFile === "function") {
@@ -270,11 +270,11 @@ function getExports(instance: ViewBase): any {
}
function parseInternal(value: string, context: any, uri?: string, moduleNamePath?: string): ComponentModule {
- var start: xml2ui.XmlStringParser;
- var ui: xml2ui.ComponentParser;
+ let start: xml2ui.XmlStringParser;
+ let ui: xml2ui.ComponentParser;
- var errorFormat = (debug && uri) ? xml2ui.SourceErrorFormat(uri) : xml2ui.PositionErrorFormat;
- var componentSourceTracker = (debug && uri) ? xml2ui.ComponentSourceTracker(uri) : () => {
+ const errorFormat = (debug && uri) ? xml2ui.SourceErrorFormat(uri) : xml2ui.PositionErrorFormat;
+ const componentSourceTracker = (debug && uri) ? xml2ui.ComponentSourceTracker(uri) : () => {
// no-op
};
@@ -320,7 +320,7 @@ namespace xml2ui {
}
public parse(value: string) {
- var xmlParser = new xml.XmlParser((args: xml.ParserEvent) => {
+ const xmlParser = new xml.XmlParser((args: xml.ParserEvent) => {
try {
this.next(args);
} catch (e) {
@@ -346,7 +346,7 @@ namespace xml2ui {
export function SourceErrorFormat(uri): ErrorFormatter {
return (e: Error, p: xml.Position) => {
- var source = p ? new Source(uri, p.line, p.column) : new Source(uri, -1, -1);
+ const source = p ? new Source(uri, p.line, p.column) : new Source(uri, -1, -1);
e = new SourceError(e, source, "Building UI from XML.");
return e;
}
@@ -359,7 +359,7 @@ namespace xml2ui {
export function ComponentSourceTracker(uri): SourceTracker {
return (component: any, p: xml.Position) => {
if (!Source.get(component)) {
- var source = p ? new Source(uri, p.line, p.column) : new Source(uri, -1, -1);
+ const source = p ? new Source(uri, p.line, p.column) : new Source(uri, -1, -1);
Source.set(component, source);
}
}
@@ -528,12 +528,12 @@ namespace xml2ui {
}
public buildTemplate(): Template {
- var context = this._context;
- var errorFormat = this._templateProperty.errorFormat;
- var sourceTracker = this._templateProperty.sourceTracker;
- var template: Template = profile("Template()", () => {
- var start: xml2ui.XmlArgsReplay;
- var ui: xml2ui.ComponentParser;
+ const context = this._context;
+ const errorFormat = this._templateProperty.errorFormat;
+ const sourceTracker = this._templateProperty.sourceTracker;
+ const template: Template = profile("Template()", () => {
+ let start: xml2ui.XmlArgsReplay;
+ let ui: xml2ui.ComponentParser;
(start = new xml2ui.XmlArgsReplay(this._recordedXmlStream, errorFormat))
// No platform filter, it has been filtered already
@@ -543,6 +543,7 @@ namespace xml2ui {
return ui.rootComponentModule.component;
});
+
return template;
}
}
@@ -633,14 +634,14 @@ namespace xml2ui {
public parse(args: xml.ParserEvent): XmlStateConsumer {
// Get the current parent.
- var parent = this.parents[this.parents.length - 1];
- var complexProperty = this.complexProperties[this.complexProperties.length - 1];
+ const parent = this.parents[this.parents.length - 1];
+ const complexProperty = this.complexProperties[this.complexProperties.length - 1];
// Create component instance from every element declaration.
if (args.eventType === xml.ParserEventType.StartElement) {
if (ComponentParser.isComplexProperty(args.elementName)) {
- var name = ComponentParser.getComplexPropertyName(args.elementName);
+ const name = ComponentParser.getComplexPropertyName(args.elementName);
const complexProperty: ComponentParser.ComplexProperty = {
parent: parent,
@@ -677,7 +678,7 @@ namespace xml2ui {
} else {
- var componentModule = this.buildComponent(args);
+ const componentModule = this.buildComponent(args);
if (componentModule) {
this.sourceTracker(componentModule.component, args.position);
@@ -734,10 +735,10 @@ namespace xml2ui {
}
public static getComplexPropertyName(fullName: string): string {
- var name: string;
+ let name: string;
if (isString(fullName)) {
- var names = fullName.split(".");
+ const names = fullName.split(".");
name = names[names.length - 1];
}
@@ -754,7 +755,7 @@ namespace xml2ui {
private static addToComplexProperty(parent: ComponentModule, complexProperty: ComponentParser.ComplexProperty, elementModule: ComponentModule) {
// If property name is known collection we populate array with elements.
- var parentComponent = parent.component;
+ const parentComponent = parent.component;
if (ComponentParser.isKnownCollection(complexProperty.name, parent.exports)) {
complexProperty.items.push(elementModule.component);
} else if (parentComponent._addChildFromBuilder) {
diff --git a/tns-core-modules/ui/builder/component-builder/component-builder.ts b/tns-core-modules/ui/builder/component-builder/component-builder.ts
index fe20bfa18..add4aa427 100644
--- a/tns-core-modules/ui/builder/component-builder/component-builder.ts
+++ b/tns-core-modules/ui/builder/component-builder/component-builder.ts
@@ -28,10 +28,10 @@ const CSSFILE = "cssFile";
const IMPORT = "import";
const createComponentInstance = profile("createComponentInstance", (elementName: string, namespace: string): { instance: View, instanceModule: Object } => {
- var instance: View;
- var instanceModule: Object;
+ let instance: View;
+ let instanceModule: Object;
// Get module id.
- var moduleId = MODULES[elementName] || UI_PATH +
+ let moduleId = MODULES[elementName] || UI_PATH +
(elementName.toLowerCase().indexOf("layout") !== -1 ? "layouts/" : "") +
elementName.split(/(?=[A-Z])/).join("-").toLowerCase();
@@ -141,10 +141,10 @@ const applyComponentAttributes = profile("applyComponentAttributes", (instance:
if (instance && instanceModule) {
for (let attr in attributes) {
- var attrValue = attributes[attr];
+ const attrValue = attributes[attr];
if (attr.indexOf(":") !== -1) {
- var platformName = attr.split(":")[0].trim();
+ const platformName = attr.split(":")[0].trim();
if (platformName.toLowerCase() === platform.device.os.toLowerCase()) {
attr = attr.split(":")[1].trim();
@@ -186,7 +186,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
applyComponentAttributes(instance, instanceModule, moduleExports, attributes);
- var componentModule;
+ let componentModule;
if (instance && instanceModule) {
componentModule = { component: instance, exports: instanceModule };
}
@@ -196,7 +196,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
export function setPropertyValue(instance: View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: any) {
// Note: instanceModule can be null if we are loading custom compnenet with no code-behind.
if (isBinding(propertyValue) && instance.bind) {
- var bindOptions = getBindingOptions(propertyName, getBindingExpressionFromAttribute(propertyValue));
+ const bindOptions = getBindingOptions(propertyName, getBindingExpressionFromAttribute(propertyValue));
instance.bind({
sourceProperty: bindOptions[bindingConstants.sourceProperty],
targetProperty: bindOptions[bindingConstants.targetProperty],
@@ -206,7 +206,7 @@ export function setPropertyValue(instance: View, instanceModule: Object, exports
}
else if (isEventOrGesture(propertyName, instance)) {
// Get the event handler from page module exports.
- var handler = exports && exports[propertyValue];
+ const handler = exports && exports[propertyValue];
// Check if the handler is function and add it to the instance for specified event name.
if (typeof handler === "function") {
@@ -226,10 +226,10 @@ function getBindingExpressionFromAttribute(value: string): string {
}
function isBinding(value: any): boolean {
- var isBinding;
+ let isBinding;
if (typeof value === "string") {
- var str = value.trim();
+ const str = value.trim();
isBinding = str.indexOf("{{") === 0 && str.lastIndexOf("}}") === str.length - 2;
}
diff --git a/tns-core-modules/ui/core/control-state-change/control-state-change.ios.ts b/tns-core-modules/ui/core/control-state-change/control-state-change.ios.ts
index 87546d616..e903adebf 100644
--- a/tns-core-modules/ui/core/control-state-change/control-state-change.ios.ts
+++ b/tns-core-modules/ui/core/control-state-change/control-state-change.ios.ts
@@ -59,7 +59,7 @@ export class ControlStateChangeListener implements ControlStateChangeListenerDef
}
private _updateState() {
- var state = "normal";
+ let state = "normal";
if (this._control.highlighted) {
state = "highlighted";
}
diff --git a/tns-core-modules/ui/core/dependency-observable/dependency-observable.d.ts b/tns-core-modules/ui/core/dependency-observable/dependency-observable.d.ts
index e611b834f..d31aaae77 100644
--- a/tns-core-modules/ui/core/dependency-observable/dependency-observable.d.ts
+++ b/tns-core-modules/ui/core/dependency-observable/dependency-observable.d.ts
@@ -251,19 +251,19 @@ export module PropertyMetadataSettings {
/**
* No options are specified. This is the default value.
*/
- export var None: number;
+ export const None: number;
/**
* A change in the Property associated with the metadata will invalidate the layout.
*/
- export var AffectsLayout;
+ export const AffectsLayout;
/**
* The Property associated with the metadata is inheritable and its value should be propagated down in the visual tree.
*/
- export var Inheritable: number;
+ export const Inheritable: number;
/**
* A change in the Property associated with the metadata will cause all CSS styles to be re-evaluated for for owning element.
*/
- export var AffectsStyle: number;
+ export const AffectsStyle: number;
}
/**
@@ -273,21 +273,21 @@ export module ValueSource {
/**
* Default value, coming from the PropertyMetadata.defaultValue.
*/
- export var Default: number;
+ export const Default: number;
/**
* Inherited value, coming from the logical parent of the current DependencyObservable instance.
*/
- export var Inherited: number;
+ export const Inherited: number;
/**
* Css value, coming a css selector and rule that matches the current DependencyObservable instance.
*/
- export var Css: number;
+ export const Css: number;
/**
* Local value, set directly to the current DependencyObservable instance.
*/
- export var Local: number;
+ export const Local: number;
/**
* VisualState value, coming from a visual-state css selector. E.g. { button:pressed }.
*/
- export var VisualState: number;
+ export const VisualState: number;
}
diff --git a/tns-core-modules/ui/core/dependency-observable/dependency-observable.ts b/tns-core-modules/ui/core/dependency-observable/dependency-observable.ts
index 6848faf35..9cbd2c15a 100644
--- a/tns-core-modules/ui/core/dependency-observable/dependency-observable.ts
+++ b/tns-core-modules/ui/core/dependency-observable/dependency-observable.ts
@@ -9,8 +9,7 @@ import { getClassInfo, isString } from "../../../utils/types";
import { unsetValue } from "../properties";
// use private variables in the scope of the module rather than static members of the class since a member is still accessible through JavaScript and may be changed.
-var propertyFromKey = {};
-// var propertyIdCounter = 0;
+const propertyFromKey = {};
function generatePropertyKey(name: string, ownerType: string, validate?: boolean) {
if (validate) {
@@ -30,9 +29,9 @@ function validateRegisterParameters(name: string, ownerType: string) {
}
function getPropertyByNameAndType(name: string, owner: any): Property {
- var result;
- var key;
- var classInfo = getClassInfo(owner);
+ let result;
+ let key;
+ let classInfo = getClassInfo(owner);
while (classInfo) {
key = generatePropertyKey(name, classInfo.name);
result = propertyFromKey[key];
@@ -45,18 +44,18 @@ function getPropertyByNameAndType(name: string, owner: any): Property {
}
export module PropertyMetadataSettings {
- export var None = 0;
- export var AffectsLayout = 1;
- export var AffectsStyle = 1 << 1;
- export var Inheritable = 1 << 2;
+ export const None = 0;
+ export const AffectsLayout = 1;
+ export const AffectsStyle = 1 << 1;
+ export const Inheritable = 1 << 2;
}
export module ValueSource {
- export var Default = 0;
- export var Inherited = 1;
- export var Css = 2;
- export var Local = 3;
- export var VisualState = 4;
+ export const Default = 0;
+ export const Inherited = 1;
+ export const Css = 2;
+ export const Local = 3;
+ export const VisualState = 4;
}
export class PropertyMetadata implements PropertyMetadataDefinition {
@@ -127,7 +126,7 @@ export class DependencyObservable extends Observable implements DependencyObserv
throw new Error("* @deprecated use 'ui/core/view-base or ui/core/view' as base class.");
}
public set(name: string, value: any) {
- var property = getPropertyByNameAndType(name, this);
+ const property = getPropertyByNameAndType(name, this);
if (property) {
this._setValueInternal(property, value, ValueSource.Local);
} else {
@@ -136,7 +135,7 @@ export class DependencyObservable extends Observable implements DependencyObserv
}
public get(name: string): any {
- var property = getPropertyByNameAndType(name, this);
+ const property = getPropertyByNameAndType(name, this);
if (property) {
return this._getValue(property);
} else {
@@ -149,7 +148,7 @@ export class DependencyObservable extends Observable implements DependencyObserv
}
public _getValueSource(property: Property): number {
- var entry: PropertyEntry = this._propertyEntries[property.id];
+ const entry: PropertyEntry = this._propertyEntries[property.id];
if (entry) {
return entry.valueSource;
}
@@ -158,7 +157,7 @@ export class DependencyObservable extends Observable implements DependencyObserv
}
public _getValue(property: Property): any {
- var entry: PropertyEntry = this._propertyEntries[property.id];
+ const entry: PropertyEntry = this._propertyEntries[property.id];
if (entry) {
return entry.effectiveValue;
}
diff --git a/tns-core-modules/ui/core/properties/properties.ts b/tns-core-modules/ui/core/properties/properties.ts
index 5f54f7b97..bf6c7ba0d 100644
--- a/tns-core-modules/ui/core/properties/properties.ts
+++ b/tns-core-modules/ui/core/properties/properties.ts
@@ -1100,7 +1100,7 @@ export const initNativeView = profile("\"properties\".initNativeView", function
export function applyPendingNativeSetters(view: ViewBase): void {
// TODO: Check what happens if a view was suspended and its value was reset, or set back to default!
const suspendedUpdates = view._suspendedUpdates;
- for (var propertyName in suspendedUpdates) {
+ for (let propertyName in suspendedUpdates) {
const property = suspendedUpdates[propertyName];
const setNative = property.setNative;
if (view[setNative]) {
@@ -1305,7 +1305,7 @@ export function getSetProperties(view: ViewBase): [string, any][] {
export function getComputedCssValues(view: ViewBase): [string, any][] {
const result = [];
const style = view.style;
- for (var prop of cssPropertyNames) {
+ for (let prop of cssPropertyNames) {
result.push([prop, style[prop]]);
}
diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts
index 1f14c34d6..9dfab6815 100644
--- a/tns-core-modules/ui/core/view/view-common.ts
+++ b/tns-core-modules/ui/core/view/view-common.ts
@@ -259,7 +259,14 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
if (args.length === 2) {
options = args[1];
} else {
- // TODO: Add deprecation warning
+ if (args[0] instanceof ViewCommon) {
+ console.log("showModal(view: ViewBase, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) " +
+ "is deprecated. Use showModal(view: ViewBase, modalOptions: ShowModalOptions) instead.");
+ } else {
+ console.log("showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) " +
+ "is deprecated. Use showModal(moduleName: string, modalOptions: ShowModalOptions) instead.");
+ }
+
options = {
context: args[1],
closeCallback: args[2],
diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts
index 19e01ed0f..c733f9066 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/core/weak-event-listener/weak-event-listener.ts b/tns-core-modules/ui/core/weak-event-listener/weak-event-listener.ts
index 864291f8a..a58b3b018 100644
--- a/tns-core-modules/ui/core/weak-event-listener/weak-event-listener.ts
+++ b/tns-core-modules/ui/core/weak-event-listener/weak-event-listener.ts
@@ -14,27 +14,28 @@ class TargetHandlerPair {
}
function getHandlerForEventName(eventName: string): (eventData: EventData) => void {
- var handler = handlersForEventName.get(eventName);
+ let handler = handlersForEventName.get(eventName);
if (!handler) {
handler = function (eventData: EventData) {
- var source = eventData.object;
- var sourceEventMap = sourcesMap.get(source);
+ const source = eventData.object;
+ const sourceEventMap = sourcesMap.get(source);
if (!sourceEventMap) {
// There is no event map for this source - it is safe to detach the listener;
source.removeEventListener(eventName, handlersForEventName.get(eventName));
return;
}
- var targetHandlerPairList = sourceEventMap.get(eventName);
+ const targetHandlerPairList = sourceEventMap.get(eventName);
if (!targetHandlerPairList) {
return;
}
- var deadPairsIndexes = [];
- for (var i = 0; i < targetHandlerPairList.length; i++) {
- var pair = targetHandlerPairList[i];
-
- var target = pair.tagetRef.get();
+ const deadPairsIndexes = [];
+ let pair;
+ let target;
+ for (let i = 0; i < targetHandlerPairList.length; i++) {
+ pair = targetHandlerPairList[i];
+ target = pair.tagetRef.get();
if (target) {
pair.handler.call(target, eventData);
}
@@ -49,7 +50,7 @@ function getHandlerForEventName(eventName: string): (eventData: EventData) => vo
sourceEventMap.delete(eventName);
}
else {
- for (var j = deadPairsIndexes.length - 1; j >= 0; j--) {
+ for (let j = deadPairsIndexes.length - 1; j >= 0; j--) {
targetHandlerPairList.splice(deadPairsIndexes[j], 1);
}
}
@@ -81,16 +82,16 @@ function validateArgs(source: Observable, eventName: string, handler: (eventData
export function addWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any) {
validateArgs(source, eventName, handler, target);
- var shouldAttach: boolean = false;
+ let shouldAttach: boolean = false;
- var sourceEventMap = sourcesMap.get(source);
+ let sourceEventMap = sourcesMap.get(source);
if (!sourceEventMap) {
sourceEventMap = new Map>();
sourcesMap.set(source, sourceEventMap);
shouldAttach = true;
}
- var pairList = sourceEventMap.get(eventName);
+ let pairList = sourceEventMap.get(eventName);
if (!pairList) {
pairList = new Array();
sourceEventMap.set(eventName, pairList);
@@ -107,28 +108,30 @@ export function addWeakEventListener(source: Observable, eventName: string, hand
export function removeWeakEventListener(source: Observable, eventName: string, handler: (eventData: EventData) => void, target: any) {
validateArgs(source, eventName, handler, target);
- var handlerForEventWithName = handlersForEventName.get(eventName);
+ const handlerForEventWithName = handlersForEventName.get(eventName);
if (!handlerForEventWithName) {
// We have never created handler for event with this name;
return;
}
- var sourceEventMap = sourcesMap.get(source);
+ const sourceEventMap = sourcesMap.get(source);
if (!sourceEventMap) {
return;
}
- var targetHandlerPairList = sourceEventMap.get(eventName);
+ const targetHandlerPairList = sourceEventMap.get(eventName);
if (!targetHandlerPairList) {
return;
}
// Remove all pairs that match given target and handler or have a dead target
- var targetHandlerPairsToRemove = [];
- for (var i = 0; i < targetHandlerPairList.length; i++) {
- var pair = targetHandlerPairList[i];
+ const targetHandlerPairsToRemove = [];
+ let pair;
+ let registeredTarget;
+ for (let i = 0; i < targetHandlerPairList.length; i++) {
+ pair = targetHandlerPairList[i];
- var registeredTarget = pair.tagetRef.get();
+ registeredTarget = pair.tagetRef.get();
if (!registeredTarget || (registeredTarget === target && handler === pair.handler)) {
targetHandlerPairsToRemove.push(i);
}
@@ -140,7 +143,7 @@ export function removeWeakEventListener(source: Observable, eventName: string, h
sourceEventMap.delete(eventName);
}
else {
- for (var j = targetHandlerPairsToRemove.length - 1; j >= 0; j--) {
+ for (let j = targetHandlerPairsToRemove.length - 1; j >= 0; j--) {
targetHandlerPairList.splice(targetHandlerPairsToRemove[j], 1);
}
}
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/dialogs/dialogs.d.ts b/tns-core-modules/ui/dialogs/dialogs.d.ts
index 2b24c73cb..d200b4a43 100644
--- a/tns-core-modules/ui/dialogs/dialogs.d.ts
+++ b/tns-core-modules/ui/dialogs/dialogs.d.ts
@@ -10,32 +10,32 @@ export module inputType {
/**
* Plain text input type.
*/
- export var text: string;
+ export const text: string;
/**
* Password input type.
*/
- export var password: string;
+ export const password: string;
/**
* Email input type.
*/
- export var email: string;
+ export const email: string;
/**
* Number input type.
*/
- export var number: string;
+ export const number: string;
/**
* Decimal input type.
*/
- export var decimal: string;
+ export const decimal: string;
/**
* Phone input type.
*/
- export var phone: string;
+ export const phone: string;
}
/**
@@ -45,22 +45,22 @@ export module capitalizationType {
/**
* No automatic capitalization.
*/
- export var none: string;
+ export const none: string;
/**
* Capitalizes every character.
*/
- export var all: string;
+ export const all: string;
/**
* Capitalize the first word of each sentence.
*/
- export var sentences: string;
+ export const sentences: string;
/**
* Capitalize the first letter of every word.
*/
- export var words: string;
+ export const words: string;
}
/**
diff --git a/tns-core-modules/ui/enums/enums.d.ts b/tns-core-modules/ui/enums/enums.d.ts
index d54ac27d9..fe7b6eee4 100644
--- a/tns-core-modules/ui/enums/enums.d.ts
+++ b/tns-core-modules/ui/enums/enums.d.ts
@@ -49,30 +49,30 @@ export module KeyboardType {
* Android: [TYPE_CLASS_DATETIME](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_DATETIME) | [TYPE_DATETIME_VARIATION_NORMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_DATETIME_VARIATION_NORMAL)
* iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
- export var datetime: BaseKeyboardType
+ export const datetime: BaseKeyboardType
/**
* Android: [TYPE_CLASS_PHONE](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_PHONE)
* iOS: [UIKeyboardTypePhonePad](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
- export var phone: BaseKeyboardType
+ export const phone: BaseKeyboardType
/**
* Android: [TYPE_CLASS_NUMBER](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_NUMBER) | [TYPE_NUMBER_VARIATION_NORMAL](http://developer.android.com/intl/es/reference/android/text/InputType.html#TYPE_NUMBER_VARIATION_NORMAL) | [TYPE_NUMBER_FLAG_SIGNED](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_SIGNED) | [TYPE_NUMBER_FLAG_DECIMAL](http://developer.android.com/reference/android/text/InputType.html#TYPE_NUMBER_FLAG_DECIMAL)
* iOS: [UIKeyboardTypeNumbersAndPunctuation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
- export var number: BaseKeyboardType
+ export const number: BaseKeyboardType
/**
* Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_URI](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_URI)
* iOS: [UIKeyboardTypeURL](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
- export var url: BaseKeyboardType
+ export const url: BaseKeyboardType
/**
* Android: [TYPE_CLASS_TEXT](http://developer.android.com/reference/android/text/InputType.html#TYPE_CLASS_TEXT) | [TYPE_TEXT_VARIATION_EMAIL_ADDRESS](http://developer.android.com/reference/android/text/InputType.html#TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
* iOS: [UIKeyboardTypeEmailAddress](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIKeyboardType)
*/
- export var email: BaseKeyboardType
+ export const email: BaseKeyboardType
}
/**
@@ -83,31 +83,31 @@ export module ReturnKeyType {
* Android: [IME_ACTION_DONE](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE)
* iOS: [UIReturnKeyDone](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType)
*/
- export var done: BaseReturnKeyType;
+ export const done: BaseReturnKeyType;
/**
* Android: [IME_ACTION_NEXT](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_NEXT)
* iOS: [UIReturnKeyNext](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType)
*/
- export var next: BaseReturnKeyType;
+ export const next: BaseReturnKeyType;
/**
* Android: [IME_ACTION_GO](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_GO)
* iOS: [UIReturnKeyGo](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType)
*/
- export var go: BaseReturnKeyType;
+ export const go: BaseReturnKeyType;
/**
* Android: [IME_ACTION_SEARCH](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_SEARCH)
* iOS: [UIReturnKeySearch](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType)
*/
- export var search: BaseReturnKeyType;
+ export const search: BaseReturnKeyType;
/**
* Android: [IME_ACTION_SEND](http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_SEND)
* iOS: [UIReturnKeySend](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInputTraits_Protocol/index.html#//apple_ref/c/tdef/UIReturnKeyType)
*/
- export var send: string;
+ export const send: string;
}
/**
@@ -117,17 +117,17 @@ export module TextAlignment {
/**
* Represents left text-align.
*/
- export var left: BaseTextAlignment;
+ export const left: BaseTextAlignment;
/**
* Represents center text-align.
*/
- export var center: BaseTextAlignment;
+ export const center: BaseTextAlignment;
/**
* Represents right text-align.
*/
- export var right: BaseTextAlignment;
+ export const right: BaseTextAlignment;
}
/**
@@ -137,11 +137,11 @@ export module Orientation {
/**
* Layout should be horizontally oriented.
*/
- export var horizontal: BaseOrientation;
+ export const horizontal: BaseOrientation;
/**
* Layout should be vertically oriented.
*/
- export var vertical: BaseOrientation;
+ export const vertical: BaseOrientation;
}
/**
@@ -151,15 +151,15 @@ export module DeviceOrientation {
/**
* Portrait orientation.
*/
- export var portrait: string;
+ export const portrait: string;
/**
* Landscape orientation.
*/
- export var landscape: string;
+ export const landscape: string;
/**
* Orientation cannot be determined.
*/
- export var unknown: string;
+ export const unknown: string;
}
/**
@@ -169,22 +169,22 @@ export module HorizontalAlignment {
/**
* An element should be left aligned.
*/
- export var left: BaseHorizontalAlignment;
+ export const left: BaseHorizontalAlignment;
/**
* An element should be center aligned.
*/
- export var center: BaseHorizontalAlignment;
+ export const center: BaseHorizontalAlignment;
/**
* An element should be right aligned.
*/
- export var right: BaseHorizontalAlignment;
+ export const right: BaseHorizontalAlignment;
/**
* An element should be stretched to fill all the available size.
*/
- export var stretch: BaseHorizontalAlignment;
+ export const stretch: BaseHorizontalAlignment;
}
/**
@@ -194,27 +194,27 @@ export module VerticalAlignment {
/**
* An element should be top aligned.
*/
- export var top: BaseVerticalAlignment;
+ export const top: BaseVerticalAlignment;
/**
* An element should be center aligned.
*/
- export var center: BaseVerticalAlignment;
+ export const center: BaseVerticalAlignment;
/**
* Same as center. An element should be aligned in the middle.
*/
- export var middle: BaseVerticalAlignment;
+ export const middle: BaseVerticalAlignment;
/**
* An element should be bottom aligned.
*/
- export var bottom: BaseVerticalAlignment;
+ export const bottom: BaseVerticalAlignment;
/**
* An element should be stretched to fill all the available size.
*/
- export var stretch: BaseVerticalAlignment;
+ export const stretch: BaseVerticalAlignment;
}
/**
@@ -224,25 +224,25 @@ export module Stretch {
/**
* The image preserves its original size.
*/
- export var none: BaseStretch;
+ export const none: BaseStretch;
/**
* The image is resized to fill in the destination dimensions while it preserves its native aspect ratio.
* If the aspect ratio of the destination rectangle differs from the image, the image is clipped to fill
* in the destination.
*/
- export var aspectFill: BaseStretch;
+ export const aspectFill: BaseStretch;
/**
* The image is resized to fit the destination dimensions while it preserves
* its native aspect ratio.
*/
- export var aspectFit: BaseStretch;
+ export const aspectFit: BaseStretch;
/**
* The image is resized to fill the destination dimensions. The aspect ratio is not preserved.
*/
- export var fill: BaseStretch;
+ export const fill: BaseStretch;
}
/**
@@ -252,17 +252,17 @@ export module Visibility {
/**
* The view is visible.
*/
- export var visible: BaseVisibility;
+ export const visible: BaseVisibility;
/**
* The view is not visible and won't take place in the layout.
*/
- export var collapse: BaseVisibility;
+ export const collapse: BaseVisibility;
/**
* The view is not visible but will take place in the layout.
*/
- export var hidden: BaseVisibility;
+ export const hidden: BaseVisibility;
}
/**
@@ -272,17 +272,17 @@ export module FontAttributes {
/**
* Denotes that text should be drawn in a normal style.
*/
- export var Normal: number;
+ export const Normal: number;
/**
* Denotes that text should be drawn in a bold weight.
*/
- export var Bold: number;
+ export const Bold: number;
/**
* Denotes that text should be drawn in a italic style.
*/
- export var Italic: number;
+ export const Italic: number;
}
/**
@@ -292,12 +292,12 @@ export module DeviceType {
/**
* Indicates a smart-phone device.
*/
- export var Phone: string;
+ export const Phone: string;
/**
* Indicates a tablet device.
*/
- export var Tablet: string;
+ export const Tablet: string;
}
/**
@@ -307,12 +307,12 @@ export module UpdateTextTrigger {
/**
* The text property will be udpaded when the widget loses focus.
*/
- export var focusLost: BaseUpdateTrigger;
+ export const focusLost: BaseUpdateTrigger;
/**
* The text property will be udpaded on every single character typed by the user.
*/
- export var textChanged: BaseUpdateTrigger;
+ export const textChanged: BaseUpdateTrigger;
}
/**
@@ -322,12 +322,12 @@ export module Accuracy {
/**
* The default accuracy. About 300 meters.
*/
- export var any: number;
+ export const any: number;
/**
* High accuracy. About 3 meters.
*/
- export var high: number;
+ export const high: number;
}
/**
@@ -337,22 +337,22 @@ export module Dock {
/**
* A child element that is positioned on the left side of the DockLayout.
*/
- export var left: BaseDock;
+ export const left: BaseDock;
/**
* A child element that is positioned on the top side of the DockLayout.
*/
- export var top: BaseDock;
+ export const top: BaseDock;
/**
* A child element that is positioned on the right side of the DockLayout.
*/
- export var right: BaseDock;
+ export const right: BaseDock;
/**
* A child element that is positioned on the bottom side of the DockLayout.
*/
- export var bottom: BaseDock;
+ export const bottom: BaseDock;
}
/**
@@ -362,22 +362,22 @@ export module AutocapitalizationType {
/**
* Do not capitalize any text automatically.
*/
- export var none: BaseAutocapitalizationType;
+ export const none: BaseAutocapitalizationType;
/**
* Capitalize the first letter of each word automatically.
*/
- export var words: BaseAutocapitalizationType;
+ export const words: BaseAutocapitalizationType;
/**
* Capitalize the first letter of each sentence automatically.
*/
- export var sentences: BaseAutocapitalizationType;
+ export const sentences: BaseAutocapitalizationType;
/**
* Capitalize all characters automatically.
*/
- export var allCharacters: BaseAutocapitalizationType;
+ export const allCharacters: BaseAutocapitalizationType;
}
/**
@@ -387,17 +387,17 @@ export module ImageFormat {
/**
* The W3C Portable Network Graphics (PNG) image format.
*/
- export var png: string;
+ export const png: string;
/**
* The Joint Photographic Experts Group (JPEG) image format.
*/
- export var jpeg: string;
+ export const jpeg: string;
/**
* The Joint Photographic Experts Group (JPEG) image format.
*/
- export var jpg: string;
+ export const jpg: string;
}
/**
@@ -407,26 +407,26 @@ export module NavigationBarVisibility {
/**
* NavigationBar will be visible if there if frame backstack canGoBack is true or if the page Action Bar is not empty.
*/
- export var auto: string;
+ export const auto: string;
/**
* NavigationBar will be hidden.
*/
- export var never: string;
+ export const never: string;
/**
* NavigationBar will be visible.
*/
- export var always: string;
+ export const always: string;
}
/**
* Specifies the visibility of the application bar icon
*/
export module AndroidActionBarIconVisibility {
- export var auto: string;
- export var never: string;
- export var always: string;
+ export const auto: string;
+ export const never: string;
+ export const always: string;
}
/**
@@ -436,17 +436,17 @@ export module AndroidActionItemPosition {
/**
* Always show this item as a button in an Action Bar.
*/
- export var actionBar: string;
+ export const actionBar: string;
/**
* Show this item as a button in an Action Bar if the system decides there is room for it.
*/
- export var actionBarIfRoom: string;
+ export const actionBarIfRoom: string;
/**
* Never show this item as a button in an Action Bar.
*/
- export var popup: string;
+ export const popup: string;
}
/**
@@ -456,12 +456,12 @@ export module FontStyle {
/**
* Normal font style.
*/
- export var normal: BaseFontStyle;
+ export const normal: BaseFontStyle;
/**
* Italic font style.
*/
- export var italic: BaseFontStyle;
+ export const italic: BaseFontStyle;
}
/**
@@ -471,17 +471,17 @@ export module TextDecoration {
/**
* No decoration.
*/
- export var none: BaseTextDecoration;
+ export const none: BaseTextDecoration;
/**
* Text decoration underline.
*/
- export var underline: BaseTextDecoration;
+ export const underline: BaseTextDecoration;
/**
* Text decoration line-through.
*/
- export var lineThrough: BaseTextDecoration;
+ export const lineThrough: BaseTextDecoration;
}
/**
@@ -491,22 +491,22 @@ export module TextTransform {
/**
* No transform.
*/
- export var none: BaseTextTransform;
+ export const none: BaseTextTransform;
/**
* Text transform capitalize.
*/
- export var capitalize: BaseTextTransform;
+ export const capitalize: BaseTextTransform;
/**
* Text transform uppercase.
*/
- export var uppercase: BaseTextTransform;
+ export const uppercase: BaseTextTransform;
/**
* Text transform lowercase.
*/
- export var lowercase: BaseTextTransform;
+ export const lowercase: BaseTextTransform;
}
/**
@@ -516,12 +516,12 @@ export module WhiteSpace {
/**
* Normal wrap.
*/
- export var normal: BaseWhiteSpace;
+ export const normal: BaseWhiteSpace;
/**
* No wrap.
*/
- export var nowrap: BaseWhiteSpace;
+ export const nowrap: BaseWhiteSpace;
}
/**
@@ -531,57 +531,57 @@ export module FontWeight {
/**
* Thin font weight. CSS font-weight 100.
*/
- export var thin: BaseFontWeight;
+ export const thin: BaseFontWeight;
/**
* Extra-light / Ultra-light font weight. CSS font-weight 200.
*/
- export var extraLight: BaseFontWeight;
+ export const extraLight: BaseFontWeight;
/**
* Light font weight. CSS font-weight 300.
*/
- export var light: BaseFontWeight;
+ export const light: BaseFontWeight;
/**
* Normal font weight. CSS font-weight 400.
*/
- export var normal: BaseFontWeight;
+ export const normal: BaseFontWeight;
/**
* Medium font weight. CSS font-weight 500.
*/
- export var medium: BaseFontWeight;
+ export const medium: BaseFontWeight;
/**
* Semi-bold / Demi-bold font weight. CSS font-weight 600.
*/
- export var semiBold: BaseFontWeight;
+ export const semiBold: BaseFontWeight;
/**
* Bold font weight. CSS font-weight 700.
*/
- export var bold: BaseFontWeight;
+ export const bold: BaseFontWeight;
/**
* Extra-bold / Ultra-bold font weight. CSS font-weight 800.
*/
- export var extraBold: BaseFontWeight;
+ export const extraBold: BaseFontWeight;
/**
* Black font weight. CSS font-weight 900.
*/
- export var black: BaseFontWeight;
+ export const black: BaseFontWeight;
}
/**
* Specifies background repeat.
*/
export module BackgroundRepeat {
- export var repeat: BaseBackgroundRepeat;
- export var repeatX: BaseBackgroundRepeat;
- export var repeatY: BaseBackgroundRepeat;
- export var noRepeat: BaseBackgroundRepeat;
+ export const repeat: BaseBackgroundRepeat;
+ export const repeatX: BaseBackgroundRepeat;
+ export const repeatY: BaseBackgroundRepeat;
+ export const noRepeat: BaseBackgroundRepeat;
}
/**
@@ -591,12 +591,12 @@ export module IOSActionItemPosition {
/**
* Show this item at the left of the navigation bar.
*/
- export var left: string;
+ export const left: string;
/**
* Show this item at the right of the action bar.
*/
- export var right: string;
+ export const right: string;
}
/**
@@ -607,32 +607,32 @@ export module AnimationCurve {
/**
* Default value. Specifies a transition effect with a slow start, then fast, then end slowly (equivalent to cubic-bezier(0.25,0.1,0.25,1))
*/
- export var ease: string;
+ export const ease: string;
/**
* An ease-in curve causes the animation to begin slowly, and then speed up as it progresses.
*/
- export var easeIn: string;
+ export const easeIn: string;
/**
* An ease-out curve causes the animation to begin quickly, and then slow down as it completes.
*/
- export var easeOut: string;
+ export const easeOut: string;
/**
* An ease-in ease-out curve causes the animation to begin slowly, accelerate through the middle of its duration, and then slow again before completing.
*/
- export var easeInOut: string;
+ export const easeInOut: string;
/**
* A linear animation curve causes an animation to occur evenly over its duration.
*/
- export var linear: string;
+ export const linear: string;
/**
* A spring animation curve causes an animation to produce a spring (bounce) effect.
*/
- export var spring: string;
+ export const spring: string;
/**
* A custom cubic bezier function defined by its two control points. Possible values are numeric values from 0 to 1
@@ -647,10 +647,10 @@ export module StatusBarStyle {
/**
* The light style of the status bar - light background with dark letters.
*/
- export var light: string;
+ export const light: string;
/**
* The dark style of the status bar - dark background with light letters.
*/
- export var dark: string;
+ export const dark: string;
}
diff --git a/tns-core-modules/ui/enums/enums.ts b/tns-core-modules/ui/enums/enums.ts
index 7b7779f4e..624000da1 100644
--- a/tns-core-modules/ui/enums/enums.ts
+++ b/tns-core-modules/ui/enums/enums.ts
@@ -1,185 +1,188 @@
+// imported for definition purposes only
+import * as animationModule from "../../ui/animation";
+
export module KeyboardType {
- export var datetime = "datetime";
- export var phone = "phone";
- export var number = "number";
- export var url = "url";
- export var email = "email";
+ export const datetime = "datetime";
+ export const phone = "phone";
+ export const number = "number";
+ export const url = "url";
+ export const email = "email";
}
export module ReturnKeyType {
- export var done = "done";
- export var next = "next";
- export var go = "go";
- export var search = "search";
- export var send = "send";
+ export const done = "done";
+ export const next = "next";
+ export const go = "go";
+ export const search = "search";
+ export const send = "send";
}
export module TextAlignment {
- export var left = "left";
- export var center = "center";
- export var right = "right";
+ export const left = "left";
+ export const center = "center";
+ export const right = "right";
}
export module TextDecoration {
- export var none = "none";
- export var underline = "underline";
- export var lineThrough = "line-through";
+ export const none = "none";
+ export const underline = "underline";
+ export const lineThrough = "line-through";
}
export module TextTransform {
- export var none = "none";
- export var capitalize = "capitalize";
- export var uppercase = "uppercase";
- export var lowercase = "lowercase";
+ export const none = "none";
+ export const capitalize = "capitalize";
+ export const uppercase = "uppercase";
+ export const lowercase = "lowercase";
}
export module WhiteSpace {
- export var normal = "normal";
- export var nowrap = "nowrap";
+ export const normal = "normal";
+ export const nowrap = "nowrap";
}
export module Orientation {
- export var horizontal = "horizontal";
- export var vertical = "vertical";
+ export const horizontal = "horizontal";
+ export const vertical = "vertical";
}
export module DeviceOrientation {
- export var portrait = "portrait";
- export var landscape = "landscape";
- export var unknown = "unknown";
+ export const portrait = "portrait";
+ export const landscape = "landscape";
+ export const unknown = "unknown";
}
export module HorizontalAlignment {
- export var left = "left";
- export var center = "center";
- export var right = "right";
- export var stretch = "stretch";
+ export const left = "left";
+ export const center = "center";
+ export const right = "right";
+ export const stretch = "stretch";
}
export module VerticalAlignment {
- export var top = "top";
- export var middle = "middle";
- export var bottom = "bottom";
- export var stretch = "stretch";
+ export const top = "top";
+ export const middle = "middle";
+ export const bottom = "bottom";
+ export const stretch = "stretch";
}
export module Stretch {
- export var none: string = "none";
- export var aspectFill: string = "aspectFill";
- export var aspectFit: string = "aspectFit";
- export var fill: string = "fill";
+ export const none: string = "none";
+ export const aspectFill: string = "aspectFill";
+ export const aspectFit: string = "aspectFit";
+ export const fill: string = "fill";
}
export module Visibility {
- export var visible: string = "visible";
- export var collapse: string = "collapse";
- export var collapsed: string = "collapsed";
+ export const visible: string = "visible";
+ export const collapse: string = "collapse";
+ export const collapsed: string = "collapsed";
}
export module FontAttributes {
- export var Normal = 0;
- export var Bold = 1;
- export var Italic = 1 << 1;
+ export const Normal = 0;
+ export const Bold = 1;
+ export const Italic = 1 << 1;
}
export module DeviceType {
- export var Phone: string = "Phone";
- export var Tablet: string = "Tablet";
+ export const Phone: string = "Phone";
+ export const Tablet: string = "Tablet";
}
export module UpdateTextTrigger {
- export var focusLost: string = "focusLost";
- export var textChanged: string = "textChanged";
+ export const focusLost: string = "focusLost";
+ export const textChanged: string = "textChanged";
}
export module Accuracy {
- export var any: number = 300;
- export var high: number = 3;
+ export const any: number = 300;
+ export const high: number = 3;
}
export module Dock {
- export var left: string = "left";
- export var top: string = "top";
- export var right: string = "right";
- export var bottom: string = "bottom";
+ export const left: string = "left";
+ export const top: string = "top";
+ export const right: string = "right";
+ export const bottom: string = "bottom";
}
export module AutocapitalizationType {
- export var none: string = "none";
- export var words: string = "words";
- export var sentences: string = "sentences";
- export var allCharacters: string = "allcharacters";
+ export const none: string = "none";
+ export const words: string = "words";
+ export const sentences: string = "sentences";
+ export const allCharacters: string = "allcharacters";
}
export module NavigationBarVisibility {
- export var auto: string = "auto";
- export var never: string = "never";
- export var always: string = "always";
+ export const auto: string = "auto";
+ export const never: string = "never";
+ export const always: string = "always";
}
export module AndroidActionBarIconVisibility {
- export var auto: string = "auto";
- export var never: string = "never";
- export var always: string = "always";
+ export const auto: string = "auto";
+ export const never: string = "never";
+ export const always: string = "always";
}
export module AndroidActionItemPosition {
- export var actionBar: string = "actionBar";
- export var actionBarIfRoom: string = "actionBarIfRoom";
- export var popup: string = "popup";
+ export const actionBar: string = "actionBar";
+ export const actionBarIfRoom: string = "actionBarIfRoom";
+ export const popup: string = "popup";
}
export module IOSActionItemPosition {
- export var left: string = "left";
- export var right: string = "right";
+ export const left: string = "left";
+ export const right: string = "right";
}
export module ImageFormat {
- export var png: string = "png";
- export var jpeg: string = "jpeg";
- export var jpg: string = "jpg";
+ export const png: string = "png";
+ export const jpeg: string = "jpeg";
+ export const jpg: string = "jpg";
}
export module FontStyle {
- export var normal: string = "normal";
- export var italic: string = "italic";
+ export const normal: string = "normal";
+ export const italic: string = "italic";
}
export module FontWeight {
- export var thin: string = "100";
- export var extraLight: string = "200";
- export var light: string = "300";
- export var normal: string = "normal"; // 400
- export var medium: string = "500";
- export var semiBold: string = "600";
- export var bold: string = "bold"; // 700
- export var extraBold: string = "800";
- export var black: string = "900";
+ export const thin: string = "100";
+ export const extraLight: string = "200";
+ export const light: string = "300";
+ export const normal: string = "normal"; // 400
+ export const medium: string = "500";
+ export const semiBold: string = "600";
+ export const bold: string = "bold"; // 700
+ export const extraBold: string = "800";
+ export const black: string = "900";
}
export module BackgroundRepeat {
- export var repeat: string = "repeat";
- export var repeatX: string = "repeat-x";
- export var repeatY: string = "repeat-y";
- export var noRepeat: string = "no-repeat";
+ export const repeat: string = "repeat";
+ export const repeatX: string = "repeat-x";
+ export const repeatY: string = "repeat-y";
+ export const noRepeat: string = "no-repeat";
}
-var animationModule;
+let animation: typeof animationModule;
export module AnimationCurve {
- export var ease = "ease";
- export var easeIn = "easeIn";
- export var easeOut = "easeOut";
- export var easeInOut = "easeInOut";
- export var linear = "linear";
- export var spring = "spring";
+ export const ease = "ease";
+ export const easeIn = "easeIn";
+ export const easeOut = "easeOut";
+ export const easeInOut = "easeInOut";
+ export const linear = "linear";
+ export const spring = "spring";
export function cubicBezier(x1: number, y1: number, x2: number, y2: number): Object {
- animationModule = animationModule || require("ui/animation");
- return new animationModule.CubicBezierAnimationCurve(x1, y1 , x2, y2);
+ animation = animation || require("ui/animation");
+ return new animation.CubicBezierAnimationCurve(x1, y1 , x2, y2);
}
}
export module StatusBarStyle {
- export var light = "light";
- export var dark = "dark";
-}
\ No newline at end of file
+ export const light = "light";
+ export const dark = "dark";
+}
diff --git a/tns-core-modules/ui/frame/activity.android.ts b/tns-core-modules/ui/frame/activity.android.ts
index 946ca63df..9a4b9ce84 100644
--- a/tns-core-modules/ui/frame/activity.android.ts
+++ b/tns-core-modules/ui/frame/activity.android.ts
@@ -26,12 +26,11 @@ class NativeScriptActivity extends android.support.v7.app.AppCompatActivity {
setActivityCallbacks(this);
}
- this._callbacks.onCreate(this, savedInstanceState, super.onCreate);
+ this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), super.onCreate);
}
public onNewIntent(intent: android.content.Intent): void {
- super.onNewIntent(intent);
- super.setIntent(intent);
+ this._callbacks.onNewIntent(this, intent, super.setIntent, super.onNewIntent);
}
public onSaveInstanceState(outState: android.os.Bundle): void {
diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts
index f3f2decbe..f878f1709 100644
--- a/tns-core-modules/ui/frame/frame.android.ts
+++ b/tns-core-modules/ui/frame/frame.android.ts
@@ -944,11 +944,19 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
}
@profile
- public onCreate(activity: android.support.v7.app.AppCompatActivity, savedInstanceState: android.os.Bundle, superFunc: Function): void {
+ public onCreate(activity: android.support.v7.app.AppCompatActivity, savedInstanceState: android.os.Bundle, intentOrSuperFunc: android.content.Intent | Function, superFunc?: Function): void {
if (traceEnabled()) {
traceWrite(`Activity.onCreate(${savedInstanceState})`, traceCategories.NativeLifecycle);
}
+ const intent: android.content.Intent = superFunc ? intentOrSuperFunc : undefined;
+
+ if (!superFunc) {
+ console.log("AndroidActivityCallbacks.onCreate(activity: any, savedInstanceState: any, superFunc: Function) " +
+ "is deprecated. Use AndroidActivityCallbacks.onCreate(activity: any, savedInstanceState: any, intent: any, superFunc: Function) instead.");
+ superFunc = intentOrSuperFunc;
+ }
+
// If there is savedInstanceState this call will recreate all fragments that were previously in the navigation.
// We take care of associating them with a Page from our backstack in the onAttachFragment callback.
// If there is savedInstanceState and moduleLoaded is false we are restarted but process was killed.
@@ -966,6 +974,15 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
}
}
+ if (intent && intent.getAction()) {
+ application.android.notify({
+ eventName: application.AndroidApplication.activityNewIntentEvent,
+ object: application.android,
+ activity,
+ intent
+ });
+ }
+
this.setActivityContent(activity, savedInstanceState, true);
moduleLoaded = true;
}
@@ -982,6 +999,19 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
outState.putInt(ROOT_VIEW_ID_EXTRA, rootView._domId);
}
+ @profile
+ public onNewIntent(activity: android.support.v7.app.AppCompatActivity, intent: android.content.Intent, superSetIntentFunc: Function, superFunc: Function): void {
+ superFunc.call(activity, intent);
+ superSetIntentFunc.call(activity, intent);
+
+ application.android.notify({
+ eventName: application.AndroidApplication.activityNewIntentEvent,
+ object: application.android,
+ activity,
+ intent
+ });
+ }
+
@profile
public onStart(activity: any, superFunc: Function): void {
superFunc.call(activity);
@@ -1188,7 +1218,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
if (shouldCreateRootFrame) {
const extras = intent.getExtras();
let frameId = -1;
-
+
// We have extras when we call - new Frame().navigate();
// savedInstanceState is used when activity is recreated.
// NOTE: On API 23+ we get extras on first run.
@@ -1196,17 +1226,17 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
if (extras) {
frameId = extras.getInt(INTENT_EXTRA, -1);
}
-
+
if (savedInstanceState && frameId < 0) {
frameId = savedInstanceState.getInt(INTENT_EXTRA, -1);
}
-
+
if (!rootView) {
// If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate()))
// Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend)
rootView = getFrameByNumberId(frameId) || new Frame();
}
-
+
if (rootView instanceof Frame) {
rootView.navigate(mainEntry);
} else {
diff --git a/tns-core-modules/ui/frame/frame.d.ts b/tns-core-modules/ui/frame/frame.d.ts
index 9718f39ed..5983e9aa1 100644
--- a/tns-core-modules/ui/frame/frame.d.ts
+++ b/tns-core-modules/ui/frame/frame.d.ts
@@ -16,7 +16,7 @@ export * from "../page";
export class Frame extends View {
/**
* @deprecated
- *
+ *
* String value used when hooking to androidOptionSelected event (prefix `android` states that this event is available only in Android).
*/
public static androidOptionSelectedEvent: string;
@@ -33,11 +33,11 @@ export class Frame extends View {
canGoBack(): boolean;
/**
- * Navigates to a Page instance as described by the module name.
+ * Navigates to a Page instance as described by the module name.
* This method will require the module and will check for a Page property in the exports of the module.
* @param pageModuleName The name of the module to require starting from the application root.
* For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this:
- * var frames = require("ui/frame");
+ * const frames = require("ui/frame");
* frames.topmost().navigate("app/subFolder/myPage");
*/
navigate(pageModuleName: string);
@@ -175,7 +175,7 @@ export class Frame extends View {
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
- * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
+ * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
@@ -210,7 +210,7 @@ export function goBack();
/**
* @deprecated use getFrameById() if you want to retrieve a frame different than the topmost one
- *
+ *
* Gets the frames stack.
*/
export function stack(): Array;
@@ -264,7 +264,7 @@ export interface NavigationEntry extends ViewEntry {
transitionAndroid?: NavigationTransition;
/**
- * True to record the navigation in the backstack, false otherwise.
+ * True to record the navigation in the backstack, false otherwise.
* If the parameter is set to false then the Page will be displayed but once navigated from it will not be able to be navigated back to.
*/
backstackVisible?: boolean;
@@ -350,7 +350,7 @@ export interface BackstackEntry {
}
/**
- * Represents the data passed to the androidOptionSelected event.
+ * Represents the data passed to the androidOptionSelected event.
* This event is raised by the Android OS when an option in the Activity's action bar has been selected.
*/
export interface AndroidOptionEventData extends EventData {
@@ -398,7 +398,7 @@ export interface AndroidFrame extends Observable {
/**
* @deprecated this property is not used internally
- *
+ *
* Gets or sets whether the page UI will be cached when navigating away from the page.
*/
cachePagesOnNavigate: boolean;
@@ -413,8 +413,12 @@ export interface AndroidFrame extends Observable {
export interface AndroidActivityCallbacks {
getRootView(): View;
resetActivityContent(activity: any): void;
-
+
+ /**
+ * @deprecated use onCreate(activity, savedInstanceState, intent, superFunc) instead.
+ */
onCreate(activity: any, savedInstanceState: any, superFunc: Function): void;
+ onCreate(activity: any, savedInstanceState: any, intent: any, superFunc: Function): void;
onSaveInstanceState(activity: any, outState: any, superFunc: Function): void;
onStart(activity: any, superFunc: Function): void;
onStop(activity: any, superFunc: Function): void;
@@ -423,6 +427,7 @@ export interface AndroidActivityCallbacks {
onBackPressed(activity: any, superFunc: Function): void;
onRequestPermissionsResult(activity: any, requestCode: number, permissions: Array, grantResults: Array, superFunc: Function): void;
onActivityResult(activity: any, requestCode: number, resultCode: number, data: any, superFunc: Function);
+ onNewIntent(activity: any, intent: any, superSetIntentFunc: Function, superFunc: Function): void;
}
export interface AndroidFragmentCallbacks {
diff --git a/tns-core-modules/ui/gestures/gestures.d.ts b/tns-core-modules/ui/gestures/gestures.d.ts
index 6be6706e8..43891978b 100644
--- a/tns-core-modules/ui/gestures/gestures.d.ts
+++ b/tns-core-modules/ui/gestures/gestures.d.ts
@@ -94,22 +94,22 @@ export module TouchAction {
/**
* Down action.
*/
- export var down: string;
+ export const down: string;
/**
* Up action.
*/
- export var up: string;
+ export const up: string;
/**
* Move action.
*/
- export var move: string;
+ export const move: string;
/**
* Cancel action.
*/
- export var cancel: string;
+ export const cancel: string;
}
/**
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-common.ts b/tns-core-modules/ui/image-cache/image-cache-common.ts
index 3dbd50809..967e3d3ad 100644
--- a/tns-core-modules/ui/image-cache/image-cache-common.ts
+++ b/tns-core-modules/ui/image-cache/image-cache-common.ts
@@ -28,7 +28,7 @@ export class Cache extends observable.Observable implements definition.Cache {
// schedule all pending downloads
this._enabled = true;
- var request: DownloadRequest;
+ let request: DownloadRequest;
while (this._queue.length > 0 && this._currentDownloads < this.maxRequests) {
request = this._queue.pop();
@@ -56,13 +56,13 @@ export class Cache extends observable.Observable implements definition.Cache {
private _addRequest(request: DownloadRequest, onTop: boolean): void {
if (request.key in this._pendingDownloads) {
- var existingRequest = this._pendingDownloads[request.key];
+ const existingRequest = this._pendingDownloads[request.key];
this._mergeRequests(existingRequest, request);
}
else {
// TODO: Potential performance bottleneck - traversing the whole queue on each download request.
- var queueRequest: DownloadRequest;
- for (var i = 0; i < this._queue.length; i++) {
+ let queueRequest: DownloadRequest;
+ for (let i = 0; i < this._queue.length; i++) {
if (this._queue[i].key === request.key) {
queueRequest = this._queue[i];
break;
@@ -83,8 +83,8 @@ export class Cache extends observable.Observable implements definition.Cache {
private _mergeRequests(existingRequest: DownloadRequest, newRequest: DownloadRequest) {
if (existingRequest.completed) {
if (newRequest.completed) {
- var existingCompleted = existingRequest.completed;
- var stackCompleted = function (result: imageSource.ImageSource, key: string) {
+ const existingCompleted = existingRequest.completed;
+ const stackCompleted = function (result: imageSource.ImageSource, key: string) {
existingCompleted(result, key);
newRequest.completed(result, key);
}
@@ -97,8 +97,8 @@ export class Cache extends observable.Observable implements definition.Cache {
}
if (existingRequest.error) {
if (newRequest.error) {
- var existingError = existingRequest.error;
- var stackError = function (key: string) {
+ const existingError = existingRequest.error;
+ const stackError = function (key: string) {
existingError(key);
newRequest.error(key);
}
@@ -139,7 +139,7 @@ export class Cache extends observable.Observable implements definition.Cache {
/* tslint:enable:no-unused-variable */
public _onDownloadCompleted(key: string, image: any) {
- var request = this._pendingDownloads[key];
+ const request = this._pendingDownloads[key];
this.set(request.key, image);
this._currentDownloads--;
@@ -163,7 +163,7 @@ export class Cache extends observable.Observable implements definition.Cache {
}
public _onDownloadError(key: string, err: Error) {
- var request = this._pendingDownloads[key];
+ const request = this._pendingDownloads[key];
this._currentDownloads--;
if (request.error) {
@@ -215,7 +215,7 @@ export class Cache extends observable.Observable implements definition.Cache {
return;
}
- var request = this._queue.pop();
+ const request = this._queue.pop();
this._download(request);
}
}
diff --git a/tns-core-modules/ui/image-cache/image-cache.android.ts b/tns-core-modules/ui/image-cache/image-cache.android.ts
index 96118aeed..acd8c0ee9 100644
--- a/tns-core-modules/ui/image-cache/image-cache.android.ts
+++ b/tns-core-modules/ui/image-cache/image-cache.android.ts
@@ -1,7 +1,7 @@
import * as common from "./image-cache-common";
import * as trace from "../../trace";
-var LruBitmapCacheClass;
+let LruBitmapCacheClass;
function ensureLruBitmapCacheClass() {
if (LruBitmapCacheClass) {
return;
@@ -16,14 +16,10 @@ function ensureLruBitmapCacheClass() {
public sizeOf(key: string, bitmap: android.graphics.Bitmap): number {
// The cache size will be measured in kilobytes rather than
// number of items.
- var result = Math.round(bitmap.getByteCount() / 1024);
- //console.log("sizeOf key: " + result);
+ const result = Math.round(bitmap.getByteCount() / 1024);
+
return result;
}
-
- //protected entryRemoved(evicted: boolean, key: string, oldValue: android.graphics.Bitmap, newValue: android.graphics.Bitmap): void {
- // console.log("entryRemoved("+evicted+", "+key+", "+oldValue+", "+newValue+")");
- //}
};
LruBitmapCacheClass = LruBitmapCache;
@@ -37,14 +33,14 @@ export class Cache extends common.Cache {
super();
ensureLruBitmapCacheClass();
- var maxMemory = java.lang.Runtime.getRuntime().maxMemory() / 1024;
- var cacheSize = maxMemory / 8;
+ const maxMemory = java.lang.Runtime.getRuntime().maxMemory() / 1024;
+ const cacheSize = maxMemory / 8;
this._cache = new LruBitmapCacheClass(cacheSize);
- var that = new WeakRef(this);
+ const that = new WeakRef(this);
this._callback = new org.nativescript.widgets.Async.CompleteCallback({
onComplete: function (result: any, context: any) {
- var instance = that.get();
+ const instance = that.get();
if (instance) {
if (result) {
instance._onDownloadCompleted(context, result);
@@ -54,7 +50,7 @@ export class Cache extends common.Cache {
}
},
onError: function (err: string, context: any) {
- var instance = that.get();
+ const instance = that.get();
if (instance) {
instance._onDownloadError(context, new Error(err));
}
@@ -67,7 +63,7 @@ export class Cache extends common.Cache {
}
public get(key: string): any {
- var result = this._cache.get(key);
+ const result = this._cache.get(key);
return result;
}
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..f82391381 100644
--- a/tns-core-modules/ui/image-cache/image-cache.ios.ts
+++ b/tns-core-modules/ui/image-cache/image-cache.ios.ts
@@ -1,29 +1,17 @@
-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;
+let httpRequest: typeof httpRequestModule;
function ensureHttpRequest() {
if (!httpRequest) {
httpRequest = require("http/http-request");
}
}
-//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,7 @@ class MemmoryWarningHandler extends NSObject {
export class Cache extends common.Cache {
private _cache: NSCache;
- //private _delegate: NSCacheDelegate;
+
//@ts-ignore
private _memoryWarningHandler: MemmoryWarningHandler;
@@ -74,9 +62,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);
}
@@ -86,7 +71,7 @@ export class Cache extends common.Cache {
httpRequest.request({ url: request.url, method: "GET" })
.then((response) => {
try {
- var image = UIImage.alloc().initWithData(response.content.raw);
+ const image = UIImage.alloc().initWithData(response.content.raw);
this._onDownloadCompleted(request.key, image);
} catch (err) {
this._onDownloadError(request.key, err);
diff --git a/tns-core-modules/ui/layouts/grid-layout/grid-layout-common.ts b/tns-core-modules/ui/layouts/grid-layout/grid-layout-common.ts
index 0f2bef6ac..e9f2f5009 100644
--- a/tns-core-modules/ui/layouts/grid-layout/grid-layout-common.ts
+++ b/tns-core-modules/ui/layouts/grid-layout/grid-layout-common.ts
@@ -195,7 +195,7 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
throw new Error("Value is null.");
}
- var index = this._rows.indexOf(itemSpec);
+ const index = this._rows.indexOf(itemSpec);
if (itemSpec.owner !== this || index < 0) {
throw new Error("Row is not child of this GridLayout");
}
@@ -211,7 +211,7 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
throw new Error("Value is null.");
}
- var index = this._cols.indexOf(itemSpec);
+ const index = this._cols.indexOf(itemSpec);
if (itemSpec.owner !== this || index < 0) {
throw new Error("Column is not child of this GridLayout");
}
@@ -223,7 +223,7 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
}
public removeColumns() {
- for (var i = this._cols.length - 1; i >= 0; i--) {
+ for (let i = this._cols.length - 1; i >= 0; i--) {
const colSpec = this._cols[i];
this._onColumnRemoved(colSpec, i);
colSpec.index = -1;
@@ -233,7 +233,7 @@ export class GridLayoutBase extends LayoutBase implements GridLayoutDefinition {
}
public removeRows() {
- for (var i = this._rows.length - 1; i >= 0; i--) {
+ for (let i = this._rows.length - 1; i >= 0; i--) {
const rowSpec = this._rows[i];
this._onRowRemoved(rowSpec, i);
rowSpec.index = -1;
diff --git a/tns-core-modules/ui/layouts/layout-base-common.ts b/tns-core-modules/ui/layouts/layout-base-common.ts
index 104338337..6b7d27f89 100644
--- a/tns-core-modules/ui/layouts/layout-base-common.ts
+++ b/tns-core-modules/ui/layouts/layout-base-common.ts
@@ -59,7 +59,7 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
this._removeView(child);
// TODO: consider caching the index on the child.
- var index = this._subViews.indexOf(child);
+ const index = this._subViews.indexOf(child);
this._subViews.splice(index, 1);
this._unregisterLayoutChild(child);
}
@@ -129,7 +129,7 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
}
public eachLayoutChild(callback: (child: View, isLast: boolean) => void): void {
- var lastChild: View = null;
+ let lastChild: View = null;
this.eachChildView((cv) => {
cv._eachLayoutView((lv) => {
diff --git a/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.ios.ts b/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.ios.ts
index 2d1d3a3d0..1d95a78d0 100644
--- a/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.ios.ts
+++ b/tns-core-modules/ui/layouts/wrap-layout/wrap-layout.ios.ts
@@ -42,10 +42,10 @@ export class WrapLayout extends WrapLayoutBase {
let remainingHeight = availableHeight;
this._lengths.length = 0;
- var rowOrColumn = 0;
- var maxLength = 0;
+ let rowOrColumn = 0;
+ let maxLength = 0;
- var isVertical = this.orientation === "vertical";
+ const isVertical = this.orientation === "vertical";
let useItemWidth: boolean = this.effectiveItemWidth > 0;
let useItemHeight: boolean = this.effectiveItemHeight > 0;
diff --git a/tns-core-modules/ui/list-picker/list-picker-common.ts b/tns-core-modules/ui/list-picker/list-picker-common.ts
index 75eb8aab8..d6e44374d 100644
--- a/tns-core-modules/ui/list-picker/list-picker-common.ts
+++ b/tns-core-modules/ui/list-picker/list-picker-common.ts
@@ -29,7 +29,7 @@ export class ListPickerBase extends View implements ListPickerDefinition {
}
public updateSelectedValue(index) {
- var newVal = null;
+ let newVal = null;
if (index >= 0) {
const item = this.items[index];
diff --git a/tns-core-modules/ui/list-view/list-view.d.ts b/tns-core-modules/ui/list-view/list-view.d.ts
index b64181693..4cc3ba1ab 100644
--- a/tns-core-modules/ui/list-view/list-view.d.ts
+++ b/tns-core-modules/ui/list-view/list-view.d.ts
@@ -12,7 +12,7 @@ export module knownTemplates {
/**
* The ListView item template.
*/
- export var itemTemplate: string;
+ export const itemTemplate: string;
}
/**
diff --git a/tns-core-modules/ui/list-view/list-view.ios.ts b/tns-core-modules/ui/list-view/list-view.ios.ts
index a68067c5f..8fb180625 100644
--- a/tns-core-modules/ui/list-view/list-view.ios.ts
+++ b/tns-core-modules/ui/list-view/list-view.ios.ts
@@ -365,7 +365,7 @@ export class ListView extends ListViewBase {
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
this.widthMeasureSpec = widthMeasureSpec;
- var changed = this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
+ const changed = this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
super.measure(widthMeasureSpec, heightMeasureSpec);
if (changed) {
this.ios.reloadData();
diff --git a/tns-core-modules/ui/page/page.d.ts b/tns-core-modules/ui/page/page.d.ts
index e8f973e59..942d1d5dc 100644
--- a/tns-core-modules/ui/page/page.d.ts
+++ b/tns-core-modules/ui/page/page.d.ts
@@ -33,7 +33,7 @@ export interface NavigatedData extends EventData {
}
export module knownCollections {
- export var actionItems: string;
+ export const actionItems: string;
}
/**
diff --git a/tns-core-modules/ui/repeater/repeater.ts b/tns-core-modules/ui/repeater/repeater.ts
index ee1470b01..4c6553ffe 100644
--- a/tns-core-modules/ui/repeater/repeater.ts
+++ b/tns-core-modules/ui/repeater/repeater.ts
@@ -85,13 +85,7 @@ export class Repeater extends CustomLayoutView implements RepeaterDefinition {
}
get _childrenCount(): number {
- var count = 0;
-
- if (this.itemsLayout) {
- count++;
- }
-
- return count;
+ return this.itemsLayout ? 1 : 0;
}
public eachChildView(callback: (child: View) => boolean) {
diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts
index 7180dce45..780fb32fd 100644
--- a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts
+++ b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts
@@ -7,7 +7,7 @@ import {
export * from "../core/view";
export module knownCollections {
- export var items = "items";
+ export const items = "items";
}
@CSSType("SegmentedBarItem")
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/css-selector/css-selector.ts b/tns-core-modules/ui/styling/css-selector/css-selector.ts
index 875425508..c97daa760 100644
--- a/tns-core-modules/ui/styling/css-selector/css-selector.ts
+++ b/tns-core-modules/ui/styling/css-selector/css-selector.ts
@@ -38,11 +38,11 @@ namespace Match {
/**
* Depends on attributes or pseudoclasses state;
*/
- export var Dynamic = true;
+ export const Dynamic = true;
/**
* Depends only on the tree structure.
*/
- export var Static = false;
+ export const Static = false;
}
function getNodeDirectSibling(node): null | Node {
@@ -436,14 +436,17 @@ function createSelectorFromAst(ast: parser.Selector): SimpleSelector | SimpleSel
return createSimpleSelectorSequenceFromAst(ast[0][0]);
} else {
let simpleSelectorSequences = [];
- for (var i = 0; i < ast.length; i ++) {
- const simpleSelectorSequence = createSimpleSelectorSequenceFromAst(ast[i][0]);
- const combinator = ast[i][1];
+ let simpleSelectorSequence: SimpleSelectorSequence | SimpleSelector;
+ let combinator: parser.Combinator;
+ for (let i = 0; i < ast.length; i ++) {
+ simpleSelectorSequence = createSimpleSelectorSequenceFromAst(ast[i][0]);
+ combinator = ast[i][1];
if (combinator) {
simpleSelectorSequence.combinator = combinator;
}
simpleSelectorSequences.push(simpleSelectorSequence);
}
+
return new Selector(simpleSelectorSequences);
}
}
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/ui/web-view/web-view.ios.ts b/tns-core-modules/ui/web-view/web-view.ios.ts
index ebe6c640a..8a124ff07 100644
--- a/tns-core-modules/ui/web-view/web-view.ios.ts
+++ b/tns-core-modules/ui/web-view/web-view.ios.ts
@@ -145,7 +145,7 @@ export class WebView extends WebViewBase {
public _loadUrl(src: string) {
if (src.startsWith("file:///")) {
- var cachePath = src.substring(0, src.lastIndexOf("/"));
+ const cachePath = src.substring(0, src.lastIndexOf("/"));
this.ios.loadFileURLAllowingReadAccessToURL(NSURL.URLWithString(src), NSURL.URLWithString(cachePath));
} else {
this.ios.loadRequest(NSURLRequest.requestWithURL(NSURL.URLWithString(src)));
diff --git a/tns-core-modules/utils/debug.d.ts b/tns-core-modules/utils/debug.d.ts
index dfcf448a1..93dd43f9c 100644
--- a/tns-core-modules/utils/debug.d.ts
+++ b/tns-core-modules/utils/debug.d.ts
@@ -5,7 +5,7 @@
/**
* A runtime option indicating whether the build has debugging enabled.
*/
-export var debug: boolean;
+export let debug: boolean;
/**
* A class encapsulating information for source code origin.
diff --git a/tns-core-modules/utils/debug.ts b/tns-core-modules/utils/debug.ts
index 189941756..83684d0a3 100644
--- a/tns-core-modules/utils/debug.ts
+++ b/tns-core-modules/utils/debug.ts
@@ -1,9 +1,9 @@
import { knownFolders } from "../file-system"
import { isAndroid } from "../platform"
-export var debug = true;
+export let debug = true;
-var applicationRootPath: string;
+let applicationRootPath: string;
function ensureAppRootPath() {
if (!applicationRootPath) {
applicationRootPath = knownFolders.currentApp().path;
diff --git a/tns-core-modules/utils/module-merge.ts b/tns-core-modules/utils/module-merge.ts
index a88a565e3..7fe2ba210 100644
--- a/tns-core-modules/utils/module-merge.ts
+++ b/tns-core-modules/utils/module-merge.ts
@@ -1,7 +1,7 @@
// This method iterates all the keys in the source exports object and copies them to the destination exports one.
// Note: the method will not check for naming collisions and will override any already existing entries in the destination exports.
-export var merge = function (sourceExports: any, destExports: any) {
- for (var key in sourceExports) {
+export function merge(sourceExports: any, destExports: any) {
+ for (let key in sourceExports) {
destExports[key] = sourceExports[key];
}
}
\ No newline at end of file
diff --git a/tns-core-modules/utils/types.ts b/tns-core-modules/utils/types.ts
index 53ccc87d8..02327e96a 100644
--- a/tns-core-modules/utils/types.ts
+++ b/tns-core-modules/utils/types.ts
@@ -42,16 +42,16 @@ export function verifyCallback(value: any) {
}
}
-var classInfosMap = new Map();
-var funcNameRegex = /function ([_a-zA-Z0-9]{1,})\(/;
+const classInfosMap = new Map();
+const funcNameRegex = /function ([_a-zA-Z0-9]{1,})\(/;
export function getClass(object: Object): string {
return getClassInfo(object).name;
}
export function getClassInfo(object: Object): ClassInfo {
- var constructor = object.constructor;
+ const constructor = object.constructor;
- var result = classInfosMap.get(constructor);
+ let result = classInfosMap.get(constructor);
if (!result) {
result = new ClassInfo(constructor);
classInfosMap.set(constructor, result);
@@ -61,8 +61,8 @@ export function getClassInfo(object: Object): ClassInfo {
}
export function getBaseClasses(object): Array {
- var result = [];
- var info = getClassInfo(object);
+ const result = [];
+ let info = getClassInfo(object);
while (info) {
result.push(info.name);
info = info.baseClassInfo;
@@ -81,7 +81,7 @@ export class ClassInfo {
get name(): string {
if (!this._name) {
- var results = (funcNameRegex).exec(this._typeCosntructor.toString());
+ const results = (funcNameRegex).exec(this._typeCosntructor.toString());
this._name = (results && results.length > 1) ? results[1] : "";
}
@@ -102,8 +102,8 @@ export class ClassInfo {
}
private static _getBase(info: ClassInfo): ClassInfo {
- var result = null;
- var constructorProto = info._typeCosntructor.prototype;
+ let result = null;
+ const constructorProto = info._typeCosntructor.prototype;
if (constructorProto.__proto__) {
result = getClassInfo(constructorProto.__proto__);
}
diff --git a/tns-core-modules/utils/utils-common.ts b/tns-core-modules/utils/utils-common.ts
index 76bb98bbd..ae8c03cd6 100644
--- a/tns-core-modules/utils/utils-common.ts
+++ b/tns-core-modules/utils/utils-common.ts
@@ -9,15 +9,13 @@ export function escapeRegexSymbols(source: string): string {
}
export function convertString(value: any): any {
- var result;
+ let result;
- if (!types.isString(value)) {
- result = value;
- } else if (value.trim() === "") {
+ if (!types.isString(value) || value.trim() === "") {
result = value;
} else {
// Try to convert value to number.
- var valueAsNumber = +value;
+ const valueAsNumber = +value;
if (!isNaN(valueAsNumber)) {
result = valueAsNumber;
} else if (value && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
diff --git a/tns-core-modules/utils/utils.android.ts b/tns-core-modules/utils/utils.android.ts
index 2b3845652..b050042f9 100644
--- a/tns-core-modules/utils/utils.android.ts
+++ b/tns-core-modules/utils/utils.android.ts
@@ -131,9 +131,9 @@ export module ad {
export module collections {
export function stringArrayToStringSet(str: string[]): java.util.HashSet {
- var hashSet = new java.util.HashSet();
+ const hashSet = new java.util.HashSet();
if (str !== undefined) {
- for (var element in str) {
+ for (let element in str) {
hashSet.add("" + str[element]);
}
}
@@ -141,11 +141,11 @@ export module ad {
}
export function stringSetToStringArray(stringSet: any): string[] {
- var arr = [];
+ const arr = [];
if (stringSet !== undefined) {
- var it = stringSet.iterator();
+ const it = stringSet.iterator();
while (it.hasNext()) {
- var element = "" + it.next();
+ const element = "" + it.next();
arr.push(element);
}
}
@@ -155,8 +155,8 @@ export module ad {
}
export module resources {
- var attr;
- var attrCache = new Map();
+ let attr;
+ const attrCache = new Map();
export function getDrawableId(name) {
return getId(":drawable/" + name);
@@ -167,9 +167,9 @@ export module ad {
}
export function getId(name: string): number {
- var resources = getResources();
- var packageName = getPackageName();
- var uri = packageName + name;
+ const resources = getResources();
+ const packageName = getPackageName();
+ const uri = packageName + name;
return resources.getIdentifier(uri, null, null);
}
export function getPalleteColor(name: string, context: android.content.Context): number {
@@ -180,7 +180,7 @@ export module ad {
return attrCache.get(name);
}
- var result = 0;
+ let result = 0;
try {
if (!attr) {
attr = java.lang.Class.forName("android.support.v7.appcompat.R$attr")
@@ -219,7 +219,7 @@ export function releaseNativeObject(object: java.lang.Object) {
export function openUrl(location: string): boolean {
const context = ad.getApplicationContext();
try {
- var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
+ const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(location.trim()));
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
diff --git a/tns-core-modules/utils/utils.d.ts b/tns-core-modules/utils/utils.d.ts
index 2e4e06fca..3cab654c1 100644
--- a/tns-core-modules/utils/utils.d.ts
+++ b/tns-core-modules/utils/utils.d.ts
@@ -24,13 +24,13 @@ export module layout {
/**
* Bits that provide the actual measured size.
*/
- export var MEASURED_HEIGHT_STATE_SHIFT: number;
- export var MEASURED_SIZE_MASK: number;
- export var MEASURED_STATE_MASK: number;
- export var MEASURED_STATE_TOO_SMALL: number;
- export var UNSPECIFIED: number;
- export var EXACTLY: number;
- export var AT_MOST: number;
+ export const MEASURED_HEIGHT_STATE_SHIFT: number;
+ export const MEASURED_SIZE_MASK: number;
+ export const MEASURED_STATE_MASK: number;
+ export const MEASURED_STATE_TOO_SMALL: number;
+ export const UNSPECIFIED: number;
+ export const EXACTLY: number;
+ export const AT_MOST: number;
/**
* Gets layout mode from a given specification as string.
@@ -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.
@@ -227,7 +229,7 @@ export module ios {
/**
* Gets the iOS device major version (for 8.1 will return 8).
*/
- export var MajorVersion: number;
+ export const MajorVersion: number;
/**
* Opens file with associated application.
diff --git a/tns-core-modules/utils/utils.ios.ts b/tns-core-modules/utils/utils.ios.ts
index 53c2c19a7..941782f16 100644
--- a/tns-core-modules/utils/utils.ios.ts
+++ b/tns-core-modules/utils/utils.ios.ts
@@ -12,8 +12,8 @@ function isOrientationLandscape(orientation: number) {
}
export module layout {
- var MODE_SHIFT = 30;
- var MODE_MASK = 0x3 << MODE_SHIFT;
+ const MODE_SHIFT = 30;
+ const MODE_MASK = 0x3 << MODE_SHIFT;
export function makeMeasureSpec(size: number, mode: number): number {
return (Math.round(Math.max(0, size)) & ~MODE_MASK) | (mode & MODE_MASK);
@@ -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 {
@@ -59,7 +60,7 @@ export module ios {
}
export function nsArrayToJSArray(a: NSArray): Array