-
Notifications
You must be signed in to change notification settings - Fork 340
adds search icon to inbox and combined feed pages #1864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -84,6 +84,23 @@ class _HomePageState extends State<HomePage> { | |||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
List<Widget>? get _currentTabAppBarActions { | ||||||||||||
switch(_tab.value) { | ||||||||||||
case _HomePageTab.inbox: | ||||||||||||
return [ | ||||||||||||
IconButton( | ||||||||||||
icon: const Icon(ZulipIcons.search), | ||||||||||||
tooltip: ZulipLocalizations.of(context).searchMessagesPageTitle, | ||||||||||||
onPressed: () => Navigator.of(context).push(MessageListPage.buildRoute( | ||||||||||||
context: context, narrow: KeywordSearchNarrow(''))), | ||||||||||||
), | ||||||||||||
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: more generally, make this look as similar as possible to the other navigation callback found in this same widget. That way the only substantive difference between them — the difference in what narrow to go to — stands out. Similarly, make this look identical to the navigation callback added in your other commit, which is intended to have an identical effect. In particular that means use |
||||||||||||
]; | ||||||||||||
case _HomePageTab.channels: | ||||||||||||
case _HomePageTab.directMessages: | ||||||||||||
return null; | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
@override | ||||||||||||
Widget build(BuildContext context) { | ||||||||||||
const pageBodies = [ | ||||||||||||
|
@@ -120,7 +137,9 @@ class _HomePageState extends State<HomePage> { | |||||||||||
final designVariables = DesignVariables.of(context); | ||||||||||||
return Scaffold( | ||||||||||||
appBar: ZulipAppBar(titleSpacing: 16, | ||||||||||||
title: Text(_currentTabTitle)), | ||||||||||||
title: Text(_currentTabTitle), | ||||||||||||
actions: _currentTabAppBarActions | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
(or else put the closing |
||||||||||||
), | ||||||||||||
body: Stack( | ||||||||||||
children: [ | ||||||||||||
for (final (tab, body) in pageBodies) | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,6 +416,12 @@ abstract class _MessageListAppBar { | |
List<Widget> actions = []; | ||
switch (narrow) { | ||
case CombinedFeedNarrow(): | ||
actions.add(IconButton( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit in commit message:
In our commit-message summary lines, the message list is so frequent that we use an abbreviation for it: |
||
icon: const Icon(ZulipIcons.search), | ||
tooltip: zulipLocalizations.searchMessagesPageTitle, | ||
onPressed: () => Navigator.push(context, | ||
MessageListPage.buildRoute(context: context, | ||
narrow: KeywordSearchNarrow(''))))); | ||
case MentionsNarrow(): | ||
case StarredMessagesNarrow(): | ||
case KeywordSearchNarrow(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -363,6 +363,35 @@ void main() { | |
|
||
check(find.text('DMs with Muted user, User 2, Muted user')).findsOne(); | ||
}); | ||
|
||
testWidgets('search button on combined feed navigates to search page', (tester) async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I requested above (#1864 (comment)), let's also have a test that looks at a message list on some other narrow and checks that there isn't a search button there. (But, as discussed in that subthread, not the whole suite of all the other narrow types.) |
||
final pushedRoutes = <Route<dynamic>>[]; | ||
final testNavObserver = TestNavigatorObserver() | ||
..onPushed = (route, prevRoute) => pushedRoutes.add(route); | ||
|
||
await setupMessageListPage(tester, | ||
narrow: const CombinedFeedNarrow(), | ||
messages: [], | ||
navObservers: [testNavObserver]); | ||
|
||
final searchButtonFinder = find.descendant( | ||
of: find.byType(ZulipAppBar), | ||
matching: find.byIcon(ZulipIcons.search)); | ||
check(searchButtonFinder).findsOne(); | ||
|
||
pushedRoutes.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: move this to right after the step that pushed these routes (and then join it in the same stanza, with no separating blank line) |
||
|
||
connection.prepare(json: eg.newestGetMessagesResult( | ||
foundOldest: true, messages: []).toJson()); | ||
|
||
await tester.tap(searchButtonFinder); | ||
Comment on lines
+380
to
+387
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be simplified a bit: the |
||
await tester.pump(); | ||
|
||
check(pushedRoutes).single.isA<WidgetRoute>().page | ||
.isA<MessageListPage>() | ||
.initNarrow.equals(KeywordSearchNarrow('')); | ||
await tester.pump(Duration.zero); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting — what's this final pump about? What happens if it's removed? |
||
}); | ||
}); | ||
|
||
group('no-messages placeholder', () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's shorten the commit message down to just what's needed:
Fixes-partly: #1854
, and the next one (which completes the fix) should sayFixes #1854
._currentTabAppBarActions
isn't quite accurate: it's not that we're really changing/refactoring existing logic; rather it's more like we're adding logic that wasn't there before. There isn't anything very remarkable about how we're doing this, so I would just remove the sentence.for consistency with the message list search button." At this commit, "message list search button" doesn't refer to anything that exists, so it's confusing. You could rewrite it to make the context clear, by mentioning the plan to add a similar button the "Combined feed", which is done in the next commit…but you don't need to; the reader can easily look at the code if they're worried abou an inconsistency.
So, putting all that together, it would be something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the commit message as per suggestion.