mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Apply getter check to determine if API is exposed as property or as method for iOS backward compatibility
This commit is contained in:
@ -15,6 +15,9 @@ import timer = require("timer");
|
|||||||
import trace = require("trace");
|
import trace = require("trace");
|
||||||
import types = require("utils/types");
|
import types = require("utils/types");
|
||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
var sdkVersion = parseInt(platform.device.sdkVersion);
|
var sdkVersion = parseInt(platform.device.sdkVersion);
|
||||||
|
|
||||||
trace.enable();
|
trace.enable();
|
||||||
@ -377,7 +380,8 @@ export var waitUntilReady = function (isReady: () => boolean, timeoutSec?: numbe
|
|||||||
var waitTime = 20 / 1000;
|
var waitTime = 20 / 1000;
|
||||||
var totalWaitTime = 0;
|
var totalWaitTime = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
NSRunLoop.currentRunLoop().runUntilDate(<any>NSDate.dateWithTimeIntervalSinceNow(waitTime));
|
utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop).runUntilDate(<any>NSDate.dateWithTimeIntervalSinceNow(waitTime));
|
||||||
|
|
||||||
if (isReady()) {
|
if (isReady()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ import app = require("application");
|
|||||||
import TKUnit = require("./TKUnit");
|
import TKUnit = require("./TKUnit");
|
||||||
import commonTests = require("./application-tests-common");
|
import commonTests = require("./application-tests-common");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
global.moduleMerge(commonTests, exports);
|
global.moduleMerge(commonTests, exports);
|
||||||
|
|
||||||
// >> application-ios-observer
|
// >> application-ios-observer
|
||||||
@ -10,7 +13,7 @@ global.moduleMerge(commonTests, exports);
|
|||||||
if (app.ios) {
|
if (app.ios) {
|
||||||
var observer = app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
|
var observer = app.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification,
|
||||||
function onReceiveCallback(notification: NSNotification) {
|
function onReceiveCallback(notification: NSNotification) {
|
||||||
var percent = UIDevice.currentDevice().batteryLevel * 100;
|
var percent = getter(UIDevice, UIDevice.currentDevice).batteryLevel * 100;
|
||||||
var message = "Battery: " + percent + "%";
|
var message = "Battery: " + percent + "%";
|
||||||
////console.log(message);
|
////console.log(message);
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,8 @@ import buttons = require("ui/button");
|
|||||||
import app = require("application");
|
import app = require("application");
|
||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
function printDeviceInfoAndroid() {
|
function printDeviceInfoAndroid() {
|
||||||
console.log("android.os.Build.DEVICE = " + android.os.Build.DEVICE); //android.os.Build.DEVICE = hammerhead
|
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
|
console.log("android.os.Build.VERSION.SDK = " + android.os.Build.VERSION.SDK); //android.os.Build.VERSION.SDK = 19
|
||||||
@ -27,7 +29,7 @@ function printDeviceInfoAndroid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function printDeviceInfoIOS() {
|
function printDeviceInfoIOS() {
|
||||||
var device = UIDevice.currentDevice();
|
var device = utils.ios.getter(UIDevice, UIDevice.currentDevice);
|
||||||
console.log("device.name = " + device.name); //device.name = iPhone Simulator
|
console.log("device.name = " + device.name); //device.name = iPhone Simulator
|
||||||
console.log("device.systemName = " + device.systemName); //device.systemName = iPhone OS
|
console.log("device.systemName = " + device.systemName); //device.systemName = iPhone OS
|
||||||
console.log("device.systemVersion = " + device.systemVersion); //device.systemVersion = 8.1
|
console.log("device.systemVersion = " + device.systemVersion); //device.systemVersion = 8.1
|
||||||
@ -35,7 +37,7 @@ function printDeviceInfoIOS() {
|
|||||||
console.log("device.localizedModel = " + device.localizedModel); //device.localizedModel = iPhone Simulator
|
console.log("device.localizedModel = " + device.localizedModel); //device.localizedModel = iPhone Simulator
|
||||||
console.log("device.userInterfaceIdiom = " + device.userInterfaceIdiom); //device.userInterfaceIdiom = 0
|
console.log("device.userInterfaceIdiom = " + device.userInterfaceIdiom); //device.userInterfaceIdiom = 0
|
||||||
console.log("device.batteryLevel = " + device.batteryLevel); //device.batteryLevel = -1
|
console.log("device.batteryLevel = " + device.batteryLevel); //device.batteryLevel = -1
|
||||||
var screen = UIScreen.mainScreen();
|
var screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
|
||||||
console.log("screen = " + screen);
|
console.log("screen = " + screen);
|
||||||
console.log("screen.nativeBounds = " + screen.nativeBounds.size.width + ", " + screen.nativeBounds.size.height); //screen.nativeBounds = 640, 1136
|
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
|
console.log("screen.scale = " + screen.scale); //screen.scale = 2
|
||||||
|
@ -112,7 +112,9 @@ var testsWithLongDelay = {
|
|||||||
testLoadExistingUrl: 10000 * 5,
|
testLoadExistingUrl: 10000 * 5,
|
||||||
testLoadLocalFile: 10000 * 5,
|
testLoadLocalFile: 10000 * 5,
|
||||||
testLoadInvalidUrl: 10000,
|
testLoadInvalidUrl: 10000,
|
||||||
testLoadUpperCaseSrc: 10000 * 5
|
testLoadUpperCaseSrc: 10000 * 5,
|
||||||
|
test_SettingImageSrc: 30 * 1000,
|
||||||
|
test_ChainingAnimations: 30 * 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
var startTime;
|
var startTime;
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import datePickerModule = require("ui/date-picker");
|
import datePickerModule = require("ui/date-picker");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
export function getNativeYear(datePicker: datePickerModule.DatePicker): number {
|
export function getNativeYear(datePicker: datePickerModule.DatePicker): number {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).year;
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).year;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeMonth(datePicker: datePickerModule.DatePicker): number {
|
export function getNativeMonth(datePicker: datePickerModule.DatePicker): number {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).month;
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).month;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeDay(datePicker: datePickerModule.DatePicker): number {
|
export function getNativeDay(datePicker: datePickerModule.DatePicker): number {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).day;
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date).day;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeMaxDate(datePicker: datePickerModule.DatePicker): Date {
|
export function getNativeMaxDate(datePicker: datePickerModule.DatePicker): Date {
|
||||||
@ -21,31 +23,31 @@ export function getNativeMinDate(datePicker: datePickerModule.DatePicker): Date
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeYear(datePicker: datePickerModule.DatePicker, value: number): void {
|
export function setNativeYear(datePicker: datePickerModule.DatePicker, value: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
||||||
comps.year = value;
|
comps.year = value;
|
||||||
datePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeMonth(datePicker: datePickerModule.DatePicker, value: number): void {
|
export function setNativeMonth(datePicker: datePickerModule.DatePicker, value: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
||||||
comps.month = value;
|
comps.month = value;
|
||||||
datePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeDay(datePicker: datePickerModule.DatePicker, value: number): void {
|
export function setNativeDay(datePicker: datePickerModule.DatePicker, value: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
||||||
comps.day = value;
|
comps.day = value;
|
||||||
datePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeDate(datePicker: datePickerModule.DatePicker, year: number, month: number, day: number): void {
|
export function setNativeDate(datePicker: datePickerModule.DatePicker, year: number, month: number, day: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, datePicker.ios.date);
|
||||||
comps.year = year;
|
comps.year = year;
|
||||||
comps.month = month;
|
comps.month = month;
|
||||||
comps.day = day;
|
comps.day = day;
|
||||||
datePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
datePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
(<any>datePicker)._changeHandler.valueChanged(datePicker.ios);
|
||||||
}
|
}
|
@ -1,32 +1,34 @@
|
|||||||
import timePickerModule = require("ui/time-picker");
|
import timePickerModule = require("ui/time-picker");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
export function getNativeHour(timePicker: timePickerModule.TimePicker): number {
|
export function getNativeHour(timePicker: timePickerModule.TimePicker): number {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).hour;
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeMinute(timePicker: timePickerModule.TimePicker): number {
|
export function getNativeMinute(timePicker: timePickerModule.TimePicker): number {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).minute;
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date).minute;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeHour(timePicker: timePickerModule.TimePicker, value: number): void {
|
export function setNativeHour(timePicker: timePickerModule.TimePicker, value: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
||||||
comps.hour = value;
|
comps.hour = value;
|
||||||
timePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeMinute(timePicker: timePickerModule.TimePicker, value: number): void {
|
export function setNativeMinute(timePicker: timePickerModule.TimePicker, value: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
||||||
comps.minute = value;
|
comps.minute = value;
|
||||||
timePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNativeTime(timePicker: timePickerModule.TimePicker, hour: number, minute: number): void {
|
export function setNativeTime(timePicker: timePickerModule.TimePicker, hour: number, minute: number): void {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, timePicker.ios.date);
|
||||||
comps.hour = hour;
|
comps.hour = hour;
|
||||||
comps.minute = minute;
|
comps.minute = minute;
|
||||||
timePicker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
timePicker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
(<any>timePicker)._changeHandler.valueChanged(timePicker.ios);
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ export function checkNativeBackgroundColor(v: view.View): boolean {
|
|||||||
if (v.ios instanceof UILabel) {
|
if (v.ios instanceof UILabel) {
|
||||||
var cgColor1 = (<UILabel>v.ios).layer.backgroundColor;
|
var cgColor1 = (<UILabel>v.ios).layer.backgroundColor;
|
||||||
var cgColor2 = (<UIColor>v.backgroundColor.ios).CGColor;
|
var cgColor2 = (<UIColor>v.backgroundColor.ios).CGColor;
|
||||||
return v.backgroundColor && CGColorEqualToColor(cgColor1, cgColor2);
|
return v.backgroundColor && !!CGColorEqualToColor(cgColor1, cgColor2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.backgroundColor && (<UIView>v.ios).backgroundColor.isEqual(v.backgroundColor.ios);
|
return v.backgroundColor && (<UIView>v.ios).backgroundColor.isEqual(v.backgroundColor.ios);
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import Common = require("./application-settings-common");
|
import Common = require("./application-settings-common");
|
||||||
|
|
||||||
var userDefaults = NSUserDefaults.standardUserDefaults();
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
|
var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
|
||||||
|
|
||||||
export var hasKey = function (key: string): boolean {
|
export var hasKey = function (key: string): boolean {
|
||||||
Common.checkKey(key);
|
Common.checkKey(key);
|
||||||
return userDefaults.objectForKey(key) !== null;
|
return userDefaults.objectForKey(key) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getters
|
// utils.ios.getters
|
||||||
export var getBoolean = function (key: string, defaultValue?: boolean): boolean {
|
export var getBoolean = function (key: string, defaultValue?: boolean): boolean {
|
||||||
Common.checkKey(key);
|
Common.checkKey(key);
|
||||||
if (hasKey(key)) {
|
if (hasKey(key)) {
|
||||||
@ -61,5 +63,5 @@ export var remove = function (key: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var clear = function (): void {
|
export var clear = function (): void {
|
||||||
userDefaults.removePersistentDomainForName(NSBundle.mainBundle().bundleIdentifier);
|
userDefaults.removePersistentDomainForName(utils.ios.getter(NSBundle, NSBundle.mainBundle).bundleIdentifier);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import * as uiUtils from "ui/utils";
|
|||||||
import * as typesModule from "utils/types";
|
import * as typesModule from "utils/types";
|
||||||
import * as enumsModule from "ui/enums";
|
import * as enumsModule from "ui/enums";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
var typedExports: typeof definition = exports;
|
var typedExports: typeof definition = exports;
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ class Window extends UIWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public layoutSubviews(): void {
|
public layoutSubviews(): void {
|
||||||
uiUtils.ios._layoutRootView(this._content, UIScreen.mainScreen().bounds);
|
uiUtils.ios._layoutRootView(this._content, utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
public rootController: any;
|
public rootController: any;
|
||||||
|
|
||||||
private _delegate: typeof UIApplicationDelegate;
|
private _delegate: typeof UIApplicationDelegate;
|
||||||
private _currentOrientation = UIDevice.currentDevice().orientation;
|
private _currentOrientation = utils.ios.getter(UIDevice, UIDevice.currentDevice).orientation;
|
||||||
private _window: Window;
|
private _window: Window;
|
||||||
private _observers: Array<NotificationObserver>;
|
private _observers: Array<NotificationObserver>;
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get nativeApp(): UIApplication {
|
get nativeApp(): UIApplication {
|
||||||
return UIApplication.sharedApplication();
|
return utils.ios.getter(UIApplication, UIApplication.sharedApplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
get delegate(): typeof UIApplicationDelegate {
|
get delegate(): typeof UIApplicationDelegate {
|
||||||
@ -90,7 +92,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
|
|
||||||
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
||||||
var observer = NotificationObserver.new().initWithCallback(onReceiveCallback);
|
var observer = NotificationObserver.new().initWithCallback(onReceiveCallback);
|
||||||
NSNotificationCenter.defaultCenter().addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
|
utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
|
||||||
this._observers.push(observer);
|
this._observers.push(observer);
|
||||||
return observer;
|
return observer;
|
||||||
}
|
}
|
||||||
@ -99,13 +101,13 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
var index = this._observers.indexOf(observer);
|
var index = this._observers.indexOf(observer);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
this._observers.splice(index, 1);
|
this._observers.splice(index, 1);
|
||||||
NSNotificationCenter.defaultCenter().removeObserverNameObject(observer, notificationName, null);
|
utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(observer, notificationName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private didFinishLaunchingWithOptions(notification: NSNotification) {
|
private didFinishLaunchingWithOptions(notification: NSNotification) {
|
||||||
this._window = <Window>Window.alloc().initWithFrame(UIScreen.mainScreen().bounds);
|
this._window = <Window>Window.alloc().initWithFrame(utils.ios.getter(UIScreen, UIScreen.mainScreen).bounds);
|
||||||
this._window.backgroundColor = UIColor.whiteColor();
|
this._window.backgroundColor = utils.ios.getter(UIColor, UIColor.whiteColor);
|
||||||
|
|
||||||
if (typedExports.onLaunch) {
|
if (typedExports.onLaunch) {
|
||||||
typedExports.onLaunch(undefined);
|
typedExports.onLaunch(undefined);
|
||||||
@ -165,7 +167,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
typedExports.onResume();
|
typedExports.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedExports.notify({ eventName: typedExports.resumeEvent, object: this, ios: UIApplication.sharedApplication() });
|
typedExports.notify({ eventName: typedExports.resumeEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||||
}
|
}
|
||||||
|
|
||||||
private didEnterBackground(notification: NSNotification) {
|
private didEnterBackground(notification: NSNotification) {
|
||||||
@ -173,7 +175,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
typedExports.onSuspend();
|
typedExports.onSuspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedExports.notify({ eventName: typedExports.suspendEvent, object: this, ios: UIApplication.sharedApplication() });
|
typedExports.notify({ eventName: typedExports.suspendEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||||
}
|
}
|
||||||
|
|
||||||
private willTerminate(notification: NSNotification) {
|
private willTerminate(notification: NSNotification) {
|
||||||
@ -181,7 +183,7 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
typedExports.onExit();
|
typedExports.onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedExports.notify({ eventName: typedExports.exitEvent, object: this, ios: UIApplication.sharedApplication() });
|
typedExports.notify({ eventName: typedExports.exitEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||||
}
|
}
|
||||||
|
|
||||||
private didReceiveMemoryWarning(notification: NSNotification) {
|
private didReceiveMemoryWarning(notification: NSNotification) {
|
||||||
@ -189,11 +191,11 @@ class IOSApplication implements definition.iOSApplication {
|
|||||||
typedExports.onLowMemory();
|
typedExports.onLowMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedExports.notify({ eventName: typedExports.lowMemoryEvent, object: this, android: undefined, ios: UIApplication.sharedApplication() });
|
typedExports.notify({ eventName: typedExports.lowMemoryEvent, object: this, android: undefined, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
|
||||||
}
|
}
|
||||||
|
|
||||||
private orientationDidChange(notification: NSNotification) {
|
private orientationDidChange(notification: NSNotification) {
|
||||||
var orientation = UIDevice.currentDevice().orientation;
|
var orientation = utils.ios.getter(UIDevice, UIDevice.currentDevice).orientation;
|
||||||
|
|
||||||
if (this._currentOrientation !== orientation) {
|
if (this._currentOrientation !== orientation) {
|
||||||
this._currentOrientation = orientation;
|
this._currentOrientation = orientation;
|
||||||
|
@ -3,6 +3,8 @@ var inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBacken
|
|||||||
|
|
||||||
import * as debuggerDomains from "./debugger";
|
import * as debuggerDomains from "./debugger";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
declare var __inspectorTimestamp;
|
declare var __inspectorTimestamp;
|
||||||
|
|
||||||
const frameId = "NativeScriptMainFrameIdentifier";
|
const frameId = "NativeScriptMainFrameIdentifier";
|
||||||
@ -212,9 +214,9 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
|
|||||||
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
|
* 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 } {
|
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string, mimeType: string, status: number } {
|
||||||
let appPath = NSBundle.mainBundle().bundlePath;
|
let appPath = utils.ios.getter(NSBundle, NSBundle.mainBundle).bundlePath;
|
||||||
let pathUrl = params.url.replace("file://", appPath);
|
let pathUrl = params.url.replace("file://", appPath);
|
||||||
let fileManager = NSFileManager.defaultManager();
|
let fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
|
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
|
||||||
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : "";
|
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : "";
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import textModule = require("text");
|
import textModule = require("text");
|
||||||
import * as utilsModule from "utils/utils";
|
import * as utilsModule from "utils/utils";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
// TODO: Implement all the APIs receiving callback using async blocks
|
// TODO: Implement all the APIs receiving callback using async blocks
|
||||||
// TODO: Check whether we need try/catch blocks for the iOS implementation
|
// TODO: Check whether we need try/catch blocks for the iOS implementation
|
||||||
export class FileSystemAccess {
|
export class FileSystemAccess {
|
||||||
|
|
||||||
public getLastModified(path: string): Date {
|
public getLastModified(path: string): Date {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var attributes = fileManager.attributesOfItemAtPathError(path);
|
var attributes = fileManager.attributesOfItemAtPathError(path);
|
||||||
|
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
@ -18,7 +20,7 @@ export class FileSystemAccess {
|
|||||||
|
|
||||||
public getParent(path: string, onError?: (error: any) => any): { path: string; name: string } {
|
public getParent(path: string, onError?: (error: any) => any): { path: string; name: string } {
|
||||||
try {
|
try {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var nsString = NSString.stringWithString(path);
|
var nsString = NSString.stringWithString(path);
|
||||||
|
|
||||||
var parentPath = nsString.stringByDeletingLastPathComponent;
|
var parentPath = nsString.stringByDeletingLastPathComponent;
|
||||||
@ -40,7 +42,7 @@ export class FileSystemAccess {
|
|||||||
|
|
||||||
public getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string } {
|
public getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string } {
|
||||||
try {
|
try {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var exists = fileManager.fileExistsAtPath(path);
|
var exists = fileManager.fileExistsAtPath(path);
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
@ -73,7 +75,7 @@ export class FileSystemAccess {
|
|||||||
|
|
||||||
public getFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
|
public getFolder(path: string, onError?: (error: any) => any): { path: string; name: string } {
|
||||||
try {
|
try {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var exists = this.folderExists(path);
|
var exists = this.folderExists(path);
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
@ -150,7 +152,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private exists(path: string): { exists: boolean, isDirectory: boolean } {
|
private exists(path: string): { exists: boolean, isDirectory: boolean } {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var isDirectory = new interop.Reference(interop.types.bool, false);
|
var isDirectory = new interop.Reference(interop.types.bool, false);
|
||||||
var exists = fileManager.fileExistsAtPathIsDirectory(path, isDirectory);
|
var exists = fileManager.fileExistsAtPathIsDirectory(path, isDirectory);
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public emptyFolder(path: string, onError?: (error: any) => any) {
|
public emptyFolder(path: string, onError?: (error: any) => any) {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var entities = this.getEntities(path, onError);
|
var entities = this.getEntities(path, onError);
|
||||||
|
|
||||||
if (!entities) {
|
if (!entities) {
|
||||||
@ -199,7 +201,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public rename(path: string, newPath: string, onError?: (error: any) => any) {
|
public rename(path: string, newPath: string, onError?: (error: any) => any) {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileManager.moveItemAtPathToPathError(path, newPath);
|
fileManager.moveItemAtPathToPathError(path, newPath);
|
||||||
@ -212,7 +214,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getLogicalRootPath(): string {
|
public getLogicalRootPath(): string {
|
||||||
let mainBundlePath = NSBundle.mainBundle().bundlePath;
|
let mainBundlePath = utils.ios.getter(NSBundle, NSBundle.mainBundle).bundlePath;
|
||||||
let resolvedPath = NSString.stringWithString(mainBundlePath).stringByResolvingSymlinksInPath;
|
let resolvedPath = NSString.stringWithString(mainBundlePath).stringByResolvingSymlinksInPath;
|
||||||
return resolvedPath;
|
return resolvedPath;
|
||||||
}
|
}
|
||||||
@ -298,7 +300,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getKnownPath(folderType: number): string {
|
private getKnownPath(folderType: number): string {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
var paths = fileManager.URLsForDirectoryInDomains(folderType, NSSearchPathDomainMask.UserDomainMask);
|
var paths = fileManager.URLsForDirectoryInDomains(folderType, NSSearchPathDomainMask.UserDomainMask);
|
||||||
|
|
||||||
var url = paths.objectAtIndex(0);
|
var url = paths.objectAtIndex(0);
|
||||||
@ -326,7 +328,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private deleteEntity(path: string, onError?: (error: any) => any) {
|
private deleteEntity(path: string, onError?: (error: any) => any) {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
try {
|
try {
|
||||||
fileManager.removeItemAtPathError(path);
|
fileManager.removeItemAtPathError(path);
|
||||||
}
|
}
|
||||||
@ -339,7 +341,7 @@ export class FileSystemAccess {
|
|||||||
|
|
||||||
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
|
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
|
||||||
try {
|
try {
|
||||||
var fileManager = NSFileManager.defaultManager();
|
var fileManager = utils.ios.getter(NSFileManager, NSFileManager.defaultManager);
|
||||||
try {
|
try {
|
||||||
var files = fileManager.contentsOfDirectoryAtPathError(path);
|
var files = fileManager.contentsOfDirectoryAtPathError(path);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import definition = require("fps-meter/fps-native");
|
import definition = require("fps-meter/fps-native");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
class FrameHandlerImpl extends NSObject {
|
class FrameHandlerImpl extends NSObject {
|
||||||
|
|
||||||
private _owner: WeakRef<FPSCallback>;
|
private _owner: WeakRef<FPSCallback>;
|
||||||
@ -35,10 +37,10 @@ export class FPSCallback implements definition.FPSCallback {
|
|||||||
|
|
||||||
this.displayLink = CADisplayLink.displayLinkWithTargetSelector(this.impl, "handleFrame");
|
this.displayLink = CADisplayLink.displayLinkWithTargetSelector(this.impl, "handleFrame");
|
||||||
this.displayLink.paused = true;
|
this.displayLink.paused = true;
|
||||||
this.displayLink.addToRunLoopForMode(NSRunLoop.currentRunLoop(), NSDefaultRunLoopMode);
|
this.displayLink.addToRunLoopForMode(utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop), NSDefaultRunLoopMode);
|
||||||
// UIScrollView (including in UIITableView) will run a loop in UITrackingRunLoopMode during scrolling.
|
// 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.
|
// If we do not add the CADisplayLink in this mode, it would appear paused during scrolling.
|
||||||
this.displayLink.addToRunLoopForMode(NSRunLoop.currentRunLoop(), UITrackingRunLoopMode);
|
this.displayLink.addToRunLoopForMode(utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop), UITrackingRunLoopMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public start() {
|
public start() {
|
||||||
|
@ -6,25 +6,20 @@ import http = require("http");
|
|||||||
|
|
||||||
import * as types from "utils/types";
|
import * as types from "utils/types";
|
||||||
import * as imageSourceModule from "image-source";
|
import * as imageSourceModule from "image-source";
|
||||||
import * as utilsModule from "utils/utils";
|
|
||||||
import * as fsModule from "file-system";
|
import * as fsModule from "file-system";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
import domainDebugger = require("./../debugger/debugger");
|
import domainDebugger = require("./../debugger/debugger");
|
||||||
|
|
||||||
var GET = "GET";
|
var GET = "GET";
|
||||||
var USER_AGENT_HEADER = "User-Agent";
|
var USER_AGENT_HEADER = "User-Agent";
|
||||||
var USER_AGENT = "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25";
|
var USER_AGENT = "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25";
|
||||||
var sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration();
|
var sessionConfig = getter(NSURLSessionConfiguration, NSURLSessionConfiguration.defaultSessionConfiguration);
|
||||||
var queue = NSOperationQueue.mainQueue();
|
var queue = getter(NSOperationQueue, NSOperationQueue.mainQueue);
|
||||||
var session = NSURLSession.sessionWithConfigurationDelegateDelegateQueue(sessionConfig, null, queue);
|
var session = NSURLSession.sessionWithConfigurationDelegateDelegateQueue(sessionConfig, null, queue);
|
||||||
|
|
||||||
var utils: typeof utilsModule;
|
|
||||||
function ensureUtils() {
|
|
||||||
if (!utils) {
|
|
||||||
utils = require("utils/utils");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var imageSource: typeof imageSourceModule;
|
var imageSource: typeof imageSourceModule;
|
||||||
function ensureImageSource() {
|
function ensureImageSource() {
|
||||||
if (!imageSource) {
|
if (!imageSource) {
|
||||||
@ -93,7 +88,6 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
|||||||
raw: data,
|
raw: data,
|
||||||
toString: () => { return NSDataToString(data); },
|
toString: () => { return NSDataToString(data); },
|
||||||
toJSON: () => {
|
toJSON: () => {
|
||||||
ensureUtils();
|
|
||||||
return utils.parseJSON(NSDataToString(data));
|
return utils.parseJSON(NSDataToString(data));
|
||||||
},
|
},
|
||||||
toImage: () => {
|
toImage: () => {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* tslint:disable:class-name */
|
/* tslint:disable:class-name */
|
||||||
import definition = require("platform");
|
import definition = require("platform");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
export module platformNames {
|
export module platformNames {
|
||||||
export var android = "Android";
|
export var android = "Android";
|
||||||
export var ios = "iOS";
|
export var ios = "iOS";
|
||||||
@ -24,7 +26,7 @@ class Device implements definition.Device {
|
|||||||
|
|
||||||
get osVersion(): string {
|
get osVersion(): string {
|
||||||
if (!this._osVersion) {
|
if (!this._osVersion) {
|
||||||
this._osVersion = UIDevice.currentDevice().systemVersion;
|
this._osVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._osVersion;
|
return this._osVersion;
|
||||||
@ -32,7 +34,7 @@ class Device implements definition.Device {
|
|||||||
|
|
||||||
get model(): string {
|
get model(): string {
|
||||||
if (!this._model) {
|
if (!this._model) {
|
||||||
this._model = UIDevice.currentDevice().model;
|
this._model = utils.ios.getter(UIDevice, UIDevice.currentDevice).model;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._model;
|
return this._model;
|
||||||
@ -40,7 +42,7 @@ class Device implements definition.Device {
|
|||||||
|
|
||||||
get sdkVersion(): string {
|
get sdkVersion(): string {
|
||||||
if (!this._sdkVersion) {
|
if (!this._sdkVersion) {
|
||||||
this._sdkVersion = UIDevice.currentDevice().systemVersion;
|
this._sdkVersion = utils.ios.getter(UIDevice, UIDevice.currentDevice).systemVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._sdkVersion;
|
return this._sdkVersion;
|
||||||
@ -50,7 +52,7 @@ class Device implements definition.Device {
|
|||||||
if (!this._deviceType) {
|
if (!this._deviceType) {
|
||||||
var enums = require("ui/enums");
|
var enums = require("ui/enums");
|
||||||
|
|
||||||
if (UIDevice.currentDevice().userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
|
if (utils.ios.getter(UIDevice, UIDevice.currentDevice).userInterfaceIdiom === UIUserInterfaceIdiom.Phone) {
|
||||||
this._deviceType = enums.DeviceType.Phone;
|
this._deviceType = enums.DeviceType.Phone;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -62,7 +64,7 @@ class Device implements definition.Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get uuid(): string {
|
get uuid(): string {
|
||||||
var userDefaults = NSUserDefaults.standardUserDefaults();
|
var userDefaults = utils.ios.getter(NSUserDefaults, NSUserDefaults.standardUserDefaults);
|
||||||
var uuid_key = "TNSUUID";
|
var uuid_key = "TNSUUID";
|
||||||
var app_uuid = userDefaults.stringForKey(uuid_key);
|
var app_uuid = userDefaults.stringForKey(uuid_key);
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ class Device implements definition.Device {
|
|||||||
|
|
||||||
get language(): string {
|
get language(): string {
|
||||||
if (!this._language) {
|
if (!this._language) {
|
||||||
var languages = NSLocale.preferredLanguages();
|
var languages = utils.ios.getter(NSLocale, NSLocale.preferredLanguages);
|
||||||
this._language = languages[0];
|
this._language = languages[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ class Device implements definition.Device {
|
|||||||
|
|
||||||
get region(): string {
|
get region(): string {
|
||||||
if(!this._region) {
|
if(!this._region) {
|
||||||
this._region = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode);
|
this._region = utils.ios.getter(NSLocale, NSLocale.currentLocale).objectForKey(NSLocaleCountryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._region;
|
return this._region;
|
||||||
@ -98,7 +100,7 @@ class MainScreen implements definition.ScreenMetrics {
|
|||||||
private _screen: UIScreen;
|
private _screen: UIScreen;
|
||||||
private get screen(): UIScreen {
|
private get screen(): UIScreen {
|
||||||
if (!this._screen) {
|
if (!this._screen) {
|
||||||
this._screen = UIScreen.mainScreen();
|
this._screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._screen;
|
return this._screen;
|
||||||
|
@ -2,6 +2,8 @@ import spanCommon = require("./span-common");
|
|||||||
import enums = require("ui/enums");
|
import enums = require("ui/enums");
|
||||||
import formattedString = require("text/formatted-string");
|
import formattedString = require("text/formatted-string");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(spanCommon, exports);
|
global.moduleMerge(spanCommon, exports);
|
||||||
|
|
||||||
export class Span extends spanCommon.Span {
|
export class Span extends spanCommon.Span {
|
||||||
@ -16,7 +18,7 @@ export class Span extends spanCommon.Span {
|
|||||||
if (realFontAttributes || realFontFamily || realFontSize) {
|
if (realFontAttributes || realFontFamily || realFontSize) {
|
||||||
var font;
|
var font;
|
||||||
if (!realFontSize) {
|
if (!realFontSize) {
|
||||||
realFontSize = UIFont.systemFontSize();
|
realFontSize = utils.ios.getter(UIFont, UIFont.systemFontSize);
|
||||||
}
|
}
|
||||||
if (realFontFamily) {
|
if (realFontFamily) {
|
||||||
font = UIFont.fontWithNameSize(realFontFamily, realFontSize);
|
font = UIFont.fontWithNameSize(realFontFamily, realFontSize);
|
||||||
|
@ -6,6 +6,8 @@ import enums = require("ui/enums");
|
|||||||
import style = require("ui/styling/style");
|
import style = require("ui/styling/style");
|
||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
|
||||||
let _transform = "_transform";
|
let _transform = "_transform";
|
||||||
@ -239,7 +241,7 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
};
|
};
|
||||||
originalValue = nativeView.layer.backgroundColor;
|
originalValue = nativeView.layer.backgroundColor;
|
||||||
if (nativeView instanceof UILabel) {
|
if (nativeView instanceof UILabel) {
|
||||||
nativeView.setValueForKey(UIColor.clearColor(), "backgroundColor");
|
nativeView.setValueForKey(utils.ios.getter(UIColor, UIColor.clearColor), "backgroundColor");
|
||||||
}
|
}
|
||||||
value = value.CGColor;
|
value = value.CGColor;
|
||||||
break;
|
break;
|
||||||
|
@ -4,11 +4,13 @@ import proxy = require("ui/core/proxy");
|
|||||||
import style = require("ui/styling/style");
|
import style = require("ui/styling/style");
|
||||||
import view = require("ui/core/view");
|
import view = require("ui/core/view");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
function onYearPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
function onYearPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
var picker = <DatePicker>data.object;
|
var picker = <DatePicker>data.object;
|
||||||
|
|
||||||
if (picker.ios) {
|
if (picker.ios) {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
||||||
comps.year = data.newValue;
|
comps.year = data.newValue;
|
||||||
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||||
}
|
}
|
||||||
@ -20,7 +22,7 @@ function onMonthPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
|||||||
var picker = <DatePicker>data.object;
|
var picker = <DatePicker>data.object;
|
||||||
|
|
||||||
if (picker.ios) {
|
if (picker.ios) {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
||||||
comps.month = data.newValue;
|
comps.month = data.newValue;
|
||||||
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||||
}
|
}
|
||||||
@ -32,7 +34,7 @@ function onDayPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
|||||||
var picker = <DatePicker>data.object;
|
var picker = <DatePicker>data.object;
|
||||||
|
|
||||||
if (picker.ios) {
|
if (picker.ios) {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
||||||
comps.day = data.newValue;
|
comps.day = data.newValue;
|
||||||
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
picker.date = new Date(comps.year, comps.month - 1, comps.day);
|
||||||
}
|
}
|
||||||
@ -65,12 +67,12 @@ function onDatePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
|||||||
var picker = <DatePicker>data.object;
|
var picker = <DatePicker>data.object;
|
||||||
|
|
||||||
if (picker.ios) {
|
if (picker.ios) {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, picker.ios.date);
|
||||||
let newDate = data.newValue;
|
let newDate = data.newValue;
|
||||||
comps.year = newDate.getFullYear();
|
comps.year = newDate.getFullYear();
|
||||||
comps.month = newDate.getMonth() + 1;
|
comps.month = newDate.getMonth() + 1;
|
||||||
comps.day = newDate.getDate();
|
comps.day = newDate.getDate();
|
||||||
picker.ios.setDateAnimated(NSCalendar.currentCalendar().dateFromComponents(comps), false);
|
picker.ios.setDateAnimated(utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(comps), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ class UIDatePickerChangeHandlerImpl extends NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public valueChanged(sender: UIDatePicker) {
|
public valueChanged(sender: UIDatePicker) {
|
||||||
var comps = NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date);
|
var comps = utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay, sender.date);
|
||||||
|
|
||||||
let owner = this._owner.get();
|
let owner = this._owner.get();
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
import dialogs = require("ui/dialogs");
|
import dialogs = require("ui/dialogs");
|
||||||
import dialogsCommon = require("./dialogs-common");
|
import dialogsCommon = require("./dialogs-common");
|
||||||
import types = require("utils/types");
|
import types = require("utils/types");
|
||||||
import utils = require("utils/utils");
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
global.moduleMerge(dialogsCommon, exports);
|
global.moduleMerge(dialogsCommon, exports);
|
||||||
|
|
||||||
@ -476,7 +478,7 @@ export function action(arg: any): Promise<string> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
actionSheet.delegate = delegate;
|
actionSheet.delegate = delegate;
|
||||||
actionSheet.showInView(UIApplication.sharedApplication().keyWindow);
|
actionSheet.showInView(getter(UIApplication, UIApplication.sharedApplication).keyWindow);
|
||||||
} else {
|
} else {
|
||||||
var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title, options.message, UIAlertControllerStyle.ActionSheet);
|
var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title, options.message, UIAlertControllerStyle.ActionSheet);
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import common = require("./image-cache-common");
|
import common = require("./image-cache-common");
|
||||||
import utils = require("utils/utils");
|
|
||||||
import trace = require("trace");
|
import trace = require("trace");
|
||||||
import * as httpRequestModule from "http/http-request";
|
import * as httpRequestModule from "http/http-request";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
var httpRequest: typeof httpRequestModule;
|
var httpRequest: typeof httpRequestModule;
|
||||||
function ensureHttpRequest() {
|
function ensureHttpRequest() {
|
||||||
if (!httpRequest) {
|
if (!httpRequest) {
|
||||||
@ -32,7 +34,7 @@ class MemmoryWarningHandler extends NSObject {
|
|||||||
public initWithCache(cache: NSCache<any, any>): MemmoryWarningHandler {
|
public initWithCache(cache: NSCache<any, any>): MemmoryWarningHandler {
|
||||||
this._cache = cache;
|
this._cache = cache;
|
||||||
|
|
||||||
NSNotificationCenter.defaultCenter().addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
|
getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||||
if (trace.enabled) {
|
if (trace.enabled) {
|
||||||
trace.write("[MemmoryWarningHandler] Added low memory observer.", trace.categories.Debug);
|
trace.write("[MemmoryWarningHandler] Added low memory observer.", trace.categories.Debug);
|
||||||
}
|
}
|
||||||
@ -41,7 +43,7 @@ class MemmoryWarningHandler extends NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public dealloc(): void {
|
public dealloc(): void {
|
||||||
NSNotificationCenter.defaultCenter().removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
|
getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null);
|
||||||
if (trace.enabled) {
|
if (trace.enabled) {
|
||||||
trace.write("[MemmoryWarningHandler] Removed low memory observer.", trace.categories.Debug);
|
trace.write("[MemmoryWarningHandler] Removed low memory observer.", trace.categories.Debug);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
import {View} from "ui/core/view";
|
import {View} from "ui/core/view";
|
||||||
import trace = require("trace");
|
import trace = require("trace");
|
||||||
import uiUtils = require("ui/utils");
|
import uiUtils = require("ui/utils");
|
||||||
import utils = require("utils/utils");
|
|
||||||
import {device} from "platform";
|
import {device} from "platform";
|
||||||
import {DeviceType} from "ui/enums";
|
import {DeviceType} from "ui/enums";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
global.moduleMerge(pageCommon, exports);
|
global.moduleMerge(pageCommon, exports);
|
||||||
const ENTRY = "_entry";
|
const ENTRY = "_entry";
|
||||||
const DELEGATE = "_delegate";
|
const DELEGATE = "_delegate";
|
||||||
@ -79,7 +81,7 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
if (owner._modalParent) {
|
if (owner._modalParent) {
|
||||||
let isTablet = device.deviceType === DeviceType.Tablet;
|
let isTablet = device.deviceType === DeviceType.Tablet;
|
||||||
let isFullScreen = !owner._UIModalPresentationFormSheet || !isTablet;
|
let isFullScreen = !owner._UIModalPresentationFormSheet || !isTablet;
|
||||||
let frame = isFullScreen ? UIScreen.mainScreen().bounds : this.view.frame;
|
let frame = isFullScreen ? getter(UIScreen, UIScreen.mainScreen).bounds : this.view.frame;
|
||||||
let size = frame.size;
|
let size = frame.size;
|
||||||
let width = size.width;
|
let width = size.width;
|
||||||
let height = size.height;
|
let height = size.height;
|
||||||
@ -99,7 +101,7 @@ class UIViewControllerImpl extends UIViewController {
|
|||||||
|
|
||||||
let bottom = height;
|
let bottom = height;
|
||||||
let statusBarHeight = uiUtils.ios.getStatusBarHeight();
|
let statusBarHeight = uiUtils.ios.getStatusBarHeight();
|
||||||
let statusBarVisible = !UIApplication.sharedApplication().statusBarHidden;
|
let statusBarVisible = !getter(UIApplication, UIApplication.sharedApplication).statusBarHidden;
|
||||||
let backgroundSpanUnderStatusBar = owner.backgroundSpanUnderStatusBar;
|
let backgroundSpanUnderStatusBar = owner.backgroundSpanUnderStatusBar;
|
||||||
if (statusBarVisible && !backgroundSpanUnderStatusBar) {
|
if (statusBarVisible && !backgroundSpanUnderStatusBar) {
|
||||||
height -= statusBarHeight;
|
height -= statusBarHeight;
|
||||||
@ -396,7 +398,7 @@ export class Page extends pageCommon.Page {
|
|||||||
super._raiseShowingModallyEvent();
|
super._raiseShowingModallyEvent();
|
||||||
|
|
||||||
parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 7, null);
|
parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 7, null);
|
||||||
let transitionCoordinator = parent.ios.transitionCoordinator();
|
let transitionCoordinator = getter(parent.ios, parent.ios.transitionCoordinator);
|
||||||
if (transitionCoordinator) {
|
if (transitionCoordinator) {
|
||||||
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(transitionCoordinator, null, () => this._raiseShownModallyEvent());
|
UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(transitionCoordinator, null, () => this._raiseShownModallyEvent());
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import style = require("ui/styling/style");
|
|||||||
import font = require("ui/styling/font");
|
import font = require("ui/styling/font");
|
||||||
import view = require("ui/core/view");
|
import view = require("ui/core/view");
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
|
||||||
var color: typeof colorModule;
|
var color: typeof colorModule;
|
||||||
@ -175,7 +177,7 @@ export class SegmentedBarStyler implements style.Styler {
|
|||||||
else {
|
else {
|
||||||
attrs = NSMutableDictionary.new();
|
attrs = NSMutableDictionary.new();
|
||||||
}
|
}
|
||||||
let newFont = (<font.Font>newValue).getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize()));
|
let newFont = (<font.Font>newValue).getUIFont(UIFont.systemFontOfSize(utils.ios.getter(UIFont, UIFont.labelFontSize)));
|
||||||
attrs.setValueForKey(newFont, NSFontAttributeName);
|
attrs.setValueForKey(newFont, NSFontAttributeName);
|
||||||
bar.setTitleTextAttributesForState(attrs, UIControlState.Normal);
|
bar.setTitleTextAttributesForState(attrs, UIControlState.Normal);
|
||||||
}
|
}
|
||||||
@ -202,7 +204,7 @@ export class SegmentedBarStyler implements style.Styler {
|
|||||||
currentFont = currentAttrs.objectForKey(NSFontAttributeName);
|
currentFont = currentAttrs.objectForKey(NSFontAttributeName);
|
||||||
}
|
}
|
||||||
if (!currentFont) {
|
if (!currentFont) {
|
||||||
currentFont = UIFont.systemFontOfSize(UIFont.labelFontSize());
|
currentFont = UIFont.systemFontOfSize(utils.ios.getter(UIFont, UIFont.labelFontSize));
|
||||||
}
|
}
|
||||||
return currentFont;
|
return currentFont;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ import viewModule = require("ui/core/view");
|
|||||||
import common = require("./background-common");
|
import common = require("./background-common");
|
||||||
import * as styleModule from "./style";
|
import * as styleModule from "./style";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
|
||||||
var style: typeof styleModule;
|
var style: typeof styleModule;
|
||||||
@ -193,7 +195,7 @@ function drawClipPath(view: viewModule.View) {
|
|||||||
borderLayer.path = path;
|
borderLayer.path = path;
|
||||||
borderLayer.lineWidth = view.borderWidth * 2;
|
borderLayer.lineWidth = view.borderWidth * 2;
|
||||||
borderLayer.strokeColor = view.borderColor.ios.CGColor;
|
borderLayer.strokeColor = view.borderColor.ios.CGColor;
|
||||||
borderLayer.fillColor = UIColor.clearColor().CGColor;
|
borderLayer.fillColor = utils.ios.getter(UIColor, UIColor.clearColor).CGColor;
|
||||||
|
|
||||||
borderLayer.frame = nativeView.bounds;
|
borderLayer.frame = nativeView.bounds;
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ import common = require("./font-common");
|
|||||||
import fs = require("file-system");
|
import fs = require("file-system");
|
||||||
import * as traceModule from "trace";
|
import * as traceModule from "trace";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
export class Font extends common.Font {
|
export class Font extends common.Font {
|
||||||
public static default = new Font(undefined, undefined, enums.FontStyle.normal, enums.FontWeight.normal);
|
public static default = new Font(undefined, undefined, enums.FontStyle.normal, enums.FontWeight.normal);
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ export function ensureSystemFontSets() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nsFontFamilies = UIFont.familyNames();
|
var nsFontFamilies = utils.ios.getter(UIFont, UIFont.familyNames);
|
||||||
for (var i = 0; i < nsFontFamilies.count; i++) {
|
for (var i = 0; i < nsFontFamilies.count; i++) {
|
||||||
var family = nsFontFamilies.objectAtIndex(i);
|
var family = nsFontFamilies.objectAtIndex(i);
|
||||||
systemFontFamilies.add(family);
|
systemFontFamilies.add(family);
|
||||||
@ -98,7 +100,7 @@ function createUIFont(font: Font, defaultFont: UIFont) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
descriptor = defaultFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
descriptor = utils.ios.getter(defaultFont, defaultFont.fontDescriptor).fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIFont.fontWithDescriptorSize(descriptor, size);
|
return UIFont.fontWithDescriptorSize(descriptor, size);
|
||||||
@ -115,19 +117,19 @@ function tryResolveWithSystemFont(font: Font, size: number, symbolicTraits: numb
|
|||||||
else {
|
else {
|
||||||
systemFont = UIFont.systemFontOfSize(size);
|
systemFont = UIFont.systemFontOfSize(size);
|
||||||
}
|
}
|
||||||
result = systemFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
result = utils.ios.getter(systemFont, systemFont.fontDescriptor).fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case common.genericFontFamilies.monospace:
|
case common.genericFontFamilies.monospace:
|
||||||
if ((<any>UIFont).monospacedDigitSystemFontOfSizeWeight) {// This method is available on iOS 9.0 and later.
|
if ((<any>UIFont).monospacedDigitSystemFontOfSizeWeight) {// This method is available on iOS 9.0 and later.
|
||||||
systemFont = (<any>UIFont).monospacedDigitSystemFontOfSizeWeight(size, getiOSFontWeight(font.fontWeight));
|
systemFont = (<any>UIFont).monospacedDigitSystemFontOfSizeWeight(size, getiOSFontWeight(font.fontWeight));
|
||||||
result = systemFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
result = utils.ios.getter(systemFont, systemFont.fontDescriptor).fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemFont) {
|
if (systemFont) {
|
||||||
var result = systemFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
|
var result = utils.ios.getter(systemFont, systemFont.fontDescriptor).fontDescriptorWithSymbolicTraits(symbolicTraits);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +293,7 @@ export module ios {
|
|||||||
if (!fs.File.exists(filePath)) {
|
if (!fs.File.exists(filePath)) {
|
||||||
filePath = fs.path.join(fs.knownFolders.currentApp().path, fontFile);
|
filePath = fs.path.join(fs.knownFolders.currentApp().path, fontFile);
|
||||||
}
|
}
|
||||||
var fontData = NSFileManager.defaultManager().contentsAtPath(filePath);
|
var fontData = utils.ios.getter(NSFileManager, NSFileManager.defaultManager).contentsAtPath(filePath);
|
||||||
if (!fontData) {
|
if (!fontData) {
|
||||||
throw new Error("Could not load font from: " + fontFile);
|
throw new Error("Could not load font from: " + fontFile);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import definition = require("ui/tab-view");
|
import definition = require("ui/tab-view");
|
||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
import trace = require("trace");
|
import trace = require("trace");
|
||||||
import utils = require("utils/utils");
|
|
||||||
import view = require("ui/core/view");
|
import view = require("ui/core/view");
|
||||||
import types = require("utils/types");
|
import types = require("utils/types");
|
||||||
import proxy = require("ui/core/proxy");
|
import proxy = require("ui/core/proxy");
|
||||||
@ -11,6 +10,9 @@ import * as imageSourceModule from "image-source";
|
|||||||
import style = require("ui/styling/style");
|
import style = require("ui/styling/style");
|
||||||
import { Page } from "ui/page";
|
import { Page } from "ui/page";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
|
||||||
var imageSource: typeof imageSourceModule;
|
var imageSource: typeof imageSourceModule;
|
||||||
@ -487,7 +489,7 @@ export class TabViewStyler implements style.Styler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currentFont) {
|
if (!currentFont) {
|
||||||
currentFont = UIFont.systemFontOfSize(UIFont.labelFontSize());
|
currentFont = UIFont.systemFontOfSize(getter(UIFont, UIFont.labelFontSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentFont;
|
return currentFont;
|
||||||
|
@ -6,6 +6,8 @@ import {View} from "ui/core/view";
|
|||||||
import * as style from "ui/styling/style";
|
import * as style from "ui/styling/style";
|
||||||
import {isNullOrUndefined} from "utils/types";
|
import {isNullOrUndefined} from "utils/types";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
|
||||||
class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
|
||||||
@ -119,7 +121,7 @@ export class TextView extends common.TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _showHint(hint: string) {
|
public _showHint(hint: string) {
|
||||||
this.ios.textColor = this.ios.textColor ? this.ios.textColor.colorWithAlphaComponent(0.22) : UIColor.blackColor().colorWithAlphaComponent(0.22);
|
this.ios.textColor = this.ios.textColor ? this.ios.textColor.colorWithAlphaComponent(0.22) : utils.ios.getter(UIColor, UIColor.blackColor).colorWithAlphaComponent(0.22);
|
||||||
this.ios.text = isNullOrUndefined(hint) ? "" : hint + "";
|
this.ios.text = isNullOrUndefined(hint) ? "" : hint + "";
|
||||||
(<any>this.ios).isShowingHint = true;
|
(<any>this.ios).isShowingHint = true;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,17 @@
|
|||||||
import style = require("ui/styling/style");
|
import style = require("ui/styling/style");
|
||||||
import {View} from "ui/core/view";
|
import {View} from "ui/core/view";
|
||||||
|
|
||||||
|
import * as utils from "utils/utils";
|
||||||
|
|
||||||
function getDate(hour: number, minute: number): Date {
|
function getDate(hour: number, minute: number): Date {
|
||||||
var comps = NSDateComponents.alloc().init();
|
var comps = NSDateComponents.alloc().init();
|
||||||
comps.hour = hour;
|
comps.hour = hour;
|
||||||
comps.minute = minute;
|
comps.minute = minute;
|
||||||
return NSCalendar.currentCalendar().dateFromComponents(<any>comps);
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).dateFromComponents(<any>comps);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getComponents(date: Date | NSDate): NSDateComponents {
|
function getComponents(date: Date | NSDate): NSDateComponents {
|
||||||
return NSCalendar.currentCalendar().componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, <any>date);
|
return utils.ios.getter(NSCalendar, NSCalendar.currentCalendar).componentsFromDate(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, <any>date);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.moduleMerge(common, exports);
|
global.moduleMerge(common, exports);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {View} from "ui/core/view";
|
import {View} from "ui/core/view";
|
||||||
import * as utils from "utils/utils";
|
import * as utils from "utils/utils";
|
||||||
|
import getter = utils.ios.getter;
|
||||||
|
|
||||||
export module ios {
|
export module ios {
|
||||||
export function getActualHeight(view: UIView): number {
|
export function getActualHeight(view: UIView): number {
|
||||||
@ -11,7 +12,7 @@ export module ios {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getStatusBarHeight(): number {
|
export function getStatusBarHeight(): number {
|
||||||
var app = UIApplication.sharedApplication();
|
var app = getter(UIApplication, UIApplication.sharedApplication);
|
||||||
if (!app || app.statusBarHidden) {
|
if (!app || app.statusBarHidden) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
7
tns-core-modules/utils/utils.d.ts
vendored
7
tns-core-modules/utils/utils.d.ts
vendored
@ -154,6 +154,13 @@
|
|||||||
* Module with ios specific utilities.
|
* Module with ios specific utilities.
|
||||||
*/
|
*/
|
||||||
module ios {
|
module ios {
|
||||||
|
/**
|
||||||
|
* 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));
|
||||||
|
*/
|
||||||
|
export function getter<T>(_this: any, propertyValue: T | {(): T}): T;
|
||||||
export function getTransformedText(view, source: string, transform: string): string;
|
export function getTransformedText(view, source: string, transform: string): string;
|
||||||
export function setWhiteSpace(view, value: string, parentView?: any);
|
export function setWhiteSpace(view, value: string, parentView?: any);
|
||||||
export function setTextAlignment(view, value: string);
|
export function setTextAlignment(view, value: string);
|
||||||
|
@ -56,6 +56,14 @@ export module ios {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getter<T>(_this: any, property: T | {(): T}): T {
|
||||||
|
if (typeof property === "function") {
|
||||||
|
return (<{(): T}>property).call(_this);
|
||||||
|
} else {
|
||||||
|
return <T>property;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getTransformedText(view, source: string, transform: string): string {
|
export function getTransformedText(view, source: string, transform: string): string {
|
||||||
let result = source;
|
let result = source;
|
||||||
|
|
||||||
@ -131,13 +139,13 @@ export module ios {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isLandscape(): boolean {
|
export function isLandscape(): boolean {
|
||||||
var device = UIDevice.currentDevice();
|
var device = getter(UIDevice, UIDevice.currentDevice);
|
||||||
var statusBarOrientation = UIApplication.sharedApplication().statusBarOrientation;
|
var statusBarOrientation = getter(UIApplication, UIApplication.sharedApplication).statusBarOrientation;
|
||||||
var isStatusBarOrientationLandscape = isOrientationLandscape(statusBarOrientation);
|
var isStatusBarOrientationLandscape = isOrientationLandscape(statusBarOrientation);
|
||||||
return isOrientationLandscape(device.orientation) || isStatusBarOrientationLandscape;
|
return isOrientationLandscape(device.orientation) || isStatusBarOrientationLandscape;
|
||||||
}
|
}
|
||||||
|
|
||||||
export var MajorVersion = NSString.stringWithString(UIDevice.currentDevice().systemVersion).intValue;
|
export var MajorVersion = NSString.stringWithString(getter(UIDevice, UIDevice.currentDevice).systemVersion).intValue;
|
||||||
|
|
||||||
export function openFile(filePath: string): boolean {
|
export function openFile(filePath: string): boolean {
|
||||||
try {
|
try {
|
||||||
@ -163,8 +171,8 @@ export function GC() {
|
|||||||
export function openUrl(location: string): boolean {
|
export function openUrl(location: string): boolean {
|
||||||
try {
|
try {
|
||||||
var url = NSURL.URLWithString(location.trim());
|
var url = NSURL.URLWithString(location.trim());
|
||||||
if (UIApplication.sharedApplication().canOpenURL(url)) {
|
if (ios.getter(UIApplication, UIApplication.sharedApplication).canOpenURL(url)) {
|
||||||
return UIApplication.sharedApplication().openURL(url);
|
return ios.getter(UIApplication, UIApplication.sharedApplication).openURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
Reference in New Issue
Block a user