From 6c3d71cadf4ed0dc1baace45b826f9630208d6f0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 13 Dec 2016 16:07:42 +0200 Subject: [PATCH] fix modules build errors --- .../file-system/file-name-resolver.ts | 12 +- .../org.nativescript.widgets.d.ts | 280 ------------------ tns-core-modules/platform/platform.android.ts | 12 +- tns-core-modules/platform/platform.ios.ts | 10 +- tns-core-modules/ui/builder/builder.ts | 2 +- tns-core-modules/ui/core/view.d.ts | 2 +- .../ui/image-cache/image-cache.ios.ts | 12 +- .../android/org.nativescript.widgets.d.ts | 80 ++++- 8 files changed, 102 insertions(+), 308 deletions(-) delete mode 100644 tns-core-modules/org.nativescript.widgets.d.ts diff --git a/tns-core-modules/file-system/file-name-resolver.ts b/tns-core-modules/file-system/file-name-resolver.ts index 7ca1e155b..1f7ca0e7e 100644 --- a/tns-core-modules/file-system/file-name-resolver.ts +++ b/tns-core-modules/file-system/file-name-resolver.ts @@ -138,8 +138,8 @@ export class FileNameResolver implements definition.FileNameResolver { var candidates = this.getFileCandidatesFromFolder(path, ext); result = findFileMatch(path, ext, candidates, this._context); - if (traceEnabled) { - traceWrite("Resolved file name for \"" + path + ext + "\" result: " + (result ? result : "no match found"), traceCategories.Navigation); + if (trace.enabled) { + trace.write("Resolved file name for \"" + path + ext + "\" result: " + (result ? result : "no match found"), trace.categories.Navigation); } return result; } @@ -162,8 +162,8 @@ export class FileNameResolver implements definition.FileNameResolver { }); } else { - if (traceEnabled) { - traceWrite("Could not find folder " + folderPath + " when loading " + path + ext, traceCategories.Navigation); + if (trace.enabled) { + trace.write("Could not find folder " + folderPath + " when loading " + path + ext, trace.categories.Navigation); } } @@ -175,8 +175,8 @@ export function findFileMatch(path: string, ext: string, candidates: Array, - backgroundSize: string, - backgroundSizeParsedCSSValues: native.Array - ); - public getBorderWidth(): number; - public getBorderColor(): number; - public getBorderRadius(): number; - public getClipPath(): string; - public getBackgroundColor(): number; - public getBackgroundImage(): android.graphics.Bitmap; - public getBackgroundRepeat(): string; - public getBackgroundPosition(): string; - public getBackgroundSize(): string; - } - - export class CSSValue { - constructor(type: string, str: string, unit: string, value: number); - public getType(): string; - public getString(): string; - public getUnit(): string; - public getValue(): number; - } - - export class CommonLayoutParams extends android.widget.FrameLayout.LayoutParams { - constructor(); - - public widthPercent: number; - public heightPercent: number; - - public topMarginPercent: number; - public leftMarginPercent: number; - public bottomMarginPercent: number; - public rightMarginPercent: number; - - public left: number; - public top: number; - - public dock: Dock; - - public row: number; - public column: number; - - public rowSpan: number; - public columnSpan: number; - } - - export enum Stretch { - none, - aspectFill, - aspectFit, - fill - } - - export enum Dock { - left, - top, - right, - bottom - } - - export enum GridUnitType { - auto, - pixel, - star - } - - export enum Orientation { - horizontal, - vertical - } - - export class OriginPoint { - public static setX(view: android.view.View, value: number); - public static setY(view: android.view.View, value: number); - } - - export class LayoutBase extends android.view.ViewGroup { - constructor(context: android.content.Context); - } - - export class AbsoluteLayout extends LayoutBase { - constructor(context: android.content.Context); - } - - export class DockLayout extends LayoutBase { - constructor(context: android.content.Context); - - public getStretchLastChild(): boolean; - public setStretchLastChild(value: boolean): void; - } - - export class StackLayout extends LayoutBase { - constructor(context: android.content.Context); - - public getOrientation(): Orientation; - public setOrientation(value: Orientation): void; - } - - export class WrapLayout extends LayoutBase { - constructor(context: android.content.Context); - - public getOrientation(): Orientation; - public setOrientation(value: Orientation): void; - - public getItemWidth(): number; - public setItemWidth(value: number): void; - - public getItemHeight(): number; - public setItemHeight(value: number): void; - } - - export class ItemSpec { - constructor(); - constructor(value: number, unitType: GridUnitType); - public getGridUnitType(): GridUnitType; - public getIsAbsolute(): boolean; - public getIsAuto(): boolean; - public getIsStar(): boolean; - public getValue(): number; - public getActualLength(): number; - } - - export class GridLayout extends LayoutBase { - constructor(context: android.content.Context); - - public addRow(itemSpec: ItemSpec): void; - public addColumn(itemSpec: ItemSpec): void; - - public removeRow(itemSpec: ItemSpec): void; - public removeColumn(itemSpec: ItemSpec): void; - - public removeRowAt(index: number): void; - public removeColumnAt(index: number): void; - - public getColumns(): Array; - public getRows(): Array; - } - - export class ContentLayout extends LayoutBase { - constructor(context: android.content.Context); - } - - export class VerticalScrollView extends android.widget.ScrollView { - constructor(context: android.content.Context); - public getScrollableLength(): number; - } - - export class HorizontalScrollView extends android.widget.HorizontalScrollView { - constructor(context: android.content.Context); - public getScrollableLength(): number; - } - - export class ImageView extends android.widget.ImageView { - constructor(context: android.content.Context); - getCornerRadius(): number; - setCornerRadius(radius: number): void; - - getBorderWidth(): number; - setBorderWidth(width: number): void; - } - - export class TabLayout extends android.widget.HorizontalScrollView { - constructor(context: android.content.Context); - constructor(context: android.content.Context, attrs: android.util.IAttributeSet); - constructor(context: android.content.Context, attrs: android.util.IAttributeSet, defStyle: number); - - setSelectedIndicatorColors(color: Array): void; - - setItems(items: Array, viewPager: android.support.v4.view.ViewPager): void; - updateItemAt(position: number, itemSpec: TabItemSpec): void; - - getTextViewForItemAt(index: number): android.widget.TextView; - getViewForItemAt(index: number): android.widget.LinearLayout; - } - - export class TabItemSpec { - title: string; - iconId: number; - iconDrawable: android.graphics.drawable.Drawable; - } - - export class ViewHelper { - public static getMinWidth(view: android.view.View): number; - public static setMinWidth(view: android.view.View, value: number): void; - - public static getMinHeight(view: android.view.View): number; - public static setMinHeight(view: android.view.View, value: number): void; - - public static getWidth(view: android.view.View): number; - public static setWidth(view: android.view.View, value: number): void; - public static setWidthPercent(view: android.view.View, value: number): void; - - public static getHeight(view: android.view.View): number; - public static setHeight(view: android.view.View, value: number): void; - public static setHeightPercent(view: android.view.View, value: number): void; - - public static getMargin(view: android.view.View): { left: number, top: number, right: number, bottom: number }; - public static setMargin(view: android.view.View, left: number, top: number, right: number, bottom: number): void; - - public static getMarginLeft(view: android.view.View): number; - public static setMarginLeft(view: android.view.View, value: number): void; - public static setMarginLeftPercent(view: android.view.View, value: number): void; - - public static getMarginTop(view: android.view.View): number; - public static setMarginTop(view: android.view.View, value: number): void; - public static setMarginTopPercent(view: android.view.View, value: number): void; - - public static getMarginRight(view: android.view.View): number; - public static setMarginRight(view: android.view.View, value: number): void; - public static setMarginRightPercent(view: android.view.View, value: number): void; - - public static getMarginBottom(view: android.view.View): number; - public static setMarginBottom(view: android.view.View, value: number): void; - public static setMarginBottomPercent(view: android.view.View, value: number): void; - - public static getHorizontalAlignment(view: android.view.View): string; - public static setHorizontalAlignment(view: android.view.View, value: string): void; - - public static getVerticalAlignment(view: android.view.View): string; - public static setVerticalAlignment(view: android.view.View, value: string): void; - - public static getPadding(view: android.view.View): { left: number, top: number, right: number, bottom: number }; - public static setPadding(view: android.view.View, left: number, top: number, right: number, bottom: number): void; - - public static getPaddingLeft(view: android.view.View): number; - public static setPaddingLeft(view: android.view.View, value: number): void; - - public static getPaddingTop(view: android.view.View): number; - public static setPaddingTop(view: android.view.View, value: number): void; - - public static getPaddingRight(view: android.view.View): number; - public static setPaddingRight(view: android.view.View, value: number): void; - - public static getPaddingBottom(view: android.view.View): number; - public static setPaddingBottom(view: android.view.View, value: number): void; - - public static getRotate(view: android.view.View): number; - public static setRotate(view: android.view.View, value: number): void; - - public static getScaleX(view: android.view.View): number; - public static setScaleX(view: android.view.View, value: number): void; - - public static getScaleY(view: android.view.View): number; - public static setScaleY(view: android.view.View, value: number): void; - - public static getTranslateX(view: android.view.View): number; - public static setTranslateX(view: android.view.View, value: number): void; - - public static getTranslateY(view: android.view.View): number; - public static setTranslateY(view: android.view.View, value: number): void; - - public static getZIndex(view: android.view.View): number; - public static setZIndex(view: android.view.View, value: number): void; - - public static getLetterspacing(view: android.view.View): number; - public static setLetterspacing(view: android.view.View, value: number): void; - - } - } - } -} - -declare class TNSLabel extends UILabel { - borderThickness: UIEdgeInsets; - padding: UIEdgeInsets; -} \ No newline at end of file diff --git a/tns-core-modules/platform/platform.android.ts b/tns-core-modules/platform/platform.android.ts index 0d26ef187..fa0e65f3d 100644 --- a/tns-core-modules/platform/platform.android.ts +++ b/tns-core-modules/platform/platform.android.ts @@ -15,7 +15,7 @@ class Device implements definition.Device { private _model: string; private _osVersion: string; private _sdkVersion: string; - private _deviceType: string; + private _deviceType: "Phone" | "Tablet"; private _uuid: string; private _language: string; private _region: string; @@ -56,17 +56,15 @@ class Device implements definition.Device { return this._sdkVersion; } - get deviceType(): string { + get deviceType(): "Phone" | "Tablet" { if (!this._deviceType) { - var dips = Math.min(screen.mainScreen.widthPixels, screen.mainScreen.heightPixels) / screen.mainScreen.scale; - var enums: typeof enumsModule = require("ui/enums"); - + const dips = Math.min(screen.mainScreen.widthPixels, screen.mainScreen.heightPixels) / screen.mainScreen.scale; // If the device has more than 600 dips it is considered to be a tablet. if (dips >= MIN_TABLET_PIXELS) { - this._deviceType = enums.DeviceType.Tablet; + this._deviceType = "Tablet"; } else { - this._deviceType = enums.DeviceType.Phone; + this._deviceType = "Phone"; } } diff --git a/tns-core-modules/platform/platform.ios.ts b/tns-core-modules/platform/platform.ios.ts index c2f4e5bfa..2deebcd9b 100644 --- a/tns-core-modules/platform/platform.ios.ts +++ b/tns-core-modules/platform/platform.ios.ts @@ -12,7 +12,7 @@ class Device implements definition.Device { private _model: string; private _osVersion: string; private _sdkVersion: string; - private _deviceType: string; + private _deviceType: "Phone" | "Tablet"; private _language: string; private _region: string; @@ -48,15 +48,13 @@ class Device implements definition.Device { return this._sdkVersion; } - get deviceType(): string { + get deviceType(): "Phone" | "Tablet" { if (!this._deviceType) { - var enums = require("ui/enums"); - if (utils.ios.getter(UIDevice, UIDevice.currentDevice).userInterfaceIdiom === UIUserInterfaceIdiom.Phone) { - this._deviceType = enums.DeviceType.Phone; + this._deviceType = "Phone"; } else { - this._deviceType = enums.DeviceType.Tablet; + this._deviceType = "Tablet"; } } diff --git a/tns-core-modules/ui/builder/builder.ts b/tns-core-modules/ui/builder/builder.ts index e70de54eb..31d9bfda9 100644 --- a/tns-core-modules/ui/builder/builder.ts +++ b/tns-core-modules/ui/builder/builder.ts @@ -112,7 +112,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr } else { ensureTrace(); - traceWrite("CSS file found but no page specified. Please specify page in the options!", traceCategories.Error, trace.messageType.error); + trace.write("CSS file found but no page specified. Please specify page in the options!", trace.categories.Error, trace.messageType.error); } } diff --git a/tns-core-modules/ui/core/view.d.ts b/tns-core-modules/ui/core/view.d.ts index 9f17fe54c..76fbe84a3 100644 --- a/tns-core-modules/ui/core/view.d.ts +++ b/tns-core-modules/ui/core/view.d.ts @@ -697,7 +697,7 @@ declare module "ui/core/view" { /** * Defines an interface used to create a member of a class from string representation (used in xml declaration). */ - interface ApplyXmlAttributes { + export interface ApplyXmlAttributes { /** * Called for every attribute in xml declaration. <... fontAttributes="bold" ../> * @param attributeName - the name of the attribute (fontAttributes) diff --git a/tns-core-modules/ui/image-cache/image-cache.ios.ts b/tns-core-modules/ui/image-cache/image-cache.ios.ts index 1d2a8a2d5..4471067c0 100644 --- a/tns-core-modules/ui/image-cache/image-cache.ios.ts +++ b/tns-core-modules/ui/image-cache/image-cache.ios.ts @@ -35,8 +35,8 @@ class MemmoryWarningHandler extends NSObject { this._cache = cache; getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(this, "clearCache", "UIApplicationDidReceiveMemoryWarningNotification", null); - if (traceEnabled) { - traceWrite("[MemmoryWarningHandler] Added low memory observer.", traceCategories.Debug); + if (trace.enabled) { + trace.write("[MemmoryWarningHandler] Added low memory observer.", trace.categories.Debug); } return this; @@ -44,15 +44,15 @@ class MemmoryWarningHandler extends NSObject { public dealloc(): void { getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).removeObserverNameObject(this, "UIApplicationDidReceiveMemoryWarningNotification", null); - if (traceEnabled) { - traceWrite("[MemmoryWarningHandler] Removed low memory observer.", traceCategories.Debug); + if (trace.enabled) { + trace.write("[MemmoryWarningHandler] Removed low memory observer.", trace.categories.Debug); } super.dealloc(); } public clearCache(): void { - if (traceEnabled) { - traceWrite("[MemmoryWarningHandler] Clearing Image Cache.", traceCategories.Debug); + if (trace.enabled) { + trace.write("[MemmoryWarningHandler] Clearing Image Cache.", trace.categories.Debug); } this._cache.removeAllObjects(); utils.GC(); diff --git a/tns-platform-declarations/android/org.nativescript.widgets.d.ts b/tns-platform-declarations/android/org.nativescript.widgets.d.ts index a8e57924f..8ee7e7724 100644 --- a/tns-platform-declarations/android/org.nativescript.widgets.d.ts +++ b/tns-platform-declarations/android/org.nativescript.widgets.d.ts @@ -396,7 +396,7 @@ public addImageCache(cache: Cache): void; public initCache(): void; public clearCache(): void; - public loadImage(data: Object, imageView: ImageView, + public loadImage(data: Object, imageView: ImageView, decodeWidth: number, decodeHeight: number, useCache: boolean, async: boolean, listener: Worker.IOnImageLoadedListener): void; } @@ -410,6 +410,84 @@ } } } + + export class ViewHelper { + public static getMinWidth(view: android.view.View): number; + public static setMinWidth(view: android.view.View, value: number): void; + + public static getMinHeight(view: android.view.View): number; + public static setMinHeight(view: android.view.View, value: number): void; + + public static getWidth(view: android.view.View): number; + public static setWidth(view: android.view.View, value: number): void; + public static setWidthPercent(view: android.view.View, value: number): void; + + public static getHeight(view: android.view.View): number; + public static setHeight(view: android.view.View, value: number): void; + public static setHeightPercent(view: android.view.View, value: number): void; + + public static getMargin(view: android.view.View): { left: number, top: number, right: number, bottom: number }; + public static setMargin(view: android.view.View, left: number, top: number, right: number, bottom: number): void; + + public static getMarginLeft(view: android.view.View): number; + public static setMarginLeft(view: android.view.View, value: number): void; + public static setMarginLeftPercent(view: android.view.View, value: number): void; + + public static getMarginTop(view: android.view.View): number; + public static setMarginTop(view: android.view.View, value: number): void; + public static setMarginTopPercent(view: android.view.View, value: number): void; + + public static getMarginRight(view: android.view.View): number; + public static setMarginRight(view: android.view.View, value: number): void; + public static setMarginRightPercent(view: android.view.View, value: number): void; + + public static getMarginBottom(view: android.view.View): number; + public static setMarginBottom(view: android.view.View, value: number): void; + public static setMarginBottomPercent(view: android.view.View, value: number): void; + + public static getHorizontalAlignment(view: android.view.View): string; + public static setHorizontalAlignment(view: android.view.View, value: string): void; + + public static getVerticalAlignment(view: android.view.View): string; + public static setVerticalAlignment(view: android.view.View, value: string): void; + + public static getPadding(view: android.view.View): { left: number, top: number, right: number, bottom: number }; + public static setPadding(view: android.view.View, left: number, top: number, right: number, bottom: number): void; + + public static getPaddingLeft(view: android.view.View): number; + public static setPaddingLeft(view: android.view.View, value: number): void; + + public static getPaddingTop(view: android.view.View): number; + public static setPaddingTop(view: android.view.View, value: number): void; + + public static getPaddingRight(view: android.view.View): number; + public static setPaddingRight(view: android.view.View, value: number): void; + + public static getPaddingBottom(view: android.view.View): number; + public static setPaddingBottom(view: android.view.View, value: number): void; + + public static getRotate(view: android.view.View): number; + public static setRotate(view: android.view.View, value: number): void; + + public static getScaleX(view: android.view.View): number; + public static setScaleX(view: android.view.View, value: number): void; + + public static getScaleY(view: android.view.View): number; + public static setScaleY(view: android.view.View, value: number): void; + + public static getTranslateX(view: android.view.View): number; + public static setTranslateX(view: android.view.View, value: number): void; + + public static getTranslateY(view: android.view.View): number; + public static setTranslateY(view: android.view.View, value: number): void; + + public static getZIndex(view: android.view.View): number; + public static setZIndex(view: android.view.View, value: number): void; + + public static getLetterspacing(view: android.view.View): number; + public static setLetterspacing(view: android.view.View, value: number): void; + + } } } }