Skip to content

Commit 865b141

Browse files
author
chimnayajith
committed
home: Display current organization's name and icon atop menu
Fixes #1037
1 parent bbcc4c9 commit 865b141

11 files changed

+113
-0
lines changed

assets/l10n/app_en.arb

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"@switchAccountButton": {
2424
"description": "Label for main-menu button leading to the choose-account page."
2525
},
26+
"organizationsButtonLabel": "Organizations",
27+
"@organizationsButtonLabel": {
28+
"description": "Button text to view and switch between different organizations."
29+
},
2630
"tryAnotherAccountMessage": "Your account at {url} is taking a while to load.",
2731
"@tryAnotherAccountMessage": {
2832
"description": "Message that appears on the loading screen after waiting for some time.",

lib/generated/l10n/zulip_localizations.dart

+6
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ abstract class ZulipLocalizations {
141141
/// **'Switch account'**
142142
String get switchAccountButton;
143143

144+
/// Button text to view and switch between different organizations.
145+
///
146+
/// In en, this message translates to:
147+
/// **'Organizations'**
148+
String get organizationsButtonLabel;
149+
144150
/// Message that appears on the loading screen after waiting for some time.
145151
///
146152
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Switch account';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Your account at $url is taking a while to load.';

lib/generated/l10n/zulip_localizations_en.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Switch account';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Your account at $url is taking a while to load.';

lib/generated/l10n/zulip_localizations_ja.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Switch account';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Your account at $url is taking a while to load.';

lib/generated/l10n/zulip_localizations_nb.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Switch account';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Your account at $url is taking a while to load.';

lib/generated/l10n/zulip_localizations_pl.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Przełącz konto';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Twoje konto na $url wymaga jeszcze chwili na załadowanie.';

lib/generated/l10n/zulip_localizations_ru.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Сменить учетную запись';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Ваша учетная запись на $url загружается медленно.';

lib/generated/l10n/zulip_localizations_sk.dart

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
2626
@override
2727
String get switchAccountButton => 'Zmeniť účet';
2828

29+
@override
30+
String get organizationsButtonLabel => 'Organizations';
31+
2932
@override
3033
String tryAnotherAccountMessage(Object url) {
3134
return 'Načítavanie vášho konta na adrese $url chvílu trvá.';

lib/widgets/home.dart

+64
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void _showMainMenu(BuildContext context, {
310310
crossAxisAlignment: CrossAxisAlignment.stretch,
311311
mainAxisSize: MainAxisSize.min,
312312
children: [
313+
_OrganizationHeader(),
313314
Flexible(child: InsetShadowBox(
314315
top: 8, bottom: 8,
315316
color: designVariables.bgBotBar,
@@ -326,6 +327,69 @@ void _showMainMenu(BuildContext context, {
326327
});
327328
}
328329

330+
class _OrganizationHeader extends StatelessWidget {
331+
@override
332+
Widget build(BuildContext context) {
333+
final store = PerAccountStoreWidget.of(context);
334+
final designVariables = DesignVariables.of(context);
335+
final zulipLocalizations = ZulipLocalizations.of(context);
336+
337+
String organizationName = store.realmName;
338+
Uri? organizationIcon = store.tryResolveUrl(store.realmIcon);
339+
final buttonStyle = TextButton.styleFrom(
340+
splashFactory: NoSplash.splashFactory,
341+
overlayColor: Colors.transparent
342+
);
343+
344+
return Padding(
345+
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
346+
child: Row(
347+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
348+
children: [
349+
Expanded(
350+
child: Row(
351+
children: [
352+
Image.network(
353+
organizationIcon.toString(),
354+
width: 28,
355+
height: 28,
356+
fit: BoxFit.contain,
357+
),
358+
const SizedBox(width: 8),
359+
Expanded(
360+
child: Text(
361+
organizationName,
362+
style: const TextStyle(
363+
fontWeight: FontWeight.bold,
364+
fontSize: 20,
365+
),
366+
overflow: TextOverflow.ellipsis,
367+
maxLines: 1,
368+
),
369+
),
370+
],
371+
),
372+
),
373+
TextButton(
374+
onPressed: () {
375+
Navigator.of(context).push(MaterialWidgetRoute(page: const ChooseAccountPage()));
376+
},
377+
style: buttonStyle,
378+
child: Text(
379+
zulipLocalizations.organizationsButtonLabel,
380+
style: TextStyle(
381+
fontSize: 19,
382+
fontWeight: FontWeight.w500,
383+
color: designVariables.icon,
384+
),
385+
),
386+
),
387+
],
388+
),
389+
);
390+
}
391+
}
392+
329393
abstract class _MenuButton extends StatelessWidget {
330394
const _MenuButton();
331395

test/widgets/home_test.dart

+18
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,24 @@ void main () {
248248
check(find.byType(BottomSheet)).findsNothing();
249249
});
250250

251+
testWidgets('organization header shows realm info and navigation works', (tester) async {
252+
await prepare(tester);
253+
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
254+
await tapOpenMenu(tester);
255+
256+
check(find.text(store.realmName)).findsOne();
257+
check(find.byType(Image)).findsOne();
258+
259+
final organizationsButton = find.text('Organizations');
260+
check(organizationsButton).findsOne();
261+
262+
await tester.tap(organizationsButton);
263+
await tester.pump(Duration.zero);
264+
await tester.pump(const Duration(milliseconds: 250)); // wait for animation
265+
266+
check(find.byType(ChooseAccountPage)).findsOne();
267+
});
268+
251269
testWidgets('_MyProfileButton', (tester) async {
252270
await prepare(tester);
253271
await tapOpenMenu(tester);

0 commit comments

Comments
 (0)