From cf187831243ff77f7a4a294ad42f92be5e09756a Mon Sep 17 00:00:00 2001 From: billy Date: Fri, 13 Dec 2024 21:17:14 +0000 Subject: [PATCH] nav: Add an About Zulip button to the main menu Fixes: #1128 --- lib/widgets/home.dart | 19 +++++++++++++++++++ test/widgets/home_test.dart | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/widgets/home.dart b/lib/widgets/home.dart index fcd7a41b98..f12b37bce6 100644 --- a/lib/widgets/home.dart +++ b/lib/widgets/home.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import '../generated/l10n/zulip_localizations.dart'; import '../model/narrow.dart'; +import 'about_zulip.dart'; import 'action_sheet.dart'; import 'app.dart'; import 'app_bar.dart'; @@ -264,6 +265,7 @@ void _showMainMenu(BuildContext context, { // TODO(#97): Settings // TODO(#661): Notifications // const SizedBox(height: 8), + const _AboutZulipButton(), // TODO(#1095): VersionInfo ]; @@ -551,6 +553,23 @@ class _SwitchAccountButton extends _MenuButton { } } +class _AboutZulipButton extends _MenuButton { + const _AboutZulipButton(); + + @override + IconData get icon => ZulipIcons.info; + + @override + String label(ZulipLocalizations zulipLocalizations) { + return zulipLocalizations.aboutPageTitle; + } + + @override + void onPressed(BuildContext context) { + Navigator.of(context).push(AboutZulipPage.buildRoute(context)); + } +} + /// Apply [Transform.scale] to the child widget when tapped, and reset its scale /// when released, while animating the transitions. class AnimatedScaleOnTap extends StatefulWidget { diff --git a/test/widgets/home_test.dart b/test/widgets/home_test.dart index 1cfdc52944..fe9c396d55 100644 --- a/test/widgets/home_test.dart +++ b/test/widgets/home_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_checks/flutter_checks.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:zulip/api/model/events.dart'; import 'package:zulip/model/store.dart'; +import 'package:zulip/widgets/about_zulip.dart'; import 'package:zulip/widgets/app.dart'; import 'package:zulip/widgets/app_bar.dart'; import 'package:zulip/widgets/home.dart'; @@ -215,6 +216,16 @@ void main () { check(find.byType(ProfilePage)).findsOne(); check(find.text(eg.selfUser.fullName)).findsAny(); }); + + testWidgets('_AboutZulipButton', (tester) async { + await prepare(tester); + await tapOpenMenu(tester); + + await tester.tap(find.byIcon(ZulipIcons.info)); + await tester.pump(Duration.zero); // tap the button + await tester.pump(const Duration(milliseconds: 250)); // wait for animation + check(find.byType(AboutZulipPage)).findsOne(); + }); }); group('_LoadingPlaceholderPage', () {