Skip to content

Commit c287c69

Browse files
committed
fix(textview): same padding fixes as textfield
1 parent 9629e28 commit c287c69

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

src/textview/textview.android.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ import {
88
helperColorProperty,
99
helperProperty,
1010
strokeColorProperty,
11-
strokeInactiveColorProperty,
11+
strokeInactiveColorProperty
1212
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
13-
import { Background, Color, Utils, backgroundInternalProperty, borderBottomLeftRadiusProperty, hintProperty, placeholderColorProperty } from '@nativescript/core';
13+
import {
14+
Background,
15+
Color,
16+
Length,
17+
Utils,
18+
backgroundInternalProperty,
19+
borderBottomLeftRadiusProperty,
20+
hintProperty,
21+
paddingBottomProperty,
22+
paddingLeftProperty,
23+
paddingRightProperty,
24+
paddingTopProperty,
25+
placeholderColorProperty
26+
} from '@nativescript/core';
1427
import { TextViewBase } from './textview.common';
1528
import { getLayout, stateSets } from '@nativescript-community/ui-material-core/android/utils';
1629

@@ -36,11 +49,13 @@ export class TextView extends TextViewBase {
3649
constructor() {
3750
super();
3851
}
52+
53+
//@ts-ignore
3954
get nativeTextViewProtected() {
4055
return this.editText;
4156
}
4257

43-
drawingBackground = false;
58+
//@ts-ignore
4459
get nativeViewProtected() {
4560
return this.layoutView;
4661
}
@@ -259,5 +274,17 @@ export class TextView extends TextViewBase {
259274
}
260275
}
261276
}
277+
[paddingTopProperty.setNative](value: Length) {
278+
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
279+
}
280+
[paddingRightProperty.setNative](value: Length) {
281+
org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0));
282+
}
283+
[paddingBottomProperty.setNative](value: Length) {
284+
org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0));
285+
}
286+
[paddingLeftProperty.setNative](value: Length) {
287+
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
288+
}
262289
}
263290
//

src/textview/textview.ios.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
helperColorProperty,
1111
helperProperty,
1212
strokeColorProperty,
13-
strokeInactiveColorProperty,
13+
strokeInactiveColorProperty
1414
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
1515
import {
1616
Background,
@@ -25,7 +25,7 @@ import {
2525
editableProperty,
2626
hintProperty,
2727
isAndroid,
28-
placeholderColorProperty,
28+
placeholderColorProperty
2929
} from '@nativescript/core';
3030
import { resetSymbol, textProperty } from '@nativescript/core/ui/text-base';
3131
import { TextViewBase } from './textview.common';
@@ -66,8 +66,8 @@ class TextViewInputControllerUnderlineImpl extends MDCTextInputControllerUnderli
6666

6767
return delegate;
6868
}
69-
textInsets(defaultValue) {
70-
let result = super.textInsets(defaultValue);
69+
textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint) {
70+
let result = super.textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint);
7171
const owner = this._owner ? this._owner.get() : null;
7272
if (owner) {
7373
result = owner._getTextInsetsForBounds(result);
@@ -85,8 +85,8 @@ class TextViewInputControllerImpl extends MDCTextInputControllerBase {
8585

8686
return delegate;
8787
}
88-
textInsets(defaultValue) {
89-
let result = super.textInsets(defaultValue);
88+
textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint) {
89+
let result = super.textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint);
9090
const owner = this._owner ? this._owner.get() : null;
9191
if (owner) {
9292
result = owner._getTextInsetsForBounds(result);
@@ -104,8 +104,8 @@ class TextViewInputControllerOutlinedImpl extends MDCTextInputControllerOutlined
104104

105105
return delegate;
106106
}
107-
textInsets(defaultValue) {
108-
let result = super.textInsets(defaultValue);
107+
textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint) {
108+
let result = super.textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint);
109109
const owner = this._owner ? this._owner.get() : null;
110110
if (owner) {
111111
result = owner._getTextInsetsForBounds(result);
@@ -123,8 +123,8 @@ class TextViewInputControllerFilledImpl extends MDCTextInputControllerFilled {
123123

124124
return delegate;
125125
}
126-
textInsets(defaultValue) {
127-
let result = super.textInsets(defaultValue);
126+
textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint) {
127+
let result = super.textInsetsWithSizeThatFitsWidthHint(defaultValue, widthHint);
128128
const owner = this._owner ? this._owner.get() : null;
129129
if (owner) {
130130
result = owner._getTextInsetsForBounds(result);
@@ -180,9 +180,11 @@ export class TextView extends TextViewBase {
180180
}
181181

182182
// N bug fix
183+
// @ts-ignore
183184
get ios() {
184185
return this.nativeTextViewProtected;
185186
}
187+
// @ts-ignore
186188
get nativeTextViewProtected() {
187189
return this.nativeViewProtected.textView;
188190
}

0 commit comments

Comments
 (0)