Skip to content

Commit

Permalink
nav: Add an About Zulip button to the main menu
Browse files Browse the repository at this point in the history
Fixes: zulip#1128
  • Loading branch information
tomlin7 committed Dec 18, 2024
1 parent 3a13431 commit da70d76
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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 @@ -264,6 +265,7 @@ void _showMainMenu(BuildContext context, {
// TODO(#97): Settings
// TODO(#661): Notifications
// const SizedBox(height: 8),
const _AboutZulipButton(),
// TODO(#1095): VersionInfo
];

Expand Down Expand Up @@ -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 {
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(ZulipIcons.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 da70d76

Please sign in to comment.