Unverified Commit 5029be0b authored by chunhtai's avatar chunhtai Committed by GitHub

Add dismiss action to modal barrier (#78808)

* Add dismiss action to modal barrier

* fix test

* fix another test
parent 891511d5
......@@ -92,6 +92,11 @@ class ModalBarrier extends StatelessWidget {
assert(platformSupportsDismissingBarrier != null);
final bool semanticsDismissible = dismissible && platformSupportsDismissingBarrier;
final bool modalBarrierSemanticsDismissible = barrierSemanticsDismissible ?? semanticsDismissible;
void handleDismiss() {
Navigator.maybePop(context);
}
return BlockSemantics(
child: ExcludeSemantics(
// On Android, the back button is used to dismiss a modal. On iOS, some
......@@ -100,12 +105,13 @@ class ModalBarrier extends StatelessWidget {
child: _ModalBarrierGestureDetector(
onDismiss: () {
if (dismissible)
Navigator.maybePop(context);
handleDismiss();
else
SystemSound.play(SystemSoundType.alert);
},
child: Semantics(
label: semanticsDismissible ? semanticsLabel : null,
onDismiss: semanticsDismissible ? handleDismiss : null,
textDirection: semanticsDismissible && semanticsLabel != null ? Directionality.of(context) : null,
child: MouseRegion(
cursor: SystemMouseCursors.basic,
......
......@@ -1340,7 +1340,7 @@ void main() {
await tester.pumpAndSettle();
expect(semantics, includesNodeWith(
actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Dismiss',
));
debugDefaultTargetPlatformOverride = null;
......
......@@ -378,7 +378,7 @@ void main() {
children: <TestSemantics>[
TestSemantics.rootChild(
rect: TestSemantics.fullScreen,
actions: SemanticsAction.tap.index,
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Dismiss',
textDirection: TextDirection.ltr,
),
......
......@@ -1544,7 +1544,7 @@ void main() {
TestSemantics(
id: 5,
rect: TestSemantics.fullScreen,
actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'test label',
textDirection: TextDirection.ltr,
),
......
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