Skip to content

Commit adc6013

Browse files
author
MritunjayTiwari14
committed
semantic: Add announce service for screens on home
1 parent aadda36 commit adc6013

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/widgets/home.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter/rendering.dart';
45

56
import '../generated/l10n/zulip_localizations.dart';
67
import '../model/narrow.dart';
@@ -74,14 +75,21 @@ class _HomePageState extends State<HomePage> {
7475

7576
String get _currentTabTitle {
7677
final zulipLocalizations = ZulipLocalizations.of(context);
78+
String pageTitle;
7779
switch(_tab.value) {
7880
case _HomePageTab.inbox:
79-
return zulipLocalizations.inboxPageTitle;
81+
pageTitle = zulipLocalizations.inboxPageTitle;
82+
break;
8083
case _HomePageTab.channels:
81-
return zulipLocalizations.channelsPageTitle;
84+
pageTitle = zulipLocalizations.channelsPageTitle;
85+
break;
8286
case _HomePageTab.directMessages:
83-
return zulipLocalizations.recentDmConversationsPageTitle;
87+
pageTitle = zulipLocalizations.recentDmConversationsPageTitle;
8488
}
89+
90+
SemanticsService.sendAnnouncement(View.of(context), pageTitle,
91+
Directionality.of(context));
92+
return pageTitle;
8593
}
8694

8795
@override
@@ -132,9 +140,6 @@ class _HomePageState extends State<HomePage> {
132140
body: Stack(
133141
children: [
134142
for (final (tab, body) in pageBodies)
135-
// TODO(#535): Decide if we find it helpful to use something like
136-
// [SemanticsProperties.namesRoute] to structure this UI better
137-
// for screen-reader software.
138143
Offstage(offstage: tab != _tab.value, child: body),
139144
]),
140145
bottomNavigationBar: DecoratedBox(
@@ -304,6 +309,8 @@ void _showMainMenu(BuildContext context, {
304309
// TODO(#1095): VersionInfo
305310
];
306311

312+
SemanticsService.sendAnnouncement(View.of(context),
313+
ZulipLocalizations.of(context).navBarMenuLabel, Directionality.of(context));
307314
final designVariables = DesignVariables.of(context);
308315
final accountId = PerAccountStoreWidget.accountIdOf(context);
309316
showModalBottomSheet<void>(

test/widgets/home_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,27 @@ void main () {
117117
check(find.descendant(
118118
of: find.byType(ZulipAppBar),
119119
matching: find.text('Inbox'))).findsOne();
120+
check(find.descendant(
121+
of: find.byType(ZulipAppBar),
122+
matching: find.bySemanticsLabel(RegExp("Inbox")))).findsOne();
120123

121124
await tester.tap(find.byIcon(ZulipIcons.hash_italic));
122125
await tester.pump();
123126
check(find.descendant(
124127
of: find.byType(ZulipAppBar),
125128
matching: find.text('Channels'))).findsOne();
129+
check(find.descendant(
130+
of: find.byType(ZulipAppBar),
131+
matching: find.bySemanticsLabel(RegExp("Channels")))).findsOne();
126132

127133
await tester.tap(find.byIcon(ZulipIcons.two_person));
128134
await tester.pump();
129135
check(find.descendant(
130136
of: find.byType(ZulipAppBar),
131137
matching: find.text('Direct messages'))).findsOne();
138+
check(find.descendant(
139+
of: find.byType(ZulipAppBar),
140+
matching: find.bySemanticsLabel(RegExp("Direct messages")))).findsOne();
132141
});
133142

134143
testWidgets('combined feed', (tester) async {

0 commit comments

Comments
 (0)