Unverified Commit f0c4bc30 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add SemanticService.tooltip method for Android tooltips (#16978)

parent 6334da01
...@@ -147,6 +147,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -147,6 +147,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
_entry = new OverlayEntry(builder: (BuildContext context) => overlay); _entry = new OverlayEntry(builder: (BuildContext context) => overlay);
Overlay.of(context, debugRequiredFor: widget).insert(_entry); Overlay.of(context, debugRequiredFor: widget).insert(_entry);
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent); GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
SemanticsService.tooltip(widget.message);
_controller.forward(); _controller.forward();
return true; return true;
} }
......
...@@ -88,3 +88,22 @@ class AnnounceSemanticsEvent extends SemanticsEvent { ...@@ -88,3 +88,22 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
}; };
} }
} }
/// An event for a semantic announcement of a tooltip.
///
/// This is only used by Android to announce tooltip values.
class TooltipSemanticsEvent extends SemanticsEvent {
/// Constructs an event that triggers a tooltip announcement by the platform.
const TooltipSemanticsEvent(this.message) : super('tooltip');
/// The text content of the tooltip.
final String message;
@override
Map<String, dynamic> getDataMap() {
return <String, dynamic>{
'message': message,
};
}
}
...@@ -7,7 +7,7 @@ import 'dart:ui' show TextDirection; ...@@ -7,7 +7,7 @@ import 'dart:ui' show TextDirection;
import 'package:flutter/services.dart' show SystemChannels; import 'package:flutter/services.dart' show SystemChannels;
import 'semantics_event.dart' show AnnounceSemanticsEvent; import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent;
/// Allows access to the platform's accessibility services. /// Allows access to the platform's accessibility services.
...@@ -31,4 +31,12 @@ class SemanticsService { ...@@ -31,4 +31,12 @@ class SemanticsService {
final AnnounceSemanticsEvent event = new AnnounceSemanticsEvent(message, textDirection); final AnnounceSemanticsEvent event = new AnnounceSemanticsEvent(message, textDirection);
await SystemChannels.accessibility.send(event.toMap()); await SystemChannels.accessibility.send(event.toMap());
} }
/// Sends a semantic announcement of a tooltip.
///
/// This is only used by Android.
static Future<Null> tooltip(String message) async {
final TooltipSemanticsEvent event = new TooltipSemanticsEvent(message);
await SystemChannels.accessibility.send(event.toMap());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment