fix(ios): FormattedString and Span a11y font scale (#10281)

This commit is contained in:
Dimitris-Rafail Katsampas
2023-05-01 22:29:36 +03:00
committed by GitHub
parent b8a548f009
commit a14becdc6a
8 changed files with 142 additions and 46 deletions

View File

@@ -227,6 +227,9 @@ allTests['LISTVIEW'] = listViewTests;
import * as activityIndicatorTests from './ui/activity-indicator/activity-indicator-tests';
allTests['ACTIVITY-INDICATOR'] = activityIndicatorTests;
import * as textBaseTests from './ui/text-base/text-base-tests';
allTests['TEXT-BASE'] = textBaseTests;
import * as textFieldTests from './ui/text-field/text-field-tests';
allTests['TEXT-FIELD'] = textFieldTests;

View File

@@ -580,26 +580,6 @@ export function test_setting_font_properties_sets_native_font() {
test_native_font('italic', 'bold');
}
export function test_native_font_size_with_a11y_font_scale() {
if (isIOS) {
const deviceFontScaleMock = 4.0;
const page = helper.getCurrentPage();
const testView = new Label();
const layout = new StackLayout();
layout.addChild(testView);
page.content = layout;
layout.style.iosAccessibilityAdjustsFontSize = true;
layout.style.fontScaleInternal = deviceFontScaleMock;
const nativeFontSize = testView.nativeTextViewProtected.font.pointSize;
const expectedNativeFontSize = testView.style.fontInternal.fontSize * deviceFontScaleMock;
TKUnit.assertEqual(nativeFontSize, expectedNativeFontSize, 'View font size does not respect a11y font scaling');
}
}
function test_native_font(style: 'normal' | 'italic', weight: '100' | '200' | '300' | 'normal' | '400' | '500' | '600' | 'bold' | '700' | '800' | '900') {
const testView = new Button();

View File

@@ -0,0 +1,23 @@
import * as TKUnit from '../../tk-unit';
import * as helper from '../../ui-helper';
import { FormattedString, isIOS, Label, Span, StackLayout } from '@nativescript/core';
export function test_native_font_size_with_a11y_font_scale() {
if (isIOS) {
const deviceFontScaleMock = 4.0;
const page = helper.getCurrentPage();
const testView = new Label();
const layout = new StackLayout();
layout.addChild(testView);
page.content = layout;
layout.style.iosAccessibilityAdjustsFontSize = true;
layout.style.fontScaleInternal = deviceFontScaleMock;
const nativeFontSize = testView.nativeTextViewProtected.font.pointSize;
const expectedNativeFontSize = testView.style.fontInternal.fontSize * deviceFontScaleMock;
TKUnit.assertEqual(nativeFontSize, expectedNativeFontSize, 'View font size does not respect a11y font scaling');
}
}