Skip to content

Commit

Permalink
nav: Add about-zulip button to menu bar
Browse files Browse the repository at this point in the history
This is an implementation for issue zulip#1128

This commit includes localizations and tests for the button as well.
  • Loading branch information
tomlin7 committed Dec 13, 2024
1 parent 28b3536 commit 9f015f5
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
19 changes: 19 additions & 0 deletions lib/widgets/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions test/widgets/home_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> tapOpenMenu(WidgetTester tester) async {
await tester.tap(find.byIcon(ZulipIcons.menu));
Expand Down Expand Up @@ -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', () {
Expand Down

0 comments on commit 9f015f5

Please sign in to comment.