Skip to content

Commit 0dc755e

Browse files
author
farfromrefug
committed
fix(android)!: added androidA11yAdjustsFontSize property. It is a breaking change in the sense that now it defaults to false. Before it was always on.
1 parent 93c56ca commit 0dc755e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/label/index.android.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const formattedTextProperty = new Property<Label, FormattedString>({
5454
valueChanged: onFormattedTextPropertyChanged
5555
});
5656
export const htmlProperty = new Property<Label, string>({ name: 'html', defaultValue: null, affectsLayout: true });
57+
export const androidA11yAdjustsFontSizeProperty = new Property<Label, boolean>({ name: 'androidA11yAdjustsFontSize', defaultValue: false });
5758

5859
@CSSType('HTMLLabel')
5960
abstract class LabelBase extends View implements LabelViewDefinition {
@@ -68,6 +69,7 @@ abstract class LabelBase extends View implements LabelViewDefinition {
6869
@cssProperty textShadow: ShadowCSSValues;
6970
@cssProperty linkUnderline: boolean;
7071
public html: string;
72+
public androidA11yAdjustsFontSize: boolean;
7173
@cssProperty selectable: boolean;
7274

7375
public mIsSingleLine: boolean;
@@ -269,7 +271,13 @@ export class Label extends LabelBase {
269271
}
270272
}
271273
[fontSizeProperty.setNative](value: number | { nativeSize: number }) {
272-
this.nativeTextViewProtected.setLabelTextSize(2, typeof value === 'number' ? value : value.nativeSize, this.minFontSize || 10, this.maxFontSize || 200, this.autoFontSizeStep || 1);
274+
this.nativeTextViewProtected.setLabelTextSize(
275+
this.androidA11yAdjustsFontSize ? 2 /* COMPLEX_UNIT_SP */ : 1 /* COMPLEX_UNIT_DIP */,
276+
typeof value === 'number' ? value : value.nativeSize,
277+
this.minFontSize || 10,
278+
this.maxFontSize || 200,
279+
this.autoFontSizeStep || 1
280+
);
273281
}
274282

275283
[lineHeightProperty.setNative](value: number) {
@@ -453,6 +461,7 @@ export class Label extends LabelBase {
453461

454462
textProperty.register(Label);
455463
htmlProperty.register(Label);
464+
androidA11yAdjustsFontSizeProperty.register(Label);
456465
formattedTextProperty.register(Label);
457466

458467
function onFormattedTextPropertyChanged(textBase: Label, oldValue: FormattedString, newValue: FormattedString) {

0 commit comments

Comments
 (0)