From c66e3e8ab535f02bcd226f821919a743b699e2b3 Mon Sep 17 00:00:00 2001 From: Panayot Cankov Date: Tue, 27 Dec 2016 13:20:59 +0200 Subject: [PATCH] Fix tslint errors --- tns-core-modules/ui/border/border.ts | 2 - tns-core-modules/ui/button/button.ios.ts | 8 -- .../ui/content-view/content-view.ts | 1 - .../ui/layouts/grid-layout/grid-layout.ios.ts | 2 - tns-core-modules/ui/styling/style-scope.ts | 79 ++++++------------- .../ui/text-base/text-base.ios.ts | 1 + 6 files changed, 27 insertions(+), 66 deletions(-) diff --git a/tns-core-modules/ui/border/border.ts b/tns-core-modules/ui/border/border.ts index 8ab08c0ed..372af91aa 100644 --- a/tns-core-modules/ui/border/border.ts +++ b/tns-core-modules/ui/border/border.ts @@ -20,7 +20,6 @@ export class Border extends ContentView implements BorderDefinition { let height = layout.getMeasureSpecSize(heightMeasureSpec); let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - let style = this.style; let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; @@ -35,7 +34,6 @@ export class Border extends ContentView implements BorderDefinition { } public onLayout(left: number, top: number, right: number, bottom: number): void { - let style = this.style; let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth; let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth; diff --git a/tns-core-modules/ui/button/button.ios.ts b/tns-core-modules/ui/button/button.ios.ts index af5feaaba..bf5ffee97 100644 --- a/tns-core-modules/ui/button/button.ios.ts +++ b/tns-core-modules/ui/button/button.ios.ts @@ -69,7 +69,6 @@ export class Button extends ButtonBase { } set [borderTopWidthProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let top = this.effectivePaddingTop + this.effectiveBorderTopWidth; this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right }; } @@ -82,7 +81,6 @@ export class Button extends ButtonBase { } set [borderRightWidthProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let right = this.effectivePaddingRight + this.effectiveBorderRightWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right }; } @@ -95,7 +93,6 @@ export class Button extends ButtonBase { } set [borderBottomWidthProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right }; } @@ -108,7 +105,6 @@ export class Button extends ButtonBase { } set [borderLeftWidthProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right }; } @@ -121,7 +117,6 @@ export class Button extends ButtonBase { } set [paddingTopProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let top = this.effectivePaddingTop + this.effectiveBorderTopWidth; this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right }; } @@ -134,7 +129,6 @@ export class Button extends ButtonBase { } set [paddingRightProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let right = this.effectivePaddingRight + this.effectiveBorderRightWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right }; } @@ -147,7 +141,6 @@ export class Button extends ButtonBase { } set [paddingBottomProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right }; } @@ -160,7 +153,6 @@ export class Button extends ButtonBase { } set [paddingLeftProperty.native](value: Length) { let inset = this.nativeView.contentEdgeInsets; - let style = this.style; let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth; this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right }; } diff --git a/tns-core-modules/ui/content-view/content-view.ts b/tns-core-modules/ui/content-view/content-view.ts index cd8bf3a4b..a06455df4 100644 --- a/tns-core-modules/ui/content-view/content-view.ts +++ b/tns-core-modules/ui/content-view/content-view.ts @@ -77,7 +77,6 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti let height = layout.getMeasureSpecSize(heightMeasureSpec); let heightMode = layout.getMeasureSpecMode(heightMeasureSpec); - let style = this.style; let measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth); let measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight); diff --git a/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts b/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts index a554cfca8..3d30bbea5 100644 --- a/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts +++ b/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts @@ -154,8 +154,6 @@ export class GridLayout extends GridLayoutBase { public onLayout(left: number, top: number, right: number, bottom: number): void { super.onLayout(left, top, right, bottom); - const style = this.style; - let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft; let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop; diff --git a/tns-core-modules/ui/styling/style-scope.ts b/tns-core-modules/ui/styling/style-scope.ts index 11fecf064..6af7bc657 100644 --- a/tns-core-modules/ui/styling/style-scope.ts +++ b/tns-core-modules/ui/styling/style-scope.ts @@ -25,7 +25,32 @@ export class CssState { resetStyleProperties(this.view.style); let matchingSelectors = this.match.selectors.filter(sel => sel.dynamic ? sel.match(this.view) : true); - matchingSelectors.forEach(s => applyDescriptors(this.view, s.ruleset)); + matchingSelectors.forEach(s => this.applyDescriptors(this.view, s.ruleset)); + } + + private applyDescriptors(view: ViewBase, ruleset: RuleSet): void { + let style = view.style; + ruleset.declarations.forEach(d => { + let name = `css-${d.property}`; + if (name in style) { + style[name] = d.value; + } else { + view[name] = d.value; + } + }); + + let ruleAnimations: KeyframeAnimationInfo[] = ruleset[animationsSymbol]; + if (ruleAnimations && view.isLoaded && view.nativeView !== undefined) { + for (let animationInfo of ruleAnimations) { + let animation = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo); + if (animation) { + view._registerAnimation(animation); + animation.play(view) + .then(() => { view._unregisterAnimation(animation); }) + .catch((e) => { view._unregisterAnimation(animation); }); + } + } + } } } @@ -249,58 +274,6 @@ function isKeyframe(node: Node): node is Keyframes { return node.type === "keyframes"; } -function applyDescriptors(view: ViewBase, ruleset: RuleSet): void { - let style = view.style; - ruleset.declarations.forEach(d => { - let name = `css-${d.property}`; - if (name in style) { - style[name] = d.value; - } else { - view[name] = d.value; - } - }); - - // let modifier = observable.ValueSource.Css; - // ruleset.declarations.forEach(d => withStyleProperty(d.property, d.value, (property, value) => { - // if (types.isString(property)) { - // const propertyName = property; - // let attrHandled = false; - // let specialSetter = getSpecialPropertySetter(propertyName); - - // if (!attrHandled && specialSetter) { - // specialSetter(view, value); - // attrHandled = true; - // } - - // if (!attrHandled && propertyName in view) { - // view[propertyName] = convertString(value); - // } - // } else { - // const resolvedProperty = property; - // try { - // view.style._setValue(resolvedProperty, value, modifier); - // } catch (ex) { - // if (traceEnabled) { - // traceWrite("Error setting property: " + resolvedProperty.name + " view: " + view + " value: " + value + " " + ex, traceCategories.Style, trace.messageType.error); - // } - // } - // } - // })); - - let ruleAnimations: KeyframeAnimationInfo[] = ruleset[animationsSymbol]; - if (ruleAnimations && view.isLoaded && view.nativeView !== undefined) { - for (let animationInfo of ruleAnimations) { - let animation = KeyframeAnimation.keyframeAnimationFromInfo(animationInfo); - if (animation) { - view._registerAnimation(animation); - animation.play(view) - .then(() => { view._unregisterAnimation(animation); }) - .catch((e) => { view._unregisterAnimation(animation); }); - } - } - } -} - function applyInlineStyle(view: ViewBase, declarations: Declaration[]): void { let style = view.style; declarations.forEach(d => { diff --git a/tns-core-modules/ui/text-base/text-base.ios.ts b/tns-core-modules/ui/text-base/text-base.ios.ts index 2ae2ab819..24c865955 100644 --- a/tns-core-modules/ui/text-base/text-base.ios.ts +++ b/tns-core-modules/ui/text-base/text-base.ios.ts @@ -11,6 +11,7 @@ export class TextBase extends TextBaseCommon { //Text get [textProperty.native](): string { + console.log("Set textProperty.native..."); let nativeView = this.nativeView; if (nativeView instanceof UIButton) { return nativeView.titleForState(UIControlState.Normal);