-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Announce snackbar on iOS #41435
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
Announce snackbar on iOS #41435
Conversation
goderbauer
left a comment
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.
So, live regions do not work on iOS? We have them hooked up to UIAccessibilityTraitUpdatesFrequently - maybe that's not the correct mapping?
And should this maybe live in the iOS accessibility bridge to make iOS announce whenever the value of a live region changes instead of special casing this in the framework just for snackbars?
| @override | ||
| void assembleSemanticsNode(SemanticsNode node, SemanticsConfiguration config, Iterable<SemanticsNode> children) { | ||
| super.assembleSemanticsNode(node, config, children); | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && node.label != null && node.label != _lastAnnouncedLabel) { |
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.
Can you use a switch over the defaultTargetPlatform so the analyser reminds us to check this place whenever we add a new TargetPlatform?
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.
Done
| super.assembleSemanticsNode(node, config, children); | ||
| if (defaultTargetPlatform == TargetPlatform.iOS && node.label != null && node.label != _lastAnnouncedLabel) { | ||
| _lastAnnouncedLabel = node.label; | ||
| SemanticsService.announce(_lastAnnouncedLabel, textDirection); |
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.
This seems hacky to make an announcement as a side effect of assembling the tree...
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.
Yes, its a bit of a hack. Unfortunately since we take a child: Widget instead of a text String I don't think we have a better way of figuring out what to announce until after we've built the semantics tree. We could build a live region concept into our own semantics...
|
Correct, there is no live region concept on iOS, which ties our hands here a bit. The updates frequently trait does not trigger any announcements as far as I can tell, it only changes how the accessibility system reads/polls for the label |
|
Couldn't we do the same thing in the iOS accessibility bridge, though in a more general case: If a node has the live region flag we compare its label/value with the old one and if it has changed, we announce it from there? Basically implement the concept of live regions in the iOS bridge instead of hacking it into individual widgets on the framework side? |
|
Yeah that's a good point. I'll take a look at wiring something up |
Description
Create a custom render semantics which will perform an announcement of the combined semantic label on iOS platforms.
Fixes #41427