mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup a11y and add demo page
This commit is contained in:
@@ -24,12 +24,16 @@ function makePropertyEnumConverter<T>(enumValues) {
|
||||
};
|
||||
}
|
||||
|
||||
export const accessibilityEnabledProperty = new CssProperty<Style, boolean>({
|
||||
export const accessibilityEnabledProperty = new Property<View, boolean>({
|
||||
name: 'accessible',
|
||||
cssName: 'a11y-enabled',
|
||||
valueConverter: booleanConverter,
|
||||
// cssName: 'a11y-enabled',
|
||||
defaultValue: false,
|
||||
valueConverter: (v) => {
|
||||
console.log('accessibilityEnabledProperty:', v);
|
||||
return booleanConverter(v);
|
||||
},
|
||||
});
|
||||
accessibilityEnabledProperty.register(Style);
|
||||
// accessibilityEnabledProperty.register(Style);
|
||||
|
||||
const accessibilityHiddenPropertyName = 'accessibilityHidden';
|
||||
const accessibilityHiddenCssName = 'a11y-hidden';
|
||||
|
||||
@@ -235,7 +235,7 @@ function ensureNativeClasses() {
|
||||
}
|
||||
}
|
||||
|
||||
if (view.accessible === true) {
|
||||
if (view.accessible) {
|
||||
info.setFocusable(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { AccessibilityRole } from '../../accessibility';
|
||||
export abstract class ButtonBase extends TextBase implements ButtonDefinition {
|
||||
public static tapEvent = 'tap';
|
||||
|
||||
accessible = true;
|
||||
// accessible = true;
|
||||
accessibilityRole = AccessibilityRole.Button;
|
||||
|
||||
get textWrap(): boolean {
|
||||
|
||||
@@ -23,7 +23,7 @@ import { LinearGradient } from '../../styling/linear-gradient';
|
||||
|
||||
import * as am from '../../animation';
|
||||
import { AccessibilityLiveRegion, AccessibilityRole, AccessibilityState, AccessibilityTrait, AndroidAccessibilityEvent, IOSPostAccessibilityNotificationType } from '../../../accessibility/accessibility-types';
|
||||
import { accessibilityHintProperty, accessibilityIdentifierProperty, accessibilityLabelProperty, accessibilityTraitsProperty, accessibilityValueProperty } from '../../../accessibility/accessibility-properties';
|
||||
import { accessibilityEnabledProperty, accessibilityHintProperty, accessibilityIdentifierProperty, accessibilityLabelProperty, accessibilityTraitsProperty, accessibilityValueProperty } from '../../../accessibility/accessibility-properties';
|
||||
import { accessibilityBlurEvent, accessibilityFocusChangedEvent, accessibilityFocusEvent, getCurrentFontScale } from '../../../accessibility';
|
||||
import { CSSShadow } from '../../styling/css-shadow';
|
||||
|
||||
@@ -99,6 +99,9 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
|
||||
_androidContentDescriptionUpdated?: boolean;
|
||||
|
||||
// a11y
|
||||
_accessible: boolean;
|
||||
|
||||
get css(): string {
|
||||
const scope = this._styleScope;
|
||||
|
||||
@@ -754,10 +757,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
}
|
||||
|
||||
get accessible(): boolean {
|
||||
return this.style.accessible;
|
||||
// return this.style.accessible;
|
||||
return this._accessible;
|
||||
}
|
||||
set accessible(value: boolean) {
|
||||
this.style.accessible = value;
|
||||
// this.style.accessible = value;
|
||||
this._accessible = value;
|
||||
}
|
||||
|
||||
get accessibilityHidden(): boolean {
|
||||
@@ -1155,6 +1160,7 @@ export const iosIgnoreSafeAreaProperty = new InheritedProperty({
|
||||
valueConverter: booleanConverter,
|
||||
});
|
||||
iosIgnoreSafeAreaProperty.register(ViewCommon);
|
||||
accessibilityEnabledProperty.register(ViewCommon);
|
||||
accessibilityIdentifierProperty.register(ViewCommon);
|
||||
accessibilityLabelProperty.register(ViewCommon);
|
||||
accessibilityValueProperty.register(ViewCommon);
|
||||
|
||||
@@ -21,7 +21,7 @@ export class SliderBase extends View implements SliderDefinition {
|
||||
this.style.accessibilityStep = value;
|
||||
}
|
||||
|
||||
accessible = true;
|
||||
// accessible = true;
|
||||
accessibilityRole = AccessibilityRole.Adjustable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user