Skip to content

Commit

Permalink
feat: option to open search without focus
Browse files Browse the repository at this point in the history
  • Loading branch information
lucien144 committed Jun 27, 2023
1 parent c03f8e4 commit acde45f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/components/WhatsNew.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ class WhatsNew extends StatelessWidget {
description: 'Další novinkou je fulltextové hledání příspěvků napříč Nyxem. Hledání je dostupné z hlavního menu.',
action: new WhatsNewAction(action: () {
Navigator.of(context).pop();
var arguments = SearchPageArguments(searchTerm: 'fyx');
var arguments = SearchPageArguments(searchTerm: MainRepository().credentials!.nickname, focus: false);
Navigator.of(context, rootNavigator: true).pushNamed('/search', arguments: arguments);
}, label: 'Chci si vyzkoušet hledání.')),
}, label: 'Vyzkoušet hledání.')),
item(
context: context,
icon: MdiIcons.bug,
title: 'Opravy a drobná vylepšení.',
description:
'Nehlasovat v anketě, neresetovat hodnocení při mínusu, krátký spoiler, ikona přečteno v pošte, odpověď na inzerát a další...'),
'Nehlasovat v anketě, neresetovat hodnocení při změně palečků, krátký spoiler, ikona přečteno v pošte, odpověď na inzerát a další...'),
CupertinoButton(child: Text('Pokračovat'), onPressed: () => Navigator.of(context).pop(), color: colors.primary)
]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/bottom_sheets/post_context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class _PostContextMenuState extends ConsumerState<PostContextMenu<IPost>> {
if (isPost)
gridItem('Vyhledat příspěvky\n@${post.nick}', MdiIcons.accountSearchOutline, onTap: () {
Navigator.of(context).pop();
var arguments = SearchPageArguments(searchTerm: '@${post.nick}');
var arguments = SearchPageArguments(searchTerm: '@${post.nick}', focus: false);
Navigator.of(context, rootNavigator: true).pushNamed('/search', arguments: arguments);
AnalyticsProvider().logEvent('filter_user_discussions');
}),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/post/advertisement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Advertisement extends StatelessWidget {
icon: MdiIcons.accountSearchOutline,
onTap: () {
Navigator.of(context).pop();
var arguments = SearchPageArguments(searchTerm: '@${this.username}');
var arguments = SearchPageArguments(searchTerm: '@${this.username}', focus: false);
Navigator.of(context, rootNavigator: true).pushNamed('/search', arguments: arguments);
AnalyticsProvider().logEvent('filter_user_discussions / ad');
}),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/post/post_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class PostHtml extends StatelessWidget {
// Search click through
var searchTerm = Helpers.parseSearchUri(link);
if (searchTerm != null) {
var arguments = SearchPageArguments(searchTerm: searchTerm);
var arguments = SearchPageArguments(searchTerm: searchTerm, focus: false);
Navigator.of(context.buildContext, rootNavigator: true).pushNamed('/search', arguments: arguments);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import 'package:fyx/pages/DiscussionPage.dart';

class SearchPageArguments {
final String? searchTerm;
final bool focus;

SearchPageArguments({this.searchTerm});
SearchPageArguments({this.searchTerm, this.focus = true});
}

class SearchPage extends StatefulWidget {
Expand Down Expand Up @@ -58,7 +59,7 @@ class _SearchPageState extends State<SearchPage> {
child: PullToRefreshList(
emptyWidget: emptyWidget,
searchEnabled: true,
searchFocus: true,
searchFocus: pageArguments?.focus ?? true,
searchLabel: 'Hledej v příspěvcích...',
searchTerm: this._searchTerm,
onSearch: (term) {
Expand Down

0 comments on commit acde45f

Please sign in to comment.