mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge branch 'master' into border-outline
This commit is contained in:
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,3 +1,29 @@
|
||||
<a name="5.3.0"></a>
|
||||
# [5.3.0](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.3.0) (2019-03-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **android:** resource ID not found on navigation between pages with nested and single frames ([#6955](https://github.com/NativeScript/NativeScript/issues/6955)) ([33d6d1f](https://github.com/NativeScript/NativeScript/commit/33d6d1f))
|
||||
* **android:** navigation between pages with single and nested frames ([#7011](https://github.com/NativeScript/NativeScript/issues/7011)) ([91d90cc](https://github.com/NativeScript/NativeScript/commit/91d90cc))
|
||||
* **http:** ensure httpcontent.toFile() creates intermediate directories ([#6451](https://github.com/NativeScript/NativeScript/issues/6451)) ([d7fb9b8](https://github.com/NativeScript/NativeScript/commit/d7fb9b8))
|
||||
* WrappedValue.unwrap empty string behavior ([#6900](https://github.com/NativeScript/NativeScript/issues/6900)) ([0482460](https://github.com/NativeScript/NativeScript/commit/0482460))
|
||||
* **android-bottom-tabs:** use immediate transition on programmatic selectedIndex change ([#6942](https://github.com/NativeScript/NativeScript/issues/6942)) ([e9dfa20](https://github.com/NativeScript/NativeScript/commit/e9dfa20))
|
||||
* **ios:** disable default tab reselect behavior ([#6968](https://github.com/NativeScript/NativeScript/issues/6968)) ([043cbf3](https://github.com/NativeScript/NativeScript/commit/043cbf3))
|
||||
* **ios-webview:** report hostname lookup errors in loadFinished event ([#6988](https://github.com/NativeScript/NativeScript/issues/6988)) ([e6486f6](https://github.com/NativeScript/NativeScript/commit/e6486f6))
|
||||
* **ios-webview:** loading of local-file dependency ([#6947](https://github.com/NativeScript/NativeScript/issues/6947)) ([dcad754](https://github.com/NativeScript/NativeScript/commit/dcad754)), closes [/github.com/NativeScript/NativeScript/issues/6377#issuecomment-433322681](https://github.com//github.com/NativeScript/NativeScript/issues/6377/issues/issuecomment-433322681) [#6377](https://github.com/NativeScript/NativeScript/issues/6377)
|
||||
* set/unset touchListener.owner onLoaded/onUnloaded ([#6922](https://github.com/NativeScript/NativeScript/issues/6922)) ([f056167](https://github.com/NativeScript/NativeScript/commit/f056167))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* local icon handling in actionbar and tabview ([#7009](https://github.com/NativeScript/NativeScript/issues/7009)) ([cd66300](https://github.com/NativeScript/NativeScript/commit/cd66300))
|
||||
* **android:** add openFile to utils ([#6895](https://github.com/NativeScript/NativeScript/issues/6895)) ([f8eee40](https://github.com/NativeScript/NativeScript/commit/f8eee40))
|
||||
* **hmr:** style views at runtime ([#7012](https://github.com/NativeScript/NativeScript/issues/7012)) ([3c2c1d9](https://github.com/NativeScript/NativeScript/commit/3c2c1d9))
|
||||
* **hmr:** apply changes in page styles at runtime when app root is a frame ([#6857](https://github.com/NativeScript/NativeScript/issues/6857)) ([44b8acd](https://github.com/NativeScript/NativeScript/commit/44b8acd))
|
||||
* **view** expose missing backgroundSize, backgroundRepeat, and backgroundPosition properties on View class ([#7032](https://github.com/NativeScript/NativeScript/issues/7032)) ([88f2242](https://github.com/NativeScript/NativeScript/commit/88f2242))
|
||||
|
||||
|
||||
<a name="5.2.2"></a>
|
||||
## [5.2.2](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.2.2) (2019-03-01)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
(<any>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);
|
||||
(<any>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);
|
||||
(<any>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);
|
||||
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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<any> {
|
||||
};
|
||||
|
||||
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<any> {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
(<any>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);
|
||||
(<any>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);
|
||||
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as utils from "../utils/utils";
|
||||
|
||||
var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
|
||||
var userDefaults = NSUserDefaults.standardUserDefaults;
|
||||
|
||||
export var hasKey = function (key: string): boolean {
|
||||
Common.checkKey(key);
|
||||
@@ -59,7 +59,7 @@ export var remove = function (key: string): void {
|
||||
}
|
||||
|
||||
export var clear = function (): void {
|
||||
userDefaults.removePersistentDomainForName(utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier);
|
||||
userDefaults.removePersistentDomainForName(NSBundle.mainBundle.bundleIdentifier);
|
||||
}
|
||||
|
||||
export var flush = function (): boolean {
|
||||
|
||||
@@ -18,9 +18,11 @@ export * from "./application-common";
|
||||
import { createViewFromEntry } from "../ui/builder";
|
||||
import { ios as iosView, View } from "../ui/core/view";
|
||||
import { Frame, NavigationEntry } from "../ui/frame";
|
||||
import * as utils from "../utils/utils";
|
||||
import { ios } from "../utils/utils";
|
||||
import { profile, level as profilingLevel, Level } from "../profiling";
|
||||
|
||||
const getVisibleViewController = ios.getVisibleViewController;
|
||||
|
||||
// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430
|
||||
// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved:
|
||||
// https://github.com/NativeScript/ios-runtime/issues/1012
|
||||
@@ -60,7 +62,7 @@ let displayedLink;
|
||||
class CADisplayLinkTarget extends NSObject {
|
||||
onDisplayed(link: CADisplayLink) {
|
||||
link.invalidate();
|
||||
const ios = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
|
||||
const ios = UIApplication.sharedApplication;
|
||||
const object = iosApp;
|
||||
displayedOnce = true;
|
||||
notify(<ApplicationEventData>{ 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<NotificationObserver>;
|
||||
private _rootView: View;
|
||||
@@ -94,7 +96,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
}
|
||||
|
||||
get nativeApp(): UIApplication {
|
||||
return utils.ios.getter(UIApplication, UIApplication.sharedApplication);
|
||||
return UIApplication.sharedApplication;
|
||||
}
|
||||
|
||||
get window(): UIWindow {
|
||||
@@ -116,7 +118,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
|
||||
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
||||
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
|
||||
utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
|
||||
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
|
||||
this._observers.push(observer);
|
||||
return observer;
|
||||
}
|
||||
@@ -125,7 +127,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
var index = this._observers.indexOf(observer);
|
||||
if (index >= 0) {
|
||||
this._observers.splice(index, 1);
|
||||
utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(observer, notificationName, null);
|
||||
NSNotificationCenter.defaultCenter.removeObserverNameObject(observer, notificationName, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +140,9 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
displayedLink.addToRunLoopForMode(NSRunLoop.mainRunLoop, UITrackingRunLoopMode);
|
||||
}
|
||||
|
||||
this._window = UIWindow.alloc().initWithFrame(utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds);
|
||||
this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
|
||||
// TODO: Expose Window module so that it can we styled from XML & CSS
|
||||
this._window.backgroundColor = utils.ios.getter(UIColor, UIColor.whiteColor);
|
||||
this._window.backgroundColor = UIColor.whiteColor;
|
||||
|
||||
this.notifyAppStarted(notification);
|
||||
|
||||
@@ -166,7 +168,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
|
||||
@profile
|
||||
private didBecomeActive(notification: NSNotification) {
|
||||
const ios = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
|
||||
const ios = UIApplication.sharedApplication;
|
||||
const object = this;
|
||||
notify(<ApplicationEventData>{ eventName: resumeEvent, object, ios });
|
||||
const rootView = this._rootView;
|
||||
@@ -176,7 +178,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
}
|
||||
|
||||
private didEnterBackground(notification: NSNotification) {
|
||||
notify(<ApplicationEventData>{ eventName: suspendEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||
notify(<ApplicationEventData>{ 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(<ApplicationEventData>{ eventName: exitEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||
notify(<ApplicationEventData>{ 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(<ApplicationEventData>{ eventName: lowMemoryEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||
notify(<ApplicationEventData>{ eventName: lowMemoryEvent, object: this, ios: UIApplication.sharedApplication });
|
||||
}
|
||||
|
||||
private orientationDidChange(notification: NSNotification) {
|
||||
const orientation = utils.ios.getter(UIDevice, UIDevice.currentDevice).orientation;
|
||||
const orientation = UIDevice.currentDevice.orientation;
|
||||
|
||||
if (this._currentOrientation !== orientation) {
|
||||
this._currentOrientation = orientation;
|
||||
@@ -324,7 +326,7 @@ export function start(entry?: string | NavigationEntry) {
|
||||
if (embedderDelegate) {
|
||||
embedderDelegate.presentNativeScriptApp(controller);
|
||||
} else {
|
||||
let visibleVC = utils.ios.getVisibleViewController(rootController);
|
||||
let visibleVC = getVisibleViewController(rootController);
|
||||
visibleVC.presentViewControllerAnimatedCompletion(controller, true, null);
|
||||
}
|
||||
iosApp.notifyAppStarted();
|
||||
|
||||
@@ -4,19 +4,6 @@ var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBacken
|
||||
import * as debuggerDomains from "./debugger";
|
||||
|
||||
declare var __inspectorSendEvent;
|
||||
/**
|
||||
* Checks if the property is a function and if it is, calls it on this.
|
||||
* Designed to support backward compatibility for methods that became properties.
|
||||
* Will not work on delegates since it checks if the propertyValue is a function, and delegates are marshalled as functions.
|
||||
* Example: getter(NSRunLoop, NSRunLoop.currentRunLoop).runUntilDate(NSDate.dateWithTimeIntervalSinceNow(waitTime));
|
||||
*/
|
||||
function getter<T>(_this: any, property: T | {(): T}): T {
|
||||
if (typeof property === "function") {
|
||||
return (<{(): T}>property).call(_this);
|
||||
} else {
|
||||
return <T>property;
|
||||
}
|
||||
}
|
||||
|
||||
declare var __inspectorTimestamp;
|
||||
|
||||
@@ -237,9 +224,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
||||
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
|
||||
*/
|
||||
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string, mimeType: string, status: number } {
|
||||
let appPath = getter(NSBundle, NSBundle.mainBundle).bundlePath;
|
||||
let appPath = NSBundle.mainBundle.bundlePath;
|
||||
let pathUrl = params.url.replace("file://", appPath);
|
||||
let fileManager = getter(NSFileManager, NSFileManager.defaultManager);
|
||||
let fileManager = NSFileManager.defaultManager;
|
||||
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
|
||||
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : "";
|
||||
|
||||
|
||||
@@ -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<string>;
|
||||
try {
|
||||
files = fileManager.contentsOfDirectoryAtPathError(path);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
/**
|
||||
* Android specific http request implementation.
|
||||
*/
|
||||
import { fromNativeSource } from "../../image-source";
|
||||
import { screen } from "../../platform";
|
||||
import { File } from "../../file-system";
|
||||
// imported for definition purposes only
|
||||
import * as httpModule from "../../http";
|
||||
import * as imageSourceModule from "../../image-source";
|
||||
import * as platformModule from "../../platform";
|
||||
import * as fsModule from "../../file-system";
|
||||
|
||||
import { getFilenameFromUrl } from "./http-request-common";
|
||||
|
||||
// this is imported for definition purposes only
|
||||
import * as http from "../../http";
|
||||
|
||||
import { NetworkAgent } from "../../debugger/debugger";
|
||||
|
||||
export enum HttpResponseEncoding {
|
||||
@@ -28,6 +24,27 @@ function parseJSON(source: string): any {
|
||||
let requestIdCounter = 0;
|
||||
const pendingRequests = {};
|
||||
|
||||
let imageSource: typeof imageSourceModule;
|
||||
function ensureImageSource() {
|
||||
if (!imageSource) {
|
||||
imageSource = require("image-source");
|
||||
}
|
||||
}
|
||||
|
||||
let platform: typeof platformModule;
|
||||
function ensurePlatform() {
|
||||
if (!platform) {
|
||||
platform = require("platform");
|
||||
}
|
||||
}
|
||||
|
||||
let fs: typeof fsModule;
|
||||
function ensureFileSystem() {
|
||||
if (!fs) {
|
||||
fs = require("file-system");
|
||||
}
|
||||
}
|
||||
|
||||
let completeCallback: org.nativescript.widgets.Async.CompleteCallback;
|
||||
function ensureCompleteCallback() {
|
||||
if (completeCallback) {
|
||||
@@ -55,7 +72,7 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
|
||||
}
|
||||
|
||||
// read the headers
|
||||
const headers: http.Headers = {};
|
||||
const headers: httpModule.Headers = {};
|
||||
if (result.headers) {
|
||||
const jHeaders = result.headers;
|
||||
const length = jHeaders.size();
|
||||
@@ -97,9 +114,11 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
|
||||
return parseJSON(str);
|
||||
},
|
||||
toImage: () => {
|
||||
ensureImageSource();
|
||||
|
||||
return new Promise<any>((resolveImage, rejectImage) => {
|
||||
if (result.responseAsImage != null) {
|
||||
resolveImage(fromNativeSource(result.responseAsImage));
|
||||
resolveImage(imageSource.fromNativeSource(result.responseAsImage));
|
||||
}
|
||||
else {
|
||||
rejectImage(new Error("Response content may not be converted to an Image"));
|
||||
@@ -107,13 +126,15 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
|
||||
});
|
||||
},
|
||||
toFile: (destinationFilePath: string) => {
|
||||
ensureFileSystem();
|
||||
|
||||
if (!destinationFilePath) {
|
||||
destinationFilePath = getFilenameFromUrl(callbacks.url);
|
||||
}
|
||||
let stream: java.io.FileOutputStream;
|
||||
try {
|
||||
// ensure destination path exists by creating any missing parent directories
|
||||
const file = File.fromPath(destinationFilePath);
|
||||
const file = fs.File.fromPath(destinationFilePath);
|
||||
|
||||
const javaFile = new java.io.File(destinationFilePath);
|
||||
stream = new java.io.FileOutputStream(javaFile);
|
||||
@@ -144,7 +165,7 @@ function onRequestError(error: string, requestId: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function buildJavaOptions(options: http.HttpRequestOptions) {
|
||||
function buildJavaOptions(options: httpModule.HttpRequestOptions) {
|
||||
if (typeof options.url !== "string") {
|
||||
throw new Error("Http request must provide a valid url.");
|
||||
}
|
||||
@@ -177,20 +198,23 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
|
||||
javaOptions.headers = arrayList;
|
||||
}
|
||||
|
||||
ensurePlatform();
|
||||
|
||||
// pass the maximum available image size to the request options in case we need a bitmap conversion
|
||||
javaOptions.screenWidth = screen.mainScreen.widthPixels;
|
||||
javaOptions.screenHeight = screen.mainScreen.heightPixels;
|
||||
const screen = platform.screen.mainScreen;
|
||||
javaOptions.screenWidth = screen.widthPixels;
|
||||
javaOptions.screenHeight = screen.heightPixels;
|
||||
|
||||
return javaOptions;
|
||||
}
|
||||
|
||||
export function request(options: http.HttpRequestOptions): Promise<http.HttpResponse> {
|
||||
export function request(options: httpModule.HttpRequestOptions): Promise<httpModule.HttpResponse> {
|
||||
if (options === undefined || options === null) {
|
||||
// TODO: Shouldn't we throw an error here - defensive programming
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise<http.HttpResponse>((resolve, reject) => {
|
||||
return new Promise<httpModule.HttpResponse>((resolve, reject) => {
|
||||
try {
|
||||
// initialize the options
|
||||
const javaOptions = buildJavaOptions(options);
|
||||
@@ -228,7 +252,7 @@ function decodeResponse(raw: any, encoding?: HttpResponseEncoding) {
|
||||
return raw.toString(charsetName)
|
||||
}
|
||||
|
||||
export function addHeader(headers: http.Headers, key: string, value: string): void {
|
||||
export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
|
||||
if (!headers[key]) {
|
||||
headers[key] = value;
|
||||
} else if (Array.isArray(headers[key])) {
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
/**
|
||||
* iOS specific http request implementation.
|
||||
*/
|
||||
// imported for definition purposes only
|
||||
import * as httpModule from "../../http";
|
||||
import * as imageSourceModule from "../../image-source";
|
||||
import * as fsModule from "../../file-system";
|
||||
|
||||
import { HttpRequestOptions, HttpResponse, Headers } from "../../http";
|
||||
import * as types from "../../utils/types";
|
||||
import { fromNativeSource } from "../../image-source";
|
||||
import { File } from "../../file-system";
|
||||
|
||||
import * as utils from "../../utils/utils";
|
||||
import getter = utils.ios.getter;
|
||||
|
||||
import * as domainDebugger from "../../debugger/debugger";
|
||||
import { getFilenameFromUrl } from "./http-request-common";
|
||||
|
||||
@@ -18,15 +12,15 @@ export enum HttpResponseEncoding {
|
||||
GBK
|
||||
}
|
||||
|
||||
const currentDevice = getter(UIDevice, UIDevice.currentDevice);
|
||||
const currentDevice = UIDevice.currentDevice;
|
||||
const device = currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Phone ? "Phone" : "Pad";
|
||||
const osVersion = currentDevice.systemVersion;
|
||||
|
||||
const GET = "GET";
|
||||
const USER_AGENT_HEADER = "User-Agent";
|
||||
const USER_AGENT = `Mozilla/5.0 (i${device}; CPU OS ${osVersion.replace(".", "_")} like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/${osVersion} Mobile/10A5355d Safari/8536.25`;
|
||||
const sessionConfig = getter(NSURLSessionConfiguration, NSURLSessionConfiguration.defaultSessionConfiguration);
|
||||
const queue = getter(NSOperationQueue, NSOperationQueue.mainQueue);
|
||||
const sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration;
|
||||
const queue = NSOperationQueue.mainQueue;
|
||||
|
||||
function parseJSON(source: string): any {
|
||||
const src = source.trim();
|
||||
@@ -59,8 +53,22 @@ function ensureSessionNotFollowingRedirects() {
|
||||
}
|
||||
}
|
||||
|
||||
export function request(options: HttpRequestOptions): Promise<HttpResponse> {
|
||||
return new Promise<HttpResponse>((resolve, reject) => {
|
||||
let imageSource: typeof imageSourceModule;
|
||||
function ensureImageSource() {
|
||||
if (!imageSource) {
|
||||
imageSource = require("image-source");
|
||||
}
|
||||
}
|
||||
|
||||
let fs: typeof fsModule;
|
||||
function ensureFileSystem() {
|
||||
if (!fs) {
|
||||
fs = require("file-system");
|
||||
}
|
||||
}
|
||||
|
||||
export function request(options: httpModule.HttpRequestOptions): Promise<httpModule.HttpResponse> {
|
||||
return new Promise<httpModule.HttpResponse>((resolve, reject) => {
|
||||
|
||||
if (!options.url) {
|
||||
reject(new Error("Request url was empty."));
|
||||
@@ -106,7 +114,7 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
|
||||
if (error) {
|
||||
reject(new Error(error.localizedDescription));
|
||||
} else {
|
||||
const headers: Headers = {};
|
||||
const headers: httpModule.Headers = {};
|
||||
if (response && response.allHeaderFields) {
|
||||
const headerFields = response.allHeaderFields;
|
||||
|
||||
@@ -136,10 +144,12 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
|
||||
toString: (encoding?: any) => NSDataToString(data, encoding),
|
||||
toJSON: (encoding?: any) => parseJSON(NSDataToString(data, encoding)),
|
||||
toImage: () => {
|
||||
ensureImageSource();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
(<any>UIImage).tns_decodeImageWithDataCompletion(data, image => {
|
||||
if (image) {
|
||||
resolve(fromNativeSource(image));
|
||||
resolve(imageSource.fromNativeSource(image));
|
||||
} else {
|
||||
reject(new Error("Response content may not be converted to an Image"));
|
||||
}
|
||||
@@ -147,12 +157,14 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
|
||||
});
|
||||
},
|
||||
toFile: (destinationFilePath?: string) => {
|
||||
ensureFileSystem();
|
||||
|
||||
if (!destinationFilePath) {
|
||||
destinationFilePath = getFilenameFromUrl(options.url);
|
||||
}
|
||||
if (data instanceof NSData) {
|
||||
// ensure destination path exists by creating any missing parent directories
|
||||
const file = File.fromPath(destinationFilePath);
|
||||
const file = fs.File.fromPath(destinationFilePath);
|
||||
|
||||
data.writeToFileAtomically(destinationFilePath, true);
|
||||
|
||||
@@ -192,7 +204,7 @@ function NSDataToString(data: any, encoding?: HttpResponseEncoding): string {
|
||||
return NSString.alloc().initWithDataEncoding(data, code).toString();
|
||||
}
|
||||
|
||||
export function addHeader(headers: Headers, key: string, value: string): void {
|
||||
export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
|
||||
if (!headers[key]) {
|
||||
headers[key] = value;
|
||||
} else if (Array.isArray(headers[key])) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get osVersion(): string {
|
||||
if (!this._osVersion) {
|
||||
this._osVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
|
||||
this._osVersion = UIDevice.currentDevice.systemVersion;
|
||||
}
|
||||
|
||||
return this._osVersion;
|
||||
@@ -34,7 +34,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get model(): string {
|
||||
if (!this._model) {
|
||||
this._model = utils.ios.getter(UIDevice, UIDevice.currentDevice).model;
|
||||
this._model = UIDevice.currentDevice.model;
|
||||
}
|
||||
|
||||
return this._model;
|
||||
@@ -42,7 +42,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get sdkVersion(): string {
|
||||
if (!this._sdkVersion) {
|
||||
this._sdkVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
|
||||
this._sdkVersion = UIDevice.currentDevice.systemVersion;
|
||||
}
|
||||
|
||||
return this._sdkVersion;
|
||||
@@ -50,7 +50,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get deviceType(): "Phone" | "Tablet" {
|
||||
if (!this._deviceType) {
|
||||
if (utils.ios.getter(UIDevice, UIDevice.currentDevice).userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
|
||||
if (UIDevice.currentDevice.userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
|
||||
this._deviceType = "Phone";
|
||||
}
|
||||
else {
|
||||
@@ -62,7 +62,7 @@ class Device implements DeviceDefinition {
|
||||
}
|
||||
|
||||
get uuid(): string {
|
||||
var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
|
||||
var userDefaults = NSUserDefaults.standardUserDefaults;
|
||||
var uuid_key = "TNSUUID";
|
||||
var app_uuid = userDefaults.stringForKey(uuid_key);
|
||||
|
||||
@@ -77,7 +77,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get language(): string {
|
||||
if (!this._language) {
|
||||
var languages = utils.ios.getter(NSLocale, NSLocale.preferredLanguages);
|
||||
var languages = NSLocale.preferredLanguages;
|
||||
this._language = languages[0];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class Device implements DeviceDefinition {
|
||||
|
||||
get region(): string {
|
||||
if (!this._region) {
|
||||
this._region = utils.ios.getter(NSLocale, NSLocale.currentLocale).objectForKey(NSLocaleCountryCode);
|
||||
this._region = NSLocale.currentLocale.objectForKey(NSLocaleCountryCode);
|
||||
}
|
||||
|
||||
return this._region;
|
||||
@@ -98,7 +98,7 @@ class MainScreen implements ScreenMetricsDefinition {
|
||||
|
||||
private get screen(): UIScreen {
|
||||
if (!this._screen) {
|
||||
this._screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
|
||||
this._screen = UIScreen.mainScreen;
|
||||
}
|
||||
|
||||
return this._screen;
|
||||
|
||||
@@ -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<NSTimer, TimerTargetImpl> = { k: timer, v: timerTarget };
|
||||
timeoutCallbacks.set(id, pair);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -431,7 +431,7 @@ export class View extends ViewCommon {
|
||||
const animated = options.animated === undefined ? true : !!options.animated;
|
||||
(<any>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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as common from "./image-cache-common";
|
||||
import * as trace from "../../trace";
|
||||
// imported for definition purposes only
|
||||
import * as httpRequestModule from "../../http/http-request";
|
||||
|
||||
import * as common from "./image-cache-common";
|
||||
import * as trace from "../../trace";
|
||||
import * as utils from "../../utils/utils";
|
||||
import getter = utils.ios.getter;
|
||||
|
||||
var httpRequest: typeof httpRequestModule;
|
||||
function ensureHttpRequest() {
|
||||
@@ -12,18 +12,6 @@ function ensureHttpRequest() {
|
||||
}
|
||||
}
|
||||
|
||||
//class NSCacheDelegateImpl extends NSObject implements NSCacheDelegate {
|
||||
// public static ObjCProtocols = [NSCacheDelegate];
|
||||
|
||||
// static new(): NSCacheDelegateImpl {
|
||||
// return <NSCacheDelegateImpl>super.new();
|
||||
// }
|
||||
|
||||
// public cacheWillEvictObject(cache: NSCache, obj: any): void {
|
||||
// traceWrite("NSCacheDelegateImpl.cacheWillEvictObject(" + obj + ");", traceCategories.Debug);
|
||||
// }
|
||||
//}
|
||||
|
||||
class MemmoryWarningHandler extends NSObject {
|
||||
static new(): MemmoryWarningHandler {
|
||||
return <MemmoryWarningHandler>super.new();
|
||||
@@ -34,7 +22,7 @@ class MemmoryWarningHandler extends NSObject {
|
||||
public initWithCache(cache: NSCache<any, any>): MemmoryWarningHandler {
|
||||
this._cache = cache;
|
||||
|
||||
getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||
NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||
if (trace.isEnabled()) {
|
||||
trace.write("[MemmoryWarningHandler] Added low memory observer.", trace.categories.Debug);
|
||||
}
|
||||
@@ -43,7 +31,7 @@ class MemmoryWarningHandler extends NSObject {
|
||||
}
|
||||
|
||||
public dealloc(): void {
|
||||
getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||
NSNotificationCenter.defaultCenter.removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||
if (trace.isEnabled()) {
|
||||
trace.write("[MemmoryWarningHandler] Removed low memory observer.", trace.categories.Debug);
|
||||
}
|
||||
@@ -65,7 +53,6 @@ class MemmoryWarningHandler extends NSObject {
|
||||
|
||||
export class Cache extends common.Cache {
|
||||
private _cache: NSCache<any, any>;
|
||||
//private _delegate: NSCacheDelegate;
|
||||
//@ts-ignore
|
||||
private _memoryWarningHandler: MemmoryWarningHandler;
|
||||
|
||||
@@ -74,9 +61,6 @@ export class Cache extends common.Cache {
|
||||
|
||||
this._cache = new NSCache<any, any>();
|
||||
|
||||
//this._delegate = NSCacheDelegateImpl.new();
|
||||
//this._cache.delegate = this._delegate;
|
||||
|
||||
this._memoryWarningHandler = MemmoryWarningHandler.new().initWithCache(this._cache);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(<any>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);
|
||||
}
|
||||
|
||||
@@ -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(<any>components);
|
||||
return NSCalendar.currentCalendar.dateFromComponents(<any>components);
|
||||
}
|
||||
|
||||
function getComponents(date: Date | NSDate): NSDateComponents {
|
||||
return getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, <any>date);
|
||||
return NSCalendar.currentCalendar.componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, <any>date);
|
||||
}
|
||||
|
||||
export class TimePicker extends TimePickerBase {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
2
tns-core-modules/utils/utils.d.ts
vendored
2
tns-core-modules/utils/utils.d.ts
vendored
@@ -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.
|
||||
|
||||
@@ -46,6 +46,7 @@ export module layout {
|
||||
|
||||
export module ios {
|
||||
export function getter<T>(_this: any, property: T | { (): T }): T {
|
||||
console.log("utils.ios.getter() is deprecated; use the respective native property instead");
|
||||
if (typeof property === "function") {
|
||||
return (<{ (): T }>property).call(_this);
|
||||
} else {
|
||||
@@ -72,13 +73,13 @@ export module ios {
|
||||
}
|
||||
|
||||
export function isLandscape(): boolean {
|
||||
const device = getter(UIDevice, UIDevice.currentDevice);
|
||||
const statusBarOrientation = getter(UIApplication, UIApplication.sharedApplication).statusBarOrientation;
|
||||
const device = UIDevice.currentDevice;
|
||||
const statusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
|
||||
const isStatusBarOrientationLandscape = isOrientationLandscape(statusBarOrientation);
|
||||
return isOrientationLandscape(device.orientation) || isStatusBarOrientationLandscape;
|
||||
}
|
||||
|
||||
export var MajorVersion = NSString.stringWithString(getter(UIDevice, UIDevice.currentDevice).systemVersion).intValue;
|
||||
export var MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
|
||||
|
||||
export function openFile(filePath: string): boolean {
|
||||
try {
|
||||
@@ -147,8 +148,8 @@ export function releaseNativeObject(object: NSObject) {
|
||||
export function openUrl(location: string): boolean {
|
||||
try {
|
||||
var url = NSURL.URLWithString(location.trim());
|
||||
if (ios.getter(UIApplication, UIApplication.sharedApplication).canOpenURL(url)) {
|
||||
return ios.getter(UIApplication, UIApplication.sharedApplication).openURL(url);
|
||||
if (UIApplication.sharedApplication.canOpenURL(url)) {
|
||||
return UIApplication.sharedApplication.openURL(url);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
@@ -162,7 +163,7 @@ class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UI
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
|
||||
public getViewController(): UIViewController {
|
||||
const app = ios.getter(UIApplication, UIApplication.sharedApplication);
|
||||
const app = UIApplication.sharedApplication;
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
|
||||
@@ -179,4 +180,4 @@ class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UI
|
||||
}
|
||||
}
|
||||
|
||||
mainScreenScale = ios.getter(UIScreen, UIScreen.mainScreen).scale;
|
||||
mainScreenScale = UIScreen.mainScreen.scale;
|
||||
|
||||
Reference in New Issue
Block a user