-
Notifications
You must be signed in to change notification settings - Fork 399
[A11y] Add UI for AccessibilityOverridesPane #9892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
349a778
AccessibilityOverridesPane UI
hannah-hyj 562125b
1
hannah-hyj 7c9ade1
resolve comments
hannah-hyj 64e52ef
Update overrides_pane.dart
hannah-hyj 58e31e1
small fix
hannah-hyj f5f931d
resolve comments
hannah-hyj fe091fe
lint
hannah-hyj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 213 additions & 0 deletions
213
packages/devtools_app/lib/src/screens/accessibility/overrides_pane.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| // Copyright 2026 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. | ||
|
|
||
| import 'package:devtools_app_shared/ui.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../../shared/globals.dart'; | ||
| import 'accessibility_controller.dart'; | ||
|
|
||
| /// A pane that displays the accessibility overrides controls. | ||
| class AccessibilityOverridesPane extends StatelessWidget { | ||
| const AccessibilityOverridesPane({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final theme = Theme.of(context); | ||
| final controller = screenControllers.lookup<AccessibilityController>(); | ||
| return DevToolsAreaPane( | ||
| header: const AreaPaneHeader( | ||
| title: Text('Accessibility Overrides'), | ||
| roundedTopBorder: false, | ||
| includeTopBorder: false, | ||
| ), | ||
| child: Scrollbar( | ||
| child: SingleChildScrollView( | ||
| padding: const EdgeInsets.all(defaultSpacing), | ||
| child: Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Text( | ||
| 'Simulate and test accessibility settings on the connected device in real-time.', | ||
| style: theme.subtleTextStyle, | ||
| ), | ||
| const SizedBox(height: defaultSpacing), | ||
| const Divider(), | ||
| const SizedBox(height: denseSpacing), | ||
| _BrightnessOverride(controller: controller), | ||
| const SizedBox(height: defaultSpacing), | ||
| _TextScaleOverride(controller: controller), | ||
| const SizedBox(height: defaultSpacing), | ||
| _SwitchOverride( | ||
| label: 'Bold Text', | ||
| description: 'Forces all text in the application to be bold.', | ||
| notifier: controller.boldText, | ||
| ), | ||
| const SizedBox(height: defaultSpacing), | ||
| _SwitchOverride( | ||
| label: 'Screen Reader Debugger', | ||
| description: 'Debug and test screen reader layouts.', | ||
| notifier: controller.screenReader, | ||
| ), | ||
| const SizedBox(height: defaultSpacing), | ||
| _SwitchOverride( | ||
| label: 'High Contrast', | ||
| description: 'Increases the contrast of text and icons.', | ||
| notifier: controller.highContrast, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _AccessibilityPanelLabel extends StatelessWidget { | ||
| const _AccessibilityPanelLabel({ | ||
| required this.label, | ||
| required this.description, | ||
| }); | ||
|
|
||
| final String label; | ||
| final String description; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final theme = Theme.of(context); | ||
| return Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Text(label, style: theme.boldTextStyle), | ||
| const SizedBox(height: densePadding), | ||
| Text(description, style: theme.subtleTextStyle), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _BrightnessOverride extends StatelessWidget { | ||
| const _BrightnessOverride({required this.controller}); | ||
|
|
||
| final AccessibilityController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| const _AccessibilityPanelLabel( | ||
| label: 'Brightness', | ||
| description: 'Override the color scheme mode of the app.', | ||
| ), | ||
| const SizedBox(height: denseSpacing), | ||
| ValueListenableBuilder<BrightnessOverride>( | ||
| valueListenable: controller.brightness, | ||
| builder: (context, value, _) { | ||
| return RoundedDropDownButton<BrightnessOverride>( | ||
| isExpanded: true, | ||
| value: value, | ||
| items: BrightnessOverride.values.map((option) { | ||
| return DropdownMenuItem<BrightnessOverride>( | ||
| value: option, | ||
| child: Text(option.display), | ||
| ); | ||
| }).toList(), | ||
| onChanged: (newValue) { | ||
| if (newValue != null) { | ||
| controller.brightness.value = newValue; | ||
| } | ||
| }, | ||
| ); | ||
| }, | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _TextScaleOverride extends StatelessWidget { | ||
| const _TextScaleOverride({required this.controller}); | ||
|
|
||
| final AccessibilityController controller; | ||
|
|
||
| static const _minTextScale = 0.5; | ||
| static const _maxTextScale = 3.0; | ||
| static const _textScaleDivisions = 25; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final theme = Theme.of(context); | ||
| return ValueListenableBuilder<double>( | ||
| valueListenable: controller.textScale, | ||
| builder: (context, value, _) { | ||
| return Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| children: [ | ||
| const _AccessibilityPanelLabel( | ||
| label: 'Text Scale', | ||
| description: 'Scale the system font size.', | ||
| ), | ||
| Text( | ||
| '${value.toStringAsFixed(2)}x', | ||
| style: theme.boldTextStyle, | ||
| ), | ||
| ], | ||
| ), | ||
| const SizedBox(height: densePadding), | ||
| Slider( | ||
| value: value, | ||
| min: _minTextScale, | ||
| max: _maxTextScale, | ||
| divisions: _textScaleDivisions, | ||
| onChanged: (newValue) { | ||
| controller.textScale.value = newValue; | ||
| }, | ||
| ), | ||
| ], | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _SwitchOverride extends StatelessWidget { | ||
| const _SwitchOverride({ | ||
| required this.label, | ||
| required this.description, | ||
| required this.notifier, | ||
| }); | ||
|
|
||
| final String label; | ||
| final String description; | ||
| final ValueNotifier<bool> notifier; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Row( | ||
| children: [ | ||
| Expanded( | ||
| child: _AccessibilityPanelLabel( | ||
| label: label, | ||
| description: description, | ||
| ), | ||
| ), | ||
| ValueListenableBuilder<bool>( | ||
| valueListenable: notifier, | ||
| builder: (context, enabled, _) { | ||
| return Switch( | ||
| value: enabled, | ||
| onChanged: (newValue) { | ||
| notifier.value = newValue; | ||
| }, | ||
| ); | ||
| }, | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
packages/devtools_app/lib/src/screens/accessibility/semantics_tree_pane.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright 2026 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. | ||
|
|
||
| import 'package:devtools_app_shared/ui.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../../shared/ui/common_widgets.dart'; | ||
|
|
||
| /// A pane that displays the semantics tree of the connected app. | ||
| class AccessibilitySemanticsTreePane extends StatelessWidget { | ||
| const AccessibilitySemanticsTreePane({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const DevToolsAreaPane( | ||
| header: AreaPaneHeader( | ||
| title: Text('Semantics Tree'), | ||
| includeTopBorder: false, | ||
| roundedTopBorder: false, | ||
| ), | ||
| child: CenteredMessage( | ||
| message: | ||
| 'Accessibility semantics tree placeholder.\n' | ||
| '// TODO(hannah-hyj): Implement semantics tree view and details explorer.', | ||
| ), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use NotifierSwitch common widget. This enforces DevTools styling and size defaults as part of the implementation