mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 12:57:42 +08:00
feat(core): first class a11y support (#8909)
This commit is contained in:

committed by
Nathan Walker

parent
ef9c3b1f5f
commit
c46da3fad9
@ -28,6 +28,7 @@ export const uncaughtErrorEvent = 'uncaughtError';
|
||||
export const discardedErrorEvent = 'discardedError';
|
||||
export const orientationChangedEvent = 'orientationChanged';
|
||||
export const systemAppearanceChangedEvent = 'systemAppearanceChanged';
|
||||
export const fontScaleChangedEvent = 'fontScaleChanged';
|
||||
|
||||
const ORIENTATION_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.portrait}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.landscape}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.unknown}`];
|
||||
|
||||
@ -122,7 +123,7 @@ function increaseStyleScopeApplicationCssSelectorVersion(rootView: View) {
|
||||
}
|
||||
}
|
||||
|
||||
function applyCssClass(rootView: View, cssClasses: string[], newCssClass: string) {
|
||||
export function applyCssClass(rootView: View, cssClasses: string[], newCssClass: string): void {
|
||||
if (!rootView.cssClasses.has(newCssClass)) {
|
||||
cssClasses.forEach((cssClass) => removeCssClass(rootView, cssClass));
|
||||
addCssClass(rootView, newCssClass);
|
||||
@ -146,7 +147,7 @@ export function orientationChanged(rootView: View, newOrientation: 'portrait' |
|
||||
}
|
||||
export let autoSystemAppearanceChanged = true;
|
||||
|
||||
export function setAutoSystemAppearanceChanged(value: boolean) {
|
||||
export function setAutoSystemAppearanceChanged(value: boolean): void {
|
||||
autoSystemAppearanceChanged = value;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ import { NavigationEntry, AndroidActivityCallbacks } from '../ui/frame/frame-int
|
||||
import { Observable } from '../data/observable';
|
||||
|
||||
import { profile } from '../profiling';
|
||||
import { initAccessibilityCssHelper } from '../accessibility/accessibility-css-helper';
|
||||
import { initAccessibilityFontScale } from '../accessibility/font-scale';
|
||||
|
||||
const ActivityCreated = 'activityCreated';
|
||||
const ActivityDestroyed = 'activityDestroyed';
|
||||
@ -172,6 +174,9 @@ export function run(entry?: NavigationEntry | string) {
|
||||
const nativeApp = getNativeApplication();
|
||||
androidApp.init(nativeApp);
|
||||
}
|
||||
|
||||
initAccessibilityCssHelper();
|
||||
initAccessibilityFontScale();
|
||||
}
|
||||
|
||||
export function addCss(cssText: string, attributeScoped?: boolean): void {
|
||||
|
12
packages/core/application/index.d.ts
vendored
12
packages/core/application/index.d.ts
vendored
@ -54,6 +54,11 @@ export const orientationChangedEvent: string;
|
||||
*/
|
||||
export const systemAppearanceChangedEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to fontScaleChanged event.
|
||||
*/
|
||||
export const fontScaleChangedEvent: string;
|
||||
|
||||
/**
|
||||
* Boolean to enable/disable systemAppearanceChanged
|
||||
*/
|
||||
@ -62,7 +67,7 @@ export let autoSystemAppearanceChanged: boolean;
|
||||
/**
|
||||
* enable/disable systemAppearanceChanged
|
||||
*/
|
||||
export function setAutoSystemAppearanceChanged(value: boolean);
|
||||
export function setAutoSystemAppearanceChanged(value: boolean): void;
|
||||
|
||||
/**
|
||||
* Updates root view classes including those of modals
|
||||
@ -184,6 +189,11 @@ export function setCssFileName(cssFile: string): void;
|
||||
*/
|
||||
export function getCssFileName(): string;
|
||||
|
||||
/**
|
||||
* Ensure css-class is set on rootView
|
||||
*/
|
||||
export function applyCssClass(rootView: View, cssClasses: string[], newCssClass: string): void;
|
||||
|
||||
/**
|
||||
* Loads immediately the app.css.
|
||||
* By default the app.css file is loaded shortly after "loaded".
|
||||
|
@ -18,6 +18,8 @@ import { IOSHelper } from '../ui/core/view/view-helper';
|
||||
import { Device } from '../platform';
|
||||
import { profile } from '../profiling';
|
||||
import { iOSNativeHelper } from '../utils';
|
||||
import { initAccessibilityCssHelper } from '../accessibility/accessibility-css-helper';
|
||||
import { initAccessibilityFontScale } from '../accessibility/font-scale';
|
||||
|
||||
const IOS_PLATFORM = 'ios';
|
||||
|
||||
@ -435,6 +437,9 @@ export function run(entry?: string | NavigationEntry) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initAccessibilityCssHelper();
|
||||
initAccessibilityFontScale();
|
||||
}
|
||||
|
||||
export function addCss(cssText: string, attributeScoped?: boolean): void {
|
||||
|
Reference in New Issue
Block a user