From 9f015f5d7f19e5fbb08243604aaa5d61a9e8cf33 Mon Sep 17 00:00:00 2001 From: billy Date: Fri, 13 Dec 2024 21:17:14 +0000 Subject: [PATCH] nav: Add about-zulip button to menu bar This is an implementation for issue #1128 This commit includes localizations and tests for the button as well. --- assets/l10n/app_en.arb | 4 ++++ lib/generated/l10n/zulip_localizations.dart | 6 ++++++ .../l10n/zulip_localizations_ar.dart | 3 +++ .../l10n/zulip_localizations_en.dart | 3 +++ .../l10n/zulip_localizations_fr.dart | 3 +++ .../l10n/zulip_localizations_ja.dart | 3 +++ .../l10n/zulip_localizations_pl.dart | 3 +++ .../l10n/zulip_localizations_ru.dart | 3 +++ lib/widgets/home.dart | 19 +++++++++++++++++++ test/widgets/home_test.dart | 14 ++++++++++++++ 10 files changed, 61 insertions(+) diff --git a/assets/l10n/app_en.arb b/assets/l10n/app_en.arb index 58822303fd..b00a3dc6fe 100644 --- a/assets/l10n/app_en.arb +++ b/assets/l10n/app_en.arb @@ -23,6 +23,10 @@ "@switchAccountButton": { "description": "Label for main-menu button leading to the choose-account page." }, + "aboutZulipMenuItem": "About Zulip", + "@aboutZulipMenuItem": { + "description": "Label for the 'About Zulip' option in the main menu." + }, "tryAnotherAccountMessage": "Your account at {url} is taking a while to load.", "@tryAnotherAccountMessage": { "description": "Message that appears on the loading screen after waiting for some time.", diff --git a/lib/generated/l10n/zulip_localizations.dart b/lib/generated/l10n/zulip_localizations.dart index 00d7cfde72..ed3e9ed70d 100644 --- a/lib/generated/l10n/zulip_localizations.dart +++ b/lib/generated/l10n/zulip_localizations.dart @@ -139,6 +139,12 @@ abstract class ZulipLocalizations { /// **'Switch account'** String get switchAccountButton; + /// Label for the 'About Zulip' option in the main menu. + /// + /// In en, this message translates to: + /// **'About Zulip'** + String get aboutZulipMenuItem; + /// Message that appears on the loading screen after waiting for some time. /// /// In en, this message translates to: diff --git a/lib/generated/l10n/zulip_localizations_ar.dart b/lib/generated/l10n/zulip_localizations_ar.dart index 542b85031b..0d31e54330 100644 --- a/lib/generated/l10n/zulip_localizations_ar.dart +++ b/lib/generated/l10n/zulip_localizations_ar.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/generated/l10n/zulip_localizations_en.dart b/lib/generated/l10n/zulip_localizations_en.dart index b6bc9f72e7..5a47c8871a 100644 --- a/lib/generated/l10n/zulip_localizations_en.dart +++ b/lib/generated/l10n/zulip_localizations_en.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/generated/l10n/zulip_localizations_fr.dart b/lib/generated/l10n/zulip_localizations_fr.dart index c857da2c82..d924af01c7 100644 --- a/lib/generated/l10n/zulip_localizations_fr.dart +++ b/lib/generated/l10n/zulip_localizations_fr.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsFr extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/generated/l10n/zulip_localizations_ja.dart b/lib/generated/l10n/zulip_localizations_ja.dart index 7adbc9ae8a..c3955d586c 100644 --- a/lib/generated/l10n/zulip_localizations_ja.dart +++ b/lib/generated/l10n/zulip_localizations_ja.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/generated/l10n/zulip_localizations_pl.dart b/lib/generated/l10n/zulip_localizations_pl.dart index 07746b3f27..9fb81b15eb 100644 --- a/lib/generated/l10n/zulip_localizations_pl.dart +++ b/lib/generated/l10n/zulip_localizations_pl.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/generated/l10n/zulip_localizations_ru.dart b/lib/generated/l10n/zulip_localizations_ru.dart index 9c2065376b..c947276758 100644 --- a/lib/generated/l10n/zulip_localizations_ru.dart +++ b/lib/generated/l10n/zulip_localizations_ru.dart @@ -26,6 +26,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations { @override String get switchAccountButton => 'Switch account'; + @override + String get aboutZulipMenuItem => 'About Zulip'; + @override String tryAnotherAccountMessage(Object url) { return 'Your account at $url is taking a while to load.'; diff --git a/lib/widgets/home.dart b/lib/widgets/home.dart index fcd7a41b98..b8c9e6e51b 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'; @@ -259,6 +260,7 @@ void _showMainMenu(BuildContext context, { // TODO(#1094): Users const _MyProfileButton(), const _SwitchAccountButton(), + const _AboutZulipButton(), // TODO(#198): Set my status // const SizedBox(height: 8), // TODO(#97): Settings @@ -551,6 +553,23 @@ class _SwitchAccountButton extends _MenuButton { } } +class _AboutZulipButton extends _MenuButton { + const _AboutZulipButton(); + + @override + IconData get icon => Icons.info; + + @override + String label(ZulipLocalizations zulipLocalizations) { + return zulipLocalizations.aboutZulipMenuItem; + } + + @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..4a7c52c401 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'; @@ -105,6 +106,9 @@ void main () { final combinedFeedMenuIconFinder = find.descendant( of: find.byType(BottomSheet), matching: find.byIcon(ZulipIcons.message_feed)); + final aboutZulipMenuIconFinder = find.descendant( + of: find.byType(BottomSheet), + matching: find.byIcon(Icons.info)); Future tapOpenMenu(WidgetTester tester) async { await tester.tap(find.byIcon(ZulipIcons.menu)); @@ -215,6 +219,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(aboutZulipMenuIconFinder); + 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', () {