diff --git a/tns-core-modules/ui/action-bar/action-bar-common.ts b/tns-core-modules/ui/action-bar/action-bar-common.ts index 06ac81cdb..5fd3af7d2 100644 --- a/tns-core-modules/ui/action-bar/action-bar-common.ts +++ b/tns-core-modules/ui/action-bar/action-bar-common.ts @@ -7,9 +7,7 @@ } from "ui/action-bar"; import { Page } from "ui/page"; import { Bindable } from "ui/core/bindable"; -import { HorizontalAlignment, VerticalAlignment, Visibility } from "ui/enums"; -import { View } from "ui/core/view"; -import { horizontalAlignmentProperty, verticalAlignmentProperty } from "ui/styling/style"; +import { View, horizontalAlignmentProperty, verticalAlignmentProperty } from "ui/core/view"; import { Property } from "ui/core/properties"; import { unsetValue } from "ui/core/dependency-observable"; import { ViewBase } from "ui/core/view-base"; @@ -68,8 +66,8 @@ export class ActionBarBase extends View implements ActionBarDefinition { this._titleView = value; if (this._titleView) { - this._titleView.style[horizontalAlignmentProperty.cssName] = HorizontalAlignment.center; - this._titleView.style[verticalAlignmentProperty.cssName] = VerticalAlignment.center; + this._titleView.style[horizontalAlignmentProperty.cssName] = "center"; + this._titleView.style[verticalAlignmentProperty.cssName] = "center"; this._addView(this._titleView); } @@ -310,15 +308,15 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition { private _addActionViewToActionBar() { if (this._actionView && !this._actionView._isAddedToNativeVisualTree && this._actionBar) { - this._actionView.style[horizontalAlignmentProperty.cssName] = HorizontalAlignment.center; - this._actionView.style[verticalAlignmentProperty.cssName] = VerticalAlignment.center; + this._actionView.style[horizontalAlignmentProperty.cssName] = "center"; + this._actionView.style[verticalAlignmentProperty.cssName] = "center"; this._actionBar._addView(this._actionView); } } } export function isVisible(item: ActionItemDefinition) { - return item.visibility === Visibility.visible; + return item.visibility === "visible"; } function onTitlePropertyChanged(actionBar: ActionBarBase, oldValue: string, newValue: string) { @@ -341,5 +339,5 @@ textProperty.register(ActionItemBase); let iconProperty = new Property({ name: "icon", valueChanged: onItemChanged }); iconProperty.register(ActionItemBase); -let visibilityProperty = new Property({ name: "visibility", defaultValue: Visibility.visible, valueChanged: onItemChanged }); +let visibilityProperty = new Property({ name: "visibility", defaultValue: "visible", valueChanged: onItemChanged }); visibilityProperty.register(ActionItemBase); \ No newline at end of file diff --git a/tns-core-modules/ui/action-bar/action-bar.android.ts b/tns-core-modules/ui/action-bar/action-bar.android.ts index 91312211d..cc9157ac2 100644 --- a/tns-core-modules/ui/action-bar/action-bar.android.ts +++ b/tns-core-modules/ui/action-bar/action-bar.android.ts @@ -1,11 +1,10 @@ import { AndroidActionBarSettings as AndroidActionBarSettingsDefinition, AndroidActionItemSettings } from "ui/action-bar"; import { ActionItemBase, ActionBarBase, isVisible } from "./action-bar-common"; import { isDefined, isNullOrUndefined, isString } from "utils/types"; -import { View } from "ui/core/view"; +import { View, colorProperty } from "ui/core/view"; import { RESOURCE_PREFIX } from "utils/utils"; import { fromFileOrResource } from "image-source"; -import { AndroidActionItemPosition, AndroidActionBarIconVisibility } from "ui/enums"; -import { colorProperty } from "ui/styling/style"; +import { AndroidActionBarIconVisibility } from "ui/enums"; import { Color } from "color"; import * as application from "application"; import * as trace from "trace"; @@ -23,7 +22,7 @@ function generateItemId(): number { export class ActionItem extends ActionItemBase { private _androidPosition: AndroidActionItemSettings = { - position: AndroidActionItemPosition.actionBar, + position: "actionBar", systemIcon: undefined }; @@ -249,7 +248,7 @@ export class ActionBar extends ActionBarBase { if (item.actionView && item.actionView.android) { // With custom action view, the menuitem cannot be displayed in a popup menu. - item.android.position = AndroidActionItemPosition.actionBar; + item.android.position = "actionBar"; menuItem.setActionView(item.actionView.android); ActionBar._setOnClickListener(item); } @@ -368,13 +367,13 @@ function getDrawableOrResourceId(icon: string, resources: android.content.res.Re function getShowAsAction(menuItem: ActionItem): number { switch (menuItem.android.position) { - case AndroidActionItemPosition.actionBarIfRoom: + case "actionBarIfRoom": return android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM; - case AndroidActionItemPosition.popup: + case "popup": return android.view.MenuItem.SHOW_AS_ACTION_NEVER; - case AndroidActionItemPosition.actionBar: + case "actionBar": default: return android.view.MenuItem.SHOW_AS_ACTION_ALWAYS; } diff --git a/tns-core-modules/ui/action-bar/action-bar.d.ts b/tns-core-modules/ui/action-bar/action-bar.d.ts index 2dc650ac0..81a076dbb 100644 --- a/tns-core-modules/ui/action-bar/action-bar.d.ts +++ b/tns-core-modules/ui/action-bar/action-bar.d.ts @@ -157,7 +157,7 @@ declare module "ui/action-bar" { * 3. popup - item is shown in the popup menu. * Note: Property not applicable to NavigationButton */ - position: string; + position: "actionBar" | "actionBarIfRoom" | "popup"; /** * Gets or sets the name of the system drawable resource to be displayed. @@ -178,7 +178,7 @@ declare module "ui/action-bar" { * 2. right - items is shown at the right part of the navigation bar. * Note: Property not applicable to NavigationButton */ - position: string; + position: "left" | "right"; /** * Gets or sets a number representing the iOS system item to be displayed. diff --git a/tns-core-modules/ui/action-bar/action-bar.ios.ts b/tns-core-modules/ui/action-bar/action-bar.ios.ts index a32c402a8..b892f6651 100644 --- a/tns-core-modules/ui/action-bar/action-bar.ios.ts +++ b/tns-core-modules/ui/action-bar/action-bar.ios.ts @@ -1,12 +1,9 @@ import { IOSActionItemSettings, ActionItem as ActionItemDefinition } from "ui/action-bar"; import { ActionItemBase, ActionBarBase, isVisible } from "./action-bar-common"; import utils = require("utils/utils"); -import { isNumber } from "utils/types"; import { Frame, topmost as topmostFrame } from "ui/frame"; -import { View } from "ui/core/view"; +import { View, colorProperty, backgroundColorProperty, backgroundInternalProperty } from "ui/core/view"; import { ImageSource, fromFileOrResource } from "image-source"; -import { IOSActionItemPosition } from "ui/enums"; -import { colorProperty, backgroundColorProperty, backgroundInternalProperty } from "ui/styling/style"; import { Color } from "color"; import { Background } from "ui/styling/background"; @@ -35,7 +32,7 @@ class TapBarItemHandlerImpl extends NSObject { export class ActionItem extends ActionItemBase { private _ios: IOSActionItemSettings = { - position: IOSActionItemPosition.left, + position: "left", systemIcon: undefined }; @@ -142,7 +139,7 @@ export class ActionBar extends ActionBarBase { let rightBarItems = []; for (let i = 0; i < items.length; i++) { let barButtonItem = this.createBarButtonItem(items[i]); - if (items[i].ios.position === IOSActionItemPosition.left) { + if (items[i].ios.position === "left") { leftBarItems.push(barButtonItem); } else { @@ -168,7 +165,7 @@ export class ActionBar extends ActionBarBase { item.actionView.ios.addGestureRecognizer(recognizer); barButtonItem = UIBarButtonItem.alloc().initWithCustomView(item.actionView.ios); } - else if (isNumber(item.ios.systemIcon)) { + else if (typeof item.ios.systemIcon === "number") { barButtonItem = UIBarButtonItem.alloc().initWithBarButtonSystemItemTargetAction(item.ios.systemIcon, tapHandler, "tap"); } else if (item.icon) { @@ -294,7 +291,7 @@ export class ActionBar extends ActionBarBase { let page = this.page; // Page should be attached to frame to update the action bar. if (!page || !page.frame) { - return; + return undefined; } return (page.frame.ios.controller).navigationBar; diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts b/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts index 6ae126baf..5d0c080b5 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator.android.ts @@ -1,6 +1,5 @@ import { ActivityIndicatorBase, busyProperty } from "./activity-indicator-common"; -import { Visibility } from "ui/enums"; -import { colorProperty, visibilityProperty } from "ui/styling/style"; +import { colorProperty, visibilityProperty } from "ui/core/view"; export * from "./activity-indicator-common"; diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts index 3edd5ffd2..6dd98bdef 100644 --- a/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts +++ b/tns-core-modules/ui/activity-indicator/activity-indicator.ios.ts @@ -1,7 +1,6 @@ import { ActivityIndicatorBase, busyProperty } from "./activity-indicator-common"; -import { Visibility } from "ui/enums"; -import { colorProperty, visibilityProperty } from "ui/styling/style"; -import * as utils from "utils/utils"; +import { colorProperty, visibilityProperty } from "ui/core/view"; +import { ios } from "utils/utils"; export * from "./activity-indicator-common"; @@ -15,7 +14,7 @@ export class ActivityIndicator extends ActivityIndicatorBase { } get [busyProperty.native](): boolean { - if (utils.ios.MajorVersion > 9) { + if (ios.MajorVersion > 9) { return this.nativeView.animating; } else { @@ -36,10 +35,10 @@ export class ActivityIndicator extends ActivityIndicatorBase { } get [visibilityProperty.native](): string { - return this.nativeView.hidden ? Visibility.collapse : Visibility.visible; + return this.nativeView.hidden ? "collapse" : "visible"; } set [visibilityProperty.native](value: string) { - this.nativeView.hidden = value !== Visibility.visible; + this.nativeView.hidden = value !== "visible"; } get [colorProperty.native](): UIColor { diff --git a/tns-core-modules/ui/animation/animation-common.ts b/tns-core-modules/ui/animation/animation-common.ts index 26660194c..8671b43f5 100644 --- a/tns-core-modules/ui/animation/animation-common.ts +++ b/tns-core-modules/ui/animation/animation-common.ts @@ -1,11 +1,13 @@ -import {CubicBezierAnimationCurve as CubicBezierAnimationCurveDefinition, - AnimationPromise as AnimationPromiseDefinition, - Animation as AnimationBaseDefinition, - AnimationDefinition, - Pair} from "ui/animation"; -import {View} from "ui/core/view"; -import {Color} from "color"; -import {isDefined, isNumber, isString} from "utils/types"; +import { + CubicBezierAnimationCurve as CubicBezierAnimationCurveDefinition, + AnimationPromise as AnimationPromiseDefinition, + Animation as AnimationBaseDefinition, + AnimationDefinition, + Pair +} from "ui/animation"; +import { View } from "ui/core/view"; +import { Color } from "color"; +import { isDefined, isNumber, isString } from "utils/types"; import * as trace from "trace"; export module Properties { @@ -64,8 +66,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition { if (trace.enabled) { trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", trace.categories.Animation); } - - this._propertyAnimations = new Array(); + + this._propertyAnimations = new Array(); for (let i = 0, length = animationDefinitions.length; i < length; i++) { animationDefinitions[i].curve = this._resolveAnimationCurve(animationDefinitions[i].curve); this._propertyAnimations = this._propertyAnimations.concat(AnimationBase._createPropertyAnimations(animationDefinitions[i])); @@ -108,13 +110,13 @@ export abstract class AnimationBase implements AnimationBaseDefinition { _this.cancel(); }; var _then = promise.then; - promise.then = function() { + promise.then = function () { var r = _then.apply(promise, arguments); _this.fixupAnimationPromise(r); return r; }; var _catch = promise.catch; - promise.catch = function() { + promise.catch = function () { var r = _catch.apply(promise, arguments); _this.fixupAnimationPromise(r); return r; @@ -187,7 +189,7 @@ export abstract class AnimationBase implements AnimationBaseDefinition { propertyAnimations.push({ target: animationDefinition.target, property: Properties.backgroundColor, - value: isString(animationDefinition.backgroundColor) ? + value: isString(animationDefinition.backgroundColor) ? new Color(animationDefinition.backgroundColor) : animationDefinition.backgroundColor, duration: animationDefinition.duration, delay: animationDefinition.delay, diff --git a/tns-core-modules/ui/animation/animation.android.ts b/tns-core-modules/ui/animation/animation.android.ts index cd1bd5094..42e9430ab 100644 --- a/tns-core-modules/ui/animation/animation.android.ts +++ b/tns-core-modules/ui/animation/animation.android.ts @@ -9,7 +9,7 @@ import { opacityProperty, backgroundColorProperty, rotateProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty -} from "ui/styling/style"; +} from "ui/core/view"; import * as trace from "trace"; export * from "./animation-common"; diff --git a/tns-core-modules/ui/animation/animation.ios.ts b/tns-core-modules/ui/animation/animation.ios.ts index b2201675e..3b41fc09d 100644 --- a/tns-core-modules/ui/animation/animation.ios.ts +++ b/tns-core-modules/ui/animation/animation.ios.ts @@ -7,7 +7,7 @@ import { opacityProperty, backgroundColorProperty, rotateProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty -} from "ui/styling/style"; +} from "ui/core/view"; import * as trace from "trace"; export * from "./animation-common"; diff --git a/tns-core-modules/ui/border/border.ts b/tns-core-modules/ui/border/border.ts index ae4873e67..f2f6e71a7 100644 --- a/tns-core-modules/ui/border/border.ts +++ b/tns-core-modules/ui/border/border.ts @@ -17,40 +17,32 @@ export class Border extends ContentView implements BorderDefinition { } public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { - View.adjustChildLayoutParams(this.layoutView, widthMeasureSpec, heightMeasureSpec); - let width = layout.getMeasureSpecSize(widthMeasureSpec); let widthMode = layout.getMeasureSpecMode(widthMeasureSpec); let height = layout.getMeasureSpecSize(heightMeasureSpec); let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - let density = layout.getDisplayDensity(); - let borderWidth = 0; - if (isNumber(this.borderWidth)) { - borderWidth = this.borderWidth; - } - let borderSize = (2 * borderWidth) * density; + let style = this.style; + let horizontalBorderLength = style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth; + let verticalBorderLength = style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth; let result = View.measureChild(this, this.layoutView, - layout.makeMeasureSpec(width - borderSize, widthMode), - layout.makeMeasureSpec(height - borderSize, heightMode)); + layout.makeMeasureSpec(width - horizontalBorderLength, widthMode), + layout.makeMeasureSpec(height - verticalBorderLength, heightMode)); - let widthAndState = View.resolveSizeAndState(result.measuredWidth + borderSize, width, widthMode, 0); - let heightAndState = View.resolveSizeAndState(result.measuredHeight + borderSize, height, heightMode, 0); + let widthAndState = View.resolveSizeAndState(result.measuredWidth + horizontalBorderLength, width, widthMode, 0); + let heightAndState = View.resolveSizeAndState(result.measuredHeight + verticalBorderLength, height, heightMode, 0); this.setMeasuredDimension(widthAndState, heightAndState); } public onLayout(left: number, top: number, right: number, bottom: number): void { let density = layout.getDisplayDensity(); - let borderWidth = 0; - if (isNumber(this.borderWidth)) { - borderWidth = this.borderWidth; - } - let borderSize = borderWidth * density; - View.layoutChild(this, this.layoutView, borderSize, borderSize, right - left - borderSize, bottom - top - borderSize); + let style = this.style; + let horizontalBorderLength = style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth; + let verticalBorderLength = style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth; - View.restoreChildOriginalParams(this.layoutView); + View.layoutChild(this, this.layoutView, style.effectiveBorderLeftWidth, style.effectiveBorderTopWidth, right - left - horizontalBorderLength, bottom - top - verticalBorderLength); } } \ No newline at end of file diff --git a/tns-core-modules/ui/builder/special-properties.ts b/tns-core-modules/ui/builder/special-properties.ts index 68a945ff6..934d4d55c 100644 --- a/tns-core-modules/ui/builder/special-properties.ts +++ b/tns-core-modules/ui/builder/special-properties.ts @@ -1,4 +1,4 @@ -import {View} from "ui/core/view"; +import { View } from "ui/core/view"; export type PropertySetter = (instance: View, propertyValue: any) => void; diff --git a/tns-core-modules/ui/button/button-common.ts b/tns-core-modules/ui/button/button-common.ts index 631c89226..e241a7689 100644 --- a/tns-core-modules/ui/button/button-common.ts +++ b/tns-core-modules/ui/button/button-common.ts @@ -1,21 +1,13 @@ import { Button as ButtonDefinition } from "ui/button"; import { TextBase } from "ui/text-base"; -import { WhiteSpace } from "ui/enums"; export abstract class ButtonBase extends TextBase implements ButtonDefinition { public static tapEvent = "tap"; get textWrap(): boolean { - return this.style.whiteSpace === WhiteSpace.normal; + return this.style.whiteSpace === "normal"; } set textWrap(value: boolean) { - this.style.whiteSpace = value ? WhiteSpace.normal : WhiteSpace.nowrap; - } - - get whiteSpace(): string { - return this.style.whiteSpace; - } - set whiteSpace(value: string) { - this.style.whiteSpace = value; + this.style.whiteSpace = value ? "normal" : "nowrap"; } } \ No newline at end of file diff --git a/tns-core-modules/ui/button/button.android.ts b/tns-core-modules/ui/button/button.android.ts index 5b5590d5c..d469e270f 100644 --- a/tns-core-modules/ui/button/button.android.ts +++ b/tns-core-modules/ui/button/button.android.ts @@ -6,7 +6,9 @@ export * from "./button-common"; @Interfaces([android.view.View.OnClickListener]) class ClickListener implements android.view.View.OnClickListener { - constructor(public owner: WeakRef