Skip to content

Commit b1d0047

Browse files
author
MritunjayTiwari14
committed
home: Expand tap area for correct feedback.
Added Gesture Detector over Column, Temporary set the onPressed of the Icon Button to null. Fixes: #1808 home: Improve performace and fix bug. Replaced IconButton widgets to Icon improve significantly performace of switching screens and wrote test for the semantic labels for App Bar. Fixes: #1879
1 parent 9950e84 commit b1d0047

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

lib/widgets/home.dart

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -253,42 +253,34 @@ class _NavigationBarButton extends StatelessWidget {
253253
Widget build(BuildContext context) {
254254
final designVariables = DesignVariables.of(context);
255255

256-
final iconColor = WidgetStateColor.fromMap({
257-
WidgetState.pressed: designVariables.iconSelected,
258-
~WidgetState.pressed: selected ? designVariables.iconSelected
259-
: designVariables.icon,
260-
});
261-
262-
final textColor = selected ? designVariables.iconSelected : designVariables.icon;
256+
final color = selected ? designVariables.iconSelected : designVariables.icon;
263257

264258
return AnimatedScaleOnTap(
265259
scaleEnd: 0.875,
266260
duration: const Duration(milliseconds: 100),
267-
child: Column(
268-
children: [
269-
SizedBox(
270-
height: 34,
271-
child: IconButton(
272-
icon: Icon(icon, size: 24),
273-
onPressed: onPressed,
274-
style: IconButton.styleFrom(
275-
// TODO(#417): Disable splash effects for all buttons globally.
276-
splashFactory: NoSplash.splashFactory,
277-
highlightColor: designVariables.navigationButtonBg,
278-
shape: const RoundedRectangleBorder(
279-
borderRadius: BorderRadius.all(Radius.circular(4))),
280-
).copyWith(foregroundColor: iconColor)),
281-
),
282-
Text(
283-
label,
284-
style: TextStyle(
285-
fontSize: 12,
286-
color: textColor,
287-
height: 1.0,),
288-
textAlign: TextAlign.center,
289-
maxLines: 2,
290-
overflow: TextOverflow.ellipsis)
291-
]));
261+
child: GestureDetector(
262+
behavior: HitTestBehavior.opaque,
263+
onTap: onPressed,
264+
child: Column(
265+
children: [
266+
SizedBox(
267+
height: 34,
268+
child: Center(
269+
child: Icon(icon, size: 24, color: color,)),
270+
),
271+
Expanded(
272+
child: Text(
273+
label,
274+
style: TextStyle(
275+
fontSize: 12,
276+
color: color,
277+
height: 1.0,),
278+
textAlign: TextAlign.center,
279+
maxLines: 2,
280+
overflow: TextOverflow.ellipsis),
281+
)
282+
]),
283+
));
292284
}
293285
}
294286

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)