Skip to content

Commit

Permalink
chore: cleanup a11y and add demo page
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Apr 6, 2021
1 parent f088ddc commit e9b5eb9
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 11 deletions.
5 changes: 5 additions & 0 deletions apps/toolbox/src/app.css
Expand Up @@ -182,3 +182,8 @@ components that have the btn class name.
.list-group .list-group-item-heading {
margin-bottom: 5
}

.a11y-item {
margin-bottom: 12;
font-size: 18;
}
1 change: 1 addition & 0 deletions apps/toolbox/src/main-page.xml
Expand Up @@ -9,6 +9,7 @@
<Button text="list-page" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
<Button text="box-shadow" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
<Button text="a11y" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
</StackLayout>
</ScrollView>
</StackLayout>
Expand Down
2 changes: 1 addition & 1 deletion apps/toolbox/src/main-view-model.ts
Expand Up @@ -3,7 +3,7 @@ import { Observable, Frame, StackLayout } from '@nativescript/core';
export class HelloWorldModel extends Observable {
viewDemo(args) {
Frame.topmost().navigate({
moduleName: `${args.object.text}`,
moduleName: `pages/${args.object.text}`,
});
}
}
8 changes: 8 additions & 0 deletions apps/toolbox/src/pages/a11y.ts
@@ -0,0 +1,8 @@
import { Observable, EventData, Page } from '@nativescript/core';

export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new AccessibilityModel();
}

export class AccessibilityModel extends Observable {}
17 changes: 17 additions & 0 deletions apps/toolbox/src/pages/a11y.xml
@@ -0,0 +1,17 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="a11y" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>

<GridLayout padding="20">
<ScrollView>
<StackLayout>
<Label text="Accessible Label" class="a11y-item text-center"></Label>
<Button text="Accessible Button" class="a11y-item"></Button>
<!-- <Label text="Accessible Label" accessible="true" class="a11y-item text-center"></Label>
<Button text="Accessible Button" accessible="true" class="a11y-item"></Button> -->
</StackLayout>
</ScrollView>
</GridLayout>
</Page>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions packages/core/accessibility/accessibility-properties.ts
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/accessibility/index.android.ts
Expand Up @@ -235,7 +235,7 @@ function ensureNativeClasses() {
}
}

if (view.accessible === true) {
if (view.accessible) {
info.setFocusable(true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ui/button/button-common.ts
Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions packages/core/ui/core/view/view-common.ts
Expand Up @@ -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';

Expand Down Expand Up @@ -99,6 +99,9 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {

_androidContentDescriptionUpdated?: boolean;

// a11y
_accessible: boolean;

get css(): string {
const scope = this._styleScope;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ui/slider/slider-common.ts
Expand Up @@ -21,7 +21,7 @@ export class SliderBase extends View implements SliderDefinition {
this.style.accessibilityStep = value;
}

accessible = true;
// accessible = true;
accessibilityRole = AccessibilityRole.Adjustable;
}

Expand Down

0 comments on commit e9b5eb9

Please sign in to comment.