Skip to content

Commit 38d8356

Browse files
committed
fix: update auto font size on min/max fontSize change
1 parent b26cf92 commit 38d8356

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/label.android.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ import {
4545
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
4646
import lazy from '@nativescript/core/utils/lazy';
4747
import { Label as LabelViewDefinition, LineBreak } from './label';
48-
import { autoFontSizeProperty, lineBreakProperty, selectableProperty, textShadowProperty } from './label-common';
48+
import {
49+
autoFontSizeProperty,
50+
lineBreakProperty,
51+
maxFontSizeProperty,
52+
minFontSizeProperty,
53+
selectableProperty,
54+
textShadowProperty
55+
} from './label-common';
4956

5057
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
5158
export * from './label-common';
@@ -537,6 +544,16 @@ export class Label extends LabelBase {
537544
android.util.TypedValue.COMPLEX_UNIT_DIP
538545
);
539546
}
547+
[maxFontSizeProperty.setNative](value) {
548+
if (this.mAutoFontSize) {
549+
this.enableAutoSize();
550+
}
551+
}
552+
[minFontSizeProperty.setNative](value) {
553+
if (this.mAutoFontSize) {
554+
this.enableAutoSize();
555+
}
556+
}
540557
private disableAutoSize() {
541558
androidx.core.widget.TextViewCompat.setAutoSizeTextTypeWithDefaults(
542559
this.nativeView,

src/label.ios.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
lineBreakProperty,
2929
linkColorProperty,
3030
linkUnderlineProperty,
31+
maxFontSizeProperty,
32+
minFontSizeProperty,
3133
needFormattedStringComputation,
3234
selectableProperty,
3335
textShadowProperty
@@ -544,6 +546,17 @@ export class Label extends LabelBase {
544546
this._setNativeText();
545547
}
546548
}
549+
550+
[maxFontSizeProperty.setNative]() {
551+
if (this.autoFontSize) {
552+
this.updateAutoFontSize({ textView: this.nativeTextViewProtected, force: true });
553+
}
554+
}
555+
[minFontSizeProperty.setNative]() {
556+
if (this.autoFontSize) {
557+
this.updateAutoFontSize({ textView: this.nativeTextViewProtected, force: true });
558+
}
559+
}
547560
_setSpannablesFontSizeWithRatio(ratio) {
548561
const nativeView = this.nativeTextViewProtected;
549562
const toChange: NSMutableAttributedString =

0 commit comments

Comments
 (0)