mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): textbase span interaction and styling improvements (#10682)
- Added `linkTap` event support for other iOS views that nest spans - Prevent android span from setting parent background color to itself since it doesn't react to changes of that property. Unless background color is specified to the span directly, it's going to be transparent - Added few missing `nativeTextViewProtected` references - Improved view disposal for classes that inherit from TextBase as they had leftovers after android activity recreation - Removed 2 assignments of `userInteractionEnabled` from TextBase as they were unneeded and had conflicts with `isUserInteractionEnabled` property. Core already sets that property to true for the views that need it in `createNativeView` call - `HTMLView` will remove extra padding using the documented `UIEdgeInsetsZero`
This commit is contained in:
committed by
GitHub
parent
03cca58712
commit
966dccd0f9
@@ -19,6 +19,8 @@ enum FixedSize {
|
||||
@CSSType('Label')
|
||||
export class Label extends TextBase implements LabelDefinition {
|
||||
nativeViewProtected: TNSLabel;
|
||||
nativeTextViewProtected: TNSLabel;
|
||||
|
||||
private _fixedSize: FixedSize;
|
||||
|
||||
public createNativeView() {
|
||||
@@ -28,6 +30,11 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
return view;
|
||||
}
|
||||
|
||||
public disposeNativeView(): void {
|
||||
super.disposeNativeView();
|
||||
this._fixedSize = null;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
get ios(): TNSLabel {
|
||||
return this.nativeTextViewProtected;
|
||||
@@ -102,7 +109,7 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
}
|
||||
|
||||
private _measureNativeView(width: number, widthMode: number, height: number, heightMode: number): { width: number; height: number } {
|
||||
const view = <UILabel>this.nativeTextViewProtected;
|
||||
const view = this.nativeTextViewProtected;
|
||||
|
||||
const nativeSize = view.textRectForBoundsLimitedToNumberOfLines(CGRectMake(0, 0, widthMode === 0 /* layout.UNSPECIFIED */ ? Number.POSITIVE_INFINITY : layout.toDeviceIndependentPixels(width), heightMode === 0 /* layout.UNSPECIFIED */ ? Number.POSITIVE_INFINITY : layout.toDeviceIndependentPixels(height)), view.numberOfLines).size;
|
||||
|
||||
@@ -123,7 +130,8 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
private adjustLineBreak() {
|
||||
const whiteSpace = this.whiteSpace;
|
||||
const textOverflow = this.textOverflow;
|
||||
const nativeView = this.nativeViewProtected;
|
||||
const nativeView = this.nativeTextViewProtected;
|
||||
|
||||
switch (whiteSpace) {
|
||||
case 'normal':
|
||||
nativeView.lineBreakMode = NSLineBreakMode.ByWordWrapping;
|
||||
@@ -158,7 +166,7 @@ export class Label extends TextBase implements LabelDefinition {
|
||||
const cgColor = color ? color.CGColor : null;
|
||||
nativeView.layer.backgroundColor = cgColor;
|
||||
},
|
||||
true
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user